function createXMLtop()
{	
	if(window.ActiveXObject)
		xhr=new ActiveXObject("Microsoft.XMLHTTP");
	else if(window.XMLHttpRequest)
	{
		xhr=new XMLHttpRequest();
		if(xhr.overrideMimeType)
		{
		  xhr.overrideMimeType("text/xml");
		}
	}
	
	return xhr;
}
function Trim(STRING)
{
	STRING = LTrim(STRING);
	return RTrim(STRING);
}
function RTrim(STRING)
{
	while(STRING.charAt((STRING.length -1))==" ")
	{
		STRING = STRING.substring(0,STRING.length-1);
	}
return STRING;
}
function LTrim(STRING)
{
	while(STRING.charAt(0)==" ")
	{
		STRING = STRING.replace(STRING.charAt(0),"");
	}
return STRING;
}
function LTrimZero(STRING)
{
	while(STRING.charAt(0)=="0")
	{
		STRING = STRING.replace(STRING.charAt(0),"");
	}
return STRING;
}
function Ischar(elem)
{
	var alphaExp = /^[a-zA-Z. ]+$/;
	if(elem.match(alphaExp))
		return true;
	else
		return false;
} 
function ValidateNo(NumStr, String ) 
{
	for( var Idx = 0; Idx < NumStr.length; Idx ++ )
	{
	 var Char = NumStr.charAt( Idx );
	 var Match = false;

		for( var Idx1 = 0; Idx1 < String.length; Idx1++) 
		{
			
			 if( Char == String.charAt( Idx1 ) ) 
			 Match = true;
		}

		if ( !Match ) 
			return false;
	}		
	return true;
}

function getPropertyType(propertycategoryId)
{
	if(propertycategoryId != "0")
	{
		ctreq = createXMLtop();
		var strURL="propertydisplay.php?propertycategory="+propertycategoryId;
		ctreq.onreadystatechange = disptype;
		ctreq.open("GET", strURL, true);
		ctreq.send(null);
	}
	else if(propertycategoryId == "0")
		document.getElementById("typedisp").disabled = true;
	
}

function disptype()
{
	var selecttype = document.getElementById("typedisp");
	var typeloading = document.getElementById("property_type");
	
	if(xhr.readyState==1)
	{
		loading="<img src='../images/loading.gif'>";
		typeloading.innerHTML=loading;
	}

	if(xhr.readyState==2)
	{
		loading="<img src='../images/loading.gif'>";
		typeloading.innerHTML=loading;
	}

	if(xhr.readyState==3)
	{
		loading="<img src='../images/loading.gif'>";
		typeloading.innerHTML=loading;
	}
	if (ctreq.readyState == 4)
	{	
		typeloading.innerHTML="";
		selecttype.disabled = false;
		var temp = ctreq.responseText;
		for(k=selecttype.length;k>=0;k--)
		{
		 	selecttype.remove(k);
		}
		var Firstopt = document.createElement("option");
		Firstopt.value = "0";
		Firstopt.text = "---Select---";
		try{
  			selecttype.add(Firstopt,null);
		}
		catch(ex){
			selecttype.add(Firstopt);
		}
		
		var getarray = temp.split(",");
		for(var i=0;i<getarray.length-2;i=i+2)
		{
			var opt = document.createElement("option");
			opt.value = getarray[i];
			opt.text = LTrim(getarray[i+1]);
			try{
				selecttype.add(opt,null);
			}
			catch(ex){
				selecttype.add(opt);
			}
		}
	}
}


