
$(document).ready(function(){
	
	var sort = $("#sortby").attr("value");
	var minPrice = "0";
	var maxPrice = "10000";
	var type = "";
	var minLength = "0";
	var maxLength = "40";
	var dataType = "k";
	dataType = $("#dataType").html();
	var catType = "k";
	catType = $("#catType").html();	
	//Display Loading Image
	function Display_Load()
	{
	    $("#loading").fadeIn(100,0);
		$("#loading").html("<img src='/loading.gif' />");
	}
	//Hide Loading Image
	function Hide_Load()
	{
		$("#loading").fadeOut('slow');
	};
	
	function Reload_Data(){
		$("#content").load("/pagination_data.php?page=1&sort="+sort+"&minPrice=" + minPrice + "&maxPrice=" + maxPrice + "&type=" + type + "&minLength=" + minLength + "&maxLength=" + maxLength + "&dest=" + dest + "&catType=" + catType + "&dataType=" + dataType, Hide_Load());
		$(".pagination").load("/listing.php?page=1&sort="+sort+"&minPrice=" + minPrice + "&maxPrice=" + maxPrice + "&type=" + type + "&minLength=" + minLength + "&maxLength=" + maxLength + "&dest=" + dest + "&catType=" + catType + "&dataType=" + dataType, Hide_Load());
	};
	
	
	//remove filters
			/*		$("#selectedfltrs .minPrice").live('click',function(){
						minPrice = "0";
						$(this).text("None");
						$("#allfltrs .minPrice").show();
					});   */
	$(".selected").live('click',function(){
		Display_Load();
		
		if($(this).attr("title") == "price"){
			minPrice = 0;
			maxPrice = 10000;
		}
		if($(this).attr("title") == "type"){
			type = "";
		}
		if($(this).attr("title") == "tripLength"){
			minLength = "0";
			maxLength = "40";
		}
		
		$(this).removeClass("selected").addClass($(this).attr("title"));
		
		$(this).css({"background" : "url('/images/add.jpg') left no-repeat"});
		
		$("."+$(this).attr("title")).show();
		
		Reload_Data();
	});
	
	
	//apply filters
	
	$(".price,.type,.tripLength").live('click',function(){
		Display_Load();
		//minPrice = $(this).attr("alt");
		
		if($(this).attr("class") == "price"){

			minPrice = $(this).attr("min");
			maxPrice = $(this).attr("max");
		}
	/*
		if($(this).attr("class") == "minPrice"){

			minPrice = $(this).attr("alt");
		}
		if($(this).attr("class") == "maxPrice"){

			maxPrice = $(this).attr("alt");
		}
		*/
		if($(this).attr("class") == "type"){

			type = $(this).attr("alt");
		}
		if($(this).attr("class") == "tripLength"){

			minLength = $(this).attr("min");
			maxLength = $(this).attr("max");
		}

		//$("#selectedfltrs .minPrice").replaceWith($(this).clone());
		$(this).attr("title",$(this).attr("class"));
		$(this).removeClass($(this).attr("class")).addClass("selected");
		$("#allfltrs ."+$(this).attr("title")).hide();
		
		$(this).css({"background" : "url('/images/change.jpg') left no-repeat"});
		
		Reload_Data();
	});
	
	
	
	
   //Default Starting Page Results
   
	$(".pagination li:first").css({'color' : '#5b5445'}).css({'border' : '1px solid #a7966e'});
	
	Display_Load();
	
	$("#content").load("/pagination_data.php?page=1&sort="+sort+"&minPrice=" + minPrice + "&maxPrice=" + maxPrice + "&type=" + type + "&minLength=" + minLength + "&maxLength=" + maxLength + "&dest=" + dest + "&catType=" + catType + "&dataType=" + dataType, Hide_Load());
	
	$(".pagination").load("/listing.php?page=1&sort="+sort+"&minPrice=" + minPrice + "&maxPrice=" + maxPrice + "&type=" + type + "&minLength=" + minLength + "&maxLength=" + maxLength + "&dest=" + dest + "&catType=" + catType + "&dataType=" + dataType, Hide_Load());
	
	
	$("select").change(function () {
		sort = $(this).attr("value");
	
		Display_Load();
		
		//CSS Styles
		$(".pagination li")
		.css({'border' : 'none'})
		.css({'background' : '#ffffff'})
		.css({'color' : '#a7966e'});

		//Loading Data
		
		
		$("#content").load("/pagination_data.php?page=1" + "&sort=" + sort + "&minPrice=" + minPrice + "&maxPrice=" + maxPrice + "&type=" + type + "&minLength=" + minLength + "&maxLength=" + maxLength + "&dest=" + dest + "&catType=" + catType + "&dataType=" + dataType, Hide_Load());
		$(".pagination li:first").css({'color' : '#ffffff'}).css({'background' : '#5b5444'}).css({'border' : '1px solid #a7966e'});
		
	})
	

	//Pagination Click
	$(".pagination li").live('click',function(){
		Display_Load();
		
		//CSS Styles
		$(".pagination li")
		.css({'border' : 'none'})
		.css({'background' : '#ffffff'})
		.css({'color' : '#a7966e'});
		
		$(this)
		.css({'color' : '#ffffff'})
		.css({'background' : '#5b5444'})
		.css({'border' : '1px solid #a7966e'});

		//Loading Data
		
		var pageNum = this.id;
		
		$("#content").load("/pagination_data.php?page=" + pageNum + "&sort=" + sort + "&minPrice=" + minPrice + "&maxPrice=" + maxPrice + "&type=" + type + "&minLength=" + minLength + "&maxLength=" + maxLength + "&dest=" + dest + "&catType=" + catType + "&dataType=" + dataType, Hide_Load());
		
		$(".clone").html($(".pagination").html());
	});
	
	
	
	
	//RANDOM JAVASCRIPT FUNCTIONS
	
	$(".listing").live('mouseover',function(){
		$(this).css({'background' : '#d6d1c8'});
		$(".vd", this).show();
	});
	
	$(".listing").live('mouseout',function(){
		$(this).css({'background' : ''});
		$(".vd", this).hide();
	});
	
	



/***
***************************************************Promo Box start*************************************************************************/	
	$("#promoBottom").click(function(){
			$("#promoTop").slideDown();
			$("#promoContent").slideDown();
			$("#promoClose").slideDown();
		});
	$("#promoClose").click(function(){
			$("#promoTop").slideUp();
			$("#promoContent").slideUp();
			$("#promoClose").slideUp();
		});
		
	$("#xPromo").click(function(){
				$("#promoTop").slideUp();
				$("#promoContent").slideUp();
				$("#promoClose").slideUp();
		});
/******************************************************Promo Box end*************************************************************************/	

/******************************************************Fancy Box start*************************************************************************/	

	$(".fancy").fancybox({
		'titlePosition'  : 'inside'
	});
/******************************************************Fancy Box end*************************************************************************/	
});	
/******************************************************NAVIGATION START*************************************************************************/
/*
	$(".dropMenu a").hover(function(){
		$(this).css({'background' : '#a7966e'});
	},
	function(){
		$(this).css({'background' : '#a7a090'});
	});
	
	$("#nav li").hover(function(){
		$(".dropMenu", this).show();
	},function(){
		$(".dropMenu", this).hide();
	});
*/

$(document).ready(function(){

	$("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*)

	$("ul.subnav").parent().hover(function(){
		$(".subnav",this).show();
	},
	function(){
		$(".subnav",this).hide();
	}); 

	$("ul.topnav li span").mouseenter(function() { //When trigger is clicked...

		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.subnav").show().show(); //Drop down the subnav on click

		$(this).parent().hover(function() {
		}, function(){
			$(this).parent().find("ul.subnav").hide(); //When the mouse hovers out of the subnav, move it back up
		});

		//Following events are applied to the trigger (Hover events for the trigger)
		});

});

	
/******************************************************NAVIGATION END*************************************************************************/
	
	

/******************************************************PNG FIX start*************************************************************************/

/*
$(document).ready(function(){ 
        $(document).pngFix(); 
    });

(function($) {

jQuery.fn.pngFix = function(settings) {

	// Settings
	settings = jQuery.extend({
		blankgif: 'blank.gif'
	}, settings);

	var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);

	if (jQuery.browser.msie && (ie55 || ie6)) {

		//fix images with png-source
		jQuery(this).find("img[src$=.png]").each(function() {

			jQuery(this).attr('width',jQuery(this).width());
			jQuery(this).attr('height',jQuery(this).height());

			var prevStyle = '';
			var strNewHTML = '';
			var imgId = (jQuery(this).attr('id')) ? 'id="' + jQuery(this).attr('id') + '" ' : '';
			var imgClass = (jQuery(this).attr('class')) ? 'class="' + jQuery(this).attr('class') + '" ' : '';
			var imgTitle = (jQuery(this).attr('title')) ? 'title="' + jQuery(this).attr('title') + '" ' : '';
			var imgAlt = (jQuery(this).attr('alt')) ? 'alt="' + jQuery(this).attr('alt') + '" ' : '';
			var imgAlign = (jQuery(this).attr('align')) ? 'float:' + jQuery(this).attr('align') + ';' : '';
			var imgHand = (jQuery(this).parent().attr('href')) ? 'cursor:hand;' : '';
			if (this.style.border) {
				prevStyle += 'border:'+this.style.border+';';
				this.style.border = '';
			}
			if (this.style.padding) {
				prevStyle += 'padding:'+this.style.padding+';';
				this.style.padding = '';
			}
			if (this.style.margin) {
				prevStyle += 'margin:'+this.style.margin+';';
				this.style.margin = '';
			}
			var imgStyle = (this.style.cssText);

			strNewHTML += '<span '+imgId+imgClass+imgTitle+imgAlt;
			strNewHTML += 'style="position:relative;white-space:pre-line;display:inline-block;background:transparent;'+imgAlign+imgHand;
			strNewHTML += 'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;';
			strNewHTML += 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + jQuery(this).attr('src') + '\', sizingMethod=\'scale\');';
			strNewHTML += imgStyle+'"></span>';
			if (prevStyle != ''){
				strNewHTML = '<span style="position:relative;display:inline-block;'+prevStyle+imgHand+'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;'+'">' + strNewHTML + '</span>';
			}

			jQuery(this).hide();
			jQuery(this).after(strNewHTML);

		});

		// fix css background pngs
		jQuery(this).find("*").each(function(){
			var bgIMG = jQuery(this).css('background-image');
			if(bgIMG.indexOf(".png")!=-1){
				var iebg = bgIMG.split('url("')[1].split('")')[0];
				jQuery(this).css('background-image', 'none');
				jQuery(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iebg + "',sizingMethod='scale')";
			}
		});
		
		//fix input with png-source
		jQuery(this).find("input[src$=.png]").each(function() {
			var bgIMG = jQuery(this).attr('src');
			jQuery(this).get(0).runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + bgIMG + '\', sizingMethod=\'scale\');';
   		jQuery(this).attr('src', settings.blankgif)
		});
	
	}
	
	return jQuery;

};

})(jQuery);

*/

/******************************************************END PNG FIX*************************************************************************/

/******************************************************Clear Input Field*************************************************************************/

function clearText(theField)
{
	if (theField.defaultValue == theField.value){
		if(theField.defaultValue == "Password"){
			theField.type = "password";
		}
		theField.value = '';
	}
}

function addText(theField)
{
	if (theField.value == ''){
		if(theField.type == "password"){
			theField.type = "text";
		}
	theField.value = theField .defaultValue;
	}
}

/******************************************************Clear Input Field*************************************************************************/


/******************************************************tool tip start*************************************************************************/

function simple_tooltip(target_items, name){
 jQuery(target_items).each(function(i){
		jQuery("body").append("<div style='display:none' class='"+name+"' id='"+name+i+"'><p>"+jQuery(this).attr('title')+"</p></div>");
		var my_tooltip = jQuery("#"+name+i);
		
		if(jQuery(this).attr("title") != "" && jQuery(this).attr("title") != "undefined" ){
		
		jQuery(this).removeAttr("title").mouseover(function(){
					my_tooltip.css({opacity:0.9, display:"none"}).fadeIn(400);
		}).mousemove(function(kmouse){
				var border_top = jQuery(window).scrollTop(); 
				var border_right = jQuery(window).width();
				var left_pos;
				var top_pos;
				var offset = 20;
				if(border_right - (offset *2) >= my_tooltip.width() + kmouse.pageX){
					left_pos = kmouse.pageX+offset;
					} else{
					left_pos = border_right-my_tooltip.width()-offset;
					}
					
				if(border_top + (offset *2)>= kmouse.pageY - my_tooltip.height()){
					top_pos = border_top +offset;
					} else{
					top_pos = kmouse.pageY-my_tooltip.height()-offset;
					}	
				
				
				my_tooltip.css({left:left_pos, top:top_pos});
		}).mouseout(function(){
				my_tooltip.css({left:"-9999px"});				  
		});
		
		}
		
		
		
	});
}

	
	
jQuery(document).ready(function(){
	 simple_tooltip("a","tooltip");
	
	$("#booking").click(function(){
		$(".booking2").show();
	});
});

/******************************************************tool tip end*************************************************************************/



/******************************************************PACKAGE TABS START*************************************************************************/


$(function(){
/* groups start */
			$("#welcome-button").css({
				borderWidth: 10
			});
			$("#chdiff-button").css({
				opacity: 0.9
			});			
			$("#themes-button").css({
				opacity: 0.9
			});
			$("#grouppackage-button").css({
				opacity: 0.9
			});
			$("#grouppackage2-button").css({
				opacity: 0.9
			});
			$("#grouprequest-button").css({
				opacity: 0.9
			});			
			$("#travelprotectionplan-button").css({
				opacity: 0.9
			});
			$("#grouprequest-button2").css({
				borderWidth: 10
			});
			$("#welcome-button2").css({
				opacity: 0.9
			});			

/* groups end */			
			$("#includes1-button").css({
				borderWidth: 10
			});
			$("#features-button").css({
				borderWidth: 10
			});
			$("#amenities-button").css({
				opacity: 0.9
			});
			$("#optexcursions-button").css({
				opacity: 0.9
			});
			$("#shipinfo-button").css({
				opacity: 0.9
			});			
			$("#includes2-button").css({
				opacity: 0.9
			});
			$("#features1-button").css({
				opacity: 0.9
			});
			$("#features2-button").css({
				opacity: 0.9
			});
			$("#itinerary1-button").css({
				opacity: 0.9
			});
			$("#itinerary2-button").css({
				opacity: 0.9
			});
			$("#rates-button").css({
				opacity: 0.9
			});
			
			$("#sightseeing-button").css({
				opacity: 0.9
			});
			
			$("#hotels-button").css({
				opacity: 0.9
			});
			
			$("#inforest-button").css({
				opacity: 0.9
			});
			
			$("#bookbutton").click(function(){
				$("#bookbutton").hide()
				$("#bookbox").fadeIn()
			});

            $("#landingmenu div.button").click(function(){

            	$clicked = $(this);

            	// if the button is not already "transformed" AND is not animated
            	if ($clicked.css("opacity") != "1" && $clicked.is(":not(animated)")) {

            		$clicked.animate({
            			opacity: 1,
            			borderWidth: 10
            		}, 600 );

            		// each button div MUST have a "xx-button" and the target div must have an id "xx" 
            		var idToLoad = $clicked.attr("id").split('-');

            		//we search trough the content for the visible div and we fade it out
            		$("#slides").find("div:visible").fadeOut("fast", function(){
            			//once the fade out is completed, we start to fade in the right div
            			$(this).parent().find("#"+idToLoad[0]).fadeIn();
            		})
            	}

            	//we reset the other buttons to default style
            	$clicked.siblings(".button").animate({
            		opacity: 0.9,
            		borderWidth: 0
            	}, 600 );

            });
		});

/******************************************************PACKAGE TABS END*************************************************************************/

/******************************************************LOGIN AND VALIDATION JS********************************************************************/
function doSubmit() {
 txt=document.login.userTypeS.options[document.login.userTypeS.selectedIndex].text;
 if(document.login.userTypeS.options[document.login.userTypeS.selectedIndex].value == "none")
{
	document.getElementById("userTypeS").style.background = "#cc0000";

}
	else if (txt.match('Customer')){
	
		var field1 = document.createElement("input");
		field1.setAttribute("type","hidden");
		field1.setAttribute("name","userType");
		field1.setAttribute("value","WU");
		document.login.appendChild(field1);

		var field2 = document.createElement("input");
		field2.setAttribute("type","hidden");
		field2.setAttribute("name","PROCESS");
		field2.setAttribute("value","1");
		document.login.appendChild(field2);

		var field3 = document.createElement("input");
		field3.setAttribute("type","hidden");
		field3.setAttribute("name","isTrackingLogged");
		field3.setAttribute("value","false");
		document.login.appendChild(field3);

		var field4 = document.createElement("input");
		field4.setAttribute("type","hidden");
		field4.setAttribute("name","BV_UseBVCookie");
		field4.setAttribute("value","yes");
		document.login.appendChild(field4);

		var field5 = document.createElement("input");
		field5.setAttribute("type","hidden");
		field5.setAttribute("name","redirectPage");
		field5.setAttribute("value","");
		document.login.appendChild(field5);

		var field6 = document.createElement("input");
		field6.setAttribute("type","hidden");
		field6.setAttribute("name","inPopUp");
		field6.setAttribute("value","");
		document.login.appendChild(field6);

		var field7 = document.createElement("input");
		field7.setAttribute("type","hidden");
		field7.setAttribute("name","nextUrl");
		field7.setAttribute("value","http://www.centralholidays.com/tools/checkcookie.php?companyID=CHT&partnerID=CHT&nextUrl=http://www.centralholidays.com/");
		document.login.appendChild(field7);
		
	  var theForm=document.login;
	  theForm.action = "http://ww2.centralholidays.com/ipmstage/custmgmt/wu_login.jsp";
	  theForm.submit();
	}
	else if (txt.match('Travel Agent')){

		var field1 = document.createElement("input");
		field1.setAttribute("type","hidden");
		field1.setAttribute("name","userType");
		field1.setAttribute("value","TA");
		document.login.appendChild(field1);

		var field2 = document.createElement("input");
		field2.setAttribute("type","hidden");
		field2.setAttribute("name","PROCESS");
		field2.setAttribute("value","A");
		document.login.appendChild(field2);

		var field3 = document.createElement("input");
		field3.setAttribute("type","hidden");
		field3.setAttribute("name","dontShow");
		field3.setAttribute("value","");
		document.login.appendChild(field3);

		var field4 = document.createElement("input");
		field4.setAttribute("type","hidden");
		field4.setAttribute("name","referer");
		field4.setAttribute("value","http://www.centralholidays.com/");
		document.login.appendChild(field4);

		var field5 = document.createElement("input");
		field5.setAttribute("type","hidden");
		field5.setAttribute("name","nextUrl");
		field5.setAttribute("value","http://www.centralholidays.com/tools/checkcookie.php?companyID=CHT&partnerID=CHT&nextUrl=");
		document.login.appendChild(field5);
		
	  var theForm=document.login;
	  theForm.action = "http://ww2.centralholidays.com/ipmstage/custmgmt/ta_login.jsp";
	  theForm.submit();
	}	
}	
function doSubmit2() {
 txt=document.login2.userTypeS2.options[document.login2.userTypeS2.selectedIndex].text;
 if(document.login2.userTypeS2.options[document.login2.userTypeS2.selectedIndex].value == "none")
{
	document.getElementById("userTypeS2").style.background = "#cc0000";

}
	else if (txt.match('Customer')){
	
		var field1 = document.createElement("input");
		field1.setAttribute("type","hidden");
		field1.setAttribute("name","userType");
		field1.setAttribute("value","WU");
		document.login2.appendChild(field1);

		var field2 = document.createElement("input");
		field2.setAttribute("type","hidden");
		field2.setAttribute("name","PROCESS");
		field2.setAttribute("value","1");
		document.login2.appendChild(field2);

		var field3 = document.createElement("input");
		field3.setAttribute("type","hidden");
		field3.setAttribute("name","isTrackingLogged");
		field3.setAttribute("value","false");
		document.login2.appendChild(field3);

		var field4 = document.createElement("input");
		field4.setAttribute("type","hidden");
		field4.setAttribute("name","BV_UseBVCookie");
		field4.setAttribute("value","yes");
		document.login2.appendChild(field4);

		var field5 = document.createElement("input");
		field5.setAttribute("type","hidden");
		field5.setAttribute("name","redirectPage");
		field5.setAttribute("value","");
		document.login2.appendChild(field5);

		var field6 = document.createElement("input");
		field6.setAttribute("type","hidden");
		field6.setAttribute("name","inPopUp");
		field6.setAttribute("value","");
		document.login2.appendChild(field6);

		var field7 = document.createElement("input");
		field7.setAttribute("type","hidden");
		field7.setAttribute("name","nextUrl");
		field7.setAttribute("value","http://www.centralholidays.com/tools/checkcookie.php?companyID=CHT&partnerID=CHT&nextUrl=http://www.centralholidays.com/");
		document.login2.appendChild(field7);
		
	  var theForm=document.login2;
	  theForm.action = "http://ww2.centralholidays.com/ipmstage/custmgmt/wu_login.jsp";
	  theForm.submit();
	}
	else if (txt.match('Travel Agent')){

		var field1 = document.createElement("input");
		field1.setAttribute("type","hidden");
		field1.setAttribute("name","userType");
		field1.setAttribute("value","TA");
		document.login2.appendChild(field1);

		var field2 = document.createElement("input");
		field2.setAttribute("type","hidden");
		field2.setAttribute("name","PROCESS");
		field2.setAttribute("value","A");
		document.login2.appendChild(field2);

		var field3 = document.createElement("input");
		field3.setAttribute("type","hidden");
		field3.setAttribute("name","dontShow");
		field3.setAttribute("value","");
		document.login2.appendChild(field3);

		var field4 = document.createElement("input");
		field4.setAttribute("type","hidden");
		field4.setAttribute("name","referer");
		field4.setAttribute("value","http://www.centralholidays.com/");
		document.login2.appendChild(field4);

		var field5 = document.createElement("input");
		field5.setAttribute("type","hidden");
		field5.setAttribute("name","nextUrl");
		field5.setAttribute("value","http://www.centralholidays.com/tools/checkcookie.php?companyID=CHT&partnerID=CHT&nextUrl=");
		document.login2.appendChild(field5);
		
	  var theForm=document.login2;
	  theForm.action = "http://ww2.centralholidays.com/ipmstage/custmgmt/ta_login.jsp";
	  theForm.submit();
	}	
}

var errArray = new Array();

	var i=0;
	//This function validates the form in Results Page.
	function onSubmitTA()
	{
	i=0;

	validateIATA(trim(document.newTA.IATA.value));
	//alert(document.newTA.IATA.value);
	//validateIATAMax(trim(document.newTA.IATA.value));
	
 	if (i > 0) {

        	if (i==1) {

			var errString = "";

            		errString = errArray[1].substring(3,errArray[1].length -1);

            		alert(errString);

        		}

        else {

    		var errString = "";

    		for(var k=1;k<= i; k ++){

    	 	    errString = errString + errArray[k];

            }

            alert(errString);

        }

    }

    else {

	document.newTA.action="http://ww2.centralholidays.com/ipmstage/custmgmt/iata.jsp";
	document.newTA.submit();
    }
	errArray = null;
	errArray = new Array();
	i = 0;
}

function numbersonly(myfield, e, dec) {
  var key;
  var keychar;

  if (window.event)
    key = window.event.keyCode;
  else if (e)
    key = e.which;
  else
    return true;
  keychar = String.fromCharCode(key);

  // control keys
  if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) )
    return true;

  // numbers
  else if ((("0123456789").indexOf(keychar) > -1))
    return true;

  // decimal point jump
  else if (dec && (keychar == ".")) {
    myfield.form.elements[dec].focus();
    return false;
  } else
    return false;
}

function validateFields(Str) {

 	   if (Str == null || Str == "" ) {
	       i = i + 1;
	     errArray[i]= i + ". All Fields are Mandatory.\n";
 		}
	 }

function validateIATA(Str) {
 	   if ((Str.length < 8)) {
	       i = i + 1;

	     errArray[i]= i + ". Please enter a valid IATA / CLIA!\n";
	     document.newTA.IATA.focus();
	   }
	 }

/*function validateIATAMax(Str) {
 	   if (Str == null || Str == "" || Str <= 8) {
	       i = i + 1;
	     errArray[i]= i + ". Invalid IATA / CLIA. Please enter a valid IATA / CLIA!\n";
	     document.newTA.IATA.focus();
 		}
	 }*/
function ltrim(str) { 
	for(var k = 0; k < str.length && isWhitespace(str.charAt(k)); k++);
	return str.substring(k, str.length);
}
function rtrim(str) {
	for(var j=str.length-1; j>=0 && isWhitespace(str.charAt(j)) ; j--) ;
	return str.substring(0,j+1);
}
function trim(str) {
	return ltrim(rtrim(str));
}
function isWhitespace(charToCheck) {
	var whitespaceChars = " \t\n\r\f";
	return (whitespaceChars.indexOf(charToCheck) != -1);
}




function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

function ValidateFormEmail(){
	var emailID=document.fpass.fpEmail
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }
/******************************************************END LOGIN AND VALIDATION JS********************************************************************/




function showdestvidgal(dest){
var str='';
str+='<iframe src="\/videogallery-dest\/'+dest+'.html" width="450" height="460" frameborder="0" style="overflow-x:hidden; overflow-y:auto"><\/iframe>';
$("#videogall").html(str);
}
//PACKAGE PAGE POPUPS
function showpvidgal(destp){
var str1='';
str1+='<iframe src="\/videogallery\/'+destp+'.html" width="450" height="460" frameborder="0" style="overflow-x:hidden; overflow-y:auto"><\/iframe>';
document.getElementById("videogall").innerHTML = str1;
}
//HOTELS PAGE POPUPS
function showhvidgal(){
var str1='';
str1+='<iframe src="\/videogallery-hotel\/hotel.html" width="450" height="460" frameborder="0" style="overflow-x:hidden; overflow-y:auto"><\/iframe>';
document.getElementById("videogall").innerHTML = str1;
}
//CRUISE PAGE POPUPS
function showcvidgal(){
var str2='';
str2+='<iframe src="\/videogallery-cruise\/cruise.html" width="450" height="460" frameborder="0" style="overflow-x:hidden; overflow-y:auto"><\/iframe>';
document.getElementById("videogall").innerHTML = str2;
}
//group video gallery
function showgrpvidgal(){
var str2='';
str2+='<iframe src="\/videogallery-group\/index.html" width="450" height="460" frameborder="0" style="overflow-x:hidden; overflow-y:auto"><\/iframe>';
document.getElementById("videogall").innerHTML = str2;
}



/*
 * jQuery infinitecarousel plugin
 * @author admin@catchmyfame.com - http://www.catchmyfame.com
 * @version 1.2.2
 * @date August 31, 2009
 * @category jQuery plugin
 * @copyright (c) 2009 admin@catchmyfame.com (www.catchmyfame.com)
 * @license CC Attribution-Share Alike 3.0 - http://creativecommons.org/licenses/by-sa/3.0/
 */

(function($){
	$.fn.extend({ 
		infiniteCarousel: function(options)
		{
			var defaults = 
			{
				transitionSpeed : 1500,
				displayTime : 8000000,
				textholderHeight : .2,
				displayProgressBar : 1,
				displayThumbnails: 1,
				displayThumbnailNumbers: 1,
				displayThumbnailBackground: 1,
				thumbnailWidth: '20px',
				thumbnailHeight: '20px',
				thumbnailFontSize: '.7em'
			};
		var options = $.extend(defaults, options);
	
    		return this.each(function() {
    			var randID = Math.round(Math.random()*100000000);
				var o=options;
				var obj = $(this);
				var curr = 1;

				var numImages = $('img', obj).length; // Number of images
				var imgHeight = $('img:first', obj).height();
				var imgWidth = $('img:first', obj).width();
				var autopilot = false;
		
				$('p', obj).hide(); // Hide any text paragraphs in the carousel
				$(obj).width(imgWidth).height(imgHeight);
			
				// Build progress bar
				if(o.displayProgressBar)
				{
					$(obj).append('<div id="progress'+randID+'" style="position:absolute;bottom:0;background:#a7a090;left:'+$(obj).css('paddingLeft')+'"></div>');
					$('#progress'+randID).width(imgWidth).height(5).css('opacity','.7');
				}
			
				// Move last image and stick it on the front
				$(obj).css({'overflow':'hidden','position':'relative'});
				$('li:last', obj).prependTo($('ul', obj));
				$('ul', obj).css('left',-imgWidth+'px');
				$('ul',obj).width(9999);

				$('ul',obj).css({'list-style':'none','margin':'0px','padding':'0px','position':'relative'});
				$('li',obj).css({'display':'inline','float':'left'});
			
				// Build textholder div thats as wide as the carousel and 20%-25% of the height
				$(obj).append('<div id="textholder'+randID+'" class="textholder" style="position:absolute;bottom:0px;margin-bottom:'+-imgHeight*o.textholderHeight+'px;left:'+$(obj).css('paddingLeft')+'"></div>');
				var correctTHWidth = parseInt($('#textholder'+randID).css('paddingTop'));
				var correctTHHeight = parseInt($('#textholder'+randID).css('paddingRight'));
				$('#textholder'+randID).width(imgWidth-(correctTHWidth * 2)).height((imgHeight*o.textholderHeight)-(correctTHHeight * 2)).css({'backgroundColor':'#000','opacity':'0.8'});
				showtext($('li:eq(1) p', obj).html());
			
				// Prev/next button(img) 
				html = '<div id="btn_rt'+randID+'" style="position:absolute;right:0;top:'+((imgHeight/2)-15)+'px"><a href="javascript:void(0);"><img style="border:none;margin-right:2px" src="/images/right.png" /></a></div>';
				html += '<div id="btn_lt'+randID+'" style="position:absolute;left:0;top:'+((imgHeight/2)-15)+'px"><a href="javascript:void(0);"><img style="border:none;margin-left:2px" src="/images/left.png" /></a></div>';
				$(obj).append(html);
			
				// Pause/play button(img)	
				//html = '<a href="javascript:void(0);"><img id="pause_btn'+randID+'" src="/js/infiniteCarousel/images/pause.png" style="position:absolute;top:3px;right:3px;border:none" alt="Pause" /></a>';
				//html += '<a href="javascript:void(0);"><img id="play_btn'+randID+'" src="/js/infiniteCarousel/images/play.png" style="position:absolute;top:3px;right:3px;border:none;display:none;" alt="Play" /></a>';
				//$(obj).append(html);
				$('#pause_btn'+randID).css('opacity','.5').hover(function(){$(this).animate({opacity:'1'},250)},function(){$(this).animate({opacity:'.5'},250)});
				$('#pause_btn'+randID).click(function(){
//					autopilot = 0;
					$('#progress'+randID).stop().fadeOut();
					clearTimeout(clearInt);
					$('#pause_btn'+randID).fadeOut(250);
					$('#play_btn'+randID).fadeIn(250);
					showminmax();
				});
				$('#play_btn'+randID).css('opacity','.5').hover(function(){$(this).animate({opacity:'1'},250)},function(){$(this).animate({opacity:'.5'},250)});
				$('#play_btn'+randID).click(function(){
//					autopilot = 1;
					anim('next');
					$('#play_btn'+randID).hide();
					clearInt=setInterval(function(){anim('next');},o.displayTime+o.transitionSpeed);
					setTimeout(function(){$('#pause_btn'+randID).show();$('#progress'+randID).fadeIn().width(imgWidth).height(5);},o.transitionSpeed);
				});
				
				// Left and right arrow image button actions
				$('#btn_rt'+randID).css('opacity','.75').click(function(){
//					autopilot = 0;
					$('#progress'+randID).stop().fadeOut();
					anim('next');
					setTimeout(function(){$('#play_btn'+randID).fadeIn(250);},o.transitionSpeed);
					clearTimeout(clearInt);
				}).hover(function(){$(this).animate({opacity:'1'},250)},function(){$(this).animate({opacity:'.75'},250)});
				$('#btn_lt'+randID).css('opacity','.75').click(function(){
//					autopilot = 0;
					$('#progress'+randID).stop().fadeOut();
					anim('prev');
					setTimeout(function(){$('#play_btn'+randID).fadeIn(250);},o.transitionSpeed);
					clearTimeout(clearInt);
				}).hover(function(){$(this).animate({opacity:'1'},250)},function(){$(this).animate({opacity:'.75'},250)});

				if(o.displayThumbnails)
				{
					// Build thumbnail viewer and thumbnail divs
					$('#topbar').html('<div id="thumbs'+randID+'" style="position:relative;overflow:auto;text-align:right;padding-top:5px;"><span>Top Picks</span></div>');
					$('#thumbs'+randID).width(imgWidth);
					for(i=0;i<=numImages-1;i++)
					{
						thumb = $('img:eq('+(i+1)+')', obj).attr('src');
						$('#thumbs'+randID).append('<div class="thumb" id="thumb'+randID+'_'+(i+1)+'" style="cursor:pointer;display:inline;float:left;text-align:center;margin-right:4px;height:20px; width:20px; margin-top:10px;color:#a7a090;font-family:verdana; font-size:12px">'+(i+1)+'</div>');
						if(i==0) $('#thumb'+randID+'_1').css({'border-color':'#ff0000'});
					}
					// Next two lines are a special case to handle the first list element which was originally the last
					//thumb = $('img:first', obj).attr('src');
					//$('#thumb'+randID+'_'+numImages).css({'background-image':'url('+thumb+')'});
					$('#thumbs'+randID+' div.thumb:not(:first)').css({'opacity':'.65'}); // makes all thumbs 65% opaque except the first one
					$('#thumbs'+randID+' div.thumb').hover(function(){$(this).animate({'opacity':.99},150)},function(){if(curr!=this.id.split('_')[1]) $(this).animate({'opacity':.65},250)}); // add hover to thumbs

					// Assign click handler for the thumbnails. Normally the format $('.thumb') would work but since it's outside of our object (obj) it would get called multiple times
					$('#thumbs'+randID+' div').bind('click', thumbclick); // We use bind instead of just plain click so that we can repeatedly remove and reattach the handler
				
					if(!o.displayThumbnailNumbers) $('#thumbs'+randID+' div').text('');
					if(!o.displayThumbnailBackground) $('#thumbs'+randID+' div').css({'background-image':'none'});
				}
				function thumbclick(event)
				{
					target_num = this.id.split('_'); // we want target_num[1]
					if(curr != target_num[1])
					{
						$('#thumb'+randID+'_'+curr).css({'border-color':'#ccc'});
						$('#progress'+randID).stop().fadeOut();
						clearTimeout(clearInt);
						//alert(event.data.src+' '+this.id+' '+target_num[1]+' '+curr);
						$('#thumbs'+randID+' div').css({'cursor':'default'}).unbind('click'); // Unbind the thumbnail click event until the transition has ended
//						autopilot = 0;
						setTimeout(function(){$('#play_btn'+randID).fadeIn(250);},o.transitionSpeed);
					}
					if(target_num[1] > curr)
					{
						diff = target_num[1] - curr;
						anim('next',diff);
					}
					if(target_num[1] < curr)
					{
						diff = curr - target_num[1];
						anim('prev', diff);
					}
				}

				function showtext(t)
				{
					// the text will always be the text of the second list item (if it exists)
					if(t != null)
					{
						$('#textholder'+randID).html(t).animate({marginBottom:'0px'},500); // Raise textholder
						showminmax();
					}
				}
				function showminmax()
				{
						if(!autopilot)
						{
//							html = '<img style="position:absolute;top:2px;right:18px;display:none;cursor:pointer" src="/js/infiniteCarousel/images/down.png" title="Minimize" alt="minimize" id="min" /><img style="position:absolute;top:2px;right:18px;display:none;cursor:pointer" src="/js/infiniteCarousel/images/up.png" title="Maximize" alt="maximize" id="max" />';
//							html += '<img style="position:absolute;top:2px;right:6px;display:none;cursor:pointer" src="/js/infiniteCarousel/images/close.png" title="Close" alt="close" id="close" />';
//							$('#textholder'+randID).append(html);
//							$('#min').fadeIn(250).click(function(){$('#textholder'+randID).animate({marginBottom:(-imgHeight*o.textholderHeight)-(correctTHHeight * 2)+24+'px'},500,function(){$("#min,#max").toggle();});});
//							$('#max').click(function(){$('#textholder'+randID).animate({marginBottom:'0px'},500,function(){$("#min,#max").toggle();});});
//							$('#close').fadeIn(250).click(function(){$('#textholder'+randID).animate({marginBottom:(-imgHeight*o.textholderHeight)-(correctTHHeight * 2)+'px'},500);});
						}
				}
				function borderpatrol(elem)
				{
					$('#thumbs'+randID+' div').css({'border-color':'#ccc'}).animate({opacity: 0.65},500);
					setTimeout(function(){elem.css({'border-color':'#ff0000'}).animate({'opacity': .99},500);},o.transitionSpeed);
				}
				function anim(direction,dist)
				{
					// Fade left/right arrows out when transitioning
					$('#btn_rt'+randID).fadeOut(500);
					$('#btn_lt'+randID).fadeOut(500);
					
					// animate textholder out of frame
					$('#textholder'+randID).animate({marginBottom:(-imgHeight*o.textholderHeight)-(correctTHHeight * 2)+'px'},500);					

					//?? Fade out play/pause?
					$('#pause_btn'+randID).fadeOut(250);
					$('#play_btn'+randID).fadeOut(250);

					if(direction == "next")
					{
						if(curr==numImages) curr=0;
						if(dist>1)
						{
							borderpatrol($('#thumb'+randID+'_'+(curr+dist)));
							$('li:lt(2)', obj).clone().insertAfter($('li:last', obj));
							$('ul', obj).animate({left:-imgWidth*(dist+1)},o.transitionSpeed,function(){
								$('li:lt(2)', obj).remove();
								for(j=1;j<=dist-2;j++)
								{
									$('li:first', obj).clone().insertAfter($('li:last', obj));
									$('li:first', obj).remove();
								}
								$('#btn_rt'+randID).fadeIn(500);
								$('#btn_lt'+randID).fadeIn(500);
								$('#play_btn'+randID).fadeIn(250);
								showtext($('li:eq(1) p', obj).html());
								$(this).css({'left':-imgWidth});
								curr = curr+dist;
								$('#thumbs'+randID+' div').bind('click', thumbclick).css({'cursor':'pointer'});
							});
						}
						else
						{
							borderpatrol($('#thumb'+randID+'_'+(curr+1)));
							$('#thumbs'+randID+' div').css({'cursor':'default'}).unbind('click'); // Unbind the thumbnail click event until the transition has ended
							// Copy leftmost (first) li and insert it after the last li
							$('li:first', obj).clone().insertAfter($('li:last', obj));	
							// Update width and left position of ul and animate ul to the left
							$('ul', obj)
								.animate({left:-imgWidth*2},o.transitionSpeed,function(){
									$('li:first', obj).remove();
									$('ul', obj).css('left',-imgWidth+'px');
									$('#btn_rt'+randID).fadeIn(500);
									$('#btn_lt'+randID).fadeIn(500);
									if(autopilot) $('#pause_btn'+randID).fadeIn(250);
									showtext($('li:eq(1) p', obj).html());
									if(autopilot)
									{
										$('#progress'+randID).width(imgWidth).height(5);
										$('#progress'+randID).animate({'width':0},o.displayTime,function(){
											$('#pause_btn'+randID).fadeOut(50);
											setTimeout(function(){$('#pause_btn'+randID).fadeIn(250)},o.transitionSpeed)
										});
									}
									curr=curr+1;
									$('#thumbs'+randID+' div').bind('click', thumbclick).css({'cursor':'pointer'});
								});
						}
					}
					if(direction == "prev")
					{
						if(dist>1)
						{
							borderpatrol($('#thumb'+randID+'_'+(curr-dist)));
							$('li:gt('+(numImages-(dist+1))+')', obj).clone().insertBefore($('li:first', obj));
							$('ul', obj).css({'left':(-imgWidth*(dist+1))}).animate({left:-imgWidth},o.transitionSpeed,function(){
								$('li:gt('+(numImages-1)+')', obj).remove();
								$('#btn_rt'+randID).fadeIn(500);
								$('#btn_lt'+randID).fadeIn(500);
								$('#play_btn'+randID).fadeIn(250);
								showtext($('li:eq(1) p', obj).html());
								curr = curr - dist;
								$('#thumbs'+randID+' div').bind('click', thumbclick).css({'cursor':'pointer'});
							});
						}
						else
						{
							borderpatrol($('#thumb'+randID+'_'+(curr-1)));
							$('#thumbs'+randID+' div').css({'cursor':'default'}).unbind('click'); // Unbind the thumbnail click event until the transition has ended
							// Copy rightmost (last) li and insert it after the first li
							$('li:last', obj).clone().insertBefore($('li:first', obj));
							// Update width and left position of ul and animate ul to the right
							$('ul', obj)
								.css('left',-imgWidth*2+'px')
								.animate({left:-imgWidth},o.transitionSpeed,function(){
									$('li:last', obj).remove();
									$('#btn_rt'+randID).fadeIn(500);
									$('#btn_lt'+randID).fadeIn(500);
									if(autopilot) $('#pause_btn'+randID).fadeIn(250);
									showtext($('li:eq(1) p', obj).html());
									curr=curr-1;
									if(curr==0) curr=numImages;
									$('#thumbs'+randID+' div').bind('click', thumbclick).css({'cursor':'pointer'});
								});
						}
					}
				}

				var clearInt = setInterval(function(){anim('next');},o.displayTime+o.transitionSpeed);
				$('#progress'+randID).animate({'width':0},o.displayTime+o.transitionSpeed,function(){
					$('#pause_btn'+randID).fadeOut(100);
					setTimeout(function(){$('#pause_btn'+randID).fadeIn(250)},o.transitionSpeed)
				});
  		});
    	}
	});
})(jQuery);


/***********************************************************/
$(document).ready(function(){
	
	$(".iWhat").click(function(){
		$("#foryou_tabs a").removeClass("active");
		$(this).addClass("active");
		$(".foryou_results").hide();
		$(".foryou_results.r"+$(this).attr("alt")).show();
	});
});
