function showPackageType (it, box) {
 /* document.getElementById('page1').style.display = 'none';
  document.getElementById('page2').style.display = 'block';  
  alert(box.checked);
  var vis = (box.checked) ? "block" : "none";
  document.getElementById(it).style.display = vis;*/
}

function checkAll(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = true ;
}

function uncheckAll(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = false ;
}


function clearText(theField)
{
if (theField.defaultValue == theField.value)
theField.value = '';
}

function addText(theField)
{
if (theField.value == '')
theField.value = theField .defaultValue;
}

function closeSpecial(){
document.getElementById("hotdealspecial").style.display = "none";
}

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
 }




/* CODE BELOW IS FILLING VIDGALL AND SITESEEKER DIV ON CLICK */




//DESTINATION PAGE POPUPS
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>';
document.getElementById("videogall").innerHTML = str;
}

function showsiteseeker(dest){
var str0='';
str0+='<iframe src="\/siteseeker\/'+dest+'.html" width="765" height="210" frameborder="0" scrolling="no"><\/iframe>';
document.getElementById("siteseeing").innerHTML = str0;
}

//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;
}

function showsiteseekerp(site){
var str2='';
str2+='<iframe src="\/siteseeker-p\/'+site+'.html" width="765" height="210" frameborder="0" scrolling="no"><\/iframe>';
document.getElementById("siteseeker").innerHTML = str2;
}

//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;
}

function showsiteseekerhall(){
var str2='';
str2+='<iframe src="\/siteseeker-hall\/index.html" width="765" height="210" frameborder="0" scrolling="no"><\/iframe>';
document.getElementById("siteseeker").innerHTML = str2;
}

//HOTEL PAGE POPUPS
function showsiteseekerh(site2,city){
var str2='';
str2+='<iframe src="\/siteseeker-h\/'+site2+'.html?&city='+city+'" width="765" height="210" frameborder="0" scrolling="no"><\/iframe>';
document.getElementById("siteseeker").innerHTML = str2;
}

//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;
}

//little helper
function showHelp(){
	var str='';
	str+='<div id="acchold" style="width:250px; position:fixed; right:5px; z-index:11000; bottom:55px"><a href="#" style="text-decoration:none; margin-top:5px; margin-left:230px; position:absolute" onclick="$(\'#acchold\').hide(\'highlight\')">x<\/a><div style="height:20px; background-image: url(/images/helpbubble.png)"><\/div><div id="accordion" style="width:220px; padding-left:15px; padding-right:15px; background: url(/images/helpbg.png) repeat-y">';
	str+='		<h5 style="margin-bottom:0px; margin-top:0px; font-size:10px"><a href="#">How to Log In<\/a><\/h5>';
	str+='		<div>';
	str+='		<img src="\/images\/help01.jpg"\/><br\/>To log in:<br\/><b style="color:#cc0000">1.<\/b> Choose either Travel Agent or Consumer<br\/><b style="color:#cc0000">2<\/b>. Enter email address<br\/><b style="color:#cc0000">3<\/b>. Enter Password <br\/><b style="color:#cc0000">4<\/b>. Click "login" button.<br\/><br\/>';
	str+='		<\/div>';
	str+='		<h5 style="margin-bottom:0px; margin-top:0px; font-size:10px"><a href="#">Forgot your password?<\/a><\/h5>';
	str+='		<div>';
	str+='		<img src="\/images\/help01.jpg"\/><br\/>If you forgot your password, click on the "?" next to the login button, enter your email address and you will receive a new password.';
	str+='		<\/div>';
	str+='		<h5 style="margin-bottom:0px; margin-top:0px; font-size:10px"><a href="#">Using filters to browse our offerings<\/a><\/h5>';
	str+='		<div style="height:250px">';
	str+='		<img src="\/images\/help02.jpg"\/><p>Filters help make browsing our packages easier. How the filters work:<br\/>Initially, all packages are displayed. Once you select a package type as a filter, only those selected will show up.<\/p><p>For best results, do not click more than once. Your click will register and takes a short amount of time to filter the results. To see all the packages again, you can uncheck all filters or click the "show all" link.<\/p><div style="clear:both"><\/div>';
	str+='		<\/div>';
	str+='		<h5 style="margin-bottom:0px; margin-top:0px; font-size:10px"><a href="#">What\'s a QuickView!?<\/a><\/h5>';
	str+='		<div>';
	str+='		<img src="\/images\/help03.jpg"\/><br\/><br\/>Our quickview allows you to view videos, current promotions and sightseeing tours and excursions for a particular package or destination without leaving the page. Just click on any of the quickview links.';
	str+='		<\/div>';
	str+='		<h5 style="margin-bottom:0px; margin-top:0px; font-size:10px"><a href="#">AGENTS<\/a><\/h5>';
	str+='		<div>';
	str+='			Agents, we have combined the agents and end-user sites. In order for you to view agent-specific information, you must log-in.';
	str+='		<\/div>';
	str+='		<h5 style="margin-bottom:0px; margin-top:0px; font-size:10px"><a href="#">Get a Quote on any package<\/a><\/h5>';
	str+='		<div>';
	str+='			<img src="\/images\/quotebtn.jpg"\/><br\/><br\/>Look for the button above on any package page to request your package quote. You can find the quote button at the top of our booking window.';
	str+='		<\/div>';
	str+='		<h5 style="margin-bottom:0px; margin-top:0px; font-size:10px"><a href="#">How can I order Brochures?<\/a><\/h5>';
	str+='		<div>';
	str+='		<img src="\/images\/help04.jpg"\/><br\/><br\/> Click this button, located in the Traveler\'s Community section on the bottom of our homepage. Once you select your user type (agent or consumer),  you will be forwarded to the correct form.';
	str+='		<\/div>';
	str+='		<h5 style="margin-bottom:0px; margin-top:0px; font-size:10px"><a href="#">How can I view online brochures?<\/a><\/h5>';
	str+='		<div>';
	str+='			<img src="\/images\/help05.jpg"\/><br\/><br\/>To view our online brochure gallery, visit the MediaCenter and click on the "e-brochures" icon. From there you can select the brochure you wish to view on the right hand side.';
	str+='		<\/div>';
	str+='		<h5 style="margin-bottom:0px; margin-top:0px; font-size:10px"><a href="#">Custom Trip Planner<\/a><\/h5>';
	str+='		<div>';
	str+='			<img src="\/images\/ctpdestimg.jpg"\/><br\/><br\/>With our custom trip planner, you can create your own vacation! You can find the Custom Trip Planner on our home page as well as on all "Destinations" pages.<br\/>Once you submit your Custom Trip to our specialists, you will promptly receive a call to discuss your trip.';
	str+='		<\/div>';
	str+='	<\/div><div style="height:35px; background-image: url(/images/helpbubble.png); background-position:bottom; "><\/div><\/div>';

	document.getElementById('help').innerHTML = str;
	
	jQuery(function() {
		jQuery("#accordion").accordion({
			collapsible: true
		});
	});

}