﻿$(function() {     
	$("#content .info").hide()  
	$("#content .info:first").show() 	
	$("ul#newSuiteLinks li a:first").css("color", "#e8d497").addClass("activated"); 
	$("ul#newSuiteLinks li:last").css("border", "none"); 
	goSifr();

});
$(window).load(function() {     	
	$("#slideHolder").load("imageLinks/restaurants.html", bleach);
		function bleach() {  
		$("#slideHolder .currentImage img").hide();
		$.preload( $('#slideHolder .currentImage img'),  { onFinish: function() {$("#slideHolder .currentImage img:first").fadeIn("slow"); $.idle(loop, 5000);}
		});
	}

	
	
function hideTabs() {       
	$("#content .info").hide()  
	$("ul#newSuiteLinks li a").css("color", "").removeClass("activated"); 
	$("#slideHolder .currentImage").css("z-index", "10").removeClass("currentImage").fadeOut("slow");   
}
		
function showTab(whatTab) {

	$(whatTab).css("color", "#e8d497"); 
	var source = whatTab.getAttribute("rel");
	var target = document.getElementById(source);        
	 $(target).fadeIn("slow");            
	var targetImage = "#mainImage #" + source + "Image";     
	$(targetImage).addClass("currentImage");  ;
		if($(targetImage + ".currentImage img").length > 1) {   
			$(targetImage + ".currentImage img").hide();
			$(targetImage + ".currentImage img:first").show();
			$(targetImage).css("z-index", "20").fadeIn("slow");             
			$.idle(loop, 5000);
		} else {
			$.idle(null, 1);
			$(targetImage).css("z-index", "20").fadeIn("slow");  
	} 
}                                                          

currentIndx = 0;                        
var suiteImages = new Array(); 

function loop(){    
	var suiteImages = $("#slideHolder .currentImage img"); 
		if (suiteImages.length > 1) { 
			for (var i=0; i < suiteImages.length; i++) {     
				$(suiteImages[currentIndx]).fadeOut("slow");
			}         
			if (currentIndx < suiteImages.length-1) {
				currentIndx=currentIndx+1;
				$(suiteImages[currentIndx]).fadeIn("slow")  
			} else {
				currentIndx=0;  
			$(suiteImages[currentIndx]).fadeIn("slow");  
}			   
$.idle(loop, 5000);      
}
}

//////////////////////    new ajax image loader   15/07/08  ///////////////////

$("ul#newSuiteLinks li a").click (
	function() {    
		if($(this).hasClass("activated")) {
			return false;
			} else {
			hideTabs(); 
			showTab(this); 
			$(this).addClass("activated");
				if($("#lightbox").css("display") == "block") {
					$("#tourHolder iframe").remove();                                       				
					$.idle("$('#lightbox').fadeOut('slow'); $('.tourControls').hide();", 500); 
				if($("#mainImage .currentImage").length > 1 ) {
					$.idle("loop()", 5000);  
			} 
			$("li.topLevel").hoverIntent (  			
					function() { $("ul", this).slideDown("fast"); } , 
					function() { $("ul", this).slideUp("fast");}
				);
		}

	}	
		
goSifr();
  
return false;					
	}
);   

/*});


$(function() {  */
	  
	  
function showLoader() {
		$("#tourHolder").html("<img src='layout/ajax-loader.gif' alt='loading' style='position: absolute; top: 150px; left: 466px;' id='loading'  />");
	}        
	
	$(".virtualTourBtn").click (
		function() { 
			if($("#lightbox").css("display") == "none") {   
				//$("a.slideOpener").css("backgroundPosition", "0 0").css("cursor", "default");
				$("li.topLevel").hoverIntent (  	
					function() {return false;},
					function(){return false}
				);
				$("#lightbox").fadeIn("slow");
				var whatIcons = $(this).attr("id");  
				var controls = "#" + whatIcons + "Control";                                
				$(controls).show();     
				$("#tourHolder img").remove(); 
				$(".galleryControls").hide();       
				$.idle(null, 5000); 
				showLoader();
		hunter = function() {$('#tourHolder').load('virtualTours/iframes/' + whatIcons + '1.html')};
		setTimeout("hunter()", 2000);            
		//$('#tourHolder').load('virtualTours/suites/' + whatIcons + '1.html').oneTime(5000);  
		$('#' + whatIcons +'1 a').css("backgroundPosition", "0 0"); 
			} else {   
				$("#tourHolder iframe").remove();                                       				
          		setTimeout("$('#lightbox').fadeOut('slow'); $('.tourControls').hide();", 500);
				$.idle(loop, 5000);  
				$("li.topLevel").hoverIntent (  			
					function() { /*$("a.slideOpener", this).css("backgroundPosition", "0 -23px"); */$("ul", this).slideDown("fast"); } , 
					function() { $("ul", this).slideUp("fast"); /*$("a.slideOpener", this).css("backgroundPosition", "0 0");*/}
				); 
			} 
		}
	);
	

	
	$(".lightBoxCloseBtn").click (
		function() {  
			$.idle(null, 5000);                        
			$("li.topLevel").hoverIntent (  			
				function() {  $("ul", this).slideDown("fast"); } , 
				function() { $("ul", this).slideUp("fast");}
			); 
			$("#tourHolder iframe").remove();                                       				
           setTimeout("$('#lightbox').fadeOut('slow'); $('.tourControls').hide();", 500); 
           if($("#mainImage .currentImage img").length > 1 ) {
				$.idle(loop, 5000);  
				//loop();
			}
		}
	);	 
	
	$(".tourLink").click (  
		function() {
			 $("#tourHolder iframe").remove();  
			 $(".tourLink a").css("backgroundPosition", "0 -22px");             
			 /*var thisLinkTag = $(this) + ".tourLink a";
			 $(thisLinkTag).css("backgroundPosition", "0 -9px");*/  
			 $(this.firstChild).css("backgroundPosition", "0 0");
			showLoader();  
			var thisLink = $(this);
			loadTour = function() {          
				var targetTour = $(thisLink).attr("id");
				$("#tourHolder").load("virtualTours/iframes/" + targetTour +".html");  		
        	}   
        		setTimeout("loadTour()", 2000); 
        		return false;
        		}
   );    
} );

/**
 * jQuery (PNG Fix) v1.2
 * Microsoft Internet Explorer 24bit PNG Fix
 *
 * The MIT License
 * 
 * Copyright (c) 2007 Paul Campbell (pauljamescampbell.co.uk)
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * @param		Object
 * @return		Array
 */
(function($) {
	
	$.fn.pngfix = function(options) {
		
		// Review the Microsoft IE developer library for AlphaImageLoader reference 
		// http://msdn2.microsoft.com/en-us/library/ms532969(VS.85).aspx
		
		// ECMA scope fix
		var elements 	= this;
		var settings 	= $.extend({
			imageFixSrc: 	false,
			sizingMethod: 	false 
		}, options);
		
		if(!$.browser.msie || ($.browser.msie &&  $.browser.version >= 7)) {
			return(elements);
		}

		function setFilter(el, path, mode) {
			var fs = el.attr("filters");
			var alpha = "DXImageTransform.Microsoft.AlphaImageLoader";
			if (fs[alpha]) {
				fs[alpha].enabled = true;
				fs[alpha].src = path; 
				fs[alpha].sizingMethod = mode;
			} else {
				el.css("filter", 'progid:' + alpha + '(enabled="true", sizingMethod="' + mode + '", src="' + path + '")');			
			}
		}
		
		function setDOMElementWidth(el) {
			if(el.css("width") == "auto" & el.css("height") == "auto") {
				el.css("width", el.attr("offsetWidth") + "px");
			}
		}

		return(
			elements.each(function() {
				
				// Scope
				var el = $(this);
				
				if(el.attr("tagName").toUpperCase() == "IMG" && (/\.png/i).test(el.attr("src"))) {
					if(!settings.imageFixSrc) {
						
						// Wrap the <img> in a <span> then apply style/filters, 
						// removing the <img> tag from the final render 
						el.wrap("<span></span>");
						var par = el.parent();
						par.css({
							height: 	el.height(),
							width: 		el.width(),
							display: 	"inline-block"
						});
						setFilter(par, el.attr("src"), "scale");
						el.remove();
					} else if((/\.gif/i).test(settings.imageFixSrc)) {
						
						// Replace the current image with a transparent GIF
						// and apply the filter to the background of the 
						// <img> tag (not the preferred route)
						setDOMElementWidth(el);
						setFilter(el, el.attr("src"), "image");
						el.attr("src", settings.imageFixSrc);
					}
					
				} else {
					var bg = new String(el.css("backgroundImage"));
					var matches = bg.match(/^url\("(.*)"\)$/);
					if(matches && matches.length) {
						
						// Elements with a PNG as a backgroundImage have the
						// filter applied with a sizing method relevant to the 
						// background repeat type
						setDOMElementWidth(el);
						el.css("backgroundImage", "none");
						
						// Restrict scaling methods to valid MSDN defintions (or one custom)
						var sc = "crop";
						if(settings.sizingMethod) {
							sc = settings.sizingMethod;
						} 
						setFilter(el, matches[1], sc);
						
						// Fix IE peek-a-boo bug for internal links
						// within that DOM element
						el.find("a").each(function() {
							$(this).css("position", "relative");
						});
					}
				}
				
			})
		);
	}

})(jQuery)

$(function() {  
				$("#lightbox").pngfix({
				sizingMethod: "scale"
			});  
				});