var showobj_search;
var show_fieldname;
var city;
function makeRequest_search(url,obj,fieldname,cname){
	

	city=cname;
	showobj_search = obj;
	show_fieldname = fieldname;

	var http_request_search = false;
		    if (window.XMLHttpRequest) { // Mozilla, Safari, ...

				http_request_search = new XMLHttpRequest();

            if (http_request_search.overrideMimeType) {
                http_request_search.overrideMimeType('text/xml');

                // See note below about this line
            }

        } else if (window.ActiveXObject) { // IE

            try {
                http_request_search = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {

                try {
                    http_request_search = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request_search) {

            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }

        http_request_search.onreadystatechange = function() { alertContents_search(http_request_search); };
        http_request_search.open('GET', url, true);
        http_request_search.send(null);
		

    }
	

function makeRequest_search_blur(url,obj,fieldname,cname){
	

	city=cname;
	showobj_search = obj;
	show_fieldname = fieldname;

	var http_request_search = false;
		    if (window.XMLHttpRequest) { // Mozilla, Safari, ...

				http_request_search = new XMLHttpRequest();

            if (http_request_search.overrideMimeType) {
                http_request_search.overrideMimeType('text/xml');

                // See note below about this line
            }

        } else if (window.ActiveXObject) { // IE

            try {
                http_request_search = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {

                try {
                    http_request_search = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request_search) {

            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }

        http_request_search.onreadystatechange = function() { alertContents_search_blur(http_request_search); };
        http_request_search.open('GET', url, true);
        http_request_search.send(null);
		

    } //end makeRequest_search_blur


function makeRequestWidgetSearch(url,obj,fieldname,cname){
	

	city=cname;
	showobj_search = obj;
	show_fieldname = fieldname;

	var http_request_search = false;
		    if (window.XMLHttpRequest) { // Mozilla, Safari, ...

				http_request_search = new XMLHttpRequest();

            if (http_request_search.overrideMimeType) {
                http_request_search.overrideMimeType('text/xml');

                // See note below about this line
            }

        } else if (window.ActiveXObject) { // IE

            try {
                http_request_search = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {

                try {
                    http_request_search = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request_search) {

            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }

        http_request_search.onreadystatechange = function() { alertContentsWidgetSearch(http_request_search); };
        http_request_search.open('GET', url, true);
        http_request_search.send(null);
		

    }


function alertContents_search(http_request_search) {

 

        if (http_request_search.readyState == 4) {
			strCheckBlur=0;
            if (http_request_search.status == 200) {

				var str=http_request_search.responseText;
				ss=str.split("|");
			
				if(ss[0]=='Yes'){
					
					if(ss[1] > 1){
						
						var randomnumber = Math.floor(Math.random()*1000000);
						id = "profile" + randomnumber;
						alert(ss[2]);
						
						document.getElementById(show_fieldname).value="";
						document.getElementById(show_fieldname).focus();
						strCheckBlur=1;
						

					}else{
					
						document.getElementById(show_fieldname+'proceedform').value='1';
						strCheckBlur=1;
					}
					
			
				}else if(ss[0]=='No'){
					document.getElementById(show_fieldname+'proceedform').value='0';
					document.getElementById(show_fieldname).value="";

					alert('The city name you entered doesnt appear to have an airport. \r\n Please DO -NOT- include State or Country \r\n ONLY INCLUDE CITY NAME or 3 LETTER AIRPORT CODE \r\n (as an example, you could enter "Los Angeles" or "LAX") \r\n ------WE PREFER 3 LETTER AIRPORT CODES------ \r\n You can Lookup the Airport code using our link called "airport code".');
					strCheckBlur=1;
				}
				
            } else {

                //alert('There was a problem with the request.');

            }
        }

    }	

	
function alertContents_search_blur(http_request_search) {

	if (http_request_search.readyState == 4) {
			strCheckBlur=0;
			
            if (http_request_search.status == 200) {

				var str = http_request_search.responseText;
				
				ss=str.split("|");
				
				if(ss[0]=='Yes'){
					
					if(ss[1] > 1){
						
						var randomnumber = Math.floor(Math.random()*1000000);
						id = "profile" + randomnumber;
						alert(ss[2]);
						
						document.getElementById(show_fieldname).value="";
						document.getElementById(show_fieldname).focus();
						strCheckBlur=1;
						

					}else{
						
						str_len =  document.getElementById(show_fieldname).value.length;
						
						if(str_len > 3){
							
							alert('The city name you entered doesnt appear to have an airport. \r\n Please DO -NOT- include State or Country \r\n ONLY INCLUDE CITY NAME or 3 LETTER AIRPORT CODE \r\n (as an example, you could enter "Los Angeles" or "LAX") \r\n ------WE PREFER 3 LETTER AIRPORT CODES------ \r\n You can Lookup the Airport code using our link called "airport code".');
							document.getElementById(show_fieldname).value = '';
							document.getElementById(show_fieldname).focus();
							
							strCheckBlur=1;
							
						}
						
						document.getElementById(show_fieldname+'proceedform').value='1';
						strCheckBlur=1;
						
					}
					
			
				}else if(ss[0]=='No'){
					
					
					document.getElementById(show_fieldname+'proceedform').value='0';
					document.getElementById(show_fieldname).value="";
					document.getElementById(show_fieldname).focus();

					alert('The city name you entered doesnt appear to have an airport. \r\n Please DO -NOT- include State or Country \r\n ONLY INCLUDE CITY NAME or 3 LETTER AIRPORT CODE \r\n (as an example, you could enter "Los Angeles" or "LAX") \r\n ------WE PREFER 3 LETTER AIRPORT CODES------ \r\n You can Lookup the Airport code using our link called "airport code".');
					strCheckBlur=1;
				}
				
            } else {

                //alert('There was a problem with the request.');

            }
			
        }//end if (http_request_search.readyState == 4)

    }	// end alertContents_search_blur
	
	
function alertContentsWidgetSearch(http_request_search) {

        if (http_request_search.readyState == 4) {

			strCheckBlur=0;

            if (http_request_search.status == 200) {

				var str=http_request_search.responseText;
				
				ss=str.split("|");
				
				if(ss[0]=='Yes'){
					
					if(ss[1] > 1){
						
						var randomnumber = Math.floor(Math.random()*1000000);
						id = "profile" + randomnumber;
						alert(ss[2]);
						
						document.getElementById(show_fieldname).value="";
						document.getElementById(show_fieldname).focus();
						strCheckBlur=1;
						

					}else{
					
						document.getElementById(show_fieldname+'proceedform').value='1';
						strCheckBlur=1;
					}
					
			
				}else if(ss[0]=='No'){
					document.getElementById(show_fieldname+'proceedform').value='0';
					document.getElementById(show_fieldname).value="";

					alert('WE ONLY ALLOW DEPARTURES FROM THE --USA AND CANADA--!');
					document.getElementById(show_fieldname).focus();
					strCheckBlur=1;
				}
				
            } else {

                //alert('There was a problem with the request.');

            }
        }

    }
	
	

var showobj;
function makeRequest(url,obj) {
		showobj=obj;
        var http_request = false;

        if (window.XMLHttpRequest) { // Mozilla, Safari, ...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                // See note below about this line
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
        http_request.onreadystatechange = function() { alertContents(http_request); };
        http_request.open('GET', url, true);
        http_request.send(null);
    }

function alertContents(http_request) {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
			    window.status = '';
                document.getElementById(showobj).innerHTML =  http_request.responseText;
            } else {
                //alert('There was a problem with the request.');
            }
        }
    }
function getSelected_widgetword(tmp,fieldname){
	
	if(document.getElementById('widgetsection').value == '1'){
		
		makeRequestWidgetSearch('../response_widgetcity.php?cid='+tmp,'show_word',fieldname,tmp);
		
	}
}

function city_status(city)
{
	if (city!='') 
		makeRequest('city_status.php?cid='+city,'cityid');
}

function getSelected()
{
	///ob=document.getElementById("package-departure-city");
	//nlength=ob.length;
	tmp=document.getElementById("package-departure-city").value;

if (tmp!='') 
	makeRequest('response.php?cid='+tmp,'showadd_travel');
}

function getSelected_hotle()
{
	ob=document.getElementById("arrival_city");
	nlength=ob.length;
	
tmp=document.getElementById("arrival_city").value;

	makeRequest('response_hotle.php?cid='+tmp,'showadd_hotel');
}
function getSelected_index2()
{ 
	tmp=document.getElementById("ewiz_arrival_city").value;
	
//alert(tmp);
if (tmp!='') 
	makeRequest('response_index2.php?cid='+tmp,'showadd_index');
}	
function getSelected_index3()
{ 
	
	var temp1;
	var temp2;
	temp1=document.getElementById("ewiz_departure_city").value;
	temp2=document.getElementById("ewiz_arrival_city").value;
	
//alert(temp2);
if (temp1!='') 
	makeRequest('response_index3.php?cid='+temp1+'&pid='+temp2,'showadd_index');
	
}	
function getSelected_vacation3()
{ //alert('ss');
	var temp3;
	var temp4;
	temp3=document.getElementById("package-departure-city").value;
	temp4=document.getElementById("package-destination-city").value;
	
//alert(temp4);

	makeRequest('response_travel2.php?cid='+temp3+'&pid='+temp4,'showadd_travel');
	
}


function getSelected_cars()
{
	ob=document.getElementById("pickup_city_cars");
	nlength=ob.length;
	
	tmp=document.getElementById("pickup_city_cars").value;
	makeRequest('response_cars.php?cid='+tmp,'show_cars');
}


function getSelected_word(tmp,fieldname){
	
		makeRequest_search('response_check.php?cid='+tmp,'show_word',fieldname,tmp);
}

function getSelected_word_blur(tmp,fieldname){
	
		makeRequest_search_blur('response_checkblur.php?cid='+tmp,'show_word',fieldname,tmp);
}

function getSelected_index()
{
	ob=document.getElementById("ewiz_departure_city");
	nlength=ob.length;

	tmp=document.getElementById("ewiz_departure_city").value;
if (tmp!='') 
	makeRequest('response_index.php?cid='+tmp,'showadd_index');
}


/*ction getSelectedA()
{
	
	ob=document.getElementById("cities[]");
	nlength=ob.length;
	
	tmp='';
	for ( i=0; i<nlength; i++ ) {
		
		if (ob.options[i].selected == true) {
			if (tmp == '' )
			{
				tmp= ob.options[i].value;
			}else{
				tmp=tmp + ',' + ob.options[i].value;
			}
		}
	}

	if (tmp!='') makeRequest('restricted_cities/response2.php?ap='+tmp,'airport');
}*/


function getNewAdvList(){

	var to = document.getElementById("ewiz_arrival_city").value;
	var from = document.getElementById("ewiz_departure_city").value;
	
	makeRequest('../response_chkcity.php?from='+from+'&to='+to,'chkcity');

}

