var xmlHttp

function chkEmail(email)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
 	{
 		alert ("Browser does not support HTTP Request")
 	return
 	}
	var email = email;
	var url = "chkemail.php"
	url = url+"?email="+email
	xmlHttp.onreadystatechange=setMessage 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
}

function showCatList()
{ 

xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }


//var webid = valButton(addImage.website, 'Please Select Website');
var webid = valButton();
var rowid = document.addImage.wRow.value;


if(webid!='' && rowid!='')
{
var url="getCatList.php"
url=url+"?webid="+webid+"&rowid="+rowid
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
}


function valButton() {
	
    var cnt = -1;
    for (var i=document.addImage.website.length-1; i > -1; i--) {
        if (document.addImage.website[i].checked) {cnt = i; i = -1;}
    }
    if (cnt > -1) return document.addImage.website[cnt].value;
	else{
	alert("Please Select Website");
	return false;
	}
   
}


function showWebCategory(website)
{ 

xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }

if(website!='')
{
var url="../getWebCatList.php"
url=url+"?website="+website
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("POST",url,true)
xmlHttp.send(null)
}else{
document.uploadListing.webcategory.value='';
//document.uploadListing.webcategory.disabled = 'true';
}
}


function getCity(strURL) {		
		
		//var req = getXMLHTTP();
		if(strURL!='')
		{
		
		var req = GetXmlHttpObject();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('citydiv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
    	}
	}
	
	
	function getCounty(strURL) {		
		
		//var req = getXMLHTTP();
		if(strURL!='')
		{
		var req = GetXmlHttpObject();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('countydiv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
     }
	}



function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 

 document.getElementById("catlist").style.display = 'block';
 document.getElementById("catlist").innerHTML=xmlHttp.responseText 
 } 
}


function setMessage() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 
 	if(xmlHttp.responseText!='')
	{
		document.getElementById("logemail").value = "";
		document.getElementById("logemail").focus();
	}
 	 document.getElementById("msg").style.display = 'block';
	 document.getElementById("msg").innerHTML=xmlHttp.responseText 
 } 
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {

 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

	function chkImageType(pathField,fieldname)
	{
	
	var imgRe = /^.+\.(jpg|jpeg|gif|png)$/i;
	var path = pathField.value;
	if (path.search(imgRe) != -1)
	{
	}else{
		alert("Please Select JPG, PNG, and GIFs Images only!");
		document.getElementById(fieldname).value = "";
		document.addImage.wImage.value ="";
	} 	
	}

function changeRow()
{
	document.addImage.wRow.value = "";
}

function getLetter(letter)
{	
	if(document.agent_search.chkfaces.checked == true)
	{
		var face = 'Y';
		window.location = 'agents_search.php?alpha='+letter+'&face='+face
	}else{
		window.location = 'agents_search.php?alpha='+letter
	}
}

function showImage(hoveritem,Aid,x,y)
{
	
	//document.getElementById('agentImage'+Aid).style.visibility = 'visible';
	hp = document.getElementById('agentImage'+Aid);

		// Set popup to visible
		//hp.style.top = hoveritem.offsetTop + 18;
		//hp.style.left = hoveritem.offsetLeft + 100;
				
		
		if (document.layers && document.layers[hp] != null) {
			document.layers[hp].Left += x;
			document.layers[hp].Top += y;
			
			}
		
		
	hp.style.visibility = "Visible";
	
}
function hideImage(Aid)
{
	//document.getElementById('agentImage'+Aid).style.visibility = 'hidden';
	hp = document.getElementById('agentImage'+Aid);
	hp.style.visibility = "Hidden";	
}

function validate(form_id,email) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = document.forms[form_id].elements[email].value;
   if(reg.test(address) == false) {
      alert('Invalid Email Address');
      return false;
   }
}


function chkTab(tabname)
{

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
 	{
 		alert ("Browser does not support HTTP Request")
 	return
 	}
	var tabname = tabname;
	var url = "showpage.php"
	url = url+"?tabname="+tabname
	//alert(url);
	xmlHttp.onreadystatechange=pageChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
}

function pageChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
	//alert(xmlHttp.responseText);
	var result = xmlHttp.responseText
	var result_split = result.split("|");
	if(result_split[0] == 'quick')
	{
		document.getElementById("span_quick").style.display ='block';
		document.getElementById("span_map").style.display ='none';
		document.getElementById("span_addrs").style.display ='none';
		document.getElementById("span_advance").style.display ='none';
	}
	if(result_split[0] == 'map')
	{
		document.getElementById("span_quick").style.display ='none';
		document.getElementById("span_map").style.display ='block';
		document.getElementById("span_addrs").style.display ='none';
		document.getElementById("span_advance").style.display ='none';
	}
	if(result_split[0] == 'address')
	{
		document.getElementById("span_quick").style.display ='none';
		document.getElementById("span_map").style.display ='none';
		document.getElementById("span_addrs").style.display ='block';
		document.getElementById("span_advance").style.display ='none';
	}
	if(result_split[0] == 'advance')
	{
		document.getElementById("span_quick").style.display ='none';
		document.getElementById("span_map").style.display ='none';
		document.getElementById("span_addrs").style.display ='none';
		document.getElementById("span_advance").style.display ='block';
		
	}
	/*document.getElementById("navigation_org").style.display ='none';
	document.getElementById("navigation").style.display ='block';
	document.getElementById("navigation").innerHTML = result_split[0];
	document.getElementById("searchoptions").innerHTML = result_split[1];*/
 	document.getElementById("searchoptions").innerHTML=result_split[1];
 } 
}
