$(function() {
	//Documentation located in special.docs.js
	
	$("#spa-modal").each(function() {
		var modalWidth = ($(window).width()-$(this).width())/2;
		$(this).css('left',modalWidth);
		$(this).css('top','120px');
		$(this).jqm({closeClass:'jqmClose'}).jqmShow();
	});
	$("#ipad-modal").each(function() {
		var modalWidth = ($(window).width()-$(this).width())/2;
		$(this).css('left',modalWidth);
		$(this).css('top','120px');
		$(this).jqm({closeClass:'jqmClose'}).jqmShow();
	});
	
	$(document).ready(function(){
			$("body.home #masthead").html('').flash({
				swf:"flash/home-masthead.swf",
				width:"2000",
				height:"409",
				params:{
					allowscriptaccess:"always",
					wmode:"transparent",
					flashvars:{
						xmlPath:"flash/flash/xml/home-masthead.xml"
					}
				}
			});
		
			/* Wedding Testimonials */
			if(!CMT){ //Run only if not on CMT
			// randomly re-sort testimonials
				var testimonials = $("div.testimonials").children("div.testimonial-wrapper");
				
				testimonials.sort(function() {return 0.5 - Math.random()});
				
				$("div.testimonials").attr("id", "below-inset");
				$("div#inset").before("<div id='above-inset' class='testimonials'></div>");
				
				var cont = 0;
				testimonials.each(function(){
					if(cont < 2){
						$("div#above-inset").append($(this));
					}else{
						$("div#below-inset").append($(this));
					}
					cont++;
				});
				
				$("div.testimonials").css("display", "block"); 
				
				$('div.testimonial-content').each(function(){
					
					var height = $(this).height();
					var readMore = '<div class="testimonial-more"><a href="#">Read More</a></div>';
					
					if($(this).height() > 100){
						$(this).addClass("collapsed").attr("height", height).after(readMore);
					}
				
				});
				
				$('div.testimonial-more a').click(function(e) {
					e.preventDefault();
					
					var testimonial = $(this).parent().prev();
					var height = testimonial.attr("height");
					var newHeight = testimonial.height();
					
					testimonial.animate({height: height+"px"}, 800 ).attr("height", newHeight).toggleClass("collapsed");
					
					if(testimonial.hasClass("collapsed")){
						$(this).text("Read more");
					}else{
						$(this).text("Read less");
					}
					
				});
			
			}
			if(CMT)$("div.testimonials").css("display", "block"); 

	
	});
	
	$('div#sidebar h3').sifr({ strSWF: '/flash/helvetica-condensed.swf', strColor: '#47220a', strWmode: 'transparent', strCase: 'upper', strFlashVars: 'textalign=left&letterSpacing=2&' },{ expressInstall: true });
	
	$('div#sidebar h4' ).sifr({ strSWF: '/flash/helvetica-condensed.swf', strColor: '#59320e', strWmode: 'transparent', strCase: 'upper', strFlashVars: 'textalign=left&letterSpacing=2&' },{ expressInstall: true });
	
	// Booking console - Check availability promo code click button
	/*$("form#reservations-console").each(function(){
		var x = $(this);
		$("a#promo-click", x).click(function(){
			$("#dropdown-fields",x).show();
			if (BROWSER=='version6') { $('select', x).hide(); }
			return false;
		});
		$("#extra-fields-close").click(function() {
			$("#dropdown-fields",x).hide();
			if (BROWSER=='version6') { $('select', x).show(); }
			return false;
		});
	});*/
	$('a#promo-click').toggle(
		function() { 
			$('div#dropdown-fields').show();
			return false;
		},function() { 
			$('div#dropdown-fields').hide();
			return false;
		}
	);
	$("#promo-done-btn").click(function(){
		$("#dropdown-fields").hide();
		if ($('#group-code').val() || $('#promo-code').val() || $('#iata-number').val()) {
			$("#promo-click").addClass("selected-promo-click");
		} else {
			$("#promo-click").removeClass("selected-promo-click");
		}
		return false;
	});
	
	/*
	$('.trigger-floor-plan').each(function(){ 
		var jqid = $(this).attr('href').substr(1); 
		$(this).click(function(e) { 
			e.preventDefault(); 
			$('#'+jqid).jqm().jqmShow(); 
		});
	});
	*/
	
	
	$("#toys-modal").each(function() {
		var modalWidth = ($(window).width()-$(this).width())/2;
		$(this).css('left',modalWidth);
		$(this).css('top','120px');
		$(this).jqm({closeClass:'jqmClose'}).jqmShow();
	});
	
	
	
	$('#photo-gallery-modal').jqm({trigger: '#utility-photo a'});
	$('#trad').jqm({trigger: '.trad'});
	$('#golf').jqm({trigger: '.golf'});
	$('#queen-parlor').jqm({trigger: '.queen-parlor'});
	$('#one-br').jqm({trigger: '.one-br'});
	$('#exec-king').jqm({trigger: '.exec-king'});
	$('#two-br').jqm({trigger: '.two-br'});
	$('#king-jacuzzi').jqm({trigger: '.king-jacuzzi'});
	$('#hospitality-suite').jqm({trigger: '.hospitality-suite'});
	
	//$('#photo-gallery-modal').jqmAddTrigger('#photo-gallery-toggle'); 
	
	$('#photo-gallery-toggle').click(function(){ 

		$('#utility-photo a').click();

	});

	
	
	
	
	
	
	
	for(var i in $.browser) {
		if ($.browser[i])
			BROWSER = i + (($.browser.msie)?$.browser.version.charAt(0):'');
	}
	numVisible=3;
	perClick=1;
	
		
	$('body.golf-staff div#inset').flash({
		  swf:"/flash/golfstaff-inset.swf",
		  width:620,
		  height:200,
			params:{
				allowscriptaccess:"always",
				wmode:"transparent",
				flashvars:{
					xmlPath: '/flash/xml/golfstaff-images.xml'
				}
			}
	 });

	$('body.golf-club div#inset').flash({
		  swf:"/flash/membership-inset.swf",
		  width:620,
		  height:200,
			params:{
				allowscriptaccess:"always",
				wmode:"transparent",
				flashvars:{
					xmlPath: '/flash/xml/membership-images.xml'
				}
			}
	 });
		
 
		
		
		
		
});
