// JavaScript Document
String.prototype.trim1 = function () {
	var reExtraSpace = /^\s+(.*?)\s+$/;
	return this.replace(reExtraSpace, "$1");
};
var xwin;

//function to create http object
var http = createRequestObject();
function createRequestObject()
{
	var objAjax;
	var browser=navigator.appName;
	if(browser=="Microsoft Internet Explorer")
	{
	objAjax=new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
	objAjax= new XMLHttpRequest();
	}
	return objAjax;
}
//for budget date search
function showtourdate()
{
	var queryString="";
	document.getElementById('category').value=0;
	document.getElementById('tour').value=0;
	document.getElementById('traveldate').value=0;
	queryString+="catid="+document.getElementById('categoryB').value;
	queryString+="&type="+"showdate";
	var URL="functions/functions.php?"+queryString;
	http.open('get',URL);
	http.onreadystatechange=value_date; 
	http.send(null);
	return false;
}

function value_date()
{
	if(http.readyState==4)
	{
		document.getElementById('bugdate').innerHTML=http.responseText;
		
	}
}

function disc_misc_change()
{

	var queryString="";
	var tot = parseFloat(document.getElementById('totamt').value) ;
	var misc = parseFloat(document.getElementById('miscost').value) ;
	var disc = parseFloat(document.getElementById('discost').value) ;
	var sessionid = parseFloat(document.getElementById('sessionid').value);
	var tourid = document.getElementById('tourid').value ;

	var disc = disc.toFixed(2);
	var misc = misc.toFixed(2);
	var tot =  tot.toFixed(2);

	queryString+="misc="+misc+"&disc="+disc+"&tot="+tot+"&tourid="+tourid+"&sessionid="+sessionid ;
	queryString+="&type="+"misc_disc_change";
	var URL="functions/functions.php?"+queryString;

	http.open('get',URL);

	http.onreadystatechange=value_disc_misc_change; 
	http.send(null);
	return false;
}

function value_disc_misc_change()
{
	//alert(1);
	if(http.readyState==4)
	{

		respvalue = http.responseText;

		var rsp = respvalue.split("@");


		var gtot = parseFloat(rsp[0]);
		var bookamt = parseFloat(rsp[1]);
		var secondpay = parseFloat(rsp[2]);


		var newtot = parseFloat(gtot) - (bookamt + secondpay) ;
		var newtot =  newtot.toFixed(2);
		
		var gtot = gtot.toFixed(2);
		if (document.getElementById("miscost").value == null) {
			var misc = 0;
		} else{
			var misc = parseFloat(document.getElementById('miscost').value)
		}

//		misc = misc.toPrecision(2);

		if (document.getElementById("discost").value == null) {
			var disc = 0;
		} else{
			var disc = parseFloat(document.getElementById('discost').value)
		}

		var obj = document.getElementById('bookingamt');

        //var misc = misc.toFixed(2);
		var disc =      disc.toFixed(2);
		var secondpay = secondpay.toFixed(2);
		var bookamt =    bookamt.toFixed(2);
		document.getElementById('miscost').innerHTML.value=misc;
		document.getElementById('discost').innerHTML.value=disc;		
		document.getElementById('gtotal').innerHTML=gtot;
		if(obj == null)
		{
			document.getElementById('grosstotal').innerHTML=gtot;
		}
		else
		{
			document.getElementById('grosstotal').innerHTML=newtot;
		}
		document.getElementById('bookingamt').innerHTML=bookamt;
		document.getElementById('bookamt').innerHTML=bookamt;
		document.getElementById('secondstageamt').innerHTML=secondpay;

	}
}

function showvideo(vidfile,id)
{
	
	var queryString="";
	queryString+="filename="+vidfile+"&id="+id;
	queryString+="&type="+"showvideo";
	var URL="functions/functions.php?"+queryString;
//	alert(URL);
	if(vidfile != ""){
	http.open('get',URL);
	http.onreadystatechange=value_video; 
	http.send(null);
	}
	return false;
}

function value_video()
{
	if(http.readyState==4)
	{

		document.getElementById('divvedio').innerHTML=http.responseText;
		
	}
}

// agent signup
function checkagent(formName)
{
	if(document.getElementById('agentname').value=="" || trim(document.getElementById('agentname').value).length==0)
	{
	alert("Enter Mandatory Field(s)");
	document.getElementById('agentname').value="";
	document.getElementById('agentname').focus();
	return false;
    }
	
	if(document.getElementById('password1').value=="" || trim(document.getElementById('password1').value).length==0)
	{
	alert("Enter Mandatory Field(s)");
	document.getElementById('password1').value="";
	document.getElementById('password1').focus();
	return false;
    }
	if(document.getElementById('confirmpassword').value=="" || trim(document.getElementById('confirmpassword').value).length==0)
	{
	alert("Enter Mandatory Field(s)");
	document.getElementById('confirmpassword').value="";
	document.getElementById('confirmpassword').focus();
	return false;
    }
else if(document.getElementById('modify_username').value!=document.getElementById('modify_username').value)
	{
		alert("passwords do not match");
		document.getElementById('confirmpassword').focus();
		return false;
	}
		else if(document.getElementById('password1').value!=document.getElementById('confirmpassword').value)
	{
		alert("passwords do not match");
		document.getElementById('confirmpassword').focus();
		return false;
	}
	 if(document.getElementById('modify_username').value=="" || trim(document.getElementById('modify_username').value).length==0)
	{
	alert("Enter Mandatory Field(s)");
	document.getElementById('modify_username').value="";
	document.getElementById('modify_username').focus();
	return false;
    }
	if(document.getElementById('password2').value=="" || trim(document.getElementById('password2').value).length==0)
	{
	alert("Enter Mandatory Field(s)");
	document.getElementById('password2').value="";
	document.getElementById('password2').focus();
	return false;
    }
	if(document.getElementById('mconfirmpassword').value=="" || trim(document.getElementById('mconfirmpassword').value).length==0)
	{
	alert("Enter Mandatory Field(s)");
	document.getElementById('mconfirmpassword').value="";
	document.getElementById('mconfirmpassword').focus();
	return false;
    }
		else if(document.getElementById('password2').value!=document.getElementById('mconfirmpassword').value)
	{
		alert("passwords do not match");
		document.getElementById('mconfirmpassword').focus();
		return false;
	}
if(document.getElementById('emailid').value=="" || trim(document.getElementById('emailid').value).length==0)
	{
	alert("Enter Mandatory Field(s)");
	document.getElementById('emailid').value="";
	document.getElementById('emailid').focus();
	return false;
    }
	if(checkEmail(document.getElementById('emailid').value)==false)
		{
				
alert('Enter Valid Email');
document.getElementById('emailid').focus();
return false;
		}
	if(document.getElementById('agency').value=="" || trim(document.getElementById('agency').value).length==0)
	{
	alert("Enter Mandatory Field(s)");
	document.getElementById('agency').value="";
	document.getElementById('agency').focus();
	return false;
    }
	if(document.getElementById('address').value=="" )
	{
	alert("Enter Mandatory Field(s)");
	document.getElementById('address').value="";
	document.getElementById('address').focus();
	return false;
    }
		
		if(document.getElementById('zip').value=="" || trim(document.getElementById('zip').value).length==0)
	{
	alert("Enter Mandatory Field(s)");
	document.getElementById('zip').value="";
	document.getElementById('zip').focus();
	return false;
    }
		if(document.getElementById('state').value=="" || trim(document.getElementById('state').value).length==0)
	{
	alert("Enter Mandatory Field(s)");
	document.getElementById('state').value="";
	document.getElementById('state').focus();
	return false;
    }
		if(document.getElementById('country').value=="" || trim(document.getElementById('country').value).length==0)
	{
	alert("Enter Mandatory Field(s)");
	document.getElementById('country').value="";
	document.getElementById('country').focus();
	return false;
    }
	if(document.getElementById('declaine').checked==true )
	{
	window.location = "index.html";
	return false;
    }
	if(document.getElementById('accept').checked==false )
	{
	alert("Please Accept Terms & Conditions");
	return false;
    }
	
	var queryString="";
	queryString +="agentname" + "=" + escape(document.getElementById('agentname').value) + "&";
	queryString +="password1="+escape(document.getElementById('password1').value) + "&";
	queryString +="modify_username="+escape(document.getElementById('modify_username').value) + "&";
	queryString +="password2="+escape(document.getElementById('password2').value) + "&";
	queryString +="emailid="+escape(document.getElementById('emailid').value) + "&";
	queryString +="agency="+escape(document.getElementById('agency').value) + "&";
	queryString +="memberof="+escape(document.getElementById('memberof').value) + "&";
	queryString +="address="+escape(document.getElementById('address').value) + "&";
	queryString +="street="+escape(document.getElementById('street').value) + "&";
	queryString +="zip="+escape(document.getElementById('zip').value) + "&";
	queryString +="state="+escape(document.getElementById('state').value) + "&";
	queryString +="country="+escape(document.getElementById('country').value) + "&";
	queryString +="telephoneno="+escape(document.getElementById('telephoneno').value) + "&";
	queryString +="type" + "=" + "agentsignup";
	var URL="functions/functions.php?"+queryString;
//	alert(URL);
	http.open('get',URL);
	http.onreadystatechange=value_agent;
	http.send(null);
	return false;
}
function value_agent()
{
	if(http.readyState==4)
	{
		   //alert(http.responseText);
			if(http.responseText==5)
			{
			window.location="tradesale.html";
		    }
			else if (http.responseText==6)
			{
				alert("Username already exist");
			}
	}

}

function addMiscost(formName)
{
	if(document.getElementById('discost').value=="")
	{
		document.getElementById('discost').value=0;
	}
	if(document.getElementById('miscost').value=="")
	{
		document.getElementById('miscost').value=0;
	}
	var queryString="";
	var formLength=formName.length;
	for(i=0;i<formLength;i++)
	{
		var element=formName.elements[i];
		queryString +=element.id + "=" + element.value + "&";
	}
	queryString +="miscost="+document.getElementById('miscost').value + "&";
	queryString +="discost="+document.getElementById('discost').value + "&";
	queryString+="type" + "=" + "bookingdata";
	var URL="functions/functions.php?"+queryString;
	http.open('get',URL);
	http.onreadystatechange=value_booking;
	http.send(null);
	return false;
}
function value_booking()
{
	if(http.readyState==4)
	{
		document.getElementById('detailbuydiv').innerHTML=http.responseText;
	}
}

function popup(formName,no,filename)
{ 

	var queryString="";
	var tot=0;
	var totsupp=0;
	var totadd=0;
	var totstay=0;
	var beextra=0;
	var single=0;
	
	var totpass=parseInt(document.getElementById('noadult').value)+parseInt(document.getElementById('nochild').value)+parseInt(document.getElementById('noinfant').value);
	var tot_chpass=parseInt(document.getElementById('ch_adults').value)+parseInt(document.getElementById('ch_children').value)+parseInt(document.getElementById('ch_infants').value);
	var charterstatus = document.getElementById('charterstatus').value ;
	var link = "";

	if(document.getElementById('cabincontext').value>0)
	{
		for(i=1;i<=totpass;i++)
		{
			if(document.getElementById('cabin'+i).value=='Single Occupancy to Cabin')
			{
				single++;
				tot++;
			}
			else if(document.getElementById('cabin'+i).value=='2 Adults to a Cabin')
			{
				tot=tot+2;
			}
		}
	}



	if(no==1)
	{
//	alert("tot="+tot);
	link="cabin";
	if(tot!=totpass)
	{
		alert(" Selected Cabin Configuration should be equal to the no. of Passengers");
		return false;
	}
	if(single>3)
	{
	alert("Not More than 3 'Single Occupancy to Cabin' is allowed.");
		return false;	
	}
	}
	
	if(document.getElementById('staycontext').value>0)
	{
	for(i=1;i<=totpass;i++)
	{
		
		var data=document.getElementById('stay'+i).value;
		
		var occ=data.split("@@");
		if(occ[0]==2)
		{
		totstay=totstay+2;
		}
		if(occ[0]==1)
		{
		totstay=totstay+1;
		}
	}
	}

	if(no==4)
	{
	if(totstay!=totpass)
	{
		alert("Selected Stay Configuration should be equal to the no. of Passenger");
		return false;
	}
	}
		
	var formLength=formName.length;
	for(i=0;i<formLength;i++)
	{
		var element=formName.elements[i];
		queryString +=element.id + "=" + element.value + "&";
	}


	for(i=1;i<=document.getElementById('ctsupp').value;i++)
	{
		
		if(document.getElementById('chk'+i).checked==true)	
		{
			queryString +="chknew"+i+ "=" + "check" + "&";
			queryString +="price"+i+ "=" + document.getElementById('subprice'+i).innerHTML + "&";
			totsupp++;
		}
		else
		{
			queryString +="chknew"+i+ "=" + "nocheck" + "&";
			queryString +="price"+i+ "=" + document.getElementById('subprice'+i).innerHTML + "&";
		}
	}

	if(no==2)
	{
		link="supplements";
		if(totsupp==0)
		{
//			alert("Select checkbox for the Supplement you want to add");
//			return false;
		}
	}


	if(no==3)
	{
		link="addons";
		var taddon = document.getElementById('ctaddon').value ;
	for(i=1;i<=document.getElementById('ctaddon').value;i++)
	{
		if(document.getElementById('chkadd'+i).checked==true)	
		{
			queryString +="chkaddnew"+i+ "=" + "check" + "&";
			queryString +="addonprice"+i+ "=" + document.getElementById('addonprice'+i).value + "&";
			totadd++;
		}
		else
		{
			queryString +="chkaddnew"+i+ "=" + "nocheck" + "&";
			queryString +="addonprice"+i+ "=" + document.getElementById('addonprice'+i).value + "&";			
		}
	}
			queryString +="totaddon=" + taddon + "&";

		if(totadd==0)
		{
//			alert("Select checkbox for the Addon you want to add");
//			return false;
		}
	}
	
	if(no==6)
	{
		link="passengers";
		var totps = 0 ;
		var iTotpass = document.getElementById('ipass').value;

	for(i=1;i<=document.getElementById('ipass').value;i++)
	{
		if(document.getElementById('checkps'+i).checked==true)	
		{
			totps++;
		}
		else
		{

		}
	}
			queryString +="iTotpass="+totps + "&";
		if(totps == 0)
		{
			alert("Error: No Passenger was selected");
			return false;
		}
	}

	if(no==9){
		link = "staycon";
		ad3=0;
		ch3=0;
		stcstayroom = 0 ;
		singlesuppstay = 0;
		adult_sel3=parseInt(document.getElementById("ch_adults").value);
		child_sel3=parseInt(document.getElementById("ch_children").value);
		inf_sel3=parseInt(document.getElementById("ch_infants").value);
		

		
		child_sel3=child_sel3+inf_sel3;


		
		for(i=1;i<=totpass;i++)
		{
			val=document.getElementById("stay_room"+i).value;
			queryString +="stay_room" + i + "=" + val+"&";
			if(val == "1 Adults"){
				singlesuppstay = singlesuppstay + 1 ;								
			}
			
			if(val!=0){
				//	alert("hi");
			adval = val.substring(0,1);
			ad3=ad3+parseInt(adval);
//				ad3=ad3+parseInt(val[0]);
				stcstayroom = stcstayroom + 1;
				adval9 = 0;
				adval8 = 0 ;
				if(val.length > 13)

			adval9 = val.substring(9,10);
			adval8 = val.substring(8,9);

					if(parseInt(adval9) >= 0) {
						ch3=ch3+parseInt(adval9);
					}else if(parseInt(adval8) >= 0){
						ch3=ch3+parseInt(adval8);						
					}
			}	
			
		}
	//alert(queryString);return false;
	if(charterstatus == "1")
	{
		if((adult_sel3 > ad3) || (child_sel3 > ch3))
			{
alert("The Stay configuration selected for stay is less than the people staying in Hotel.  Stay configuration selected is for "+ad3+" Adult(s) +"+ch3+" Child(ren) whereas people staying are "+adult_sel3+" Adult(s) +"+child_sel3+"  Child(ren) .");
				 return false;
			}		
var adch = ad3 + ch3 ;
		if( adch > totpass )
			{
alert("The Stay configuration selected for stay is more than the people staying in Hotel.  Stay configuration selected is for "+ad3+" Adult(s) +"+ch3+" Child(ren) whereas people staying are "+totpass);
				 return false;
			}		

	} else {
		if((adult_sel3!=ad3) || (child_sel3!=ch3))
			{
alert("The Stay configuration selected for stay does not match the people staying in Hotel .  Stay configuration selected is for "+ad3+" Adult(s) +"+ch3+" Child(ren) whereas people staying are "+adult_sel3+" Adult(s) +"+child_sel3+"  Child(ren) .");
				 return false;
			}		
	}
	
	}

	if(no==5)
	{

		link = "extranights";
			if(document.getElementById('extranightcheck').checked==false && document.getElementById('extranightcheck1').checked==false)
		{
//			alert("Select checkbox for the Extra Nights you want to add");
//			return false;
		}
	
	singlesuppbf = 0;
	singlesuppaf = 0;

	if(document.getElementById('extranightcheck').checked==true)	
	{
		if(document.getElementById('extradate').value=="")
		{
			alert("Select Start Date");
			return false;
		}
		if(document.getElementById('extranight').value=="")
		{
			alert("Select No. of Nights");
			return false;
		}
		if(document.getElementById('extraroom').value=="")
		{
			alert("Select Room Type");
			return false;
		}


		
		adult_sel=parseInt(document.getElementById("nightA").value);
		child_sel=parseInt(document.getElementById("nightC").value);
		inf_sel=parseInt(document.getElementById("nightI").value);

		adult_sel1=parseInt(document.getElementById("nightA1").value);
		child_sel1=parseInt(document.getElementById("nightC1").value);
		inf_sel1=parseInt(document.getElementById("nightI1").value);

		
		child_sel=child_sel+inf_sel;
		child_sel1=child_sel1+inf_sel1;
		ad=0;
		ch=0;
		ad1=0;
		ch1=0;

		stcroom = 0;
		singlesuppbf = 0;
		singlesuppaf = 0;
		stcafroom = 0 ;
		adval = 0 ;
		chval = 0 ;
		chval1 = 0 ;
		var cname = "";
		for(i=1;i<=totpass;i++)
		{
			chval = 0;
			chval1 = 0;
			cname = "stayconfigselect"+i ;
			val=document.getElementById(cname).value;
			queryString +="staybf" + i + "=" + val+"&";
			if(val == "1 Adult"){
				singlesuppbf = singlesuppbf + 1 ;								
			}
			if(val!=0){
			adval = val.substring(0,1);
			ad=ad+parseInt(adval);
			stcroom = stcroom + 1 ;
			if(val.length>13)
			chval = val.substring(9,10);					
			chval1 = val.substring(8,9);					
					if(parseInt(chval) >= 0) {
						ch=ch+parseInt(chval);
					}else if(parseInt(chval1) >= 0) {
						ch=ch+parseInt(chval1);
					}			
			}
		}

//alert(charterstatus +'|adult sel: '+adult_sel+'|select ad: '+ad+'|'+child_sel+'|'+ch);return false;

	if(charterstatus == "1") 
	{
		if((adult_sel > ad) || (child_sel > ch))
			{
				 alert("The Stay configuration selected for stay is less than the people staying in Hotel.  Stay configuration selected is for "+ad+" Adult(s) +"+ch+" Child(ren) whereas people staying are "+adult_sel+" Adult(s) +"+child_sel+"  Child(ren) .");
				 return false;
			}	
		if((ad > adult_sel) || (ch > child_sel))
			{
				 alert("The Stay configuration selected for stay is greater than the people staying in Hotel.  Stay configuration selected is for "+ad+" Adult(s) +"+ch+" Child(ren) whereas people staying are "+adult_sel+" Adult(s) +"+child_sel+"  Child(ren) .");
				 return false;
			}		
	var adchtotal = ad + ch ;
		if( adchtotal > totpass )
			{
				 alert("The Stay configuration selected for stay is more than the people staying in Hotel.  Stay configuration selected is for "+ad+" Adult(s) +"+ch+" Child(ren) whereas people staying are "+totpass);
				 return false;
			}		
		
	}
	else 
	{
		if((adult_sel!=ad) || (child_sel!=ch))
			{
				 alert("The Stay configuration selected for stay does not match the people staying in Stay Configuration for Extra Nights Before Tour.  Stay configuration selected is for "+ad+" Adult(s) +"+ch+" Child(ren) whereas people staying are "+adult_sel+" Adult(s) +"+child_sel+"  Child(ren) .");
				return false;
			}				
	}
		
		
		//alert(ad+"child="+ch);
		
	/*	if(adult!=totpass)
	{
		alert("Selected Room Configuration should be equal to the no. of Passenger");
		return false;
	}
		*/
	if(document.getElementById('beforetourseaview').checked==true)	
		{
			queryString +="extranightcheck"+ "=" + "check" + "&bftourseaview=checked&"  ;
			queryString +="stc=" + stcroom + "&";
		}else {
			queryString +="extranightcheck"+ "=" + "check" + "&" ;
			queryString +="stc=0&";
		}
			queryString +="singlesuppbf=" + singlesuppbf + "&";

	}
	else
	{
		queryString +="extranightcheck"+ "=" + "nocheck" + "&stc=0&singlesuppbf=0&" ;
	}
	
	if(document.getElementById('extranightcheck1').checked==true)	
	{

		if(document.getElementById('extradate1').value=="")
		{
			alert("Select Start Date");
			return false;
		}
		if(document.getElementById('extranight1').value=="")
		{
			alert("Select No. of Nights");
			return false;
		}
		if(document.getElementById('extraroom1').value=="")
		{
			alert("Select Room Type");
			return false;
		}

		adult_sel1=parseInt(document.getElementById("nightA1").value);
		child_sel1=parseInt(document.getElementById("nightC1").value);
		inf_sel1=parseInt(document.getElementById("nightI1").value);

		child_sel1=child_sel1+inf_sel1;
		ad1=0;
		ch1=0;
		stcafroom = 0 ;
		singlesuppaf = 0;
		adval1 = 0;
		var chhval = 0;
		var chhval1 = 0;

		for(i=1;i<=totpass;i++)
		{
			chhval = 0;
			chhval1 = 0;
			val=document.getElementById("stayconfigselectt"+i).value;

			queryString +="stayaf" + i + "=" + val+"&";
			if(val == "1 Adult"){
				singlesuppaf = singlesuppaf + 1 ;								
			}
			
			if(val!=0){
			//	alert("hi");
			adval1 = val.substring(0,1);
			ad1=ad1+parseInt(adval1);

			stcafroom = stcafroom + 1 ;
			if(val.length>13)
			chhval = val.substring(9,10);					
			chhval1 = val.substring(8,9);					

				if(parseInt(chhval) >= 0) {
					ch1=ch1+parseInt(chhval);
				}else if(parseInt(chhval1) >= 0) {
					ch1=ch1+parseInt(chhval1);					
				}
			}
			
		}

		if(charterstatus == "1") 
		{
			if((adult_sel1 > ad1) || (child_sel1 > ch1))
				{
					 alert("The Stay configuration selected for stay is less than the people staying in Hotel.  Stay configuration selected is for "+ad1+" Adult(s) +"+ch1+" Child(ren) whereas people staying are "+adult_sel1+" Adult(s) +"+child_sel1+"  Child(ren) .");
					 return false;
				}
				if((adult_sel1!=ad1) || (child_sel1!=ch1))
				{
					 alert("The Stay configuration selected for stay does not match the people staying in Stay Configuration for Extra Nights Before Tour.  Stay configuration selected is for "+ad1+" Adult(s) +"+ch1+" Child(ren) whereas people staying are "+adult_sel1+" Adult(s) +"+child_sel1+"  Child(ren) .");
					return false;
				}	
				var adchtotal = ad1 + ch1 ;
			if( adchtotal > totpass )
				{
					 alert("The Stay configuration selected for stay is more than the people staying in Hotel.  Stay configuration selected is for "+ad1+" Adult(s) +"+ch1+" Child(ren) whereas people staying are "+totpass);
					 return false;
				}		
		} 
		else 
		{
			if((adult_sel1!=ad1) || (child_sel1!=ch1))
				{
					 alert("The Stay configuration selected for stay does not match the people staying in Stay Configuration for Extra Nights Before Tour.  Stay configuration selected is for "+ad1+" Adult(s) +"+ch1+" Child(ren) whereas people staying are "+adult_sel1+" Adult(s) +"+child_sel1+"  Child(ren) .");
					return false;
				}				
		}
	/*if((adult_sel1!=ad1) || (child_sel1!=ch1))
		{
			 alert("The Stay configuration selected for stay does not match the people staying in Stay Configuration for Extra Nights After Tour.  Stay configuration selected is for "+ad1+" Adult(s) +"+ch1+" Child(ren) whereas people staying are "+adult_sel1+" Adult(s) +"+child_sel1+"  Child(ren) .");
			return false;
		}*/


		if(document.getElementById('aftertourseaview').checked==true)	
		{
			queryString +="extranightcheck1"+ "=" + "check" + "&aftourseaview=checked&" ;
			queryString +="stcaf=" + stcafroom + "&singlesuppaf=" + singlesuppaf + "&";
		}else {
			queryString +="extranightcheck1"+ "=" + "check" + "&stcaf=0&singlesuppaf=" + singlesuppaf + "&" ;
		}

	}
	else
	{
		queryString +="extranightcheck1"+ "=" + "nocheck" + "&stcaf=0&singlesuppaf=0&";
	}
} 
// end if no == 5

	queryString +="convert"+ "=" + document.getElementById('currency_convertname').value + "&";
	queryString +="country"+ "=" + document.getElementById('country').value + "&";
	queryString +="single"+ "=" + single + "&link=" + link + "&" ;
//newwindow=window.open(filename+'?'+queryString,'New','scrollbars=1,top=100%,left=100%,height=630%,width=930%,top=100%,left=120%');	

	queryString +="type" + "=" + "shortenurl";
	/*var URL="functions/functions.php?"+ queryString;

	http.open('get',URL);
	http.onreadystatechange=value_showpopup;
	http.send(null);*/
	var URL="functions/functions.php";
	 //alert(URL);
	 var parameters = queryString;
	http.open("POST", URL, true);
	
	http.onreadystatechange = value_showpopup;
	//Send the proper header information along with the request
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", parameters.length);
	http.setRequestHeader("Connection", "close");


	//http.open('get',URL);
	http.send(parameters);
	return false;
}


function value_showpopup(){
try
	{
	var filename = "bookingAdd.php" ;
	var randomnumber=0;
		if(http.readyState==4)
		{
			randomnumber=http.responseText;
			if(randomnumber > 0)
			{
				var queryString = "randomid="+http.responseText ;
				var pagename = filename+'?'+queryString ;
				newwindow=window.open(filename+'?'+queryString,'New','scrollbars=1,top=100,left=100,height=550,width=930,top=100,left=120');	
			}
		}
	} catch (err){
		//alert("Not Allowed");
		return false ;
	}
}

function modpopup(formName,no,filename)
{ 

try
{

	var queryString="";
	var tot=0;
	var totsupp=0;
	var totadd=0;
	var totstay=0;
	var beextra=0;
	var single=0;

	queryString ="refid="+ document.getElementById('refid').value + "&";
	var totpass=parseInt(document.getElementById('noadult').value)+parseInt(document.getElementById('nochild').value)+parseInt(document.getElementById('noinfant').value);
	queryString +="noadult="+parseInt(document.getElementById('noadult').value)+ "&nochild="+parseInt(document.getElementById('nochild').value)+"&noinfant="+parseInt(document.getElementById('noinfant').value)+"&";	
	var charterstatus = document.getElementById('charterstatus').value ;
	var link = "";
	
	if(document.getElementById('cabincontext').value>0)
	{
		for(i=1;i<=totpass;i++)
		{
			if(document.getElementById('cabin'+i).value=='Single Occupancy to Cabin')
			{
				single++;
				tot++;
			}
			else if(document.getElementById('cabin'+i).value=='2 Adults to a Cabin')
			{
				tot=tot+2;
			}
		}
	}



	if(no==1)
	{
			queryString +="cabincontext="+ document.getElementById('cabincontext').value + "&";

	link="cabin";
	var cabin_count = 0;
		for(i=1;i<=totpass;i++)
		{
			queryString +="cabin"+i+ "=" + document.getElementById('cabin'+i).value + "&";
			cabin_count = cabin_count + 1 ;
		}
		if(tot!=totpass)
		{
			alert(" Selected Cabin Configuration should be equal to the no. of Passengers");
			return false;
		}
		if(single>3)
		{
			alert("Not More than 3 'Single Occupancy to Cabin' is allowed.");
			return false;	
		}
	}
	


	if(no==4)
	{
		link = "staycon" ;


		if(totstay!=totpass)
		{
			alert("Selected Stay Configuration should be equal to the no. of Passenger");
			return false;
		}
	if(document.getElementById('staycontext').value)
	{
	for(i=1;i<=totpass;i++)
	{
		
		var data=document.getElementById('stay'+i).value;
		
		var occ=data.split("@@");
		if(occ[0]==2)
		{
		totstay=totstay+2;
		}
		if(occ[0]==1)
		{
		totstay=totstay+1;
		}
	}
	}
	}
		queryString +="totalps=" + totpass + "&";
		
	var formLength=formName.length;



	for(i=1;i<=document.getElementById('ctsupp').value;i++)
	{
		
		if(document.getElementById('chk'+i).checked==true)	
		{
			queryString +="chknew"+i+ "=" + "check" + "&";
			queryString +="price"+i+ "=" + document.getElementById('subprice'+i).innerHTML + "&";
			totsupp++;
		}
		else
		{
			queryString +="chknew"+i+ "=" + "nocheck" + "&";
			queryString +="price"+i+ "=" + document.getElementById('subprice'+i).innerHTML + "&";
		}
	}

	if(no==2)
	{
		link="supplements";
		var totsupp = document.getElementById('ctsupp').value ;

		queryString +="ctsupp=" + totsupp + "&";

	for(i=1;i<=document.getElementById('ctsupp').value;i++)
	{


		if(document.getElementById('chk'+i).checked==true)	
		{
			queryString +="chk"+i+"="+document.getElementById('chk'+i).value+"&";
			queryString +="idsupp"+i+"="+document.getElementById('idsupp'+i).value+"&";
			queryString +="subprice"+i+"="+document.getElementById('subprice'+i).value+"&";
			queryString +="selP"+i+"="+document.getElementById('selP'+i).value+"&";
			queryString +="selD"+i+"="+document.getElementById('selD'+i).value+"&";
		}
	}
		
	}


	if(no==3)
	{
		link="addons";
		var taddon = document.getElementById('ctaddon').value ;
	for(i=1;i<=document.getElementById('ctaddon').value;i++)
	{
		if(document.getElementById('chkadd'+i).checked==true)	
		{
			queryString +="chkadd"+i+"="+document.getElementById('chkadd'+i).value+"&";
			queryString +="seladdon"+i+"="+document.getElementById('seladdon'+i).value+"&";
			queryString +="chkaddnew"+i+ "=" + "check" + "&";
			queryString +="addonprice"+i+ "=" + document.getElementById('addonprice'+i).value + "&";
			totadd++;
		}
		else
		{
			queryString +="chkaddnew"+i+ "=" + "nocheck" + "&";
			queryString +="addonprice"+i+ "=" + document.getElementById('addonprice'+i).value + "&";			
		}
	}
			queryString +="totaddon=" + taddon + "&";

		
	}
	var iTotamt = document.getElementById('gtotalamt').value;	
	queryString+="iTotamt="+iTotamt+"&";
	
	
	

	if(no==5)
	{
			link = "extranights";

			queryString +="extraroom1=" + document.getElementById('extraroom1').value + "&";
			queryString +="extradate1=" + document.getElementById('extradate1').value + "&";

			queryString +="extraroom=" + document.getElementById('extraroom').value + "&";
			queryString +="extradate=" + document.getElementById('extradate').value + "&";

			queryString +="nightA=" + document.getElementById('nightA').value + "&";
			queryString +="nightC=" + document.getElementById('nightC').value + "&";
			queryString +="nightI=" + document.getElementById('nightI').value + "&";
			queryString +="nightA1=" + document.getElementById('nightA1').value + "&";
			queryString +="nightC1=" + document.getElementById('nightC1').value + "&";
			queryString +="nightI1=" + document.getElementById('nightI1').value + "&";
			queryString +="extranight=" + document.getElementById('extranight').value + "&";
			queryString +="extranight1=" + document.getElementById('extranight1').value + "&";
			if(document.getElementById('extranightcheck').checked==false && document.getElementById('extranightcheck1').checked==false)
		{
		}
	
	singlesuppbf = 0;
	singlesuppaf = 0;
	adult_sel	 = 0;
	child_sel	 = 0;
	inf_sel		 = 0;
	adult_sel1	 = 0;
	child_sel1	 = 0;
	inf_sel1	 = 0;
	if(document.getElementById('extranightcheck').checked==true)	
	{

		if(document.getElementById('extradate').value=="")
		{
			alert("Select Start Date");
			return false;
		}
		if(document.getElementById('extranight').value=="")
		{
			alert("Select No. of Nights");
			return false;
		}
		if(document.getElementById('extraroom').value=="")
		{
			alert("Select Room Type");
			return false;
		}


		
		adult_sel=parseInt(document.getElementById("nightA").value);
		child_sel=parseInt(document.getElementById("nightC").value);
		inf_sel=parseInt(document.getElementById("nightI").value);

		adult_sel1=parseInt(document.getElementById("nightA1").value);
		child_sel1=parseInt(document.getElementById("nightC1").value);
		inf_sel1=parseInt(document.getElementById("nightI1").value);

		
		child_sel=child_sel+inf_sel;
		child_sel1=child_sel1+inf_sel1;
		ad=0;
		ch=0;
		ad1=0;
		ch1=0;

		stcroom = 0;
		singlesuppbf = 0;
		singlesuppaf = 0;
		stcafroom = 0 ;
		

		for(i=1;i<=totpass;i++)
		{
			adval = 0 ;
			chval = 0 ;
			chval1 = 0 ;
			val=document.getElementById("stayconfigselect"+i).value;
			queryString +="staybf" + i + "=" + val+"&";
			if(val == "1 Adult"){
				singlesuppbf = singlesuppbf + 1 ;								
			}
			if(val!=0){
			adval = val.substring(0,1);
			ad=ad+parseInt(adval);
			stcroom = stcroom + 1 ;
			if(val.length>13)
			chval = val.substring(9,10);					
			chval1 = val.substring(8,9);					
					if(parseInt(chval) >= 0) {
						ch=ch+parseInt(chval);
					}else if(parseInt(chval1) >= 0) {
						ch=ch+parseInt(chval1);
					}			
			}
			
		}

		if(charterstatus == "1") {
		if((adult_sel > ad) || (child_sel > ch))
			{
				 alert("The Stay configuration selected for stay is less than the people staying in Hotel.  Stay configuration selected is for "+ad+" Adult(s) +"+ch+" Child(ren) whereas people staying are "+adult_sel+" Adult(s) +"+child_sel+"  Child(ren) .");
				 return false;
			}
		if((adult_sel!=ad) || (child_sel!=ch))
			{
				 alert("The Stay configuration selected for stay does not match the people staying in Stay Configuration for Extra Nights Before Tour.  Stay configuration selected is for "+ad+" Adult(s) +"+ch+" Child(ren) whereas people staying are "+adult_sel+" Adult(s) +"+child_sel+"  Child(ren) .");
				return false;
			}	
	var adchtotal = ad + ch ;
		if( adchtotal > totpass )
			{
				 alert("The Stay configuration selected for stay is more than the people staying in Hotel.  Stay configuration selected is for "+ad+" Adult(s) +"+ch+" Child(ren) whereas people staying are "+totpass);
				 return false;
			}		
	} else {
		if((adult_sel!=ad) || (child_sel!=ch))
			{
				 alert("The Stay configuration selected for stay does not match the people staying in Stay Configuration for Extra Nights Before Tour.  Stay configuration selected is for "+ad+" Adult(s) +"+ch+" Child(ren) whereas people staying are "+adult_sel+" Adult(s) +"+child_sel+"  Child(ren) .");
				return false;
			}				
	}
	/*if((adult_sel!=ad) || (child_sel!=ch))
		{
			 alert("The Stay configuration selected for stay does not match the people staying in Stay Configuration for Extra Nights Before Tour.  Stay configuration selected is for "+ad+" Adult(s) +"+ch+" Child(ren) whereas people staying are "+adult_sel+" Adult(s) +"+child_sel+"  Child(ren) .");
			return false;
		}*/		
		

	if(document.getElementById('beforetourseaview').checked==true)	
		{
			queryString +="extranightcheck"+ "=" + "check" + "&bftourseaview=checked&"  ;
			queryString +="stc=" + stcroom + "&";
		}else {
			queryString +="extranightcheck"+ "=" + "check" + "&" ;
			queryString +="stc=0&";
		}
			queryString +="singlesuppbf=" + singlesuppbf + "&";

	}
	else
	{
		queryString +="extranightcheck"+ "=" + "nocheck" + "&stc=0&singlesuppbf=0&" ;
	}
	
	if(document.getElementById('extranightcheck1').checked==true)	
	{

		if(document.getElementById('extradate1').value=="")
		{
			alert("Select Start Date");
			return false;
		}
		if(document.getElementById('extranight1').value=="")
		{
			alert("Select No. of Nights");
			return false;
		}
		if(document.getElementById('extraroom1').value=="")
		{
			alert("Select Room Type");
			return false;
		}

		adult_sel1=parseInt(document.getElementById("nightA1").value);
		child_sel1=parseInt(document.getElementById("nightC1").value);
		inf_sel1=parseInt(document.getElementById("nightI1").value);

		child_sel1=child_sel1+inf_sel1;
		ad1=0;
		ch1=0;
		stcafroom = 0 ;
		singlesuppaf = 0;
		stcroom = 0;

		for(i=1;i<=totpass;i++)
		{
			adval = 0 ;
			chval = 0 ;
			chval1 = 0 ;
			val=document.getElementById("stayconfigselectt"+i).value;

			queryString +="stayaf" + i + "=" + val+"&";
			if(val == "1 Adult"){
				singlesuppaf = singlesuppaf + 1 ;								
			}
			
			if(val!=0){
			adval = val.substring(0,1);
			ad1=ad1+parseInt(adval);
			stcroom = stcroom + 1 ;
			if(val.length>13)
			chval = val.substring(9,10);					
			chval1 = val.substring(8,9);					
					if(parseInt(chval) >= 0) {
						ch1=ch1+parseInt(chval);
					}else if(parseInt(chval1) >= 0) {
						ch1=ch1+parseInt(chval1);
					}			
			}
			
		}

		if(charterstatus == "1") 
		{
			if((adult_sel1 > ad1) || (child_sel1 > ch1))
				{
					 alert("The Stay configuration selected for stay is less than the people staying in Hotel.  Stay configuration selected is for "+ad1+" Adult(s) +"+ch1+" Child(ren) whereas people staying are "+adult_sel1+" Adult(s) +"+child_sel1+"  Child(ren) .");
					 return false;
				}
			if((adult_sel1!=ad1) || (child_sel1!=ch1))
				{
					 alert("The Stay configuration selected for stay does not match the people staying in Stay Configuration for Extra Nights Before Tour.  Stay configuration selected is for "+ad1+" Adult(s) +"+ch1+" Child(ren) whereas people staying are "+adult_sel1+" Adult(s) +"+child_sel1+"  Child(ren) .");
					return false;
				}	
				var adchtotal = ad1 + ch1 ;
			if( adchtotal > totpass )
				{
					 alert("The Stay configuration selected for stay is more than the people staying in Hotel.  Stay configuration selected is for "+ad1+" Adult(s) +"+ch1+" Child(ren) whereas people staying are "+totpass);
					 return false;
				}		
		} 
		else 
		{
			if((adult_sel1!=ad1) || (child_sel1!=ch1))
				{
					 alert("The Stay configuration selected for stay does not match the people staying in Stay Configuration for Extra Nights Before Tour.  Stay configuration selected is for "+ad1+" Adult(s) +"+ch1+" Child(ren) whereas people staying are "+adult_sel1+" Adult(s) +"+child_sel1+"  Child(ren) .");
					return false;
				}				
		}
	/*if((adult_sel1!=ad1) || (child_sel1!=ch1))
		{
			 alert("The Stay configuration selected for stay does not match the people staying in Stay Configuration for Extra Nights After Tour.  Stay configuration selected is for "+ad1+" Adult(s) +"+ch1+" Child(ren) whereas people staying are "+adult_sel1+" Adult(s) +"+child_sel1+"  Child(ren) .");
			return false;
		}*/


		if(document.getElementById('aftertourseaview').checked==true)	
		{
			queryString +="extranightcheck1"+ "=" + "check" + "&aftourseaview=checked&" ;
			queryString +="stcaf=" + stcafroom + "&singlesuppaf=" + singlesuppaf + "&";
		}else {
			queryString +="extranightcheck1"+ "=" + "check" + "&stcaf=0&singlesuppaf=" + singlesuppaf + "&" ;
		}

	}
	else
	{
		queryString +="extranightcheck1"+ "=" + "nocheck" + "&stcaf=0&singlesuppaf=0&";
	}
} 


	
	if(no==9){
		link = "staycon";
		ad3=0;
		ch3=0;
		stcstayroom = 0 ;
		singlesuppstay = 0;
		adult_sel3=parseInt(document.getElementById("stayadults").value);
		child_sel3=parseInt(document.getElementById("staychild").value);
	
		var default_adults=0;
		var default_childs=0;
		if(charterstatus == 1)
		{
			default_adults=parseInt(document.getElementById("default_adults").value);
			default_childs=parseInt(document.getElementById("default_childs").value);
		}
		//child_sel3=child_sel3 ;

		for(i=1;i<=totpass;i++)
		{
			val=document.getElementById("stay_room"+i).value;
			queryString +="stay_room" + i + "=" + val+"&";
			if(val == "1 Adults"){
				singlesuppstay = singlesuppstay + 1 ;								
			}
			
			if(val!=0){
				
			adval = val.substring(0,1);
			ad3=ad3+parseInt(adval);

				stcstayroom = stcstayroom + 1;
				adval9 = 0;
				adval8 = 0 ;
				if(val.length > 13)

			adval9 = val.substring(9,10);
			adval8 = val.substring(8,9);

					if(parseInt(adval9) >= 0) {
						ch3=ch3+parseInt(adval9);
					}else if(parseInt(adval8) >= 0){
						ch3=ch3+parseInt(adval8);						
					}
			}	
			
		}
		
		var adch = ad3 + ch3 ;
		var totad	=	ad3;
		var totch	=	ch3;
		var totaladults	= adult_sel3;
		var totalchilds	= child_sel3;
		var seladults	= ad3;
		var selchilds	= ch3;

	if(charterstatus == "1")
	{
		if(ad3 < default_adults || ch3 < default_childs)
		{
				alert("Stay configuration selected is for "+ad3+" Adult(s) +"+ch3+" Child(ren) whereas people staying are "+default_adults+" Adult(s) +"+default_childs+"  Child(ren) .");
				 return false;
		}
		else
		{
			totad	=	ad3;
			totch	=	ch3;
			adult_sel3	= adult_sel3 - (default_adults + default_childs);
			ad3			= ad3 - default_adults;
			ch3			= ch3 - default_childs;
			adch		= default_adults + default_childs + ad3 + ch3 ;
		}
		
		if( adch > totpass )
			{
alert("The Stay configuration selected for stay is more than the people staying in Hotel.  Stay configuration selected is for "+seladults+" Adult(s) +"+selchilds+" Child(ren) whereas people staying are "+totpass);
				 return false;
			}		

	} else 
	{
		if((adult_sel3!=ad3) || (child_sel3!=ch3))
			{
alert("The Stay configuration selected for stay does not match the people staying in Hotel .  Stay configuration selected is for "+ad3+" Adult(s) +"+ch3+" Child(ren) whereas people staying are "+adult_sel3+" Adult(s) +"+child_sel3+"  Child(ren) .");
				 return false;
			}		
	}
	} 
	
	
	

if(no==12)
{

	link = "passengers";
	var icount = 1;
	var new_passenger = 0;
	var tot_passenger = document.getElementById('tot_passenger').value ;
	var new_adult = 0;
	var new_child = 0;
	var new_infant = 0 ;
	var name = "";
	var lastname = "";

	adult_sel3=parseInt(document.getElementById("noadult").value);
	child_sel3=parseInt(document.getElementById("nochild").value);
	inf_sel3=parseInt(document.getElementById("noinfant").value);
	qryString = "";
	var element;
	var formLength=formName.length;
	//if(navigator.appName != 'Microsoft Internet Explorer')
	//{
	for(i=0;i<formLength;i++)
	{
		element=formName.elements[i];
		if(element.value!='0@@0@@0'){
			if(element.name)
				queryString +=element.name + "=" + element.value + "&";
			else
				queryString +=element.id + "=" + element.value + "&";
		}
	}
	//}
	var validadult = 0 ;
	while(icount <= adult_sel3){
		if(document.getElementById('checkps'+icount).checked == true){
				new_adult = new_adult + 1 ;
			if(document.getElementById('name'+icount).value != ""){			
				validadult = 1 ;
			}
			queryString +="adps"+icount+"=checked&";
		}else{
			queryString +="adps"+icount+"=unchecked&";
		}
		icount++;
	}

	while(icount <= (adult_sel3 + child_sel3)){
		if(document.getElementById('checkps'+icount).checked == true){
			new_child = new_child + 1 ;
			queryString +="adps"+icount+"=checked&";
		}else{
			queryString +="adps"+icount+"=unchecked&";
		}
		icount++;
	}

	while(icount <= (adult_sel3 + child_sel3 + inf_sel3)){
		if(document.getElementById('checkps'+icount).checked == true){
			new_infant = new_infant + 1 ;
			queryString +="adps"+icount+"=checked&";
		}else{
			queryString +="adps"+icount+"=unchecked&";
		}
		icount++;
	}
	if((new_adult + new_child + new_infant == 0) || (validadult == 0) ){
		alert("Error: Select atleast one passenger with full name mentioned ");
		return false;
	}
	queryString +="&new_adult"+ "=" + new_adult + "&new_child="+ new_child+"&new_infant="+new_infant+"&";


	queryString +="&new_adult"+ "=" + new_adult + "&new_child="+ new_child+"&new_infant="+new_infant+"&";

} 


// end if no == 12 
	
		queryString +="single"+ "=" + single + "&link=" + link  ;
			
		queryString +="&type" + "=" + "modshortenurl";
		//var URL="functions/functions.php?"+ queryString;
		var URL="functions/functions.php";
		 //alert(URL);
		 var parameters = queryString;
		http.open("POST", URL, true);
		
		http.onreadystatechange = value_showmodpopup;
		//Send the proper header information along with the request
		http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		http.setRequestHeader("Content-length", parameters.length);
		http.setRequestHeader("Connection", "close");


		//http.open('get',URL);
		http.send(parameters);	
	
	/*else
	{
		queryString +="single"+ "=" + single + "&link=" + link  ;
			
		queryString +="&type" + "=" + "modshortenurl";
		var URL="functions/functions.php?"+ queryString;
	 
		http.open('get',URL);
		http.onreadystatechange = value_showmodpopup;
		http.send(null);
	}*/
	return false;
}
catch(err)
	{
		//alert(err.description);
		return false;
	}
}

function value_showmodpopup(){
try
	{
		var filename = "bookingmod.php" ;
		var randomnumber=0;
		if(http.readyState==4)
		{
			randomnumber = http.responseText;
			if(randomnumber > 0)
			{
				var queryString = "randomid="+ http.responseText ;
				var pagename = filename +'?'+queryString ;
				 
				newwindow=window.open(pagename,'New','scrollbars=1,top=100,left=100,height=630,width=930,top=100,left=120');	
				return false ;
			}
		}
	} catch (err){
		return false ;
	}

}

function value_ps(){
	if(http.readyState==4)
	{
//		alert(http.responseText);
	}
}

function closecabindata(formName)
{
		window.close();
		if (window.opener && !window.opener.closed) {
			window.opener.location.reload(true);
		}
}

function addcabindata(formName)
{
	var queryString="";
	var formLength=formName.length;
	for(i=0;i<formLength;i++)
	{
		var element=formName.elements[i];
		queryString +=element.id + "=" + element.value + "&";
	}
	queryString+="type" + "=" + "cabindate";
	var URL="functions/functions.php?"+queryString;


	var parameters = queryString;
	http.open("POST", URL, true);
	
	http.onreadystatechange = value_cabin;
	//Send the proper header information along with the request
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", parameters.length);
	http.setRequestHeader("Connection", "close");

	http.send(parameters);
	return false;	
}
function value_cabin()
{
	if(http.readyState==4)
	{

		window.close();
		if (window.opener && !window.opener.closed) {
			window.opener.location.reload(true);
		}
	}
}

function modifycabindata(formName)
{
	var queryString="";
	var formLength=formName.length;
	for(i=0;i<formLength;i++)
	{
		var element=formName.elements[i];
		queryString +=element.id + "=" + element.value + "&";
	}
	queryString+="type" + "=" + "bookingmodify";
	var URL="functions/functions.php?"+queryString;

	http.open('get',URL);
	http.onreadystatechange=value_cabinmodify;
	http.send(null);
	return false;	
}
function value_cabinmodify()
{
	if(http.readyState==4)
	{

			window.close();
		if (window.opener && !window.opener.closed) {
			window.opener.location.reload(true);
		}
	}
}

function charter(formName)
{

	var queryString="";
	var formLength=formName.length;
	for(i=0;i<formLength;i++)
	{
		var element=formName.elements[i];
		queryString +=element.id + "=" + element.value + "&";
	}
	queryString+="type" + "=" + "charterdata";
	//alert(queryString)
	var URL="functions/functions.php?"+queryString;
	
	http.open('get',URL);
	http.onreadystatechange=value_charter;
	http.send(null);
	return false;
}
function value_charter()
{
	if(http.readyState==4)
	{
		
		if(isNaN(http.responseText))
		{		 
		document.getElementById('detailbuydiv').innerHTML=http.responseText;
		}
		/*else
		{
		alert("Only "+http.responseText+" adults are allowed in this charter");
		}*/
		

		window.location.reload();
//		document.getElementById('chtd').display='none';
	}
}
function Change1( )
{
	alert('formName');
}
// for currency
function Changecurr(formName)
{
	
	 
//formName="detailbuy";
	var queryString="";
	var formLength=formName.length;
	for(i=0;i<formLength;i++)
	{
		var element=formName.elements[i];
		queryString +=element.id + "=" + element.value + "&";
	}
    queryString+="currid="+document.getElementById('currency_convertname').value;
	queryString+="&sessionid="+document.getElementById('sessionid').value;
	queryString+="&type="+"currencyconvert";
	var URL="functions/functions1.php?"+queryString;
	http.open('get',URL);
	//alert(URL)
	
	http.onreadystatechange=value_currency; 
	http.send(null);
	return false;
}

function value_currency()
{
	if(http.readyState==4)
	{
		 
		window.location.reload();

		
	}
}
// for invoice page currency
function Changecurr2(formName)
{
	
	//alert(document.getElementById('currency_convertname').value)
	
//if(formName==1)
//formName="detailbuy";
	var queryString="";
	var formLength=formName.length;
	for(i=0;i<formLength;i++)
	{
		var element=formName.elements[i];
		queryString +=element.id + "=" + element.value + "&";
	}
	
    queryString+="currid="+document.getElementById('currency_convertname').value;
	queryString+="&sessionid="+document.getElementById('sessionid').value;
	queryString+="&type="+"currencyconvert";
	var URL="functions/functions1.php?"+queryString;
	
	http.open('get',URL);
	//alert(URL)
	
	http.onreadystatechange=value_currency2; 
	http.send(null);
	return false;
}
function value_currency2()
{
	if(http.readyState==4)
	{
		//document.getElementById('invoicediv').innerHTML=http.responseText;
	//alert(document.getElementById("str").value);
		window.location.reload();
		
	}
}
/*function enbefore(check)
{
	if(check==true)
	{
	}
	else
	{
	}
} */

function enbefore(check)
{
	var entotpass=parseInt(document.getElementById('noadult').value)+parseInt(document.getElementById('nochild').value)+parseInt(document.getElementById('noinfant').value);
	if(check==true)
	{
		document.getElementById('extradate').disabled = false;
		document.getElementById('extranight').disabled = false;
		document.getElementById('extraroom').disabled = false;
		document.getElementById('nightA').disabled = false;
		document.getElementById('nightC').disabled = false;
		document.getElementById('nightI').disabled = false;
		document.getElementById('beforetourseaview').disabled = false;
		for(i=1;i<=entotpass;i++)
		{

			document.getElementById("stayconfigselect"+i).disabled = false;
		}
	}
	else
	{
		document.getElementById('extradate').disabled = true;
		document.getElementById('extranight').disabled = true;
		document.getElementById('extraroom').disabled = true;
		document.getElementById('nightA').disabled = true;
		document.getElementById('nightC').disabled = true;
		document.getElementById('nightI').disabled = true;
		document.getElementById('beforetourseaview').disabled = true;
		for(i=1;i<=entotpass;i++)
		{

			document.getElementById("stayconfigselect"+i).disabled = true;
		}
	}
}
function enafter(check)
{
	var eftotpass=parseInt(document.getElementById('noadult').value)+parseInt(document.getElementById('nochild').value)+parseInt(document.getElementById('noinfant').value);

	if(check==true)
	{
		document.getElementById('extradate1').disabled = false;
		document.getElementById('extranight1').disabled = false;
		document.getElementById('extraroom1').disabled = false;
		document.getElementById('nightA1').disabled = false;
		document.getElementById('nightC1').disabled = false;
		document.getElementById('nightI1').disabled = false;
		document.getElementById('aftertourseaview').disabled = false;
		for(i=1;i<=eftotpass;i++)
		{

			document.getElementById("stayconfigselectt"+i).disabled = false;
		}
	}
	else
	{
		document.getElementById('extradate1').disabled = true;
		document.getElementById('extranight1').disabled = true;
		document.getElementById('extraroom1').disabled = true;
		document.getElementById('nightA1').disabled = true;
		document.getElementById('nightC1').disabled = true;
		document.getElementById('nightI1').disabled = true;
		document.getElementById('aftertourseaview').disabled = true;
		for(i=1;i<=eftotpass;i++)
		{

			document.getElementById("stayconfigselectt"+i).disabled = true;
		}

	}
}

//show stay config
function showstayconfig()
{
	var queryString="";
	var valuemix=document.getElementById('extraroom').value;

	var valuestay=valuemix.split("@@");
	var valuestay1=valuestay[0];

	var valuestay3=valuestay[2];
	queryString+="roomid="+valuestay1;
	queryString+="&hotelid="+valuestay3;
	queryString+="&totalnum="+document.getElementById('totalnum').value;
	queryString+="&tourid="+document.getElementById('tourid').value;
	queryString+="&type="+"showstayconfig";
	var URL="functions/functions1.php?"+queryString;

	http.open('get',URL);

	http.onreadystatechange=value_stay; 
	http.send(null);
	return false;
	
}
function value_stay()
{
	if(http.readyState==4)
	{
		document.getElementById('stayconfigs').innerHTML=http.responseText;
	}
}

function showstayconfig1()
{
	var queryString="";
	var valuemixe=document.getElementById('extraroom1').value;

	var valuestay7=valuemixe.split("@@");
	var valuestay2=valuestay7[0];
	var valuestay4=valuestay7[2];

	queryString+="roomid1="+valuestay2;
	queryString+="&hotelid1="+valuestay4;
	queryString+="&totalnum="+document.getElementById('totalnum').value;
	queryString+="&tourid="+document.getElementById('tourid').value;
	queryString+="&type="+"showstayconfig1";
	var URL="functions/functions1.php?"+queryString;

	http.open('get',URL);

	http.onreadystatechange=value_stay1; 
	http.send(null);
	return false;

}
function value_stay1()
{
	if(http.readyState==4)
	{

		//alert("hii");
		document.getElementById('stayconfig1').innerHTML=http.responseText;
	}
}

function validateFloat(input, maxBefore, maxAfter)
{
	 
  eval("var floatRegex = /^-?\\d{0," + maxBefore + "}(\\.\\d{0," + maxAfter + "})?$/");
  if(input.value!="")
  {
	
 	 if( !floatRegex.test(input.value) )
 	 {
      alert("Invalid Number");
      input.value ="";
 	 }
	 if(input.value<1 || input.value>9999)
	 {
		  if(input.value!="")
  		{
			 alert("Invalid Number"); 
			 input.value = "";
		}
 	}
  }
}
