// JavaScript Document
var airWays=function(){};
airWays.airlineSearchPref='';
airWays.classOfService='';
airWays.fareType='';
function displayTab(value){
	if(value=="hotel"){
		document.getElementById("hotel").style.display="block";
		document.getElementById("air").style.display="none";
		document.getElementById("airhotel").style.display="none";
		document.getElementById("cars").style.display="none";
	}
	if(value=="air"){
		document.getElementById("hotel").style.display="none";
		document.getElementById("air").style.display="block";
		document.getElementById("airhotel").style.display="none";
		document.getElementById("cars").style.display="none";
	}
	if(value=="airhotel"){
		document.getElementById("hotel").style.display="none";
		document.getElementById("air").style.display="none";
		document.getElementById("airhotel").style.display="block";
		document.getElementById("cars").style.display="none";
	}
	if(value=="cars"){
		document.getElementById("hotel").style.display="none";
		document.getElementById("air").style.display="none";
		document.getElementById("airhotel").style.display="none";
		document.getElementById("cars").style.display="block";
	}
}
function displayages(value){
	noOfChilds=parseInt(value);
	if(noOfChilds>=1){
		document.getElementById("childAge").style.display="block";
		for(i=1;i<5;i++){
			document.getElementById("minorsAge"+i).style.display="none";
		}
		for(i=1;i<=noOfChilds;i++){
			document.getElementById("minorsAge"+i).style.display="block";
		}
	}
	else{
		document.getElementById("childAge").style.display="none";
	}
		
}
function displayagesAir(value){
	noOfChilds=parseInt(value);
	if(noOfChilds>=1){
		document.getElementById("childAgeA").style.display="block";
		for(i=1;i<5;i++){
			document.getElementById("minorsAgeA"+i).style.display="none";
		}
		for(i=1;i<=noOfChilds;i++){
			document.getElementById("minorsAgeA"+i).style.display="block";
		}
	}
	else{
		document.getElementById("childAgeA").style.display="none";
	}
}
function toggleFlights(value){
	if(value =="oneway"){
		document.getElementById("airSingle").style.display="block";
		document.getElementById("dateSelectRow").style.display="none";
		document.getElementById("returnRow").style.display="none";
		document.getElementById("airMulti").style.display="none";
 	}
	if(value =="roundtrip"){
		document.getElementById("airSingle").style.display="block";
		document.getElementById("dateSelectRow").style.display="block";
		document.getElementById("returnRow").style.display="block";
		document.getElementById("airMulti").style.display="none";
    }
	if(value =="multicity"){
		document.getElementById("airSingle").style.display="none";
		document.getElementById("dateSelectRow").style.display="none";
		document.getElementById("returnRow").style.display="none";
		document.getElementById("airMulti").style.display="block";
 	}
}
function toggleDate(value){
	if(value =="exactDates"){
		document.getElementById("dateLeavingTimeA").style.display="block";
		document.getElementById("departDateFlexibility").style.display="none";
		document.getElementById("dateReturningTimeA").style.display="block";
 		document.getElementById("returnDateFlexibility").style.display="none";
	}
	if(value =="plusMinusDates"){
		document.getElementById("departDateFlexibility").style.display="block";
		document.getElementById("dateLeavingTimeA").style.display="none";
		document.getElementById("dateReturningTimeA").style.display="none";
 		document.getElementById("returnDateFlexibility").style.display="block";
	}
}
function overlayShow(){
	bod = document.getElementsByTagName('body')[0];
		//bod.style.background = "#fff";
		document.getElementById("innerLay").style.display="none";
		/*var elements = document.searchForm.elements;
    for (var i = 0; i < elements.length; i++) {
      var element = elements[i];
      element.blur();
      element.disabled = 'true';
    }*/
		document.getElementById("overlay").style.display="block";
}
function overlayHide(){
	bod = document.getElementsByTagName('body')[0];
		/*bod.style.background = "";
		var elements = document.searchForm.elements;
    for (var i = 0; i < elements.length; i++) {
      var element = elements[i];
      //element.blur();
      element.disabled = '';
    }*/
	document.getElementById("innerLay").style.display="block";
		document.getElementById("overlay").style.display="none";
}
function setPreferences(){
	document.getElementById("alert").style.display="block";
	airWays.airlineSearchPref=document.getElementById("airlineSearchPref").value;
	airWays.classOfService=document.getElementById("classOfService").value;
	airWays.fareType=document.getElementById("fareType").value;
	overlayHide();
}
function generateCarSearch(){
	error=0;
	url="http://res.cityguru.travel/nexres/start-pages/gateway.cgi?header=carengine&footer=carengine&engine=carmpsb&src=10020839&src_aid=&trans=A";
	pucity=document.getElementById("pucity").value;
	puwhere=document.getElementById("puwhere").value;
	chk_in=document.getElementById("pkp_in").value;
	if(chk_in!=""){
		selDate=chk_in.split("/");
		a=new Date(selDate[1]+"/"+selDate[0]+"/"+selDate[2]);
		b=new Date();
  		if(Date.parse(a)<Date.parse(b)){
			if(a.getDay() != b.getDay()){
			alert('You Can\'t select past dates');
			return false;
			}
		}
	cDate=chk_in.split("/");
	chk_in=encodeURIComponent(chk_in);
	pudate_dy=cDate[0];
	pudate_mo=cDate[1];
	pu_time=document.getElementById("pu_time").value;
	}
	else{
		pudate_dy="";
		pudate_mo="";
		pu_time="";
	}
 	chk_out=document.getElementById("pkp_out").value;
	if(chk_out!=""){
		selDate=chk_out.split("/");
		a=new Date(selDate[1]+"/"+selDate[0]+"/"+selDate[2]);
		b=new Date();
  		if(Date.parse(a)<Date.parse(b)){
			if(a.getDay() != b.getDay()){
			alert('You Can\'t select past dates');
			return false;
			}
		}
	dDate=chk_out.split("/");
	chk_out=encodeURIComponent(chk_out);
	dodate_dy=dDate[0];
	dodate_mo=dDate[1];
	do_time=document.getElementById("do_time").value;
	}
	else{
		dodate_dy="";
		dodate_mo="";
		do_time="";
	}
 	carcode=document.getElementById("carcode").value;
	if(pucity=="" || chk_in=="" || chk_out==""){
 		error=1;
	}
	if(error != 0)
		alert("Please give us your details properly.");
 	else{
		finalUrl=url+"&pucity="+pucity+"&puwhere="+puwhere+"&chk_in="+chk_in+"&pudate_mo="+pudate_mo+"&pudate_dy="+pudate_dy+"&pu_time="+pu_time+"&chk_out="+chk_out+"&dodate_mo="+dodate_mo+"&dodate_dy="+dodate_dy+"&do_time="+do_time+"&carcode="+carcode+"&submit=search";
		//window.location=finalUrl;
		window.location="search.asp?q=cars+"+encodeURIComponent(pucity);
	}
}
function generateHotelSearch(src){
	error=0;
	if(src=='f')
		url="http://res.cityguru.travel/nexres/search/search_results.cgi?header=hotel&footer=hotel&";
	else
		url="http://res.cityguru.travel/nexres/search/power_search.cgi?header=hotel&footer=hotel&";
	src="src=10020839";
	url=url+src+"&tab=tab0&src_aid=&avail=Y&currency_id=USD";
	city=document.getElementById("city").value;
	vicinity=(document.forms[0].search_city_vicinity.checked)?"1":"0";
	chk_in=document.getElementById("chk_in").value;
	if(chk_in!=""){
	selDate=chk_in.split("/");
		a=new Date(selDate[1]+"/"+selDate[0]+"/"+selDate[2]);
		b=new Date();
  		if(Date.parse(a)<Date.parse(b)){
			if(a.getDay() != b.getDay()){
			alert('You Can\'t select past dates');
			return false;
			}
		}
	cDate=chk_in.split("/");
	chk_in=encodeURIComponent(chk_in);
	doa_dd=cDate[0];
	doa_mm=cDate[1];
	doa_yy=cDate[2];
	}
	else{
		doa_dd="";
		doa_mm="";
		doa_yy="";
	}
	chk_out=document.getElementById("chk_out").value;
	if(chk_out!=""){
	selDate=chk_out.split("/");
		a=new Date(selDate[1]+"/"+selDate[0]+"/"+selDate[2]);
		b=new Date();
  		if(Date.parse(a)<Date.parse(b)){
			if(a.getDay() != b.getDay()){
			alert('You Can\'t select past dates');
			return false;
			}
		}
	dDate=chk_out.split("/");
	chk_out=encodeURIComponent(chk_out);
	dod_dd=dDate[0];
	dod_mm=dDate[1];
	dod_yy=dDate[2];
	}
	else{
		dod_dd="";
		dod_mm="";
		dod_yy="";
	}
	num_rooms=document.getElementById("num_rooms").value;
	num_adults=document.getElementById("num_adults").value;
	num_children=parseInt(document.getElementById("num_children").value);
	minorsAge1=(document.getElementById("minorsAge1"))?document.getElementById("minorsAge1").value:"";
	minorsAge2=(document.getElementById("minorsAge2"))?document.getElementById("minorsAge2").value:"";
	minorsAge3=(document.getElementById("minorsAge3"))?document.getElementById("minorsAge3").value:"";
	minorsAge4=(document.getElementById("minorsAge4"))?document.getElementById("minorsAge4").value:"";
	if(city=="" || chk_in=="" || chk_out==""){
 		error=1;
	}
	if(num_children>0){
		for(j=1;j<=num_children;j++)
			if(document.getElementById("minorsAge"+j).value == "")
				error=1;
	}
	if(error != 0)
		alert("Please give us your details properly.");
 	else{
		finalUrl=url+"&city="+city+"&search_city_vicinity="+vicinity+"&chk_in="+chk_in+"&doa_mm="+doa_mm+"&doa_dd="+doa_dd+"&doa_yy="+doa_yy+"&chk_out="+chk_out+"&dod_mm="+dod_mm+"&dod_dd="+dod_dd+"&dod_yy="+dod_yy+"&num_rooms="+num_rooms+"&num_adults="+num_adults+"&num_children="+num_children+"&minorsAge1="+minorsAge1+"&minorsAge2="+minorsAge2+"&minorsAge3="+minorsAge3+"&minorsAge4="+minorsAge4+"&SearchNow=search";
		//window.location=finalUrl;
		window.location="search.asp?q=hotels+"+encodeURIComponent(city);
	}
}
function popUp(s_url,s_name,s_attrib){
  o_popwindow = window.open(s_url,s_name,s_attrib);
}
function generateAirHotelSearch(){
	error=0;
	url="http://res.cityguru.travel/nexres/start-pages/gateway.cgi?engine=customtrip&src=10020839&scr_aid=&action=search&doa_mm=&doa_dd=&doa_yy=&dod_mm=&dod_dd=&dod_yy=&SearchNow=search";
	leavingFrom=document.getElementById("leavingFrom").value;
	goingTo=document.getElementById("goingTo").value;
	date_leaving=document.getElementById("date_leaving").value;
	if(date_leaving!=""){
		selDate=date_leaving.split("/");
		a=new Date(selDate[1]+"/"+selDate[0]+"/"+selDate[2]);
		b=new Date();
  		if(Date.parse(a)<Date.parse(b)){
			if(a.getDay() != b.getDay()){
			alert('You Can\'t select past dates');
			return false;
			}
		}
	cDate=date_leaving.split("/");
	date_leaving=encodeURIComponent(date_leaving);
	dateLeavingDay=cDate[0];
	dateLeavingMonth=cDate[1];
 	}
	else{
		dateLeavingDay="";
		dateLeavingMonth="";
 	}
	dateLeavingTime=(document.getElementById("dateLeavingTime").value=="")?"+":document.getElementById("dateLeavingTime").value;
 	date_return=document.getElementById("date_return").value;
	if(date_return!=""){
	
	cDate=date_return.split("/");
	date_return=encodeURIComponent(date_return);
	dateReturningDay=cDate[0];
	dateReturningMonth=cDate[1];
 	}
	else{
		dateReturningDay="";
		dateReturningMonth="";
 	}
	dateReturningTime=(document.getElementById("dateReturningTime").value=="")?"+":document.getElementById("dateReturningTime").value;
 	stops=document.getElementById("stops").value;
	adults=document.getElementById("adults").value;
 	children=parseInt(document.getElementById("children").value);
	seniors=document.getElementById("num_seniors").value;
	minorAge1Room1=(document.getElementById("minorAgeRoom1"))?document.getElementById("minorAgeRoom1").value:"";
	minorAge2Room1=(document.getElementById("minorAgeRoom2"))?document.getElementById("minorAgeRoom2").value:"";
	minorAge3Room1=(document.getElementById("minorAgeRoom3"))?document.getElementById("minorAgeRoom3").value:"";
	minorAge4Room1=(document.getElementById("minorAgeRoom4"))?document.getElementById("minorAgeRoom4").value:"";
	if(leavingFrom=="" || date_leaving=="" || date_return=="" || goingTo=="" ){
 		error=1;
	}
	if(children>0){
		for(j=1;j<=children;j++)
			if(document.getElementById("minorAgeRoom"+j).value == "")
				error=1;
	}
	if(error != 0)
		alert("Please give us your details properly.");
  	else{
		//alert('done');
		finalUrl=url+"&leavingFrom="+leavingFrom+"&goingTo="+goingTo+"&date_leaving="+date_leaving+"&dateLeavingDay="+dateLeavingDay+"&dateLeavingMonth="+dateLeavingMonth+"&dateLeavingTime="+dateLeavingTime+"&date_return="+date_return+"&dateReturningDay="+dateReturningDay+"&dateReturningMonth="+dateReturningMonth+"&dateReturningTime="+dateReturningTime+"&stops="+stops+"&adults="+adults+"&children="+children+"&minorAge1Room1="+minorAge1Room1+"&minorAge2Room1="+minorAge2Room1+"&minorAge3Room1="+minorAge3Room1+"&minorAge4Room1="+minorAge4Room1+"&seniors="+seniors;
		//document.writeln(finalUrl);
		//window.location=finalUrl;
		window.location="search.asp?q=hotels and flights +"+encodeURIComponent(goingTo);
	}
	
}
function generateAirSearch(){
	flightType=(document.forms[0].flightType[0].checked)?document.forms[0].flightType[0].value:((document.forms[0].flightType[1].checked)?document.forms[0].flightType[1].value:document.forms[0].flightType[2].value);
 	nearbyAirports=(document.forms[0].nearbyAirports.checked)?1:0;
	dateTypeSelect=(document.forms[0].dateTypeSelect[0].checked)?"exactDates":"plusMinusDates";
 	leavingFromA=document.getElementById("leavingFromA").value
	goingToA=document.getElementById("goingToA").value
	
	leavingDate=document.getElementById("chkA_in").value 
	dateLeavingTimeA=(document.getElementById("dateLeavingTimeA"))?document.getElementById("dateLeavingTimeA").value:"";	
	departDateFlexibility=(document.getElementById("departDateFlexibility"))?document.getElementById("departDateFlexibility").value:"";
	returningDate=document.getElementById("chkA_out").value
	dateReturningTimeA=(document.getElementById("dateReturningTimeA"))?document.getElementById("dateReturningTimeA").value:"";	
	returnDateFlexibility=(document.getElementById("returnDateFlexibility"))?document.getElementById("returnDateFlexibility").value:"";
	
	leavingFrom1=(document.getElementById("leavingFrom1"))?document.getElementById("leavingFrom1").value:"";
	goingTo1=(document.getElementById("goingTo1"))?document.getElementById("goingTo1").value:"";
	leavingDate1=(document.getElementById("leavingDate1"))?document.getElementById("leavingDate1").value:"";
	leavingTime1=(document.getElementById("leavingDate1"))?document.getElementById("leavingTime1").value:"";
	
 	leavingFrom2=(document.getElementById("leavingFrom2"))?document.getElementById("leavingFrom2").value:"";
	goingTo2=(document.getElementById("goingTo2"))?document.getElementById("goingTo2").value:"";
	leavingDate2=(document.getElementById("leavingDate2"))?document.getElementById("leavingDate2").value:"";
	leavingTime2=(document.getElementById("leavingDate2"))?document.getElementById("leavingTime2").value:"";
	
	leavingFrom3=(document.getElementById("leavingFrom3"))?document.getElementById("leavingFrom3").value:"";
	goingTo3=(document.getElementById("goingTo3"))?document.getElementById("goingTo3").value:"";
	leavingDate3=(document.getElementById("leavingDate3"))?document.getElementById("leavingDate3").value:"";
	leavingTime3=(document.getElementById("leavingDate3"))?document.getElementById("leavingTime3").value:"";
	
	leavingFrom4=(document.getElementById("leavingFrom4"))?document.getElementById("leavingFrom4").value:"";
	goingTo4=(document.getElementById("goingTo4"))?document.getElementById("goingTo4").value:"";
	leavingDate4=(document.getElementById("leavingDate4"))?document.getElementById("leavingDate4").value:"";
	leavingTime4=(document.getElementById("leavingDate4"))?document.getElementById("leavingTime4").value:"";
	
 	air_seniors=document.getElementById("air_seniors").value;
	air_adults=document.getElementById("air_adults").value;
	air_children=parseInt(document.getElementById("air_children").value);
	minorsAge0=(document.getElementById("minorsAgeA1"))?document.getElementById("minorsAgeA1").value:"";
	minorsAge1=(document.getElementById("minorsAgeA2"))?document.getElementById("minorsAgeA2").value:"";
	minorsAge2=(document.getElementById("minorsAgeA3"))?document.getElementById("minorsAgeA3").value:"";
	minorsAge3=(document.getElementById("minorsAgeA4"))?document.getElementById("minorsAgeA4").value:"";
	error=0;
	
	url='http://res.cityguru.travel/nexres/start-pages/gateway.cgi?Service=TPN&affiliateId=10020839&subAffiliateId=&action=search&engine=air&flightType='+flightType+'&dateTypeSelect='+dateTypeSelect+'&leavingFrom='+leavingFromA+'&goingTo='+goingToA+'&leavingDate='+leavingDate+'&dateLeavingTime='+dateLeavingTimeA+'&departDateFlexibility='+departDateFlexibility;
	url=url+'&returningDate='+returningDate+'&dateReturningTime='+dateReturningTimeA+'&returnDateFlexibility='+returnDateFlexibility+'&leavingFrom1='+leavingFrom1+'&goingTo1='+goingTo1+'&leavingDate1='+leavingDate1+'&leavingTime1='+leavingTime1+'&leavingFrom2='+leavingFrom2+'&goingTo2='+goingTo2+'&leavingDate2='+leavingDate2+'&leavingTime2='+leavingTime2+'&leavingFrom3='+leavingFrom3+'&goingTo3='+goingTo3+'&leavingDate3='+leavingDate3+'&leavingTime3='+leavingTime3+'&leavingFrom4='+leavingFrom4+'&goingTo4='+goingTo4+'&leavingDate4='+leavingDate4;
	url=url+'&leavingTime4='+leavingTime4+'&adults='+air_adults+'&children='+air_children+'&seniors='+air_seniors+'&minorsAge0='+minorsAge0+'&minorsAge1='+minorsAge1+'&minorsAge2='+minorsAge2+'&minorsAge3='+minorsAge3+'&SearchNow=search&airlineSearchPref='+airWays.airlineSearchPref+'&classOfService='+airWays.classOfService+'&fareType='+airWays.fareType+'&nearbyAirports='+nearbyAirports;
	
	if(flightType != "multicity")
	{
		if(leavingFromA == "" || goingToA == "")
			error=1;
	}
	if(air_children>0){
		for(j=1;j<=air_children;j++)
			if(document.getElementById("minorsAgeA"+j).value == "")
				error=1;
	}
	if(error != 0)
		alert("Please give us your details properly.");
  	else{
		//document.writeln(url);
  		//window.location=url;
		goingTo=(document.getElementById("goingToA").value!="")?document.getElementById("goingToA").value:document.getElementById("goingTo1").value
		window.location="search.asp?q=flights to +"+encodeURIComponent(goingTo);
	}
	
}
function displayagesRoom(value){
	noOfChilds=parseInt(value);
	if(noOfChilds>=1){
		document.getElementById("childRoomAge").style.display="block";
		for(i=1;i<5;i++){
			document.getElementById("minorAgeRoom"+i).style.display="none";
		}
		for(i=1;i<=noOfChilds;i++){
			document.getElementById("minorAgeRoom"+i).style.display="block";
		}
	}
	else{
		document.getElementById("childRoomAge").style.display="none";
	}
		
}
function go(value){
	//if(value=="other")
	//	window.location="http://go.travelpn.com/car/CarRequest.do?Service=TPN&affiliateId=10020839&subAffiliateId=&aspHeader=car&aspFooter=car&cBox=";
	//else
		return false;
}
function showCal(id){
	var cal = new Calendar(0, null);
 
  // hide week numbers
  cal.weekNumbers = false;

  // We want some dates to be disabled; see function isDisabled above
  cal.setDisabledHandler(null);
  cal.setDateFormat("%A, %B %e");

  // this call must be the last as it might use data initialized above; if
  // we specify a parent, as opposite to the "showCalendar" function above,
  // then we create a flat calendar -- not popup.  Hidden, though, but...
  cal.create(document.getElementById(id));

  // ... we can show it here.
  cal.show();
	
}
