$(document).ready(function(){


	
  
 
//  	$(img).load(function () {   
//    	$(this).hide();
//      	$('#loader').removeClass('loading').append(this);
//      	$(this).fadeIn();
//    }).error(function () {
//      
//    }).attr('src', '/images/home_page/background.jpg');

if($(".home-page").length > 0){
//	var img = new Image();
//	var imagePath='/images/home_page/background.jpg';
//	$(img).attr("src",imagePath).load(function(){
//	       $("#loader").hide();
//	});
	if ($.browser.mozilla || $.browser.msie) {
		$("#backImage").onImagesLoad({
			selectorCallback: backgroundLoaded
		});
	}
	
	if ($.browser.opera) {
   		$("#loader").hide();
		imagePath=$("#backSrc").attr("src");
		$("#content-area").css({
			"background" : "url(" + imagePath + ") no-repeat"
		});
	}
	
	if ($.browser.safari) {
   		$("#loader").hide();
		imagePath=$("#backSrc").attr("src");
		$("#content-area").css({
			"background" : "url(" + imagePath + ") no-repeat"
		});
	}
	
	if ($.browser.msie) {
		var img = new Image();
		var imagePath='/images/home_page/background.jpg';
		$(img).attr("src",imagePath).load(function(){
		       $("#loader").hide();
			   $("#content-area").css({
					"background" : "url(" + imagePath + ") no-repeat"
				});
		});
		
	}
		
}
 	
/*
init Actions
*/
	$("#slogan").fadeIn(5000);
/*
init Actions End
*/

/*
Accordion Code
*/	

	$('#accordion').kwicks({
		min : 20,
		spacing : 0,
		sticky : true,
		event : 'click'

	});
/*
Accordion Code End
*/
	
/*
Reservation Widget Code
*/
	
	$("#depDate").datepicker({ 
	    showStatus: true,
		minDate: 0, 
    	maxDate: 365, 
		dateFormat:"dd-mm-yy",
		mandatory: true,
	    showOn: "button", 
	    buttonImage: "./images/calendar.png", 
	    buttonImageOnly: true 
	}); 
	
	$("#retDate").datepicker({ 
	    showStatus: true,
		minDate: 0, 
    	maxDate: 365, 
		dateFormat:"dd-mm-yy",
		mandatory: true,
	    showOn: "button", 
	    buttonImage: "./images/calendar.png", 
	    buttonImageOnly: true 
	});
	
	$("#retDate").datepicker("disable");

	$(':input',this).change(function(){
    	itmId=$(this).attr('id');
		switch(itmId){
			case "cboOrigin":
				index=document.getElementById(itmId).selectedIndex;
				value=document.getElementById(itmId)[index].value;
				if(value!="" && value!=undefined){
					$("#cboDestination").removeAttr("disabled");
					$(".hide").removeClass("hide");
					$("."+value.toLowerCase()).addClass("hide");
					$("#hidOrigin").val(value);
				}else{
					$(".hide").removeClass("hide");
					document.getElementById($("#cboDestination").attr("id")).selectedIndex=0;
					$("#cboDestination").attr("disabled","disabled");
				}
				break;
			case "cboDestination":
				index=document.getElementById(itmId).selectedIndex;
				value=document.getElementById(itmId)[index].value;
				if(value!="" && value!=undefined){
					$(".hide").removeClass("hide");
					$("."+value.toLowerCase()).addClass("hide");
					$("#hidDestination").val(value);
				}else{
					$(".hide").removeClass("hide");
				}
				break;
			case "depDate":
				value=$(this).val();
				arr=value.split("-");
				day=eval(arr[0]);
				month=eval(arr[1]);
				year=eval(arr[2]);
				if(validate(value).length>0 && value!="dd-mm-yyyy"){
					$("#retDate").datepicker("enable");
					$("#cbodepday").val(parseInt(day));					
					$("#cbodepdayyear").val(parseInt(month).toString()+','+year);					
				}else{
					$("#retDate").datepicker("disable");
				}
				break;
			case "retDate":
				value=$(this).val();
				arr=value.split("-");
				day=eval(arr[0]);
				month=eval(arr[1]);
				year=eval(arr[2]);
				if(validate(value).length>0 && value!="dd-mm-yyyy"){
					$("#hidRetDate").val(parseInt(day));					
					$("#cboretday").val(parseInt(day));					
					$("#cbomonthyearret").val(parseInt(month).toString()+','+year);					
				}else{
					
				}
				break;
		}
    });
	
	$("#rbRound").click(function(){
		if($(this).attr('checked')||$(this).attr('checked')=="checked"){
			$(this).val('round');
			$("#hidRound").val('round');
		}else{
			$(this).val('one');
			$("#hidRound").val('one');
		}
	});
	/*VALIDATION FUNCTIONALITY*/
		$("#send_button").click(function(){
			if($("#hidRound").val()=="round"){
				if(validate($("#retDate").val()).length>0 && $("#retDate").val()!="dd-mm-yyyy"){
					return true;
				}else{
					alert("Please enter a return date.");
					return false;
				}
			}else{
				return true;
			}
		});
	/*END VALIDATION FUNCTIONALITY*/
/*
Reservation Widget Code End
*/

/*
Site Map Code
*/
	$(".sitemap .section-box .heading a").click(function(){
		$(".clicked").removeClass("clicked");
		$(".dummy").remove();
		hLink=$(this).attr("href");
		superParent=$(this).parent().parent(".section-box");
		superParent.addClass("clicked");
		if($(".clicked .content").length>0){
			if($.browser.msie && parseInt(jQuery.browser.version)<7){
				superParent.append('<div class="clear dummy" style="height:1px!important;overflow:hidden!important;"><img src="/images/common/spacer.gif" width="0" height="0"></div>');
			}		
			$(".clicked .content").slideToggle("slow");	
		}else{
			window.location=hLink;
		}	
		
		return false;
	});
	
/*
Site Map Code end
*/
});

function backgroundLoaded(){
	$("#loader").hide();
	imagePath=$("#backSrc").attr("src");
	$("#content-area").css({
		"background" : "url(" + imagePath + ") no-repeat"
	});
}

function validate(){
	if(arguments[0]!=undefined && arguments[0] !=""){
		return arguments[0];
	}else{
		return false;
	}
}

function createElem(obj){
	var elObj=obj;
}

function writeFlash(container,swfName,xmlPath,width,height){
	var swfObj=new Object();
	if (xmlPath != undefined || xmlPath != "") {
		swfObj.xmlpath="?xmlPath="+xmlPath;
	}
	if (xmlPath == undefined || xmlPath == ""){
		swfObj.xmlpath="";
	}
	if(width!=undefined || width!=""){
		swfObj.w=width;
	}
	if(width==undefined || width==""){
		swfObj.w="188";
	}
	if(height!=undefined || height!=""){
		swfObj.h=height;
	}
	if(height==undefined || height==""){
		swfObj.h="106";
	}
	var so = new SWFObject("/flash/"+swfName+swfObj.xmlpath, "mihin", swfObj.w, swfObj.h, "6", "#999");	
	so.addVariable("ie", "0");
	so.addVariable("app", "");
	so.addVariable("id", "");
	so.addParam("wmode", "transparent");
	so.addParam("scale", "noscale");
	so.addParam("allowFullScreen", "true");
	so.write(container);
	so="";
}