var DomYes=document.getElementById?1:0;
// declare a global  XMLHTTP Request object
var XmlHttpObj;

// create an instance of XMLHTTPRequest Object, varies with browser type, try for IE first then Mozilla
function CreateXmlHttpObj()
{
	// try creating for IE (note: we don't know the user's browser type here, just attempting IE first.)
	try
	{
		XmlHttpObj = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttpObj = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttpObj = null;
		}
	}
	// if unable to create using IE specific code then try creating for Mozilla (FireFox) 
	if(!XmlHttpObj && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttpObj = new XMLHttpRequest();
	}
}

// called from onChange or onClick event of the continent dropdown list
function getCustdata() 
{
	
    var requestUrl;
    // use the following line if using asp
    requestUrl ="group1.php";
  	CreateXmlHttpObj();
	
	// verify XmlHttpObj variable was successfully initialized
	if(XmlHttpObj)
	{
        // assign the StateChangeHandler function ( defined below in this file)
        // to be called when the state of the XmlHttpObj changes
        // receiving data back from the server is one such change
		XmlHttpObj.onreadystatechange = StateChangeHandler;
		
		// define the iteraction with the server -- true for as asynchronous.
		XmlHttpObj.open("GET", requestUrl,  true);
		
		// send request to server, null arg  when using "GET"
		XmlHttpObj.send(null);		
	}
	StateChangeHandler();
}


function StateChangeHandler()
{
	// state ==4 indicates receiving response data from server is completed
	if(XmlHttpObj.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpObj.status == 200)
		{			
			populatecustomer(XmlHttpObj.responseXML.documentElement);
		}
		else
		{
			alert("problem retrieving data from the server, status code: "  + XmlHttpObj.status);
		}
	}
}



// populate the contents of the country dropdown list
function populatecustomer(countryNode)
{
	//alert(countryNode);
    var countryList = document.getElementById("group");
	// clear the country list 
	for (var count = countryList.options.length-1; count >-1; count--)
	{//alert(count);
		countryList.options[count] = null;
	}

	var countryNodes = countryNode.getElementsByTagName('country');
	var idValue;
	var textValue; 
	var optionItem;
	//alert(countryNodes);
	// populate the dropdown list with data from the xml doc
	for (var count = 0; count < countryNodes.length; count++)
	{
   		textValue = GetInnerText(countryNodes[count]);
		idValue = countryNodes[count].getAttribute("id");
		optionItem = new Option( textValue, idValue,  false, false);
		countryList.options[countryList.length] = optionItem;
		
	}
}
// returns the node text value 
function GetInnerText (node)
{
	 return (node.textContent || node.innerText || node.text) ;
}



function postDataGetText(urlToCall, dataToSend, functionToCallBack)
{
  var XMLHttpRequestObject = false;

  if (window.XMLHttpRequest) {
    XMLHttpRequestObject = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    XMLHttpRequestObject = new
     ActiveXObject("Microsoft.XMLHTTP");
  }

  if(XMLHttpRequestObject) {
    XMLHttpRequestObject.open("POST", urlToCall);
    XMLHttpRequestObject.setRequestHeader('Content-Type',
      'application/x-www-form-urlencoded');

    XMLHttpRequestObject.onreadystatechange = function()
    {
      if (XMLHttpRequestObject.readyState == 4 &&
        XMLHttpRequestObject.status == 200) {
          functionToCallBack(XMLHttpRequestObject.responseText);
          delete XMLHttpRequestObject;
          XMLHttpRequestObject = null;
      }
    }

    XMLHttpRequestObject.send(dataToSend);
  }
}
function getcity(id)
{//alert(id); return false;
//alert(empadmin.email); return false;

var data="stateid="+id;
 //alert(pass); return false;
 /* if (DomYes) {
		imgobj=document.getElementById('image'+imid);
  }
  else{
       imgobj=document.getElementById['image'+imid];
  }
  imgobj.style.border='1px solid #FF0000';*/
  postDataGetText('city_mid.php',data,displaycity);
  return false;
}
function displaycity(t)
{//alert(t);
//return false;
var dis;
  if (DomYes) {
		dis=document.getElementById('citydata');
  }
  else{
       dis=document.getElementById['citydata'];
  }
  dis.style.display='block';
  dis.innerHTML=t;
  
  return false;
}
function getstate(id)
{//alert(id); return false;
//alert(empadmin.email); return false;
var data="stateid="+id;

//var data="type=state&countryid="+id;
// alert(data); return false;
 /* if (DomYes) {
		imgobj=document.getElementById('image'+imid);
  }
  else{
       imgobj=document.getElementById['image'+imid];
  }
  imgobj.style.border='1px solid #FF0000';*/
  postDataGetText('state_mid.php',data,displaystate);
  return false;
}
function displaystate(t)
{//alert(t);
//return false;
var dis;
  if (DomYes) {
		dis=document.getElementById('statedata');
  }
  else{
       dis=document.getElementById['statedata'];
  }
  dis.style.display='block';
  dis.innerHTML=t;
  
  return false;
}
function getrest(id)
{//alert(id); return false;
//alert(empadmin.email); return false;
//var cuntryid=bussinessprof.selectcountry.value;
//alert(cuntryid);return false;
var data="type=state&restid="+id;
//alert(data); return false;
 //alert(pass); return false;
 /* if (DomYes) {
		imgobj=document.getElementById('image'+imid);
  }
  else{
       imgobj=document.getElementById['image'+imid];
  }
  imgobj.style.border='1px solid #FF0000';*/
  postDataGetText('rest_mid.php',data,displayrest);
  return false;
}
function displayrest(t)
{//alert(t);
//return false;
var dis;
var dis1
  if (DomYes) {
		dis=document.getElementById('restdata');
  }
  else{
       dis=document.getElementById['restdata'];
  }
  dis.style.display='block';
  dis.innerHTML=t;
  
  return false;
}

function getrest1(id)
{//alert(id); return false;
//alert(empadmin.email); return false;
alert("hi");
var data="type=rest&shopid="+id;
alert(data);
// alert(data); return false;
 /* if (DomYes) {
		imgobj=document.getElementById('image'+imid);
  }
  else{
       imgobj=document.getElementById['image'+imid];
  }
  imgobj.style.border='1px solid #FF0000';*/
  postDataGetText('rest_mid.php',data,displayrest);
  return false;
}
function displayrest1(t)
{//alert(t);
//return false;
var dis;
  if (DomYes) {
		dis=document.getElementById('shopdata');
  }
  else{
       dis=document.getElementById['shopdata'];
  }
  dis.style.display='block';
  dis.innerHTML=t;
  
  return false;
}
function getcity11(id)
{//alert(id); return false;
//alert(empadmin.email); return false;
//var cuntryid=bussinessprof.selectcountry.value;
//alert(cuntryid);return false;
var data="type=city&stateid="+id;
//alert(data); return false;
 //alert(pass); return false;
 /* if (DomYes) {
		imgobj=document.getElementById('image'+imid);
  }
  else{
       imgobj=document.getElementById['image'+imid];
  }
  imgobj.style.border='1px solid #FF0000';*/
  postDataGetText('state_mid_search.php',data,displaycity1);
  return false;
}
function displaycity11(t)
{//alert(t);
//return false;
var dis;
  if (DomYes) {
		dis=document.getElementById('citydata');
  }
  else{
       dis=document.getElementById['citydata'];
  }
  dis.style.display='block';
  dis.innerHTML=t;
  
  return false;
}
function getplans(id)
{//alert(id); return false;
//alert(empadmin.email); return false;

var data="catid="+id;
 //alert(pass); return false;
 /* if (DomYes) {
		imgobj=document.getElementById('image'+imid);
  }
  else{
       imgobj=document.getElementById['image'+imid];
  }
  imgobj.style.border='1px solid #FF0000';*/
  postDataGetText('plan_mid.php',data,displaplans);
  return false;
}
function displaplans(t)
{//alert(t);
//return false;
var dis;
  if (DomYes) {
		dis=document.getElementById('plandata');
  }
  else{
       dis=document.getElementById['plandata'];
  }
  dis.style.display='block';
  dis.innerHTML=t;
  
  return false;
}


function featurebusiness(id)
{//alert(id); return false;
//alert(empadmin.email); return false;

var data="stateid="+id;
 //alert(pass); return false;
 /* if (DomYes) {
		imgobj=document.getElementById('image'+imid);
  }
  else{
       imgobj=document.getElementById['image'+imid];
  }
  imgobj.style.border='1px solid #FF0000';*/
  postDataGetText('feature_mid.php',data,displayfeaturebuss);
  return false;
}
function displayfeaturebuss(t)
{//alert(t);
//return false;
var dis;
  if (DomYes) {
		dis=document.getElementById('featurebusiness');
  }
  else{
       dis=document.getElementById['featurebusiness'];
  }
  dis.style.display='block';
  dis.innerHTML=t;
  
  return false;
}

//function checkcaptcha()
//{//alert('sdfsdf'); return false;
//var sec=bussinessprof.seccode.value;// return false;
//
//var data="seccode="+sec;
// //alert(pass); return false;
// /* if (DomYes) {
//		imgobj=document.getElementById('image'+imid);
//  }
//  else{
//       imgobj=document.getElementById['image'+imid];
//  }
//  imgobj.style.border='1px solid #FF0000';*/
//  postDataGetText('mycaptcha.php',data,displaycaptcha);
//  return false;
//}
//function displaycaptcha(t)
//{//alert(t);
////return false;
//var dis;
//  if (DomYes) {
//		dis=document.getElementById('errorofcaptcha');
//		message=document.getElementById('errormessage');
//		button=document.getElementById('bussiness_sub');
//		
//  }
//  else{
//       dis=document.getElementById['errorofcaptcha'];
//	   message=document.getElementById['errormessage'];
//	   button=document.getElementById['bussiness_sub'];
//
//  }
// // var where_is_mytool="home/mytool/mytool.cgi";
// if(t!="")
// {
//var mytool_array=t.split("<br>");
//}
//  dis.style.display='block';
//  dis.innerHTML=mytool_array[0];
//  message.style.display='block';
//  message.innerHTML=mytool_array[1];
//// alert(t);//return false;
// // return true;
//  if(t=="")
//  {//alert('rtyrtytr');
////   button.disabled=false;
////  bussinessprof.submit(); 
//  return true;
//  }
//  else if(t!="")
//  {//alert('ertert');
//  //stop();
////  document.execCommand('Stop'); 
//  //button.disabled=true;
//
//  	  return false;
//	  }
//	  else{
//	  return true;
//	  }
//	  //return false;
//}
