var http = false;

if(navigator.appName == "Microsoft Internet Explorer") { 
  http = new ActiveXObject("Microsoft.XMLHTTP");
} else {
  http = new XMLHttpRequest();
} 

function addNewLocation(){
	document.getElementById('location_counter').value++;
	var val = document.getElementById('location_counter').value;
//alert(document.getElementById('location_counter').value);
	http.open("GET", "getNewLocation.php?ctr="+val, true);
	  http.onreadystatechange=function() {
   if(http.readyState == 4) {
      document.getElementById('locations').innerHTML = http.responseText;
    }else{
	 document.getElementById('locations').innerHTML = waitinglit();
	}
  }
  http.send(null);
}

function popstate(val,fieldname){
// 	alert(fieldname);
// 		alert(val);
   http.open("GET","get_states_projects.php?country_id="+val+"&fieldname="+fieldname, true);
   http.onreadystatechange=function() {
   if(http.readyState == 4) {
   document.getElementById('statespan').innerHTML = http.responseText;
    }else{
	 document.getElementById('statespan').innerHTML = waitinglit();
	}
  }
  http.send(null);

	}
function popstatemember(val,fieldname){
//	alert($fieldname);
		//alert(val);
		 http.open("GET", "get_states_ajex.php?country_id="+val+"&fieldname="+fieldname, true);
	  http.onreadystatechange=function() {
   if(http.readyState == 4) {
   document.getElementById('statespan').innerHTML = http.responseText;
    }else{
	 document.getElementById('statespan').innerHTML = waitinglit();
	}
  }
  http.send(null);

	}


function popstatelocation(val,fieldname,div_id){
// 	alert(fieldname);
       // alert(val);

        xmlhttppopstatelocation=GetXmlHttpObjectMS();
        if(val=='us'){
                         xmlhttppopstatelocation.open("GET","get_states_locations.php?country_id="+val+"&fieldname="+fieldname+"&div_id="+div_id, true);
                          xmlhttppopstatelocation.onreadystatechange=function() {
                   if(xmlhttppopstatelocation.readyState == 4) {
                // 	alert('statespan_'+div_id);
                   document.getElementById('statespan_'+div_id).innerHTML = xmlhttppopstatelocation.responseText;
                    }else{
                         document.getElementById('statespan_'+div_id).innerHTML = waitinglit();
                        }
                  }
                  xmlhttppopstatelocation.send(null);
           }
           else{
               //alert(div_id);
                 xmlhttppopstatelocation.open("GET","get_states_location_other_countries.php?country_id="+val+"&fieldname="+fieldname+"&div_id="+div_id, true);
                          xmlhttppopstatelocation.onreadystatechange=function() {
                   if(xmlhttppopstatelocation.readyState == 4) {
                // 	alert('statespan_'+div_id);

                     var state_county_city_dd = xmlhttppopstatelocation.responseText;
                     var state_county_city=state_county_city_dd.split("==||==");
                       document.getElementById('statespan_'+div_id).innerHTML = state_county_city[0];
                        document.getElementById('countyspan_'+div_id).innerHTML = state_county_city[1];
                       document.getElementById('cityspan_'+div_id).innerHTML = state_county_city[2];

                  // document.getElementById('statespan_'+div_id).innerHTML = http.responseText;
                   

                   
                    }else{
                         document.getElementById('statespan_'+div_id).innerHTML = waitinglit();
                           document.getElementById('countyspan_'+div_id).innerHTML = waitinglit();
                             document.getElementById('cityspan_'+div_id).innerHTML = waitinglit();
                        }
                  }
                  xmlhttppopstatelocation.send(null);
           }
	}

function popstatenewlocation(val,fieldname,div_id){
// 	alert(fieldname);
 xmlhttppopstatenewlocation=GetXmlHttpObjectMS();
if(val=='us'){
	 xmlhttppopstatenewlocation.open("GET","get_new_states_locations.php?country_id="+val+"&fieldname="+fieldname+"&div_id="+div_id, true);
	  xmlhttppopstatenewlocation.onreadystatechange=function() {
   if(xmlhttppopstatenewlocation.readyState == 4) {
// 	alert('statespan_'+div_id);
   document.getElementById('statespan_new_'+div_id).innerHTML = xmlhttppopstatenewlocation.responseText;
    }else{
	 document.getElementById('statespan_new_'+div_id).innerHTML = waitinglit();
	}
  }

  xmlhttppopstatenewlocation.send(null);
}
else{
               //alert(div_id);
                 xmlhttppopstatenewlocation.open("GET","get_states_location_other_countries.php?country_id="+val+"&fieldname="+fieldname+"&div_id="+div_id, true);
                          xmlhttppopstatenewlocation.onreadystatechange=function() {
                   if(xmlhttppopstatenewlocation.readyState == 4) {
                // 	alert('statespan_'+div_id);

                     var state_county_city_dd = xmlhttppopstatenewlocation.responseText;
                     var state_county_city=state_county_city_dd.split("==||==");
                       document.getElementById('statespan_new_'+div_id).innerHTML = state_county_city[0];
                        document.getElementById('countyspan_new_'+div_id).innerHTML = state_county_city[1];
                       document.getElementById('cityspan_new_'+div_id).innerHTML = state_county_city[2];

                  // document.getElementById('statespan_'+div_id).innerHTML = http.responseText;



                    }else{
                         document.getElementById('statespan_new_'+div_id).innerHTML = waitinglit();
                           document.getElementById('countyspan_new_'+div_id).innerHTML = waitinglit();
                             document.getElementById('cityspan_new_'+div_id).innerHTML = waitinglit();
                        }
                  }
                  xmlhttppopstatenewlocation.send(null);
           }

	}



function getLoctions(val){


// alert(val);
	 http.open("GET", "get_locations_ajex.php?val="+val, true);
	  http.onreadystatechange=function() {
	   if(http.readyState == 4) {

   	document.getElementById('locations').innerHTML = http.responseText;
    	}else{
	 document.getElementById('locations').innerHTML = waitinglit();
	}
  }
  http.send(null);

	}
function getLoctions(val,new_name){

//	alert($fieldname);

	var current_locations=new_name;
	
	 http.open("GET", "get_locations_ajax.php?val="+val+"&current_locations="+current_locations, true);
	  http.onreadystatechange=function() {
	   if(http.readyState == 4) {

   	document.getElementById('locations').innerHTML = http.responseText;
    	}else{
	 document.getElementById('locations').innerHTML = waitinglit();
	}
  }
  http.send(null);

	}


function getNewLoctions(val,new_name){

//	alert($fieldname);

	var current_locations=new_name;

	 http.open("GET", "get_new_locations_ajex.php?val="+val+"&current_locations="+current_locations, true);
	  http.onreadystatechange=function() {
	   if(http.readyState == 4) {

   	document.getElementById('locations').innerHTML = http.responseText;
    	}else{
	 document.getElementById('locations').innerHTML = waitinglit();
	}
  }
  http.send(null);

	}



function getEquipments(val){

//	alert($fieldname);
//  alert(val);
	 http.open("GET", "get_equipments_ajax.php?val="+val, true);
	  http.onreadystatechange=function() {
	   if(http.readyState == 4) {
	
   	document.getElementById('equipments').innerHTML = http.responseText;
    	}else{
	 document.getElementById('equipments').innerHTML = waitinglit();
	}
  }
  http.send(null);

	}



function pop_city_member(val,fieldname){
		//alert('Country : '+val);
		 http.open("GET", "get_cities_all_ajax.php?country_id="+val+"&fieldname="+fieldname, true);
	  http.onreadystatechange=function() {
   if(http.readyState == 4) {
      document.getElementById('cityspan').innerHTML = http.responseText;
    }else{
	 document.getElementById('cityspan').innerHTML = waitinglit();
	}
  }
  http.send(null);

	
}

function popstatemember(val,fieldname){
// 	alert(fieldname);
// 	alert(val);
		 http.open("GET", "getstatesmember.php?country_id="+val+"&fieldname="+fieldname, true);
	  http.onreadystatechange=function() {
   if(http.readyState == 4) {
   document.getElementById('statespan').innerHTML = http.responseText;
    }else{
	 document.getElementById('statespan').innerHTML = waitinglit();
	}
  }
  http.send(null);

	}


function pop_state_member(val,fieldname){
//	alert($fieldname);
		//alert(val);
		 http.open("GET", "get_states_ajex.php?country_id="+val+"&fieldname="+fieldname, true);
	  http.onreadystatechange=function() {
   if(http.readyState == 4) {
   document.getElementById('statespan').innerHTML = http.responseText;
    }else{
	 document.getElementById('statespan').innerHTML = waitinglit();
	}
  }
  http.send(null);

	}

// added by sudhir 20090403
// starts 


function popcitycountymember(state_id){
	
	http.open("GET", "getcitycountymemberbystate.php?state_id="+state_id, true);
	http.onreadystatechange=function() {
		if(http.readyState == 4) {

			var cityCountyData = http.responseText;
			var splitData = cityCountyData.split('====||||====');


			
			document.getElementById('cityspan').innerHTML = splitData[0];
			document.getElementById('countyspan').innerHTML = splitData[1];
		}else{
			document.getElementById('cityspan').innerHTML = waitinglit();
			document.getElementById('countyspan').innerHTML = waitinglit();
		}
	}
	http.send(null);

}

function pop_city_county(state_id){
	//alert(state_id);
	//alert(val);
	http.open("GET", "get_city_county_ajax.php?state_id="+state_id, true);
	http.onreadystatechange=function() {
		if(http.readyState == 4) {

			var cityCountyData = http.responseText;
			var splitData = cityCountyData.split('====||||====');
			
			document.getElementById('cityspan2').innerHTML = splitData[0];
			document.getElementById('countyspan').innerHTML = splitData[1];
		}else{
			document.getElementById('cityspan2').innerHTML = waitinglit();
			document.getElementById('countyspan').innerHTML = waitinglit();
		}
	}
	http.send(null);

}


// starts 

function pop_city_county_location(state_id,div_id){
// 	alert(state_id);
// 	alert(div_id);
 xmlhttppop_city_county_location=GetXmlHttpObjectMS();
		xmlhttppop_city_county_location.open("GET", "get_city_county_by_state.php?state_id="+state_id+"&div_id="+div_id, true);
	xmlhttppop_city_county_location.onreadystatechange=function() {
		if(xmlhttppop_city_county_location.readyState == 4) {

			var cityCountyData = xmlhttppop_city_county_location.responseText;
// 			document.getElementById('cityspan_'+div_id).innerHTML = splitData[0];
			document.getElementById('countyspan_'+div_id).innerHTML = xmlhttppop_city_county_location.responseText;
		}else{
// 			document.getElementById('cityspan_'+div_id).innerHTML = waitinglit();
			document.getElementById('countyspan_'+div_id).innerHTML = waitinglit();
		}
	}
	xmlhttppop_city_county_location.send(null);

}

function pop_city_location(county_id,div_id){
// 	alert(county_id);
// 	alert(div_id);

	http.open("GET", "get_location_cities_ajax.php?county_id="+county_id+"&div_id="+div_id, true);
	http.onreadystatechange=function() {
		if(http.readyState == 4) {

			var cityCountyData = http.responseText;
			document.getElementById('cityspan_'+div_id).innerHTML = http.responseText;
// 			document.getElementById('countyspan_'+div_id).innerHTML = http.responseText;
		}else{
 			document.getElementById('cityspan_'+div_id).innerHTML = http.responseText;
// 			document.getElementById('countyspan_'+div_id).innerHTML = waitinglit();
		}
	}
	http.send(null);

}


function pop_city_county_new_location(state_id,div_id){
// alert(state_id);
 xmlhttppopstatecompany=GetXmlHttpObjectMS();
	xmlhttppopstatecompany.open("GET", "get_new_city_county_by_state.php?state_id="+state_id+"&div_id="+div_id, true);
	xmlhttppopstatecompany.onreadystatechange=function() {
		if(xmlhttppopstatecompany.readyState == 4) {

			var cityCountyData = xmlhttppopstatecompany.responseText;
			var splitData = cityCountyData.split('====||||====');


			
// 			document.getElementById('cityspan_new_'+div_id).innerHTML = splitData[0];
			document.getElementById('countyspan_new_'+div_id).innerHTML = xmlhttppopstatecompany.responseText;
		}else{
// 			document.getElementById('cityspan_new_'+div_id).innerHTML = waitinglit();
			document.getElementById('countyspan_new_'+div_id).innerHTML = waitinglit();
		}
	}
	xmlhttppopstatecompany.send(null);

}


function pop_city_new_location(county_id,div_id){
        xmlhttppop_city_new_location=GetXmlHttpObjectMS();
	xmlhttppop_city_new_location.open("GET", "get_new_cities_by_county.php?county_id="+county_id+"&div_id="+div_id, true);
	xmlhttppop_city_new_location.onreadystatechange=function() {
		if(xmlhttppop_city_new_location.readyState == 4) {

			var cityCountyData = xmlhttppop_city_new_location.responseText;
			var splitData = cityCountyData.split('====||||====');


			
// 			document.getElementById('cityspan_new_'+div_id).innerHTML = splitData[0];
			document.getElementById('cityspan_new_'+div_id).innerHTML = xmlhttppop_city_new_location.responseText;
		}else{
// 			document.getElementById('cityspan_new_'+div_id).innerHTML = waitinglit();
			document.getElementById('cityspan_new_'+div_id).innerHTML = waitinglit();
		}
	}
	xmlhttppop_city_new_location.send(null);

}




function popcountyregister(val){
		 http.open("GET", "get_county_register_ajax.php?state_id="+val, true);
	  http.onreadystatechange=function() {
   if(http.readyState == 4) {
      document.getElementById('countyspan').innerHTML = http.responseText;
    }else{
	 document.getElementById('countyspan').innerHTML = waitinglit();
	}
  }
  http.send(null);
	
	}

function popcountymcp(val)
{

http.open("GET", "get_county_register_mcp_ajax.php?state_id="+val, true);
	  http.onreadystatechange=function() {
   if(http.readyState == 4) {
      document.getElementById('countyspan2').innerHTML = http.responseText;
    }else{
	 document.getElementById('countyspan2').innerHTML = waitinglit();
	}
  }
  http.send(null);
	
}

function getmultiplecity(){
	var total_states=document.getElementById('ad_state_id[]').length;
	var ad_state_id ="";
	for(var i=0; i <total_states;i++){
		if (document.getElementById('ad_state_id[]').options[i].selected) 
			{
				
				if(i!=total_states-1)
				{
					ad_state_id = ad_state_id + document.getElementById('ad_state_id[]').options[i].value + ',';
					
				}
				else
				{
					ad_state_id = ad_state_id + document.getElementById('ad_state_id[]').options[i].value;
				}
				//alert(document.getElementById('ad_states[]').options[i].value);
			}

	
	}
// 	alert(ad_state_id);
	http.open("GET", "get_counties_ad.php?states="+ad_state_id, true);
	 http.onreadystatechange=function() {
 	   if(http.readyState == 4) {
     	 document.getElementById('ad_counties').innerHTML = http.responseText;
    }
	else{
	 document.getElementById('ad_counties').innerHTML = waitinglit();
	}
  }
  http.send(null);


}


function getcitiesad(){
	xmlhttpcity=GetXmlHttpObjectMS();
	var total_county=document.getElementById('ad_county_id[]').length;
	var ad_county_id ="";
	for(var i=0; i <total_county;i++){
		if (document.getElementById('ad_county_id[]').options[i].selected) 
			{
				if(i!=total_county-1)
				{
					ad_county_id = ad_county_id + document.getElementById('ad_county_id[]').options[i].value + ',';
				}
				else
				{
					ad_county_id = ad_county_id + document.getElementById('ad_county_id[]').options[i].value;
				}
				//alert(document.getElementById('ad_states[]').options[i].value);
			}

	
	}
	xmlhttpcity.open("GET", "get_cities_ad.php?counties="+ad_county_id, true);
	 xmlhttpcity.onreadystatechange=function() {
 	   if(xmlhttpcity.readyState == 4) {
     	 document.getElementById('cityspan').innerHTML = xmlhttpcity.responseText;
    }
	else{
	 document.getElementById('cityspan').innerHTML = waitinglit();
	}
  }
 xmlhttpcity.send(null);


}




function replace2() {
	var keyword = document.getElementById('advertiser_keywords').value ;
	if(keyword==''){
		alert('Please enter Keyword first.') ;
		return false;
		}
	var ad_month	=	document.getElementById('advertiser_how_many_months').value;
	if(ad_month==''||ad_month=='-1'){
		alert('Please Select Month.') ;
		return false;
		}
	
	var ad_country_id=document.getElementById('ad_country_id').value ;
	if(ad_country_id=='' || ad_country_id=='-1' ){
		alert('Please enter Country.');
		return false;
		}
	
	if(document.getElementById('ad_state_id[]').value==""){
	alert('Please Select State.') ;
		return false;
	}
	if(document.getElementById('ad_city[]').value==""){
	alert('Please Select City.') ;
		return false;
	}
 	var mLength=document.getElementById('ad_state_id[]').length;
	var ad_state_id ="";
	
	for (var i=0; i <mLength;i++)
	{
		//alert(document.getElementById('ad_states').options[i].value);
		if (document.getElementById('ad_state_id[]').options[i].selected) 
		{
			
			if(i!=mLength-1)
			{
				ad_state_id = ad_state_id + document.getElementById('ad_state_id[]').options[i].value + ',';
				
			}
			else
			{
				ad_state_id = ad_state_id + document.getElementById('ad_state_id[]').options[i].value;
			}
			//alert(document.getElementById('ad_states[]').options[i].value);
		}
	}
	
	var city_length =document.getElementById('ad_city[]').length;
	var ad_city ="";
	
	for (var c=0; c <city_length;c++)
	{
		//alert(document.getElementById('ad_states').options[i].value);
		if (document.getElementById('ad_city[]').options[c].selected) 
		{
			
			if(i!=city_length-1)
			{
				ad_city = ad_city + document.getElementById('ad_city[]').options[c].value + ',';
			}
			else
			{
				ad_city = ad_city + document.getElementById('ad_city[]').options[c].value;
			}
			//alert(document.getElementById('ad_states[]').options[i].value);
		}
	
	}	
var left_ad	=	document.getElementById('advertisement_position1').checked;
var right_ad	=	document.getElementById('advertisement_position2').checked;

if(left_ad==true){
var ad_position	=	document.getElementById('advertisement_position1').value;
}	
if(right_ad==true){
var ad_position	=	document.getElementById('advertisement_position2').value;
}	

	
			
	/*var ad_state_id=document.getElementById('ad_state_id').value ;
	var ad_city=document.getElementById('ad_city[]').value ;
	*/var relateto1 = document.getElementById('advertiser_relates_to1').value ;
	var relateto2 = document.getElementById('advertiser_relates_to2').value ;
	var relateto3 = document.getElementById('advertiser_relates_to3').value ;
	//var relateto = document.getElementById('advertiser_relates_to').value ;
	  http.open("GET", "checkads.php?keyword="+keyword+"&relateto1="+relateto1+"&relateto2="+relateto2+"&relateto3="+relateto3+"&ad_country_id="+ad_country_id+"&ad_state_id="+ad_state_id+"&ad_city="+ad_city+"&ad_position="+ad_position, true);
	  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      document.getElementById('adstatus').innerHTML = http.responseText;
    }
	else{
	 document.getElementById('adstatus').innerHTML = waitinglit();
	}
  }
  http.send(null);
}

function checkusername() {
	var relateto = document.getElementById('member_username').value ;
	if(relateto==''){
		alert('Please enter Username first.') ;
		return false;
		}
	  http.open("GET", "checkuser.php?relateto="+relateto, true);
	  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      document.getElementById('adstatus').innerHTML = http.responseText;
    }
	else{
	 document.getElementById('adstatus').innerHTML = waitinglit();
	}
  }
  http.send(null);
}

function checkuseremail() {
	var relateto = document.getElementById('member_email').value ;
	if(relateto==''){
		alert('Please enter Email address first.') ;
		return false;
		}
	  http.open("GET", "checkuser_mail.php?relateto="+relateto, true);
	  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      document.getElementById('emailstatus').innerHTML = http.responseText;
    }
	else{
	 document.getElementById('emailstatus').innerHTML = waitinglit();
	}
  }
  http.send(null);
}
function printprofile(val){
	 http.open("GET", "member_public_profile_ajax.php?member_id="+val, true);
	  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      document.getElementById('myspan').innerHTML = http.responseText;
    }
	else{
	document.getElementById('myspan').innerHTML = waiting();
}
  }
  http.send(null);
	
	}

function printprofilec(val){
	 http.open("GET", "contractor_public_profile_ajax.php?member_id="+val, true);
	  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      document.getElementById('myspan').innerHTML = http.responseText;
    }
	else{
	document.getElementById('myspan').innerHTML = waiting();
}
  }
  http.send(null);
	
	}
function printlocationc(val){
	 http.open("GET", "contractor_location_profile_ajax.php?member_id="+val, true);
	  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      document.getElementById('myspan').innerHTML = http.responseText;
    }
	else{
	document.getElementById('myspan').innerHTML = waiting();
}
  }
  http.send(null);

	}

function isdefined( variable)
{
    return (typeof(window[variable]) == "undefined")?  false: true;
}




function popcheck(val,mcp_member_city){
// alert("hi");
//pop_city_member(val,mcp_member_city);
popcounty(val,mcp_member_city);


}
	
	
	
function waiting(){
return "<div align='center'><img src='images/ajax-loaderlit.gif'></div>" ;
}

function waitinglit(){
return "<div align='center'><img src='images/ajax-loaderlit.gif'></div>" ;
}


function waitPreloadPage() { //DOM
//alert(document.getElementById);
if (document.getElementById){
document.getElementById('prepage').style.visibility='hidden';
}else{
if (document.layers){ //NS4
document.prepage.visibility = 'hidden';
}
else { //IE4
document.all.prepage.style.visibility = 'hidden';
}
}
}
// End -->



/*  var http_request = false;
   var localWhereToPut = "";
   
   function makePOSTRequest(url, parameters, whereToPut) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } 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('Cannot create XMLHTTP instance');
         return false;
      }
      localWhereToPut = whereToPut;
	  http_request.onreadystatechange = alertContents;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

   function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById(localWhereToPut).innerHTML   = result;            
         } else {
            alert('There was a problem with the request.');
         }
      }
   }
   
   function get(obj, whichPage, whereToPut, whatToPost) {
	 makePOSTRequest(whichPage, whatToPost, whereToPut);
   }*/
function popcountyall($val,$fieldname){
		 http.open("GET", "get_county_register_ajax.php?state_id="+$val+"&fieldname="+$fieldname, true);
	 http.onreadystatechange=function() {
   if(http.readyState == 4) {
      document.getElementById('countyspan').innerHTML = http.responseText;
    }else{
	 document.getElementById('countyspan').innerHTML = waitinglit();
	}
  }
  http.send(null);
	
	}







function popStateCompanyIf(val,fieldname){
// 	alert(fieldname);
 	//	alert(val);
 xmlhttpcontractor=GetXmlHttpObjectMS();
                if(val=='us'){
                                     xmlhttpcontractor.open("GET", "get_states_company_ajex.php?country_id="+val+"&fieldname="+fieldname, true);
                                      xmlhttpcontractor.onreadystatechange=function() {
                               if(xmlhttpcontractor.readyState == 4) {
                               document.getElementById('statespanif').innerHTML = xmlhttpcontractor.responseText;
                                }else{
                                     document.getElementById('statespanif').innerHTML = waitinglit();
                                    }
                              }
                              xmlhttpcontractor.send(null);
                }
                else{
                     xmlhttpcontractor.open("GET", "get_states_company_ajax_other_country.php?country_id="+val+"&fieldname="+fieldname, true);
                                      xmlhttpcontractor.onreadystatechange=function() {
                               if(xmlhttpcontractor.readyState == 4) {

                                var state_county_city_dd = xmlhttpcontractor.responseText;
                                var state_county_city=state_county_city_dd.split("==||==");

                                document.getElementById('statespanif').innerHTML = state_county_city[0];
                                document.getElementById('countyspanif').innerHTML = state_county_city[1];
                                document.getElementById('countylabelif').innerHTML = state_county_city[1];
                                document.getElementById('cityspanif').innerHTML = state_county_city[2];

                           //    document.getElementById('statespanif').innerHTML = xmlhttpcontractor.responseText;
                               
                               

                                }else{
                                     document.getElementById('statespanif').innerHTML = waitinglit();
                                      document.getElementById('countyspanif').innerHTML = waitinglit();
                                       document.getElementById('cityspanif').innerHTML = waitinglit();
                                    }
                              }
                              xmlhttpcontractor.send(null);
                }
}






/* For Advertise     */ 
function popstatead(val,fieldname){
// 	alert(fieldname);
// 		alert(val);
		 http.open("GET", "get_state_ad.php?country_id="+val+"&fieldname="+fieldname, true);
	  http.onreadystatechange=function() {
   if(http.readyState == 4) {
   document.getElementById('statespan').innerHTML = http.responseText;
    }else{
	 document.getElementById('statespan').innerHTML = waitinglit();
	}
  }
  http.send(null);

	}



function popcitycountyad(state_id){
// 	alert(state_id);
	//alert(val);
	http.open("GET", "getcitycountyad.php?state_id="+state_id, true);
	http.onreadystatechange=function() {
		if(http.readyState == 4) {

			var cityCountyData = http.responseText;
			var splitData = cityCountyData.split('====||||====');
			
			document.getElementById('cityspan2').innerHTML = splitData[0];
			document.getElementById('countyspan').innerHTML = splitData[1];
		}else{
			document.getElementById('cityspan2').innerHTML = waitinglit();
			document.getElementById('countyspan').innerHTML = waitinglit();
		}
	}
	http.send(null);

}


function popcitystatead(country_id){
//  	alert(country_id);
	xmlhttpstate=GetXmlHttpObjectMS();
	xmlhttpstate.open("GET", "getcitystatead.php?country_id="+country_id, true);
	xmlhttpstate.onreadystatechange=function() {
		if(xmlhttpstate.readyState == 4) {
		var cityCountyData =xmlhttpstate.responseText;
		document.getElementById('statespan').innerHTML = xmlhttpstate.responseText;
// 		document.getElementById('cityspan').innerHTML = splitData[1];
		}else{
		document.getElementById('statespan').innerHTML = waitinglit();
// 		document.getElementById('cityspan').innerHTML = waitinglit();
		}
	}
	xmlhttpstate.send(null);

}



function popcitycountyproject(state_id){
// 	alert(state_id);
	//alert(val);
	http.open("GET", "get_cities_county_all.php?state_id="+state_id, true);
	http.onreadystatechange=function() {
		if(http.readyState == 4) {

			var cityCountyData = http.responseText;
// 			var splitData = cityCountyData.split('====||||====');
			
// 			document.getElementById('cityspan').innerHTML = splitData[0];
			document.getElementById('countyspan').innerHTML = http.responseText;
		}else{
// 			document.getElementById('cityspan').innerHTML = waitinglit();
			document.getElementById('countyspan').innerHTML = waitinglit();
		}
	}
	http.send(null);

}

function popstateequipment(val,fieldname,div_id){
  	//alert(div_id);
        
                if(val=='us'){
                             http.open("GET","get_states_equipment.php?country_id="+val+"&fieldname="+fieldname+"&div_id="+div_id, true);
                             http.onreadystatechange=function() {
                             if(http.readyState == 4) {
                                document.getElementById('statespane_'+div_id).innerHTML = http.responseText;
                            }else{
                                 document.getElementById('statespane_'+div_id).innerHTML = waitinglit();
                                }
                          }
                          http.send(null);
                }
                else{
                         http.open("GET","get_states_equipment_other_countries.php?country_id="+val+"&fieldname="+fieldname+"&div_id="+div_id, true);
                             http.onreadystatechange=function() {
                             if(http.readyState == 4) {

                                 var state_county_city_dd = http.responseText;
                                var state_county_city=state_county_city_dd.split("==||==");
                                document.getElementById('statespane_'+div_id).innerHTML = state_county_city[0];
                                document.getElementById('countyspane_'+div_id).innerHTML = state_county_city[1];
                               document.getElementById('cityspane_'+div_id).innerHTML = state_county_city[2];
                               // document.getElementById('statespane_'+div_id).innerHTML = http.responseText;
                            }else{
                                 document.getElementById('statespane_'+div_id).innerHTML = waitinglit();
                                  document.getElementById('countyspane_'+div_id).innerHTML = waitinglit();
                                   document.getElementById('countyspane_'+div_id).innerHTML = waitinglit();
                                }
                          }
                          http.send(null);
                }
	}


function pop_city_county_equipment(state_id,div_id){
// 	alert(state_id);
// 	
	
	http.open("GET", "get_city_county_by_state_equipment.php?state_id="+state_id+"&div_id="+div_id, true);
	http.onreadystatechange=function() {
		if(http.readyState == 4) {

			var cityCountyData = http.responseText;
// 			var splitData = cityCountyData.split('====||||====');
// 			document.getElementById('cityspan_'+div_id).innerHTML = splitData[0];
			document.getElementById('countyspane_'+div_id).innerHTML = http.responseText;
		}else{
// 			document.getElementById('cityspan_'+div_id).innerHTML = waitinglit();
			document.getElementById('countyspane_'+div_id).innerHTML = waitinglit();
		}
	}
	http.send(null);

}

function pop_city_equipment(county_id,div_id){
// 	alert(county_id);
// 	alert(div_id);
	
	
	http.open("GET", "get_city_equipment_ajax.php?county_id="+county_id+"&div_id="+div_id, true);
	http.onreadystatechange=function() {
		if(http.readyState == 4) {

			var cityCountyData = http.responseText;
			
// 			var splitData = cityCountyData.split('====||||====');
 			document.getElementById('cityspane_'+div_id).innerHTML = http.responseText;
// 			document.getElementById('countyspane_'+div_id).innerHTML = http.responseText;
		}else{
			document.getElementById('cityspane_'+div_id).innerHTML = waitinglit();
// 			document.getElementById('countyspane_'+div_id).innerHTML = waitinglit();
		}
	}
	http.send(null);

}





/*            Kapil                 */ 


function popstatecompany(val,fieldname){
//alert(fieldname);
// 		alert(val);
 xmlhttpstatecompany=GetXmlHttpObjectMS();

    if(val=='us')
	 xmlhttpstatecompany.open("GET", "get_states_company_ajex.php?country_id="+val+"&fieldname="+fieldname, true);
     else
         xmlhttpstatecompany.open("GET", "get_states_other_company_ajex.php?country_id="+val+"&fieldname="+fieldname, true);
	  xmlhttpstatecompany.onreadystatechange=function() {
   if(xmlhttpstatecompany.readyState == 4) {
   if(val=='us'){
   document.getElementById('statespan').innerHTML = xmlhttpstatecompany.responseText;
    document.getElementById('countylabel').innerHTML = "County";
   }
   else
       {

      // alert(xmlhttpstatecompany.responseText);
    var cityCountyData = xmlhttpstatecompany.responseText;
    var splitData = cityCountyData.split('==||==');

    document.getElementById('statespan').innerHTML = splitData[0];
    document.getElementById('countyspan').innerHTML = splitData[1];
    document.getElementById('countylabel').innerHTML = splitData[1];
    
    document.getElementById('cityspan').innerHTML = splitData[2];
       }
    }else{
   if(val=='us')
	 document.getElementById('statespan').innerHTML = waitinglit();
     else {
         document.getElementById('statespan').innerHTML = waitinglit();
        document.getElementById('countyspan').innerHTML = waitinglit();
        document.getElementById('cityspan').innerHTML = waitinglit();
     }
	}
  }
  xmlhttpstatecompany.send(null);

	}


function popstatecompanyEquip(val,fieldname){
//alert(fieldname);
// 		alert(val);
 xmlhttpstatecompany=GetXmlHttpObjectMS();

    if(val=='us')
	 xmlhttpstatecompany.open("GET", "get_states_company_ajex_equip.php?country_id="+val+"&fieldname="+fieldname, true);
     else
         xmlhttpstatecompany.open("GET", "get_states_other_company_ajex_equip.php?country_id="+val+"&fieldname="+fieldname, true);
	  xmlhttpstatecompany.onreadystatechange=function() {
   if(xmlhttpstatecompany.readyState == 4) {
   if(val=='us'){
   document.getElementById('statespan').innerHTML = xmlhttpstatecompany.responseText;
    
   }
   else
       {

      // alert(xmlhttpstatecompany.responseText);
    var cityCountyData = xmlhttpstatecompany.responseText;
    

    document.getElementById('statespan').innerHTML = cityCountyData;
    
       }
    }else{
   if(val=='us')
	 document.getElementById('statespan').innerHTML = waitinglit();
     else {
         document.getElementById('statespan').innerHTML = waitinglit();
        
     }
	}
  }
  xmlhttpstatecompany.send(null);

	}

//function popphysicalstatecompany_MS(val,fieldname){
////  	alert(fieldname);
////	alert(val);
//	 http.open("GET", "get_states_companies_ajex.php?country_id="+val+"&fieldname="+fieldname, true);
//	  http.onreadystatechange=function() {
//   if(http.readyState == 4) {
//   document.getElementById('physical_statespan').innerHTML = http.responseText;
//    }else{
//	 document.getElementById('physical_statespan').innerHTML = waitinglit();
//	}
//  }
//  http.send(null);
//
//	}


// Rajeev 20091124
function physical_popstatecompany(val,fieldname){

    xmlhttpcopy=GetXmlHttpObjectMS();


        if(val=='us')
         xmlhttpcopy.open("GET", "get_physical_states_company_ajax.php?country_id="+val+"&fieldname="+fieldname, true);
         else
         xmlhttpcopy.open("GET", "get_physical_other_states_company_ajax.php?country_id="+val+"&fieldname="+fieldname, true);
	  xmlhttpcopy.onreadystatechange=function() {
   if(xmlhttpcopy.readyState == 4) {
   if(val=='us'){
      document.getElementById('physical_statespan').innerHTML = xmlhttpcopy.responseText;
   }
   else {
       var state_county_city_dd = xmlhttpcopy.responseText;
       var state_county_city=state_county_city_dd.split("==||==");
       
       document.getElementById('physical_statespan').innerHTML = state_county_city[0];
        document.getElementById('physical_countyspan').innerHTML = state_county_city[1];
         document.getElementById('physical_other_country_county_span').innerHTML = state_county_city[1];
       document.getElementById('physical_cityspan').innerHTML = state_county_city[2];

          }
    }else{
	 if(val=='us')
         document.getElementById('physical_statespan').innerHTML = waitinglit();
     else
         {
         document.getElementById('physical_statespan').innerHTML = waitinglit();
         document.getElementById('physical_countyspan').innerHTML = waitinglit();
         document.getElementById('physical_cityspan').innerHTML = waitinglit();
         }

	}
  }
  xmlhttpcopy.send(null);
}

function physical_popstatecompanies(val,fieldname){
         http.open("GET", "get_physical_states_companies_ajax.php?country_id="+val+"&fieldname="+fieldname, true);
	  http.onreadystatechange=function() {
   if(http.readyState == 4) {
   document.getElementById('physical_statespan').innerHTML = http.responseText;
    }else{
	 document.getElementById('physical_statespan').innerHTML = waitinglit();
	}
  }
  http.send(null);
}


function pop_city_county_company(state_id,field_name){
// 	alert(state_id);	
//alert(field_name);
 //alert("anurag");
 	 xmlhttppop_city_county_company=GetXmlHttpObjectMS();
	xmlhttppop_city_county_company.open("GET", "get_city_county_company_ajax.php?state_id="+state_id+"&field_name="+field_name,true);
	xmlhttppop_city_county_company.onreadystatechange=function() {
		if(xmlhttppop_city_county_company.readyState == 4) {

			var cityCountyData = xmlhttppop_city_county_company.responseText;
			
			document.getElementById('countyspan').innerHTML =  xmlhttppop_city_county_company.responseText;
                        document.getElementById('countylabel').innerHTML="County";

		}else{
			document.getElementById('countyspan').innerHTML = waitinglit();
		}
	}
	xmlhttppop_city_county_company.send(null);

}


//function pop_physical_city_county_companies_MS(state_id,field_name){
//// 	alert(state_id);
////  	alert(field_name);
//
//	http.open("GET", "get_city_county_company_ajax.php?state_id="+state_id+"&field_name="+field_name,true);
//	http.onreadystatechange=function() {
//		if(http.readyState == 4) {
//
//			var cityCountyData = http.responseText;
//
//			document.getElementById('physical_countyspan').innerHTML =  http.responseText;
//		}else{
//			document.getElementById('physical_countyspan').innerHTML = waitinglit();
//		}
//	}
//	http.send(null);
//
//}

function pop_physical_city_county_company(state_id,field_name){
	//alert(state_id); return false;
 xmlhttpcitycounty=GetXmlHttpObjectMS();
    xmlhttpcitycounty.open("GET", "get_physical_city_county_company_ajax.php?state_id="+state_id+"&field_name="+field_name,true);
	xmlhttpcitycounty.onreadystatechange=function() {
		if(xmlhttpcitycounty.readyState == 4) {

			var cityCountyData = xmlhttpcitycounty.responseText;

			document.getElementById('physical_countyspan').innerHTML =  xmlhttpcitycounty.responseText;
                        document.getElementById('physical_other_country_county_span').innerHTML =  "County";
                        
		}else{
			document.getElementById('physical_countyspan').innerHTML = waitinglit();
		}
	}
	 xmlhttpcitycounty.send(null);

}

function pop_city_county_company_if(state_id,val,field_name){
//  	alert(state_id);
//  	alert(val);
 	//alert(field_name);
 xmlhttpcontractorstate=GetXmlHttpObjectMS();
	xmlhttpcontractorstate.open("GET", "get_city_county_company_ajax.php?state_id="+state_id+"&state_val="+val+"&field_name="+field_name, true);
	xmlhttpcontractorstate.onreadystatechange=function() {
		if(xmlhttpcontractorstate.readyState == 4) {

			var cityCountyData = xmlhttpcontractorstate.responseText;
		
			document.getElementById('countyspanif').innerHTML =  xmlhttpcontractorstate.responseText;
                        document.getElementById('countylabelif').innerHTML = "County";
		}else{
// 			document.getElementById('cityspanif').innerHTML = waitinglit();
			document.getElementById('countyspanif').innerHTML = waitinglit();
		}
	}
	xmlhttpcontractorstate.send(null);

}


function popcityproject(val,fieldname){
// 	alert(val);
//   	alert(fieldname);
	 http.open("GET", "get_cities_ajax.php?county_id="+val+"&fieldname="+fieldname, true);
	  http.onreadystatechange=function() {
   if(http.readyState == 4) {
      document.getElementById('cityspan').innerHTML = http.responseText;
    }else{
	 document.getElementById('cityspan').innerHTML = waitinglit();
	}
  }
  http.send(null);

	}

function popcityequipment(val,fieldname){
// 	alert(val);
//  	alert(fieldname);
	 http.open("GET", "get_cities_ajax.php?county_id="+val+"&fieldname="+fieldname, true);
	  http.onreadystatechange=function() {
   if(http.readyState == 4) {
      document.getElementById('cityspan').innerHTML = http.responseText;
    }else{
	 document.getElementById('cityspan').innerHTML = waitinglit();
	}
  }
  http.send(null);

	}

function popcityif(val,fieldname){
// 	alert(val);
// 	alert(fieldname);
	
	 http.open("GET", "get_cities_ajax.php?county_id="+val+"&fieldname="+fieldname, true);
	  http.onreadystatechange=function() {
   if(http.readyState == 4) {
      document.getElementById('cityspanif').innerHTML = http.responseText;
    }else{
	 document.getElementById('cityspanif').innerHTML = waitinglit();
	}
  }
  http.send(null);

	}

function physical_popcityif(val,fieldname){
// 	alert(val);
// 	alert(fieldname);

	 http.open("GET", "get_physical_cities_ajax.php?county_id="+val+"&fieldname="+fieldname, true);
	  http.onreadystatechange=function() {
   if(http.readyState == 4) {
      document.getElementById('physical_cityspan').innerHTML = http.responseText;
    }else{
	 document.getElementById('physical_cityspan').innerHTML = waitinglit();
	}
  }
  http.send(null);

	}

function popcity(val,fieldname){
//  	alert(val);
//   	alert(fieldname);
 xmlhttppopcity=GetXmlHttpObjectMS();
	 xmlhttppopcity.open("GET", "get_cities_ajax.php?county_id="+val+"&fieldname="+fieldname, true);
	  xmlhttppopcity.onreadystatechange=function() {
   if(xmlhttppopcity.readyState == 4) {
      document.getElementById('cityspan').innerHTML = xmlhttppopcity.responseText;
    }else{
	 document.getElementById('cityspan').innerHTML = waitinglit();
	}
  }
  xmlhttppopcity.send(null);

	}

function popPhysicalCity(val,fieldname){
//  	alert(val);
//   	alert(fieldname);
 xmlhttp=GetXmlHttpObjectMS();
	 xmlhttp.open("GET", "get_cities_ajax.php?county_id="+val+"&fieldname="+fieldname, true);
	  xmlhttp.onreadystatechange=function() {
   if(xmlhttp.readyState == 4) {
  
      document.getElementById('physical_cityspan').innerHTML = xmlhttp.responseText;
    }else{
	 document.getElementById('physical_cityspan').innerHTML = waitinglit();
	}
  }
  xmlhttp.send(null);

	}
function popzip(val,fieldname)
{
     
     http.open("GET", "get_zipcode_bycity_ajax.php?city="+val+"&fieldname="+fieldname, true);
     //http.open("GET", "get_cities_ajax.php?zip="+val+"&fieldname="+fieldname, true);
	  http.onreadystatechange=function() {
   if(http.readyState == 4) {
      document.getElementById('zipspan').innerHTML = http.responseText;
    }else{
        
	document.getElementById('zipspan').innerHTML = waitinglit();
	}
}
}

function register_copy_address(){

}


function GetXmlHttpObjectMS()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}