// JavaScript Document
$(document).ready(function() {
	function megaHoverOver(){		
		$(this).find(".sub").stop().fadeTo('fast', 1).show();
		str=$(this).find(".sub").html();
		//alert(str);
		Wid=500;
		//alert(str);
		flag=0;
		if(str!=null){
			if(str.indexOf("Welcome")!=-1){		
				Wid=600;
			}
			else if(str.indexOf("Accommodation")!=-1){
				Wid=600;
			}	
			else if(str.indexOf("Kumbalam")!=-1){
				Wid=200;
				flag=1;
			}	
			else if(str.indexOf("Guest")!=-1){
				Wid=400;
				flag=2;
			}	
		}	
			
		//Calculate width of all ul's
		(function($) { 
			jQuery.fn.calcSubWidth = function() {
				rowWidth = 0;
				//Calculate row
				$(this).find("ul").each(function() {					
					rowWidth += $(this).width(); 
				});	
			};
		})(jQuery); 
		
		if ( $(this).find(".row").length > 0 ) { //If row exists...
			var biggestRow = 0;	
			//Calculate each row
			$(this).find(".row").each(function() {							   
				$(this).calcSubWidth();
				//Find biggest row
				if(rowWidth > biggestRow) {
					biggestRow = rowWidth;
				}
			});
			//Set width
			biggestRow=Wid;
			if(flag==2 && ver<9)
				$(this).find(".sub").css({'width' :biggestRow,'z-index':99,'margin-left':-100});
			else if(flag==1 && ver<9)
				$(this).find(".sub").css({'width' :biggestRow,'z-index':99,'margin-left':-65});
			else
				$(this).find(".sub").css({'width' :biggestRow,'z-index':99});
			$(this).find(".row:last").css({'margin':'0'});
			
		} else { //If row does not exist...			
			
			$(this).calcSubWidth();
			//Set Width
			rowWidth=Wid;
			$(this).find(".sub").css({'width' : rowWidth,'z-index':99});
			
		}
	}
	
	function megaHoverOut(){ 
	  $(this).find(".sub").stop().fadeTo('fast', 0, function() {	  	  
		  $(this).hide(); 
		  str=$(this).html();
		  if(str.indexOf("Welcome")!=-1){		
		  }		
	  });
	}


	var config = {    
		 sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 100, // number = milliseconds for onMouseOver polling interval    
		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
		 timeout: 500, // number = milliseconds delay before onMouseOut    
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
	};

	$("ul#topnav li .sub").css({'opacity':'0'});
	$("ul#topnav li").hoverIntent(config);
	j=0;
	i=1;	
	
	if(ver<9){
		$("#divResort").css('padding-left',100);
		$("#sub1").css('padding-left',65);
	}
	start();
	hght=(getSizes()/2)-(280/2);
	$("#divLoader").offset({ top: hght, left: 0 });
	//alert(hght);
	$("#main_container").slideDown(3000)
	setTimeout("scrollMe()",10000);
	jQuery.preLoadImages("images/banner.jpg","new_design/home_images/1.jpg","new_design/home_images/2.jpg","new_design/home_images/3.jpg","new_design/home_images/4.jpg","new_design/home_images/5.jpg","new_design/home_images/6.jpg","new_design/home_images/7.jpg","new_design/home_images/8.jpg","new_design/home_images/9.jpg","new_design/home_images/10.jpg","new_design/home_images/11.jpg","new_design/home_images/12.jpg","new_design/home_images/13.jpg","new_design/home_images/14.jpg","new_design/home_images/15.jpg");
});
//alert(navigator.userAgent);
ver=9;
str=navigator.userAgent;
if(str.indexOf("MSIE")!=-1){
	temps=str.split("MSIE");
	temps=temps[1].split(";");
	ver=parseInt(temps[0],10);
}
function scrollMe(){
	$('#banner').html("<img src='new_design/home_images/1.jpg' id='bannerImg' height=285>");
	$('#banner').panorer({ 'easing': 'linear', 'direction': 'WE','duration':5000});		
}
function hideDiv() {document.getElementById('hideshow').style.display  = 'none'; }
function showDiv(val,w,h) { 
	str=''+'<img src="new_design/special_offers/'+val+'">';
	//alert(str);
	document.getElementById('popup_block').innerHTML=str;
	document.getElementById('popup_block').style.width=w+'px';
	document.getElementById('popup_block').style.height=h+'px';
	document.getElementById('hideshow').style.display = 'block'; 
	document.getElementById('popup').style.width=(w+50)+'px';
}
