﻿$(document).ready(function() {
	
	var url = location.pathname;
	//var url = document.location.toString();
	//alert(url);
	
	//subscribe box animation
	
	//modal background
	var background = $(".modalPopupTransparent");


$("a.subscribeFormLink").click(function() {
	
	//show the background
	$(background).css({width: screen.width});				
	$(background).css({height: screen.height});
	$(background).show();
	
	//show the form
	$("#subscribeForm").animate({
    opacity: 'show',
    height: 'toggle'
	}, 500, function() {
    // Animation complete.
  	});
	
	

});

$("a.closeIcon").click(function() {
								
								
								
	//hide the form							
	$("#subscribeForm").animate({
    opacity: 'hide',
    height: 'toggle'
	}, 500, function() {
    // Animation complete.
  	});
	//hide the background
	$(background).css({width: screen.width});				
	$(background).css({height: screen.height});
	$(background).hide();	
});
	
	
	
	$("#topNavigation ul li:last-child a").addClass("last");
	
	if(location.pathname.indexOf('Regions') > 0 || location.pathname.indexOf('Destinations') > 0){
		$("#topNavigation ul li:eq(1) a").addClass("active");
	}
	
	// if (url.indexOf("Regions") || url.indexOf("Destinations")) {
    	//$("#topNavigation ul li:last-child a").addClass("active");
  	//}

	
	
	$(".bannersNavigation a:first").addClass("active");
	var contentwidth = $("#bannersHolder").width();
	var totalcontent = $(".bannerContent").size();
	var allcontentwidth = contentwidth * totalcontent;
	$(".bannerSlides").css({'width' : allcontentwidth});
	
	rotate = function(){
		var slideid = $active.attr("rel") - 1;
		var slidedistance = slideid * contentwidth;
		$(".bannersNavigation a").removeClass('active');
		$active.addClass('active');
		$(".bannerSlides").animate({left: -slidedistance}, 500 );
	}; 
	
	rotation = function(){
		play = setInterval(function(){
		$active = $('.bannersNavigation a.active').next();
		if ( $active.length === 0) {
			$active = $('.bannersNavigation a:first');
		}
		rotate();
		//Timer speed 5 sec
		}, 5000);
	};
	
	rotation();
	
	$(".bannersNavigation a").click(function() {
		$active = $(this);	
		clearInterval(play);
		rotate();
		rotation();
		return false;
	});
	
	/*
	// To make the whole btn clickable on the home page
	$(".home_button").click(function(){
			$(this).css('cursor:pointer');							 
			 window.location=$(this).find("p.click_here a").attr("href");
		 return false;
	});
	*/
	
});




function openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function openModalWindow(passedDiv, passedBgDiv) {

    var bgDiv = $(passedBgDiv);
    bgDiv.width($(window).width());
    bgDiv.height($(document).height());
    bgDiv.show();


    var popUpDivName = $(passedDiv);
             
	//get the size of the window and calculate where the box should be placed        
    popUpDivName.css('top', (($(document).height() - popUpDivName.height() * 2) / 2) + 'px');
    popUpDivName.css('left', (($(window).width() - popUpDivName.width()) / 2) + 'px');
    if (popUpDivName.height() > $(window).height()) {
        popUpDivName.css('top', '20px');        
    }        
   
}

function closeModalWindow(passedDiv, passedBgDiv) {

    var bgDiv = $(passedBgDiv);
    var popUpDivName = $(passedDiv);
    bgDiv.hide();
    popUpDivName.hide();
}

function getBrowserWindowSize() {    
	var winW = 630, winH = 460;    
	if (parseInt(navigator.appVersion)>3) {        
		if (navigator.appName=="Netscape") {            
		winW = window.innerWidth;            
		winH = window.innerHeight;        
		}        
	if (navigator.appName.indexOf("Microsoft")!=-1) {            
		winW = document.body.offsetWidth;            
		winH = document.body.offsetHeight;        
	}  
	}    
	var rval = {        
	width: winW,        
	height: winH    
};    

return rval;
}

function toggle(idName){
    $("#" + idName).slideToggle("slow");
    //alert($("#" + idName + "_Link").html());
    
    
    if($("#" + idName + "_Link").html() == "Click to hide room configuration"){
    
    
       $("#" + idName + "_Link").html("Click to view room configuration");
    }else{
        $("#" + idName + "_Link").html("Click to hide room configuration");
    }
}


function showToolTip(idName) {
    tip = $("." + idName).parent().find('.tip');
    tip.show(); //Show tooltip
   

}

function hideToolTip(idName) {
    tip = $("." + idName).parent().find('.tip');
    tip.hide(); //Hide tooltip
}
