// JavaScript Document
var sURL = unescape(window.location.pathname);
var xmlHttp
var CtyNa = ""
var CtyDv = ""
var CtyNo = ""
var CONTROL
var fieldValue = -1
var TimeId
var ShowPk = 1
var strCty
var Codekey
var objXmlHttp=null
var CtryDv = ""
var CtryNo = ""
var Clean = 100
var Higli = 0
var ShowDIV = ""


function findObj(elemID){
	var obj=false;
	if(document.all){
		obj=document.all(elemID);
	}
	else{
		if(document.getElementById){
			obj=document.getElementById(elemID);
		}
		else{
			if(document.laers){
				obj=document.laers[elemID];
			}
		}
	}
	return obj;	
}

function displayDiv(divID,display){
	//alert(divID)
	oDiv=findObj(divID);
	if (display){
		oDiv.style['display'] = "";
	}
	else{
		//alert(divID)
		oDiv.style['display'] = "none";
	}
}

function showHintCo(str,id){
Clean = 200
window.clearTimeout(TimeId);
strCty = str.length
ShowPk = 0
CtyNo = id
//alert(CtyNo)
CtyName = "Enter City "+ id
//alert (CtyName)
	if (str != CtyName){
		if (str.length > 1){ 
		//var url="Get_Cities_Hint.asp?sid=" + Math.random() + "&q=" + str +"&ctyNo=" + id
		var url="Get_Cities_Hint_V2.asp?q=" + str +"&ctyNo=" + id
		xmlHttp=GetXmlHttpObject(stateChanged)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
		} 
		else{
		eval("document.all['txtHint"+ CtyNo +"'].innerHTML=''");
		} 
	} 
	if (navigator.userAgent.indexOf("MSIE")>=0 || navigator.userAgent.indexOf("MSIE 5.5")>=0){	
		Codekey = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	}
	else{
		Codekey = evt.which ? evt.which : evt.keyCode;
	}
}

function stateChanged(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		
		if (navigator.userAgent.indexOf("MSIE")>=0 || navigator.userAgent.indexOf("MSIE 5.5")>=0){
			eval("document.all['txtHint"+ CtyNo +"'].innerHTML=xmlHttp.responseText");
			eval("document.all['txtHint"+ CtyNo +"'].style.display='block'");
			}
		if (navigator.userAgent.indexOf("Firefox")>=0 || navigator.userAgent.indexOf("Safari")>=0){
			document.getElementById('txtHint'+ CtyNo).innerHTML=xmlHttp.responseText;
			document.getElementById('txtHint'+ CtyNo).style.display='block';
		}
		if (strCty >= 4){
			if (document.getElementById('Dest'+ CtyNo) != null){
				document.getElementById('Dest'+ CtyNo).focus();
			}
			else{
				document.getElementById('inText'+ CtyNo).focus();
			}
		}
	} 
} 

function HintCityOnly(str,id,name,iDiv){
Clean = 200
window.clearTimeout(TimeId);
strDepCty = str.length
CtyNo = id
CtyNa = name
CtyDv = iDiv
	//alert(str + id + name + iDiv)
	if (str.length > 2){ 
	var url="Get_DepCities_Hint.asp?q=" + str +"&ctyNo=" + id +"&ifield=" + name
	xmlHttp=GetXmlHttpObject(ShowCities)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
	} 
	else{
	findObj(CtyDv).innerHTML = "";
	
	} 
	
	if (navigator.userAgent.indexOf("MSIE")>=0 || navigator.userAgent.indexOf("MSIE 5.5")>=0){	
		Codekey = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	}
	else{
		Codekey = evt.which ? evt.which : evt.keyCode;
	}
}

function ShowCities(){ 

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		
		findObj(CtyDv).innerHTML = xmlHttp.responseText;
		//displayDiv('divPax',false);
		//displayDiv('DLX',false);
		displayDiv(CtyDv,true);
		//alert(CtyDv)
		if (CtyDv == 'txtDepa'){
		document.getElementById('divCab').style.visibility='hidden';
		document.getElementById('divChi').style.visibility='hidden';
		}
		//displayDiv('divCab',false);
	} 
} 

function HintCountry(name,num,str){
Clean = 200
window.clearTimeout(TimeId);
CtryDv = 'HintCon' + num
CtryNo = num
if (str == ''){
	str = 'NX'
}
	//alert(str + id + name + iDiv)
	if (num > 0){
		if (str.length > 0){
		var url="Get_Country_Hint.asp?ifield=" + name +"&No=" + num +"&q=" + str
		xmlHttp=GetXmlHttpObject(ShowCountry)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
		} 
		else{
		findObj(CtryDv).innerHTML = "";
		} 
		if (navigator.userAgent.indexOf("MSIE")>=0 || navigator.userAgent.indexOf("MSIE 5.5")>=0){	
			Codekey = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		}
		else{
			Codekey = evt.which ? evt.which : evt.keyCode;
		}
	}
}

function ShowCountry(){ 

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		
		findObj(CtryDv).innerHTML = xmlHttp.responseText;
		
		for(var i=1;i<5;i++) {
			if (i == CtryNo){
			 displayDiv('HintCon' + CtryNo,true);
			}
			if (i != CtryNo){
			displayDiv('HintCon' + i,false);
			}
		displayDiv('HintCty' + i,false);
		}
		displayDiv(CtryDv,true);
	} 
	//if (window.focus){alert('cacacacacacaca'); window.focus()}
}


function HintCityFrCty(name,num,coID,str){

if (str == '' && coID != -1 ){
	str = 'NX'
}
if (str == '' && coID == -1){
	str = 'XX'
}

Clean = 200
window.clearTimeout(TimeId);
CtyDv = 'HintCty' + num
CtyNo = num

	if (coID > 0 && str == 'NX'){
		Higli = 1
	}
	if (coID > 0 && str == 'CX'){
		Higli = -1
	}
	
	if(coID == -1){
		Higli = -1
	}
	
	if (coID == 0){
		Higli = -1
		coID = findObj('txtContry'+ num +'value').value
		//alert (coID)
		if (coID == ''){
			alert(" Please select a Country ");
			return false;
		}
	}
	//alert(str + id + name + iDiv)
	if (num > 0){
		//alert(str)
		if (str.length > 0){
		var url="/Get_Cities_FromCity.asp?ifield=" + name +"&No=" + num +"&CoID=" + coID +"&q=" + str
		//alert(url)
		xmlHttp=GetXmlHttpObject(ShowCity)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
		} 
		else{
		findObj(CtyDv).innerHTML = "";
		} 
		if (navigator.userAgent.indexOf("MSIE")>=0 || navigator.userAgent.indexOf("MSIE 5.5")>=0){	
			Codekey = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		}
		else{
			Codekey = evt.which ? evt.which : evt.keyCode;
		}
	}
}

function HintCity(name,num,coID,str){

if (str == '' && coID != -1 ){
	str = 'NX'
}
if (str == '' && coID == -1){
	str = 'XX'
}

Clean = 200
window.clearTimeout(TimeId);
CtyDv = 'HintCty' + num
CtyNo = num

	if (coID > 0 && str == 'NX'){
		Higli = 1
	}
	if (coID > 0 && str == 'CX'){
		Higli = -1
	}
	
	if(coID == -1){
		Higli = -1
	}
	
	if (coID == 0){
		Higli = -1
		coID = findObj('txtContry'+ num +'value').value
		//alert (coID)
		if (coID == ''){
			alert(" Please select a Country ");
			return false;
		}
	}
	//alert(str + id + name + iDiv)
	if (num > 0){
		//alert(str)
		if (str.length > 0){
		var url="/Get_City_Hint.asp?ifield=" + name +"&No=" + num +"&CoID=" + coID +"&q=" + str
		//alert(url)
		xmlHttp=GetXmlHttpObject(ShowCity)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
		} 
		else{
		findObj(CtyDv).innerHTML = "";
		} 
		if (navigator.userAgent.indexOf("MSIE")>=0 || navigator.userAgent.indexOf("MSIE 5.5")>=0){	
			Codekey = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		}
		else{
			Codekey = evt.which ? evt.which : evt.keyCode;
		}
	}
}

function ShowCity(){ 

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		//alert(xmlHttp.responseText)
		findObj(CtyDv).innerHTML = xmlHttp.responseText;
		displayDiv(CtyDv,true);
		//alert(CtyDv)
		for(var i=1;i<5;i++) {
			if (i == CtyNo){
			//alert(CtyNo)
			//displayDiv('HintCty' + CtyNo,true);
			}
			if (i != CtyNo){
			displayDiv('HintCty' + i,false);
			}
		if (Higli != -1){			
			if (findObj('HintCon' + i) != null){
			displayDiv('HintCon' + i,false);
			}
			}
		}
		if (Higli == 1){
		highlightN(name)
		}
	}
	
}


function HintCityCountry(name,num,coID,str){
Clean = 200
window.clearTimeout(TimeId);
if (name == 'txDes'){
CtyDv = 'txtDest'
	}
if (name == 'txDesOnly'){
CtyDv = 'txtDestO'
	}

CtyNo = num
CtyNa = name

	if (num > 0){
		//alert(str)
		if (str.length > 0){
		var url="/Get_City_Hint.asp?ifield=" + name +"&No=" + num +"&CoID=" + coID +"&q=" + str
		//alert(url)
		xmlHttp=GetXmlHttpObject(ShowCityCountry)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
		} 
		else{
		findObj(CtyDv).innerHTML = "";
		} 
		if (navigator.userAgent.indexOf("MSIE")>=0 || navigator.userAgent.indexOf("MSIE 5.5")>=0){	
			Codekey = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		}
		else{
			Codekey = evt.which ? evt.which : evt.keyCode;
		}
	}
}

function ShowCityCountry(){ 

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		//alert(xmlHttp.responseText)
		findObj(CtyDv).innerHTML = xmlHttp.responseText;
		displayDiv(CtyDv,true);
		}
	
}

function showCalendar(cal){
ShowDIV = 'showCalF'
		//alert(cal)
		var strcty = ""
		var ctid1 = findObj('txtCty1value').value;
		if (ctid1 > 0){
			strcty = ctid1
		}
		var ctid2 = findObj('txtCty2value').value;
		if (ctid2 > 0){
			strcty = strcty +'|'+ ctid2
		}
		var ctid3 = findObj('txtCty3value').value;
		if (ctid3 > 0){
			strcty = strcty +'|'+ ctid3
		}
		var ctid4 = findObj('txtCty4value').value;
		if (ctid4 > 0){
			strcty = strcty +'|'+ ctid4
		}
	//alert(strcty)
	displayDiv('showCalF',false);
	findObj(ShowDIV).innerHTML = "";
	objXmlHttp=null
	//alert(str + id + name + iDiv)
	if (cal.length > 2){ 
	var url="Get_Calendar_Hint.asp?q=" + cal +"&ctystr=" + strcty
	xmlHttp=GetXmlHttpObject(ShowCalendarType)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
	} 
	else{
	findObj(ShowDIV).innerHTML = "";
	objXmlHttp=null
	} 
}

function ShowCalendarType(){ 

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		//alert(xmlHttp.responseText)
		findObj(ShowDIV).innerHTML = xmlHttp.responseText;
		displayDiv(ShowDIV,true);
		
	} 
} 



function GetXmlHttpObject(handler){
	
	if (navigator.userAgent.indexOf("Opera")>=0){
		alert("This City selector doesn't work in Opera")
		return
	}
	if (navigator.userAgent.indexOf("MSIE")>=0){
		var strName="Msxml2.XMLHTTP"
			if (navigator.appVersion.indexOf("MSIE 5.5")>=0){
				strName="Microsoft.XMLHTTP"
			}
			try{
				objXmlHttp=new ActiveXObject(strName)
				objXmlHttp.onreadystatechange=handler
				return objXmlHttp
			}
			catch(e){
				alert("Error. Scripting for ActiveX might be disabled")
				return
			}
	}
				if (navigator.userAgent.indexOf("Firefox")>=0 || navigator.userAgent.indexOf("Safari")>=0){
				objXmlHttp=new XMLHttpRequest()
				objXmlHttp.onload=handler
				objXmlHttp.onerror=handler
				return objXmlHttp
			}

	}

function PassValueK(a,b,c,evt){
	
	if (navigator.userAgent.indexOf("MSIE")>=0 || navigator.userAgent.indexOf("MSIE 5.5")>=0){	
		var Codekey = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	}
	else{
		var Codekey = evt.which ? evt.which : evt.keyCode;
	}
	
	//alert(Codekey)
	if (Codekey == 8 || Codekey == 27){
		
		if (CtyNo <= 12){
					if (window.event) window.event.returnValue = true
					
					document.cityselect('inText'+ CtyNo).value = 'Enter City ' + CtyNo ;
/*rt*/				document.cityselect('inText'+ CtyNo).focus();
					//p = eval('document.cityselect.inText'+ CtyNo) 
					//highlight(p);
					}
		
		document.getElementById('txtHint'+ CtyNo).innerHTML='';
		document.getElementById('txtHint'+ CtyNo).style.display='none';
		objXmlHttp=null
		
	}
	
	if(Codekey == 9 || Codekey == 13){
		PassValue(a,b)
	}
	
	if (Codekey == 40){
		if (window.event) window.event.returnValue = false
		
			if (document.getElementById('pDest'+ c) != null){
				document.getElementById('pDest'+ c).focus();
			}
		}
		
	if (Codekey == 38){
		if (window.event) window.event.returnValue = true
			//alert(c + ' = c')
		d = c - 2
			//alert(d + ' = d')
		if (c==3){
		document.getElementById('Dest'+ CtyNo).focus();
		}
	else{
			if (document.getElementById('pDest'+ d) != null){
				document.getElementById('pDest'+ d).focus();
			}
		}
		}
}

function PassValue(a,b){
	
	//alert(a + ' = a || ' + b + ' = b')
	
	if (a == ''){
		ShowPk = -1
	}
	    fieldValue = 0
		if (navigator.userAgent.indexOf("Firefox")>=0){
		document.getElementById('StayCity'+ CtyNo).value=a;
		document.getElementById('StayCity'+ CtyNo +'_Name').value=b;
		document.getElementById('inText'+ CtyNo).value=b;
		document.getElementById('inText'+ CtyNo).className='BOX-Select_City_Small';
		document.getElementById('txtHint'+ CtyNo).innerHTML='';
		document.getElementById('txtHint'+ CtyNo).style.display='none';
		objXmlHttp=null
		fieldValue = -1
		
	}
	if (navigator.userAgent.indexOf("MSIE")>=0 || navigator.userAgent.indexOf("MSIE 5.5")>=0){
		
		eval("document.all['StayCity"+ CtyNo +"'].value=a");
		eval("document.all['StayCity"+ CtyNo +"_Name'].value=b");
		eval("document.all['inText"+ CtyNo +"'].value=b");
		eval("document.all['inText"+ CtyNo +"'].className='BOX-Select_City_Small'");
		eval("document.all['txtHint"+ CtyNo +"'].innerHTML=''");
		eval("document.all['txtHint"+ CtyNo +"'].style.display='none'");
		objXmlHttp=null
		//alert(document.all['StayCity'+ CtyNo +''].value)
		//alert(document.all['StayCity'+ CtyNo +'_Name'].value)
	}	
	if (CtyNo > 1 && ShowPk == 1){
		checkValue()
	}
	
	CtyNo = CtyNo + 1
			
			if (document.getElementById('inText'+ CtyNo) != null){
				
				if (CtyNo <= 12){
					if (window.event) window.event.returnValue = true
//rt				c = document.cityselect('inText'+ CtyNo)
					c = eval('document.cityselect.inText'+ CtyNo) 
					highlight(c);
					}
				}
			else{
				//alert('aaahhhhhhhhh')
				if (window.focus) window.focus()
				}
}

function highlight(field){
  field.focus();
  field.select();
}

function highlightN(field){
	findObj(field).focus();
	findObj(field).select();
}

function ValuePassK(a,b,c,evt,d){
	//alert(evt)
	
	if (navigator.userAgent.indexOf("MSIE")>=0 || navigator.userAgent.indexOf("MSIE 5.5")>=0){	
		var Codekey = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	}
	else{
		var Codekey = evt.which ? evt.which : evt.keyCode;
	}
	
	//alert(Codekey)
	if (Codekey == 8 || Codekey == 27){
		
		findObj(CtyDv).innerHTML='';
		objXmlHttp=null;
		
	}
	
	if(Codekey == 9 || Codekey == 13){
		ValuePass(a,b,d)
	}
	
	if (Codekey == 40){
		if (window.event) window.event.returnValue = false
		
			if (document.getElementById('pDest'+ c) != null){
				document.getElementById('pDest'+ c).focus();
			}
		}
		
	if (Codekey == 38){
		if (window.event) window.event.returnValue = true
			//alert(c + ' = c')
		d = c - 2
			//alert(d + ' = d')
		if (c==3){
		document.getElementById('Dest'+ CtyNo).focus();
		}
	else{
			if (document.getElementById('pDest'+ d) != null){
				document.getElementById('pDest'+ d).focus();
			}
		}
		}
}

function ValuePass(a,b,c){
	//alert(a + ' = a || ' + b + ' = b || ' + c + ' = c')
	if (b=='NotFound'){
		showCalendar('CXC')
	}
	
	if (a==0){
		a = ''
	}
		if (c == "txDep"){
			findObj('iDepCity').value=a;
			findObj('iRetCity').value=a;
			findObj(CtyNa).value=b;
			displayDiv(CtyDv,false);
			//displayDiv('divPax',true);
			//displayDiv('DLX',true);
			findObj(CtyDv).innerHTML='';
			objXmlHttp=null
			document.getElementById('divCab').style.visibility='visible';
			document.getElementById('divChi').style.visibility='visible';
		}
		if (c == "txDes" || c == "txDesOnly"){
			if (a == 2782 || a == 2758 || a == 1184 || a == 1207 || a == 2557 || a == 2781 || a == 2720 || a == 1284 || a == 3232 || a == 1096 || a == 2747 || a == 3231 || a == 2754 || a == 3015 || a == 2748 || a == 2751 || a == 981 || a == 2784 || a == 2954 || a == 1147 || a == 1093 || a == 1233 || a == 1285 || a == 2725 || a == 2716 || a == 2800 || a == 1141 || a == 2816 || a == 2749 || a == 965 || a == 2721 || a == 2736 || a == 2740 || a == 2731 || a == 2724 || a == 2735 || a == 2733 || a == 2732 || a == 2508 || a == 2804){
				u = "2|X1-X3-X5-X6" //-X5
			}
			else{
				u = "2|X1-X3-X5-X6" //-X5
			}
			//alert(u)
			findObj('StayCityS').value=a;
			findObj('StayCityS_Name').value=b;
			findObj('APICity1').value=u;
			findObj('StayCity1').value=a;
			findObj('StayCity1_Name').value=b;
			findObj('StayCityE').value=a;
			findObj('StayCityE_Name').value=b;
			//findObj('txDes').value=b;
			findObj(CtyNa).value=b;
			displayDiv(CtyDv,false);
			findObj(CtyDv).innerHTML='';
			objXmlHttp=null
		}
		
		if (c.indexOf('Contry') == 3){
			//alert(c.indexOf('Contry'))
			n = c.substr(9,c.length);
			//alert(n)
			findObj(c).value=b;
			findObj(c +'value').value=a;
			displayDiv('HintCon'+n,false);
			findObj('HintCon'+n).innerHTML='';
			objXmlHttp=null
			name = 'txtCty' + n;
			HintCity(name,n,a,'');
			
		}
		if (c.indexOf('Cty') == 3){
			//alert(c.indexOf('Cty'))
			n = c.substr(6,c.length);
			//alert(n)
			findObj(c).value=b;
			findObj(c +'value').value=a;
			displayDiv('HintCty'+n,false);
			findObj('HintCty'+n).innerHTML='';
			objXmlHttp=null;
			//checkPackages()
		}
	  if (window.focus) window.focus()
		  
}

function handleEnter(evt){
if (navigator.userAgent.indexOf("MSIE")>=0 || navigator.userAgent.indexOf("MSIE 5.5")>=0){	
var Codekey = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
}
else{

var Codekey = evt.which ? evt.which : evt.keyCode;
}

 
 if (Codekey == 40 || Codekey == 13){
	if (window.event) window.event.returnValue = false
	
		if (document.getElementById('Dest'+ CtyNo) != null){			
			document.getElementById('Dest'+ CtyNo).focus();
		}
	
 }
}

function KeyPosition(evt,n){
//alert(n)
if (navigator.userAgent.indexOf("MSIE")>=0 || navigator.userAgent.indexOf("MSIE 5.5")>=0){	
var Codekey = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
}
else{
//var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
var Codekey = evt.which ? evt.which : evt.keyCode;
}

   if (Codekey == 40 || Codekey == 13){
	if (window.event) window.event.returnValue = false;
	
	document.getElementById('Dest' + CtyNo).focus();
}
}


function Item(CONTROL){
	CONTROL = CONTROL
}
function SelectItem(CONTROL){
		for(var i = 0;i < CONTROL.length;i++){
			
			if (CONTROL.length == 1){
				CONTROL.options[i].selected = true;
			}
		if (i==0){
			CONTROL.options[i].selected = true;
			}
			}
			}
			
function checkValue(){
	if (fieldValue != -1){
		window.clearTimeout(TimeId);
		document.getElementById('showPack').style.display='block';
		var CityIds
		if (navigator.userAgent.indexOf("Firefox")>=0){
			a=document.getElementById('StayCity1').value
			b=document.getElementById('StayCity2').value
			c=document.getElementById('StayCity3').value
			d=document.getElementById('StayCity4').value
		}
		if (navigator.userAgent.indexOf("MSIE")>=0 || navigator.userAgent.indexOf("MSIE 5.5")>=0){
			eval("a=document.cityselect.StayCity1.value")
			eval("b=document.cityselect.StayCity2.value")
			eval("c=document.cityselect.StayCity3.value")
			eval("d=document.cityselect.StayCity4.value")
		}
		
		if (a != -1){
			CityIds = a
		}
		if (a != -1 && b != -1){
			CityIds = a +','+ b
		}
		if (a != -1 && b != -1 && c != -1){
			CityIds = a +','+ b +','+ c
		}
		if (a != -1 && b != -1 && c != -1 && d != -1){
			CityIds = a +','+ b +','+ c +','+ d
		}
		//alert(a)
		//alert(b)
		//alert(c)
		//alert(d)
		showPack(CityIds)
		}
       else{
		   fieldValue=document.cityselect.StayCity2.value;
		   TimeId=setTimeout("checkValue()",200)
         }
}

function checkPackages(){
	
		var sCiudad1 = findObj('txtCty1value').value; //0
		var sCiudad2 = findObj('txtCty2value').value; //0
		var sCiudad3 = findObj('txtCty3value').value; //0
		var sCiudad4 = findObj('txtCty4value').value; //0
	
	
		if (sCiudad2 != ''){
			displayDiv('showPack',true);
			var PackByCty
			PackByCty = sCiudad1 +','+ sCiudad2
				if (sCiudad3 != ''){
					PackByCty = PackByCty +','+ sCiudad3
						if (sCiudad4 != ''){
						PackByCty = PackByCty +','+ sCiudad4
						}
				}
				//alert(PackByCty)
			showPack(PackByCty)
		}
}

function showPack(ctyid){
//alert(ctyid)
displayDiv('showPack',true);
//document.getElementById('showPack').style.display='block';
var url="Get_Cities_Pack.asp?sid=" + Math.random() + "&q=" + ctyid 
xmlHttp=GetXmlHttpObject(stateChanged2)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}

function stateChanged2(){ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
	//if (navigator.userAgent.indexOf("MSIE")>=0 || navigator.userAgent.indexOf("MSIE 5.5")>=0){
		//alert(xmlHttp.responseText)
		if (xmlHttp.responseText == ''){
			displayDiv('showPack',false);
		}
		else{
		document.getElementById('showPack').innerHTML=xmlHttp.responseText;
		//document.getElementById('txtHint'+ CtyNo).style.display='block';
		}
	
}
}


function ValTransp(t){
	eval("document.cityselect.transp.value=t")
}

function MoreCities(){
	
	    var zCiudad1 = findObj('txtCty1value').value; //0
		var zCiudadID1 = findObj('txtCty1').value; //1
		var zCiudad2 = findObj('txtCty2value').value; //0
		var zCiudadID2 = findObj('txtCty2').value; //1
		var zCiudad3 = findObj('txtCty3value').value; //0
		var zCiudadID3 = findObj('txtCty3').value; //1
		var zCiudad4 = findObj('txtCty4value').value; //0
		var zCiudadID4 = findObj('txtCty4').value; //1
		createCookie('howV2',zCiudad1 +"@"+ zCiudadID1 +"@"+ zCiudad2 +"@"+ zCiudadID2 +"@"+ zCiudad3 +"@"+ zCiudadID3 +"@"+ zCiudad4 +"@"+ zCiudadID4,7);
		if (zCiudad1 > 0){
			createCookie('howV3',zCiudad1,7);
		}
		if (zCiudad2 > 0){
			createCookie('howV3',zCiudad1 +"@"+ zCiudad2,7);
		}
		if (zCiudad3 > 0){
			createCookie('howV3',zCiudad1 +"@"+ zCiudad2  +"@"+ zCiudad3,7);
		}
		if (zCiudad4 > 0){
		createCookie('howV3',zCiudad1 +"@"+ zCiudad2  +"@"+ zCiudad3 +"@"+ zCiudad4,7);
		}
		createCookie('howV4',1)
	var oForm=document.frmBuildVac;
    oForm.action="/Create_Booking.asp";//MC_ComponentList.ASP";
	//oForm.action="http://10.15.2.102/TVLAPI/Multicity3/MC_ComponentList.ASP";
	oForm.submit();
	}
	
function buildVac(type){ // T = train; S = Self-Drive; A = Advance
  // alert(type)
   
	if (type == 'T'){
		t = 'Train'
	}
	if (type == 'S'){
		t = 'Self-Drive'
	}
	if (type == 'A'){
		t = 'Advanced'
	}
	else{
		t = ''
	}
	//alert(t)
		var zTypeTrans = t; //0
		var oForm=document.frmBuildVac;
	if (type != 'C'){
		//alert(type)
		//var zhowMaCo = findObj('howMaCo').value;
		//alert (zhowMaCo)
		var zPais1 = findObj('txtContry1').value; //0
		var zPaisID1 = findObj('txtContry1value').value; //1
		var zPais2 = findObj('txtContry2').value; //0
		var zPaisID2 = findObj('txtContry2value').value; //1
		var zPais3 = findObj('txtContry3').value; //0
		var zPaisID3 = findObj('txtContry3value').value; //1
		var zPais4 = findObj('txtContry4').value; //0
		var zPaisID4 = findObj('txtContry4value').value; //1
		createCookie('howV1',"",-1);
		createCookie('howV3',"",-1);
		createCookie('howV4',"",-1);
		createCookie('fresh','1',1);
		
		//createCookie('howV1','MC' +"@"+ zPais1 +"@"+ zPaisID1 +"@"+ zPais2 +"@"+ zPaisID2 +"@"+ zPais3 +"@"+ zPaisID3 +"@"+ zPais4 +"@"+ zPaisID4 +"@"+ zTypeTrans,7);
		
	}
		var zCiudad1 = findObj('txtCty1value').value; //0
		var zCiudadID1 = findObj('txtCty1').value; //1
		var zCiudad2 = findObj('txtCty2value').value; //0
		var zCiudadID2 = findObj('txtCty2').value; //1
		var zCiudad3 = findObj('txtCty3value').value; //0
		var zCiudadID3 = findObj('txtCty3').value; //1
		var zCiudad4 = findObj('txtCty4value').value; //0
		var zCiudadID4 = findObj('txtCty4').value; //1
		createCookie('howV2',zCiudad1 +"@"+ zCiudadID1 +"@"+ zCiudad2 +"@"+ zCiudadID2 +"@"+ zCiudad3 +"@"+ zCiudadID3 +"@"+ zCiudad4 +"@"+ zCiudadID4,7);
		createCookie('fresh','1',1);
		
	    var sCiudad1 = findObj('txtCty1value').value; //0
		var sCiudad2 = findObj('txtCty2value').value; //0
		var sCiudad3 = findObj('txtCty3value').value; //0
		var sCiudad4 = findObj('txtCty4value').value; //0
		var BuildByCty
	
		if (zCiudadID1 != 'City'){
			BuildByCty = zCiudadID1;
			if (zCiudadID2 != 'City'){
				BuildByCty = BuildByCty +'_'+ zCiudadID2;
				if (zCiudadID3 != 'City'){
					BuildByCty = BuildByCty +'_'+ zCiudadID3;
					if (zCiudadID4 != 'City'){
					BuildByCty = BuildByCty +'_'+ zCiudadID4;
					}
				}
			}
		}
	
	oForm.action="/Build_Package_to_"+ BuildByCty +".aspx";//MC_ComponentList.ASP";
	//oForm.action="http://10.15.2.102/TVLAPI/Multicity3/MC_ComponentList.ASP";
	oForm.submit();
}

function build(){
document.cityselect.submit()
}


function MoreCityV1(){
	//alert('hi')
document.frmBuildVac.action = "/MoreCities.asp"
document.frmBuildVac.submit()
}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function Rcertify() 
{
popupWin = window.open('http://www.bbbonline.org/cks.asp?id=10303171211', 'Participant','location=yes,scrollbars=yes,width=450,height=300'); 
window.name = 'opener';
} 

function popUp(url) {
sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=500,height=450');
self.name = "mainWin";
}


function showcty(a,b){
	for(i=1;i<=a;i++)
	if (i==b){
    eval("document.all['shw"+ i +"'].style.display='block'")  
	}
  }
function showpic(picimage,a) {
	//alert(picimage.indexOf("plus"))
	if (picimage.indexOf("plus")> 0){
		z = "/images/minus.gif"
		eval("document.all['pic"+ a +"'].src=z");
	}
	else{
		z = "/images/plus.gif"
		eval("document.all['pic"+ a +"'].src=z");
		eval("document.all['shw"+ a +"'].style.display='none'")
	}
}
	function setImage(imgName,imgDesc){
		if (document.all){
	      document.images.SlideShow.style.filter="blendTrans(duration=.4)"
	      //document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"
	      document.images.SlideShow.filters.blendTrans.Apply()
	       
	   }
	   document.images.SlideShow.src = imgName
	   document.all.PicName.value = imgDesc
	   if (document.all){
	    document.images.SlideShow.filters.blendTrans.Play()
	   // document.input.PicName.filters.blendTrans.Play()
	   }
	}
	
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function createCookie(name,value,days) {

	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	
	document.cookie = name+"="+value+expires+"; path=/";
	
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function ChangeClean(){
	Clean = 100
	window.clearTimeout(TimeId);
}

function buildMo(){

var tripType

if (findObj('txtCty4') != null){
	if (findObj('txtCty4').value == 'City'){
		findObj('pgfirst').value = 1;
	}
}

if (findObj('inText4') != null){
	if (findObj('inText4').value == 'Enter City 4'){
		findObj('pgfirst').value = 1;
	}
}

tripType = (findObj('transp').value)
//alert(tripType)
document.cityselect.action = '/Build_Package_to_Many_Cities_by_'+ tripType +'.aspx'
document.cityselect.submit()
}

function CleanDivPage(){
	//alert('colocar codigo')
	//alert(Clean)
	TimeID = setTimeout("ChangeClean()",200)
	if (Clean == 100){	
	for(var i=1;i<5;i++){
			displayDiv('HintCty' + i,false);
			if (findObj('HintCon' + i) != null){
			displayDiv('HintCon' + i,false);
	}
	}
	displayDiv('txtDest',false);
	displayDiv('txtDepa',false);
	displayDiv('txtDestO',false);
	objXmlHttp=null
	document.getElementById('divCab').style.visibility='visible';
	document.getElementById('divChi').style.visibility='visible';
}
}
function showMoPack(a){
	if (a==1){
document.getElementById('more').style.display='none';
document.getElementById('plus10').style.display='block';
document.getElementById('sort').style.display='block';
document.getElementById('packPromo').style.display='none';
	}
	if (a==0){
document.getElementById('more').style.display='block';
document.getElementById('plus10').style.display='none';
document.getElementById('sort').style.display='none';
	}
}
function showPackCONwait(typePacks){
//alert(typePacks)
j = typePacks
switch(typePacks){
		case "TP":
			 document.getElementById('CTrain').style.display='block';
			if (document.getElementById('OCOnlyV1') != null){
				document.getElementById('OCOnlyV1').style.display='none';
				}
			if (document.getElementById('MCOnlyV1') != null){
				document.getElementById('MCOnlyV1').style.display='none';
				}			
			if (document.getElementById('OCOnly') != null){
				document.getElementById('OCOnly').style.display='none';
				}
			if (document.getElementById('CDrive') != null){
				document.getElementById('CDrive').style.display='none';
				}
			if (document.getElementById('CTD') != null){
				document.getElementById('CTD').style.display='none';
				}
			if (document.getElementById('packPromo') != null){
				document.getElementById('packPromo').style.display='none';
				}
			if (document.getElementById('MCOnly') != null){
				document.getElementById('MCOnly').style.display='none';
				}
			break;
				
		 case "CP":
			document.getElementById('CDrive').style.display='block';
			if (document.getElementById('OCOnlyV1') != null){
				document.getElementById('OCOnlyV1').style.display='none';
				}
			if (document.getElementById('MCOnlyV1') != null){
				document.getElementById('MCOnlyV1').style.display='none';
				}
			 if (document.getElementById('OCOnly') != null){
				document.getElementById('OCOnly').style.display='none';
				}
			if (document.getElementById('CTrain') != null){
				document.getElementById('CTrain').style.display='none';
				}
			if (document.getElementById('CTD') != null){
				document.getElementById('CTD').style.display='none';
				}
			if (document.getElementById('packPromo') != null){
				document.getElementById('packPromo').style.display='none';
				}
			if (document.getElementById('MCOnly') != null){
				document.getElementById('MCOnly').style.display='none';
				} 
			break;
			
			case "TCP":
			document.getElementById('CTD').style.display='block';
			if (document.getElementById('OCOnlyV1') != null){
				document.getElementById('OCOnlyV1').style.display='none';
				}
			if (document.getElementById('MCOnlyV1') != null){
				document.getElementById('MCOnlyV1').style.display='none';
				}
			if (document.getElementById('OCOnly') != null){
				document.getElementById('OCOnly').style.display='none';
				}
			if (document.getElementById('CDrive') != null){
				document.getElementById('CDrive').style.display='none';
				}
			if (document.getElementById('CTrain') != null){
				document.getElementById('CTrain').style.display='none';
				}
			if (document.getElementById('packPromo') != null){
				document.getElementById('packPromo').style.display='none';
				}
			if (document.getElementById('MCOnly') != null){
				document.getElementById('MCOnly').style.display='none';
				}	
			break;
			
			case "CPO":
			if (document.getElementById('OCOnlyV1') != null){
				document.getElementById('OCOnlyV1').style.display='block';
				}
			if (document.getElementById('MCOnlyV1') != null){
				document.getElementById('MCOnlyV1').style.display='none';
				}
			if (document.getElementById('OCOnly') != null){
				document.getElementById('OCOnly').style.display='none';
				}
			if (document.getElementById('CTD') != null){
				document.getElementById('CTD').style.display='none';
				}
			if (document.getElementById('CDrive') != null){
				document.getElementById('CDrive').style.display='none';
				}
			if (document.getElementById('CTrain') != null){
				document.getElementById('CTrain').style.display='none';
				}
			if (document.getElementById('packPromo') != null){
				document.getElementById('packPromo').style.display='none';
				}
			if (document.getElementById('MCOnly') != null){
				document.getElementById('MCOnly').style.display='none';
				}	
			break;
			
			case "MCO":
			if (document.getElementById('OCOnlyV1') != null){
				document.getElementById('OCOnlyV1').style.display='none';
				}
			if (document.getElementById('MCOnlyV1') != null){
				document.getElementById('MCOnlyV1').style.display='block';
				}
			if (document.getElementById('OCOnly') != null){
				document.getElementById('OCOnly').style.display='none';
				}
			if (document.getElementById('MCOnly') != null){
				document.getElementById('MCOnly').style.display='none';
				}
			if (document.getElementById('CDrive') != null){
				document.getElementById('CDrive').style.display='none';
				}
			if (document.getElementById('CTrain') != null){
				document.getElementById('CTrain').style.display='none';
				}
			if (document.getElementById('packPromo') != null){
				document.getElementById('packPromo').style.display='none';
				}
			if (document.getElementById('CTD') != null){
				document.getElementById('CTD').style.display='none';
				}	
			break;
 }
}
function showPromo(){
document.getElementById('packPromo').style.display='block';
}
function navtab(a){
	window.location = a
}
function showNights(a,b){
	if (a==0){
		window.location = b +"_Packages.aspx";
	}
	if (a>0){
	window.location = b +"_"+ a +"_Nights_Packages.aspx"
	}
}

function CheckAge(s,n){
if (s.length > 1){
	if (s > 11){
		alert("Please child age are under 11");
		findObj(n).value = ''
	return false;
	} 
}
return true;
}