// Default JS Content - Do Not Delete
$(document).ready(function(){
    $('#startDate').datepicker().datepicker("setDate", new Date(new Date()- -1000*60*60*24));
    $('#startDateButton').click(function(){$('#startDate').datepicker("show");});

	$('#arrive').datepicker({
		minDate:0,
		showAnim: 'slideDown'
	}).change(function(){
		var secondsInADay = 1000*60*60*24;
		$('#depart').datepicker("option",{
			/* Set the Minimum Date to this guys Days ahead plus 1 */
			minDate: Math.ceil((new Date(this.value) - new Date())/secondsInADay)- -1
		});
		/* Change the Date to that Date */
		$('#depart').datepicker("setDate", new Date(new Date(this.value)- -secondsInADay));
		
	});
	$('#depart').datepicker({
		minDate:1,
		showAnim: 'slideDown'
	});
	$('#arrive').next().click(function(){$(this).prev().datepicker("show");});
	$('#depart').next().click(function(){$(this).prev().datepicker("show");});
    $('.subnav li:last').addClass('last');
	$('#nav1 li').hover(function(){
		$(this).addClass('sfhover');
	},function(){
		$(this).removeClass('sfhover');
	});



	var data = {
		'win': ['Winthrop Boardroom','12 x 17','198','10','','','','',''],
		'john': ['John Easton Room','13 x 21','283','18','16','30','20','',''],
		'spice': ['Spiced Pear Dining Room','18 x 37','691','','36','50','55','75','65'],
		'ver': ['The Veranda','16 x 26','385','','','','25','',''],
		'ter': ['The Terrace','34 x 45','1865','','','','125','250','85'],
		'all': ['Exclusive Use - Entire Facility','','approx 4000','','','','210','300','130']
	};
	function fillData(point){
		$('.data .point').each(function(i){
			var $t = $(this);
			$t.html(data[point][i]);
			if(data[point][i]==''){
				$t.parent().hide();
			}else{
				$t.parent().show();
			}
		});
	}
	fillData('all');
	var fpi = $('#floorplanImage');
	$('#floorplanImage').maphilight({strokeOpacity:'0',fillColor:'6f6647'});
	$('#floorplan area[coords]').hover(function(){
		fillData(this.id);
	},function(){
		fillData('all');
	});
});
(function(f){var b,c,j,m,l,i,g,e,h,a,k;b=document.namespaces;has_canvas=!!document.createElement("canvas").getContext;if(!(has_canvas||b)){f.fn.maphilight=function(){return this};return}if(has_canvas){g=function(p,o,n){if(o<=1){p.style.opacity=o;window.setTimeout(g,10,p,o+0.1,10)}};e=function(n){return Math.max(0,Math.min(parseInt(n,16),255))};h=function(n,o){return"rgba("+e(n.substr(0,2))+","+e(n.substr(2,2))+","+e(n.substr(4,2))+","+o+")"};c=function(n){var o=f('<canvas style="width:'+n.width+"px;height:"+n.height+'px;"></canvas>').get(0);o.getContext("2d").clearRect(0,0,o.width,o.height);return o};j=function(q,n,t,p,o){var s,r=q.getContext("2d");r.beginPath();if(n=="rect"){r.rect(t[0],t[1],t[2]-t[0],t[3]-t[1])}else{if(n=="poly"){r.moveTo(t[0],t[1]);for(s=2;s<t.length;s+=2){r.lineTo(t[s],t[s+1])}}else{if(n=="circ"){r.arc(t[0],t[1],t[2],0,Math.PI*2,false)}}}r.closePath();if(p.fill){r.fillStyle=h(p.fillColor,p.fillOpacity);r.fill()}if(p.stroke){r.strokeStyle=h(p.strokeColor,p.strokeOpacity);r.lineWidth=p.strokeWidth;r.stroke()}if(p.fade){g(q,0)}};m=function(n,o){n.getContext("2d").clearRect(0,0,n.width,n.height)}}else{c=function(n){return f('<var style="zoom:1;overflow:hidden;display:block;width:'+n.width+"px;height:"+n.height+'px;"></var>').get(0)};j=function(o,r,s,v,n){var t,u,p,q;t='<v:fill color="#'+v.fillColor+'" opacity="'+(v.fill?v.fillOpacity:0)+'" />';u=(v.stroke?'strokeweight="'+v.strokeWidth+'" stroked="t" strokecolor="#'+v.strokeColor+'"':'stroked="f"');p='<v:stroke opacity="'+v.strokeOpacity+'"/>';if(r=="rect"){q=f('<v:rect name="'+n+'" filled="t" '+u+' style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:'+s[0]+"px;top:"+s[1]+"px;width:"+(s[2]-s[0])+"px;height:"+(s[3]-s[1])+'px;"></v:rect>')}else{if(r=="poly"){q=f('<v:shape name="'+n+'" filled="t" '+u+' coordorigin="0,0" coordsize="'+o.width+","+o.height+'" path="m '+s[0]+","+s[1]+" l "+s.join(",")+' x e" style="zoom:1;margin:0;padding:0;display:block;position:absolute;top:0px;left:0px;width:'+o.width+"px;height:"+o.height+'px;"></v:shape>')}else{if(r=="circ"){q=f('<v:oval name="'+n+'" filled="t" '+u+' style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:'+(s[0]-s[2])+"px;top:"+(s[1]-s[2])+"px;width:"+(s[2]*2)+"px;height:"+(s[2]*2)+'px;"></v:oval>')}}}q.get(0).innerHTML=t+p;f(o).append(q)};m=function(n){f(n).find("[name=highlighted]").remove()}}l=function(o){var n,p=o.getAttribute("coords").split(",");for(n=0;n<p.length;n++){p[n]=parseFloat(p[n])}return[o.getAttribute("shape").toLowerCase().substr(0,4),p]};k=function(p,o){var n=f(p);return f.extend({},o,f.metadata?n.metadata():false,n.data("maphilight"))};a=function(n){if(!n.complete){return false}if(typeof n.naturalWidth!="undefined"&&n.naturalWidth==0){return false}return true};i={position:"absolute",left:0,top:0,padding:0,border:0};var d=false;f.fn.maphilight=function(p){p=f.extend({},f.fn.maphilight.defaults,p);if(f.browser.msie&&!d){document.namespaces.add("v","urn:schemas-microsoft-com:vml");var o=document.createStyleSheet();var n=["shape","rect","oval","circ","fill","stroke","imagedata","group","textbox"];f.each(n,function(){o.addRule("v\\:"+this,"behavior: url(#default#VML); antialias:true")});d=true}return this.each(function(){var v,s,z,r,u,w,y,t,x;v=f(this);if(!a(this)){return window.setTimeout(function(){v.maphilight(p)},200)}z=f.extend({},p,f.metadata?v.metadata():false,v.data("maphilight"));x=v.get(0).getAttribute("usemap");r=f('map[name="'+x.substr(1)+'"]');if(!(v.is("img")&&x&&r.size()>0)){return}if(v.hasClass("maphilighted")){var q=v.parent();v.insertBefore(q);q.remove()}s=f("<div></div>").css({display:"block",background:"url("+this.src+")",position:"relative",padding:0,width:this.width,height:this.height});if(z.wrapClass){if(z.wrapClass===true){s.addClass(f(this).attr("class"))}else{s.addClass(z.wrapClass)}}v.before(s).css("opacity",0).css(i).remove();if(f.browser.msie){v.css("filter","Alpha(opacity=0)")}s.append(v);u=c(this);f(u).css(i);u.height=this.height;u.width=this.width;y=function(C){var A,B;B=k(this,z);if(!B.neverOn&&!B.alwaysOn){A=l(this);j(u,A[0],A[1],B,"highlighted");if(B.groupBy&&f(this).attr(B.groupBy)){var D=this;r.find("area["+B.groupBy+"="+f(this).attr(B.groupBy)+"]").each(function(){if(this!=D){var F=k(this,z);if(!F.neverOn&&!F.alwaysOn){var E=l(this);j(u,E[0],E[1],F,"highlighted")}}})}}};if(z.alwaysOn){f(r).find("area[coords]").each(y)}else{f(r).find("area[coords]").each(function(){var A,B;B=k(this,z);if(B.alwaysOn){if(!w){w=c(v.get());f(w).css(i);w.width=v.width();w.height=v.height();v.before(w)}A=l(this);if(f.browser.msie){j(u,A[0],A[1],B,"")}else{j(w,A[0],A[1],B,"")}}});f(r).find("area[coords]").mouseover(y).mouseout(function(A){m(u)})}v.before(u);v.addClass("maphilighted")})};f.fn.maphilight.defaults={fill:true,fillColor:"000000",fillOpacity:0.2,stroke:true,strokeColor:"ff0000",strokeOpacity:1,strokeWidth:1,fade:true,alwaysOn:false,neverOn:false,groupBy:false,wrapClass:true}})(jQuery);




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;
					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);
							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 animating = false;
					var nextSlide = function(next){
						/* Make sure we're not already in transition */
						if(animating) return false;
						animating = true;
						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();
									animating=false;
									/* 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();
							if($.browser.webkit){
								f.css({
									'webkitTransitionProperty': 'opacity', 
									'webkitTransitionDuration': '800ms', 
									'webkitTransitionTimingFunction': 'ease-out'
								});
								f.one('webkitTransitionEnd', function(){
									animating=false;
									$('.descriptionText').html(n.attr('imageLabel').replace(/ /g,'')==''?' ':n.attr('imageLabel'));
									var $t = $(this);
									$t.hide().css({
										'z-index':3,
										'webkitTransitionProperty': 'none'
									});
									$t.css({
										'opacity':1
									});
								});
                    			setTimeout(function($f){ $f.css({'opacity':0}) }, 0, f);
							}else{
								f.fadeOut(800,function(){
									animating=false;
									$('.descriptionText').html(n.attr('imageLabel').replace(/ /g,'')==''?' ':n.attr('imageLabel'));
								},'swing');
							}
						}
					};
					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();
					};
					$('.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://gc.synxis.com/rez.aspx"]').click(function (event) {
        SynLink($(this).attr('href'));
        event.preventDefault();
    });

	
    $("form[name='form1']").submit(function(e){
	postSynForm(document.forms['form1'])
	e.preventDefault();
    });

	$('#sp_banner').load('/i/SITE_100722_17042938_KHN51/homeRotator.cfm?type=banner&areaid=BNA_100903_10093068_2EUT1',function() {
		return false;
	});
//$('#sp_banner').fadeIn();
});

function SynLink(theUrl){
    _gaq.push(function() {
            var tracker = _gat._getTrackerByName(); 
            window.open(tracker._getLinkerUrl(theUrl));
         });
     }
	 
function postSynForm(oForm){
var qs = "";
	qs = qs + "?hotel="		+ oForm.Hotel.value;
	qs = qs + "&chain="		+ oForm.Chain.value;
	qs = qs + "&template="	+ oForm.template.value;
	qs = qs + "&shell="		+ oForm.shell.value;
	
	qs = qs + "&arrive=" 	+ oForm.arrive.value;
	qs = qs + "&depart=" 	+ oForm.depart.value;
	qs = qs + "&adults=" 	+ oForm.adults.value;
	qs = qs + "&child=" 	+ oForm.child.value;
	 _gaq.push(function() {
        	var tracker = _gat._getTrackerByName(); 
			window.open(tracker._getLinkerUrl('https://gc.synxis.com/rez.aspx' + qs));
     	 });
	}
	
/* IE PNG fix multiple filters */ 

	(function ($) {     
    	if (!$) return;     
        	$.fn.extend({
             fixPNG: function(sizingMethod, forceBG) {
                if (!($.browser.msie)) return this;
                var emptyimg = "_.gif"; //Path to empty 1x1px GIF goes here
                sizingMethod = sizingMethod || "scale";
                //sizingMethod, defaults to scale (matches image dimensions)
                    this.each(function() {
                         var isImg = (forceBG) ? false : jQuery.nodeName(this, "img"), imgname = (isImg) ? this.src : this.currentStyle.backgroundImage, src = (isImg) ? imgname : imgname.substring(5,imgname.length-2);
                         this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + sizingMethod + "')";
                             if (isImg) this.src = emptyimg;
                                else this.style.backgroundImage = "url(" + emptyimg + ")";                 
                             });                 
                             return this;}
                          }); 
                  })(jQuery); 
