/**************/
var bookmarkurl="http://www.properties.go.th"
var bookmarktitle="Properties.go.th"

function addbookmark(){
if (document.all)
window.external.AddFavorite(bookmarkurl,bookmarktitle)
}

<!--
	overhome=new Image(74, 17); outhome=new Image(74, 17); 
	overhome.src="_images/nav/1-1.gif"; outhome.src="_images/nav/1-0.gif" 
	
	overproducts=new Image(74, 17); outproducts=new Image(74, 17); 
	overproducts.src="_images/nav/2-1.gif"; outproducts.src="_images/nav/2-0.gif" 
	
	overfaqs=new Image(74, 17); outfaqs=new Image(74, 17); 
	overfaqs.src="_images/nav/3-1.gif"; outfaqs.src="_images/nav/3-0.gif" 
	
	overfreebies=new Image(74, 17); outfreebies=new Image(74, 17); 
	overfreebies.src="_images/nav/4-1.gif"; outfreebies.src="_images/nav/4-0.gif" 
	
	overlinks=new Image(74, 17); outlinks=new Image(74, 17); 
	overlinks.src="_images/nav/5-1.gif"; outlinks.src="_images/nav/5-0.gif" 
	
	oversupport=new Image(74, 17); outsupport=new Image(74, 17); 
	oversupport.src="_images/nav/6-1.gif"; outsupport.src="_images/nav/6-0.gif" 
	
	overcontact=new Image(74, 17); outcontact=new Image(74, 17); 
	overcontact.src="_images/nav/7-1.gif"; outcontact.src="_images/nav/7-0.gif" 
	
	/* Open New Window. */
	var win=null;
	function OpeNewWindow(mypage,myname,w,h,scroll,pos){
	if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=0,menubar=no,toolbar=no,resizable=yes';
	win=window.open(mypage,myname,settings);}
// -->


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

// Resize 
function setSize(width,height) {
	if (window.outerWidth) {
		window.outerWidth = width;
		window.outerHeight = height;
	}
	else if (window.resizeTo) {
		window.resizeTo(width,height);
	}
	else {
		alert("Not supported.");
	}
}


//Ajax Start load ajax. .. //
// 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 ChangeGetAjax(form) 
{
    var DropParent = document.getElementById("Filter_LOC_PROV_ID");
  
    // get selected continent from dropdown list
    var SelectedDropParent = DropParent.options[DropParent.selectedIndex].value;
    
    // url of page that will send xml data back to client browser
    var requestUrl;
    // use the following line if using asp
    requestUrl = "/bitrix/tools/prop_load_loc.php" + "?ID=" + encodeURIComponent(SelectedDropParent);
    // use the following line if using php
	CreateXMLHttpObj();
	
	// verify XMLHttpObj variable was successfully initialized
	if(XMLHttpObj)
	{
        // assign the DropParentChangeHandler 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 = DropParentChangeHandler;
		// 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);		
	}else{
		alert("Not support AJAX.");
	}
}

// called from onChange or onClick event of the continent dropdown list
function ChangeGetAjax2(form,GetID) 
{
    var DropParent = document.getElementById("Filter_LOC_PROV_ID");
  
    // get selected continent from dropdown list
    var SelectedDropParent = DropParent.options[DropParent.selectedIndex].value;
    
    // url of page that will send xml data back to client browser
    var requestUrl;
    // use the following line if using asp
    requestUrl = "/bitrix/tools/prop_load_loc.php" + "?ID=" + encodeURIComponent(SelectedDropParent);
    // use the following line if using php
	CreateXMLHttpObj();
	
	//alert("ID: "+GetID);
	// verify XMLHttpObj variable was successfully initialized
	if(XMLHttpObj)
	{
        // assign the DropParentChangeHandler 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 = DropParentChangeHandler2;
		//alert("ID: "+GetID);
		
		// 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);		
	}else{
		alert("Not support AJAX.");
	}
}


// this function called when state of  XMLHttpObj changes
// we're interested in the state that indicates data has been
// received from the server
function DropParentChangeHandler()
{
	// 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)
		{			
			CreateChildDrop(XMLHttpObj.responseXML.documentElement);
		}
		else
		{
			alert("problem retrieving data from the server, status code: "  + XMLHttpObj.status);
		}
	}
}

function DropParentChangeHandler2()
{
	
	// state ==4 indicates receiving response data from server is completed
	if(XMLHttpObj.readyState == 4)
	{
		//alert("ID: "+GetID);
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XMLHttpObj.status == 200)
		{			
			
			//var DropID= document.getElementById("Filter_LOC_AMPH_ID");
			var DropID= document.getElementById("Filter_LOC_AMPH_ID_Selected");
			//var SelectedDropID = DropID.options[DropID.selectedIndex].value;
			var SelectedDropID = DropID.value;
			//alert("ID: "+SelectedDropID);
					
			CreateChildDrop2(XMLHttpObj.responseXML.documentElement,SelectedDropID);
		}
		else
		{
			alert("problem retrieving data from the server, status code: "  + XMLHttpObj.status);
		}
	}
}


// populate the contents of the did dropdown list
function CreateChildDrop(didNode)
{
    var DropChild = document.getElementById("Filter_LOC_AMPH_ID");
	// clear the did list 
	for (var count = DropChild.options.length-1; count >-1; count--)
	{
		DropChild.options[count] = null;
	}

	
	var DropChildNodes = didNode.getElementsByTagName('record');
	//alert("Drop: "+DropChildNodes.length);  All B OK
	
	// populate the dropdown list with data from the xml doc
	for (var count = 0; count < DropChildNodes.length; count++)
	{
		
//		if (count < (DropChildNodes.length)-1){
//			DropChild.disabled = true;
//			//form.city.disabled = true;
//		}else{
//			DropChild.disabled = false;
//		}
     var DropChildNodesEnd=DropChildNodes[count].getElementsByTagName("param")
//    for (var count2 = 0; count < DropChildNodes.length; count2++)
//	 {

//	if (window.ActiveXObject)
//	  {
//		ValueNameID = DropChildNodes[count].childNodes[0].text;
//		ValueNameTXT = DropChildNodes[count].childNodes[1].text;
//		//ValueID = DropChildNodes[count].getAttribute("id");
//	  }else{
		ValueNameID = DropChildNodesEnd[0].firstChild.data;
		ValueNameTXT = DropChildNodesEnd[1].firstChild.data;
		//nodeType
//	  }
//		alert("Show: "+DropChildNodes.length+" :: "+ValueNameID+" :: "+ValueNameTXT+" // "+ValueType);
//		alert(arrTemp[i].childNodes[0].nodeValue); // alerts empty string
//		alert(arrTemp[i].childNodes[1].nodeValue); // alerts 'null'		
			OptionElement = new Option( ValueNameTXT, ValueNameID,  false, false);
// 		Create List..
		DropChild.options[DropChild.length] = OptionElement;
//	 }
	}
}

// populate the contents of the did dropdown list
function CreateChildDrop2(didNode,GetID)
{
    var DropChild = document.getElementById("Filter_LOC_AMPH_ID");
	// clear the did list 
	for (var count = DropChild.options.length-1; count >-1; count--)
	{
		DropChild.options[count] = null;
	}

	
	var DropChildNodes = didNode.getElementsByTagName('record');
	//alert("Drop: "+DropChildNodes.length);  All B OK
	
	// populate the dropdown list with data from the xml doc
	for (var count = 0; count < DropChildNodes.length; count++)
	{
		
//		if (count < (DropChildNodes.length)-1){
//			DropChild.disabled = true;
//			//form.city.disabled = true;
//		}else{
//			DropChild.disabled = false;
//		}
     var DropChildNodesEnd=DropChildNodes[count].getElementsByTagName("param")
//    for (var count2 = 0; count < DropChildNodes.length; count2++)
//	 {

//	if (window.ActiveXObject)
//	  {
//		ValueNameID = DropChildNodes[count].childNodes[0].text;
//		ValueNameTXT = DropChildNodes[count].childNodes[1].text;
//		//ValueID = DropChildNodes[count].getAttribute("id");
//	  }else{
		ValueNameID = DropChildNodesEnd[0].firstChild.data;
		ValueNameTXT = DropChildNodesEnd[1].firstChild.data;
		//nodeType
//	  }
//		alert("Show: "+DropChildNodes.length+" :: "+ValueNameID+" :: "+ValueNameTXT+" // "+ValueType);
//		alert(arrTemp[i].childNodes[0].nodeValue); // alerts empty string
//		alert(arrTemp[i].childNodes[1].nodeValue); // alerts 'null'		
		if (ValueNameID == GetID){
			OptionElement = new Option( ValueNameTXT, ValueNameID,  false, true);
		}else{
			OptionElement = new Option( ValueNameTXT, ValueNameID,  false, false);
		}
// 		Create List..
		DropChild.options[DropChild.length] = OptionElement;
//	 }
	}
}
// returns the node text value 
function GetInnerText (node)
{
//	 return (node.textContent || node.innerText || node.text) ;
	 return (node.text) ;
}

function CheckPropType(form)
{
   
//	var DownElement1 = document.getElementById("LedBranch");
//	var DownElement2 = document.getElementById("Filter_LED_BRANCH_ID");
	var DownType = document.getElementById("Filter_TYPE_ID");
	var DownCode1 = document.getElementById("NumCode1");
	var DownCode2 = document.getElementById("NumCode2");
	//var DownCode2Tips = document.getElementById("NumCode2Tips");
	var DownCode3 = document.getElementById("NumCode3");
	var DownCode4 = document.getElementById("NumCode4");
	//Filter_TYPE_ID
	var DownTypeValue = DownType.options[DownType.selectedIndex].value;
//	var SelectedDropParent = DropParent.options[DropParent.selectedIndex].value;
	//alert("Sm: "+DownTypeValue);
	
	if (DownTypeValue == '3' ){
//		 DownElement1.style.display = "";
//		 DownElement2.disabled = false;
		 DownCode1.style.display = "none";
		 DownCode2.style.display = "";
		// DownCode2Tips.style.display = "";
		 DownCode3.style.display = "";
		 DownCode4.style.display = "";
		 
		 
	}else{
//		 DownElement1.style.display = "none";
//		 DownElement2.disabled = true;
		 DownCode1.style.display = "";
		 DownCode2.style.display = "none";
		// DownCode2Tips.style.display = "none";
		 DownCode3.style.display = "none";
		 DownCode4.style.display = "none";
		 
	}
	//return true;	
}

function CheckPropTypeHome(form)
{
   
	//var DownElement1 = document.getElementById("LedBranch");
	//var DownElement2 = document.getElementById("Filter_LED_BRANCH_ID");
	var DownType = document.getElementById("Filter_TYPE_ID");
	var DownCode1 = document.getElementById("NumCode1");
	var DownCode2 = document.getElementById("NumCode2");
	var DownCode3 = document.getElementById("NumCode3");
	var DownCode4 = document.getElementById("NumCode4");
	//var DownCode2Tips = document.getElementById("NumCode2Tips");
	//Filter_TYPE_ID
	var DownTypeValue = DownType.options[DownType.selectedIndex].value;
//	var SelectedDropParent = DropParent.options[DropParent.selectedIndex].value;
	//alert("Sm: "+DownTypeValue);
	
	if (DownTypeValue == '3' ){
		 //DownElement1.style.display = "";
		//DownElement2.disabled = false;
		 DownCode1.style.display = "none";
		 DownCode2.style.display = "";
		 //DownCode2Tips.style.display = "";
		 DownCode3.style.display = "";
		 DownCode4.style.display = "";
		 
	}else{
		// DownElement1.style.display = "none";
		 //DownElement2.disabled = true;
		 DownCode1.style.display = "";
		 DownCode2.style.display = "none";
		 //DownCode2Tips.style.display = "none";
		 DownCode3.style.display = "none";
		 DownCode4.style.display = "none";

	}
	//return true;	
}

// end blui ajax...

//Numberic Only

function NumOnly() {
	if (event.keyCode>='0'.charCodeAt()&&event.keyCode <= '9'.charCodeAt()||event.keyCode==','.charCodeAt())
		event.returnValue = true;
	else
	   // alert("Please Input  Numberic Only");   //form.aCountry.focus(); 
	   // return true;
		event.returnValue = false; 

}


function  ChkNumberOnly(field)
     {
          var check = true;
          var value = field.value; //get characters
          //check that all characters are digits, ., -, or ""
          for(var i=0;i < field.value.length; ++i)
          {
               var new_key = value.charAt(i); //cycle through characters
               if(((new_key < "0") || (new_key > "9")) && 
                    !(new_key == ""))
               {
                    check = false;
                    break;
               }
          }
          //apply appropriate colour based on value
          if(!check)
          {
               return false;
          }
          else
          {
               return false;
          }
     } //chk


function checkKeyCode(e) {
var iKeyCode;
if (!e) {
var e = window.event;
}
if (e.keyCode) {
iKeyCode = e.keyCode;
} else {
if (e.which) {
iKeyCode = e.which;
}
}
var thisChar = String.fromCharCode(iKeyCode);
alert('Character ' + thisChar + ' from keyCode ' + iKeyCode);
}

function numericOnly(e) {
		var iKeyCode;
		if (!e) {
		var e = window.event;
		}
		
		if (e.keyCode) {
			iKeyCode = e.keyCode;
		} else {
			if (e.which) {
			iKeyCode = e.which;
		}
		}
		
		switch(iKeyCode) {
		case 8:
		case 9:
		case 37:
		case 38:
		case 39:
		case 40:
		case 46:
		break;
		case 48:
		case 49:
		case 50:
		case 51:
		case 52:
		case 53:
		case 54:
		case 55:
		case 56:
		case 57:
		if (e.shiftKey || e.altKey){
		return false;
		}
		break;
		case 96:
		case 97:
		case 98:
		case 99:
		case 100:
		case 101:
		case 102:
		case 103:
		case 104:
		case 105:
		//return correct numeric from keypad
		return iKeyCode - 48; break;
		case 110:
		case 190:
		//if you are supporting decimal points
		return '.'; break;
		default: return false;
		}
}









