// Default JS Content - Do Not Delete
             SA.redirection_mobile ({
                redirection_paramName:"fullsite",
                mobile_prefix : "m",
                cookie_hours : "1" 
            });
$(document).ready(function(){
	$('.subcopy li').each(function(){
		var $t = $(this);
		var text = $t.html();
		$t.html(''
			+'<table cellpadding=0 cellspacing=0 style="margin:6px;"><tr><td style="width:36px;background:url(\'/i/SITE_110606_13453345_1HMJ9/templates/bullet.png\') no-repeat 20px 0;"><img src="/i/_.gif"></td>'
			+'<td>'
			+text
			+'</td>'
			+'</tr>'
			+'</table>'
		)
	});

	/* Search Loading */
	$('#footerTop form').submit(function(){
		var keywords = this.search.value;
        
        $('#searchResults').remove();
        $(document.body).append('<div id="searchResults" />');
        $('#searchResults').attr('title','Search Results for "'+keywords+'"').html('<div id="scrolling" style="height:500px;overflow:auto;" >Searching ...</div>');
        $('#searchResults').dialog({modal:true,width:800});
		$.ajax({
			url: '/i/SITE_110606_13453345_1HMJ9/cfcs/search.cfc',
			cache: false,
			dataType: 'json',
			data:{
				returnFormat: 'json',
				method: 'search',
				keywords: keywords
			},
			success:function(r){
				var r = convertCFQuery(r);
                $('#scrolling').html('');
				for(var i in r){
					$('#scrolling').append(
						'<div class="subcopy" style="overflow:hidden;background:#FFF;padding:10px;margin:10px 10px 10px 0;cursor:pointer;" onClick="document.location.href=\''+r[i].URL+'\';">'
							+'<img src="/i/SITE_110606_13453345_1HMJ9/webshots/ws_'+r[i].PAGEID+'.jpg" style="float:left;margin:0 10px 0 0;">'
							+'<h2>'+(i- -1)+'. '+r[i].TITLE+'</h2>'
							+'<p>'+r[i].URL+'</p>'
							+'<p>'+r[i].SUMMARY+'</p>'
						+'</div>'
					);
				}
                if(r.length == 0){
                	$('#scrolling').html('No results found, please try another search term.');
                }
				_gaq.push(['_trackPageview', '/search/?q='+escape(keywords)]); 
			}
		});
		return false;
	});
	var convertCFQuery = function(original){
		var data = [];
		for(var i=0;i<original.DATA.length;i++){
			var item = {};
			for(var j=0;j<original.COLUMNS.length;j++){
				item[original.COLUMNS[j]]=original.DATA[i][j];
			}
			data.push(item);
		}
		return data;
	};

	$('#homebooking h1').click(function(){
		if($(this).hasClass('bgnone'))
			return false;
		var $t = $(this).parent();
		if($t.hasClass('active')){
			$t.find('.content').slideUp({complete:function(){$(this).removeClass('active');}});
			$t.removeClass('active');
		}else{
			$('#homebooking .active h1').click();
			$t.find('.content').slideDown({complete:function(){$(this).addClass('active');}});
			$t.addClass('active');
		}
	});
	
	
	$(window).load(function(){
	/* Rotate the images */
	$('#bgimage img:first').addClass('active').css('z-index',-1).fadeIn({duration:1500,easing:'swing'});
	var loadNext = function(){
		var $t = $('#bgimage img.active');
		var $n = $t.next('img');
		if($n.length==0)$n = $('#bgimage img:first');
		$n.css('z-index',-2).show();
		$t.delay(2500).fadeOut({duration:1500,easing:'swing',complete:function(){
			$n.addClass('active').css('z-index',-1);
			$(this).removeClass('active');
			loadNext();
		}});
	};
	setTimeout(function(){loadNext();},5000);
	setTimeout(function(){
		/*if($.browser.msie)
		   	$('#homebooking').css({background:'#000'});*/
		$('#homebooking').slideDown({duration:1000,complete:function(){
			/*if($.browser.msie){
				$('#homebooking').css({'background':''});
				$('#homebooking').css({'filter':'progid:DXImageTransform.Microsoft.gradient(startColorstr=#BF181818, endColorstr=#BF181818)'});
			}*/
		}});
	},2500);

	$('#homebooking').delay(5000).slideDown(1000);
	});
	
	var resize = function(){
		var w = $(window).width();
		if(w<1680)w=1680;
		$('#bgimage img').width(w);
		$('#bgimage img').css({
			'margin-top' : (675-$('#bgimage img').height())/2,
			'margin-left' : ($(this).width()-$('#bgimage img').width())/2
		});
		$('.subImg img').removeAttr('height').width(w);
		$('.subImg img').css({
			'margin-top' : (250-$('.subImg img').height())/2,
			'margin-left' : ($(this).width()-$('.subImg img').width())/2
		});
	};
	$(window).resize(resize);
	$(window).load(function(){resize();
if($('.subImg img').length==1)$('.subImg img').fadeIn();});

	
//calendar code

		$("#arrive").datepicker({
			minDate:0,
			showAnim: "fadeIn",
			showOn: 'both',
			buttonText: 'Select Check In Date',
			buttonImage: '/i/SITE_110606_13453345_1HMJ9/templates/btn_cal.gif',
			buttonImageOnly: true,
			onSelect:function(theDate) {
				$("#depart").datepicker('option','minDate',addDays(new Date(theDate),1))
				if(($("#depart").datepicker( 'getDate' )===null)||(trim($("#depart").datepicker( 'getDate' ))=="")||(comparedate($("#arrive").datepicker( 'getDate' ),$("#depart").datepicker( 'getDate' )))){
					$("#depart").datepicker('setDate' ,addDays(new Date(theDate),1))
				}
			}
		});

		$("#depart").datepicker({
			minDate:1,
			showAnim: "fadeIn",
			showOn: 'both',
			buttonText: 'Select Check Out Date',
			buttonImage: '/i/SITE_110606_13453345_1HMJ9/templates/btn_cal.gif',
			buttonImageOnly: true,
			defaultDate: +1,
			gotoCurrent: true
		});

});


function openWindow(theUrl) {
	open(theUrl,'','resizable=1,top=20,left=20,height=900,width=960');
}


/*for related jQuery calendars*/
function addDays(myDate,days) {
//myDate = starting	date, days = no. days to add.
	var temp_date = new Date();
	var i = 0;
	var days_to_add = 0;
	while (i < (days)){
		temp_date = new Date(myDate.getTime() +	(days_to_add*24*60*60*1000));
			i+=1;
		days_to_add += 1;
	}
	return new Date(myDate.getTime() + days_to_add*24*60*60*1000);
}
function comparedate(date1str,date2str){
	var date1 = new Date(date1str);
	var date2 = new Date(date2str);
	if (date1 > date2){
		return true;
	}else if (date1 < date2){
		return false;
	}else{
		return true;
	}
}
function trim(stringToTrim) {
	return stringToTrim.toString().replace(/^\s+|\s+$/g,"");
}







var buffer = false;
var loaded = false;
var thumbnails = true;
var aG = [];
function loadGallery(){
aG.push({
	totalW: totalW,
	totalH: totalH,
	path: path
});
$(function(){
	if(loaded) return false;
	loaded = true;
	for(var p in aG){
		var gSlideshow = $('div.slideshow:eq('+p+')')
		gSlideshow.data('mP',p);
		gSlideshow.height(aG[p].totalH);
		$.ajax({
			url: aG[p].path+'myimages.xml',
			dataType: 'xml',
			context: gSlideshow,
			success: function(data){
				var slideshow = $(this);
				var mP = slideshow.data('mP');
				var dataArray = [];
				$(data).find('data').each(function(){
					dataArray.push({img:$(this).attr('img'),imgcaption:$(this).attr('imgcaption'),thumb:$(this).attr('thumb')});
				});
				slideshow.append(
					'<img src="'+aG[mP].path
					+dataArray[0].img
					+'" imagelabel="'
					+dataArray[0].imgcaption
					+'" style="position: absolute;display: none; ">'
				);
				if(thumbnails){
					var thumbs = $('<div class="thumbnails"></div>');
					slideshow.after(thumbs);
					thumbs.append(
						'<img src="'+aG[mP].path
						+dataArray[0].thumb.replace(/_c/,'_bw')
						+'">'
					);
					var nt = $('.thumbnails img');
					nt.addClass('active').attr('src',nt.attr('src').replace(/(_bw|_b|_c)\./,'_c.'));;
					thumbs.before('<div class="descriptionText"></div>');
				}
				var loaded = false;
				dataArray.shift();
				/* As soon as the first image is loaded, we may begin */
				slideshow.find('img:first').load(function(){
					if(loaded) return false;
					loaded = true;
$(window).resize();
					for(var i in dataArray){
						slideshow.append(
							'<img sr'+'c="'+aG[mP].path
							+dataArray[i].img
							+'" imagelabel="'
							+dataArray[i].imgcaption
							+'" style="position: absolute;display: none; ">'
						);
						if(thumbnails){
							thumbs.append(
								'<img src="'+aG[mP].path
								+dataArray[i].thumb.replace(/_c/,'_bw')
								+'">'
							);
						}
					}
					
					if(thumbs){
						thumbs.append('<br style="clear:both;" />');
						$('.thumbnails img').hover(function(){
							var $t = $(this);
							$t.attr('src',$t.attr('src').replace(/(_bw|_b|_c)\./,'_b.'));
						},function(){
							var $t = $(this);
							if($t.hasClass('active'))
								$t.attr('src',$t.attr('src').replace(/(_bw|_b|_c)\./,'_c.'));
							else
								$t.attr('src',$t.attr('src').replace(/(_bw|_b|_c)\./,'_bw.'));
						}).click(function(){
							var $t = $(this);
							if($t.hasClass('active'))
								return false;
							var i = $t.prevAll('img').length;
							pause();
							nextSlide('.slideshow img:eq('+i+')');
						});
					}
					
					/* Variables */
					var transitionTime = 4200;
					
					/* Show First Image / Gallery / Hide Play Button */
					var n = slideshow.find('img:first');
					$('.descriptionText').html(n.attr('imageLabel').replace(/ /g,'')==''?' ':n.attr('imageLabel'));
					n.show();
					if(buffer){
						$('.buffer').css({
							'height':n.height(),
							'width':n.width(),
							'margin-left' : (aG[mP].totalW-n.width())/2,
							'margin-top' : (aG[mP].totalH-n.height())/2
						}).fadeOut(1000,function(){
							n.css('z-index','5');
							$('.buffer').show();
						});
						n.css({
							position : 'absolute',
							'margin-left' : (aG[mP].totalW-$(this).width())/2,
							'margin-top' : (aG[mP].totalH-$(this).height())/2
						});
					}
					
					$('.play').hide();
					var nextSlide = function(next){
						var f = slideshow.find('img:visible');
						if(next){
							var n = $(next);
						}else{
							var n = slideshow.find('img:visible').next('img');
							if(n.length==0) n = slideshow.find('img:first');
						}
						/* Make sure the next image is loaded before proceeding (don't worry, the loop event will re-fire) 
						if(!n[0].complete) return false;*/
						
						if(thumbs){
							var i = n.prevAll('img').length;
							var nt = $('.thumbnails img:eq('+i+')');
							var pt = $('.thumbnails img.active');
							pt.removeClass('active').attr('src',pt.attr('src').replace(/(_bw|_b|_c)\./,'_bw.'));
							nt.addClass('active').attr('src',nt.attr('src').replace(/(_bw|_b|_c)\./,'_c.'));;
						}
						
						/* Buffered Animation */
						if(buffer){
							$('.buffer').css({
								'z-index':'4',
								'height':f.height(),
								'width':f.width(),
								'margin-left' : (aG[mP].totalW-f.width())/2,
								'margin-top' : (aG[mP].totalH-f.height())/2
							});
							f.css('z-index','5').fadeOut(600,function(){
								$('.buffer').animate({
									'height':n.height(),
									'width':n.width(),
									'margin-left' : (aG[mP].totalW-n.width())/2,
									'margin-top' : (aG[mP].totalH-n.height())/2
								},300,'swing',function(){
									n.css({
										position : 'absolute',
										'margin-left' : (aG[mP].totalW-$(this).width())/2,
										'margin-top' : (aG[mP].totalH-$(this).height())/2,
										'z-index' : 3
									}).show();
									/* Alter Text */
									$('.descriptionText').html(n.attr('imageLabel').replace(/ /g,'')==''?' ':n.attr('imageLabel'));
									
									$('.buffer').fadeOut(1000,function(){
										n.css('z-index','5');
										$('.buffer').show();
									});
								});
							});
						}else{
							/* Non Buffered Animation */
							f.css('z-index',5);
							n.css('z-index',4).show();
								f.fadeOut(800,'swing',function(){
									$('.descriptionText').html(n.attr('imageLabel').replace(/ /g,'')==''?' ':n.attr('imageLabel'));
								});
						}
					};
					var looping=true;
					var t = setTimeout(function(){beginLoop();},transitionTime);
					var beginLoop = function(){
						nextSlide();
						t = setTimeout(function(){beginLoop();},transitionTime- -800);
					};
					var play = function(){
						clearTimeout(t);
						$('.play').hide();
						$('.pause').show();
						beginLoop();
					};
					var pause = function(){
						clearTimeout(t);
						$('.play').show();
						$('.pause').hide();
						slideshow.find('img').stop(true,true);
					};
					$('.play').click(play);
					$('.pause').click(pause);
					$('.next').click(function(){nextSlide();play();});
				/* If the image is loaded from cache, the load event doesn't fire, this checks if it's already loaded and the load event missed */
				}).each(function(){
					if(this.complete) $(this).trigger("load");
				});
			}
		});
	}
});
}





$(document).ready(function(){
	$('a[href^="https://booking.ihotelier.com/istay/istay.jsp"]').click(function (event) {
		IHLink($(this).attr('href'));
		event.preventDefault();
	});
});

function IHLink(theURL){
	_gaq.push(function() {
        	var tracker = _gat._getTrackerByName(); 
        	window.open(tracker._getLinkerUrl(theURL));
     	 });
}

function postForm(oForm){
var qs = "";
	qs = qs + "?hotelid="	+ oForm.hotelid.value;
	qs = qs + "&datein=" 	+ oForm.datein.value;
        qs = qs + "&dateout=" 	+ oForm.dateout.value;
	qs = qs + "&Adults=" 	+ oForm.adults.value;
	qs = qs + "&Children=" 	+ oForm.children.value;
	 _gaq.push(function() {
        	var tracker = _gat._getTrackerByName(); 
			window.open(tracker._getLinkerUrl('https://booking.ihotelier.com/istay/istay.jsp' + qs));
     	 });
	 return false;
	}

$(window).load(function(){$('#content,div#bgfade,div#bgimage,div.hrhome').pngFix();});
$(function(){
		   
				   
		$('#floorplans div[id^="floorplans_"]').each(function(idx){
			if(idx != 1){
				$(this).hide();
			}else{
				$("."+$(this).attr('id')).css('fontWeight','bold');
			}
		});
	
		$('#floorplans ul li a[class^="floorplans"]').each(function(e){													 
			$(this).bind('click', function(e) {
				showFloorPlans($(this).attr('class'));
				$(this).css('fontWeight','bold');
				e.preventDefault();
			});
				
		});
	
	
	function showFloorPlans(classname) {
			$('#floorplans div[id^="floorplans"]').each(function(){
				
				if($(this).attr('id') == classname) {
					$(this).slideDown();
					
				}else{
					$('.'+$(this).attr('id')).css('fontWeight','normal');
					//console.log(classname);
					$(this).hide();	
				}
				
			});
		}

});
function popupPostcard(href,width,height,scroll)
	{
		postCard= window.open(href,'myPostcard','resizable=no,toolbar=no,left=200,top=200,status=no,location=no,height=' + height + ',width=' + width + ',scrollbars=' + scroll + "'");
	};
$(document).ready(function(){
	$('#seo').load('/i/SITE_110606_13453345_1HMJ9/propertylist.cfm');
});
/* Make PDF links without new windows, have new windows */
$(function(){$('a[href$=pdf][target!=_blank]').attr('target','_blank')})
