var ajaxmessage = "AJAX Call can not be made......Browser does not support HTTP Request";
var xmlHttp;
var resCombo;
var cityList;
var prefferedCityList;
var combo;
var combolesscity;
var actiontype ;
function ChatPopUp(email){
	window.open("http://203.76.139.6/Chat/Ezeego1A.asp?Email="+email,"","scrollbars=yes,width=480,height=400,resizable=no");
}
function ajaxUrl(str){
	var xmlHttp;
	xmlHttp=GetXmlHttpObject();
	xmlHttp.onreadystatechange=function(){
		if(xmlHttp.readyState==4){
		  document.productForm.session_id.value="";
		  document.productForm.cust_name.value="";
		  document.productForm.sc_bool.value="";
		  sessionSharing("http://www.ezeego1.co.in/flights/index.php");
		}
	}
	xmlHttp.open("POST",str,true);
	xmlHttp.send(null);
}

function selectLanguage(str,lnk){
	document.productForm.language.value=str;
	sessionSharing(lnk);
}

function sessionSharing(aAction){
	document.productForm.action=aAction;
	document.productForm.submit();
}

function hideMsg(){
	document.getElementById("errTr").style.visibility = "hidden";
	document.getElementById("errTr").style.display = "none";
}

function showNRImessage(isB2BAgent){  
    if(isB2BAgent=="false"){
   		if(document.getElementById('select_nationality').value == "N"){
			alert("The site will be opened to Foreign Nationals shortly. The inconvenience caused is regretted.");
			document.getElementById('select_nationality').value = "Y";
		}
     }
}

function initRequest(url){
    if (window.XMLHttpRequest) {
        return new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        isIE = true;
        return new ActiveXObject("Microsoft.XMLHTTP");
    }
}


// Function to get xmlHttpObject...
function GetXmlHttpObject(handler){ 
	var objXMLHttp=null;
	if (window.XMLHttpRequest){
		objXMLHttp=new XMLHttpRequest();
	}else if (window.ActiveXObject){
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	return objXMLHttp;
}
function getCityList(countryid,cityid,type){
		document.getElementById("loadingimage1").style.visibility = "visible";
 		document.getElementById("loadingimage1").style.display = "";
 		xmlHttp = GetXmlHttpObject();	
		var countryname = document.getElementById(countryid).value;
		combo = document.getElementById('morecity');
		combocountry = document.getElementById('country');
		
		if(xmlHttp == null){
			alert(ajaxmessage);
		}else{
			var url = "lib/searchdb.php?country="+countryname;
			xmlHttp.onreadystatechange=stateChanged;
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
			resCombo = combo;
			//clearComboBoxes('more');
		}
}

function stateChanged(){ 
	try{
		if (xmlHttp.readyState==4 ){ 
			var itemArray = getResultArrayForXML(xmlHttp.responseText);
			createListOfItems(combo,itemArray[0],'-Select City -');
			document.getElementById("currency").value=itemArray[1];
		}
	}
	catch(error){
		alert("Error: " + "No City Names Exits");
		clearComboBoxes('morecity');
	}
}


//Function to get ResultantArray for parsed XML....
function getResultArrayForXML(xmlDoc){
	var dom = xmlDoc.split("~");
	var returnArray = new Array();     
    var arrayResult= new Array(); 
	var arrayCurrency= new Array(); 
	
	var itm1=dom[0].split(",");
	//var itm1=xmlDoc.split(",");
	var citynamesList = new Array(itm1.length);
	for (var i=0; i<itm1.length; i++){
		rtrnx= itm1[i].split("#");
		arrayResult.push(rtrnx[1]);
		arrayResult.push(rtrnx[0]);
		citynamesList[i] = rtrnx[0];
	}
	arrayCurrency.push(dom[1]);
	returnArray.push(arrayResult);
	returnArray.push(arrayCurrency);
	return returnArray;
}


function createListOfItems(NewCombo,arrayresult,type){
	clearComboBoxes(NewCombo)
	var cntcombo = 1;
	AddItem(NewCombo,type,"")
	if(arrayresult && arrayresult.length > 0){
		for(var cnt = 0;cnt<arrayresult.length;cnt++){
			AddItem(NewCombo,arrayresult[cnt],arrayresult[++cnt])
		}
	}
	document.getElementById("loadingimage1").style.visibility = "hidden";
	document.getElementById("loadingimage1").style.display = "none";
}
function AddItem(obj,Text,Value){
	var opt = document.createElement("option");
	obj.options.add(opt);        
	opt.text = Text;
	opt.value = Value;
}

function clearComboBoxes(cityid){
	cityid.length = 0;
}
function submitSearch(){
	var errorString = "";
	var bFlag = true;
	var noofpax =0; //no of pax less than 10
	if(document.getElementById("fromDate").value == "" || document.getElementById("fromDate").value == " "){
		bFlag = false;
		errorString=errorString+"Please fill in suitable date in 'date' field<br>";
	}
	if(document.getElementById("domint").value == "I" && document.getElementById("country").value == "0"){
		bFlag = false;
		errorString=errorString+"Please fill in suitable country in 'country' field<br>";
	}
	if(document.getElementById("morecity").value == "0" && document.getElementById("domcity").value == "0"){
		bFlag = false;
		errorString=errorString+"Please fill in suitable city in 'city' field";
	}
	
	noofpax =parseInt(document.getElementById('adults').value)+parseInt(document.getElementById('child').value);
	if(noofpax >=10){
		bFlag = false;
		errorString=errorString+"The maximum number of passengers allowed is 9" + "\n"; 
	}
	if(bFlag == false){
		document.getElementById("errMsg").innerHTML = errorString;
		document.getElementById("errTr").style.visibility = "visible";
		document.getElementById("errTr").style.display = "";
		window.scrollBy(0,90);
	}else{
		if(document.sightseeingsearch.isinternationalagent.value == "true"){
			if(document.sightseeingsearch.country.value == "India"){
				document.getElementById("domint").value = "domestic";
			}else{
				document.getElementById("domint").value = "international";
			}
		}
		//document.sightseeingsearch.action="sightseeingsearchdetailnew.do?productType=SIGHT";
		//document.sightseeingsearch.bizMode.value="SEARCH_RESULT";
		document.sightseeingsearch.submit();
	}	
}

function showage(val){
	if(val == 1 || val == 2){
		document.getElementById("childagetr").style.visibility = "visible";
		document.getElementById("childagetr").style.display = "";
	}else{
		document.getElementById("childagetr").style.visibility = "hidden";
		document.getElementById("childagetr").style.display = "none";
	}
	if(val == 1){
		document.getElementById("childAge1").style.visibility = "visible";
		document.getElementById("childAge1").style.display = "";
		document.getElementById("childAge2").style.visibility = "hidden";
		document.getElementById("childAge2").style.display = "none";
	}
	if(val == 2){
		document.getElementById("childAge1").style.visibility = "visible";
		document.getElementById("childAge1").style.display = "";
		document.getElementById("childAge2").style.visibility = "visible";
		document.getElementById("childAge2").style.display = "";
	}
}

function funChk(){
	if(document.sightseeingsearch.country.value != null){
		if((document.sightseeingsearch.country.value) == "India"){
			var morelink = document.getElementById("more");
			var lesscity = document.getElementById("lesscity");
			morelink.style.visibility = "visible";
			morelink.style.display = "";
			var morecity = document.getElementById("morecity");
			morecity.style.visibility = "hidden";
			morecity.style.display = "none";
			lesscity.style.visibility = "visible";
			lesscity.style.display = "";
		}else{
			var morelink = document.getElementById("more");
			var lesscity = document.getElementById("lesscity");
			morelink.style.visibility = "hidden";
			morelink.style.display = "none";
			var morecity = document.getElementById("morecity");
			morecity.style.visibility = "visible";
			morecity.style.display = "";
			lesscity.style.visibility = "hidden";
			lesscity.style.display = "none";
		}
	}
}
 
function show(getType){

	if(getType == "I"){
 		document.getElementById("morecity").style.visibility = "visible";
 		document.getElementById("morecity").style.display = "block";
 		document.getElementById("counInt").style.visibility = "visible";
 		document.getElementById("counInt").style.display = "block";
 		document.getElementById("domint").value = "I";
		document.getElementById("currency").value="";
	}else{
 		document.getElementById("morecity").style.visibility = "hidden";
 		document.getElementById("morecity").style.display = "none";
 		document.getElementById("counInt").style.visibility = "hidden";
 		document.getElementById("counInt").style.display = "none";
 	}
	
 	if(getType == "D"){
 		document.getElementById("domint").value = "domestic";
 		document.getElementById("domcity").style.visibility = "visible";
 		document.getElementById("domcity").style.display = "block";
 		document.getElementById("counDom").style.visibility = "visible";
 		document.getElementById("counDom").style.display = "block";
		document.getElementById("currency").value="INR";
 	}else{
 		document.getElementById("domcity").style.visibility = "hidden";
 		document.getElementById("domcity").style.display = "none";
 		document.getElementById("counDom").style.visibility = "hidden";
 		document.getElementById("counDom").style.display = "none";
 	}
	
}
 
 
function doDisplayInternational(){
	document.getElementById("destinationtypetr").style.visibility = "hidden";
	document.getElementById("destinationtypetr").style.display = "none";
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
}

function affiliatepopup(){
	var myWindow = window.open("http://www.ezeego1.co.in/live/affilateagentregistrationform.screen","tinyWindow");
}
