if(document.images)
{
	preload_image = new Image(14,14); 
	preload_image.src = "http://www.rumah.com/images/loading.gif"; 
}

var xmlHttp;

function showCities(str)
{ 
	xmlHttp = GetXmlHttpObject();
	if(xmlHttp==null)
 	{
 		alert("Browser does not support HTTP Request");
 		return;
 	}
	var url = "getCities.php";
	url = url + "?q=" + str;
	xmlHttp.onreadystatechange = stateChanged; 
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function showMetas(str)
{ 
	xmlHttp = GetXmlHttpObject();
	if(xmlHttp==null)
 	{
 		alert("Browser does not support HTTP Request");
 		return;
 	}
	var url = "getMetas.php";
	url = url + "?q=" + str;
	xmlHttp.onreadystatechange = stateChanged4; 
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function showCities2(str)
{ 
	xmlHttp = GetXmlHttpObject();
	if(xmlHttp==null)
 	{
 		alert("Browser does not support HTTP Request");
 		return;
 	}
	var url = "getCities.php";
	url = url + "?q=" + str + "&op";
	xmlHttp.onreadystatechange = stateChanged2; 
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);		
}

function showAreas2(str)
{ 
	xmlHttp = GetXmlHttpObject();
	if(xmlHttp==null)
 	{
 		alert("Browser does not support HTTP Request");
 		return;
 	}
	var url = "getAreas.php";
	url = url + "?q=" + str;
	xmlHttp.onreadystatechange = stateChanged3; 
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function stateChanged() 
{ 
	if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("sp_cities").innerHTML = xmlHttp.responseText;
	}
	else 
	{
		document.getElementById("sp_cities").innerHTML = ' &nbsp; &nbsp; &nbsp; &nbsp; <img src="http://www.rumah.com/images/loading.gif" alt="Loading..." height="14" width="14" /> &nbsp; &nbsp; &nbsp; &nbsp; ';
	}
}

function stateChanged2() 
{ 
	if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("sp_cities2").innerHTML = xmlHttp.responseText;
	}
	else 
	{
		document.getElementById("sp_cities2").innerHTML = ' &nbsp; &nbsp; &nbsp; &nbsp; <img src="http://www.rumah.com/images/loading.gif" alt="Loading..." height="14" width="14" /> &nbsp; &nbsp; &nbsp; &nbsp; ';
	}
}

function stateChanged3() 
{ 
	if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("sp_areas2").innerHTML = xmlHttp.responseText;
	}
	else 
	{
		document.getElementById("sp_areas2").innerHTML = ' &nbsp; &nbsp; &nbsp; &nbsp; <img src="http://www.rumah.com/images/loading.gif" alt="Loading..." height="14" width="14" /> &nbsp; &nbsp; &nbsp; &nbsp; ';
	}
}

function stateChanged4() 
{ 
	if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 		
		document.getElementById("sp_metas").innerHTML = xmlHttp.responseText;		
	}
	else 
	{
		document.getElementById("sp_metas").innerHTML = ' &nbsp; &nbsp; &nbsp; &nbsp; <img src="http://www.rumah.com/images/loading.gif" alt="Loading..." height="14" width="14" /> &nbsp; &nbsp; &nbsp; &nbsp; ';
	}
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch(e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function CheckKeyCode()
{
  if( (event.keyCode == 189 || event.keyCode == 109) ||
      (event.keyCode >= 48 && event.keyCode <= 57) || 
      (event.keyCode >= 96 && event.keyCode <= 105) ) {
    return true; }
  else {
    return false;
  }
}

function checkCompanyType(val)
{
	if(val == 1)
	{
		document.getElementById('txtCompanyName').disabled = true;
		document.getElementById('txtCompanyAddress').disabled = true;
		document.getElementById('txtCompanyCity').disabled = true;
		document.getElementById('txtCompanyProvince').disabled = true;
		document.getElementById('txtCompanyURL').disabled = true;
		document.getElementById('image2').disabled = true;
	}
	else
	{
		document.getElementById('txtCompanyName').disabled = false;
		document.getElementById('txtCompanyAddress').disabled = false;
		document.getElementById('txtCompanyCity').disabled = false;
		document.getElementById('txtCompanyProvince').disabled = false;
		document.getElementById('txtCompanyURL').disabled = false;
		document.getElementById('image2').disabled = false;
	}

}