function el( element_id ) /// element
{
	return document.getElementById( element_id );
} 


function Trim(TRIM_VALUE)
 {
 	if(TRIM_VALUE.length < 1){ return""; }
 	TRIM_VALUE = RTrim(TRIM_VALUE);
 	TRIM_VALUE = LTrim(TRIM_VALUE);
 	 if(TRIM_VALUE==""){ return ""; } else{ return TRIM_VALUE; }
  }

  function RTrim(VALUE){
  	var w_space = String.fromCharCode(32);
  	var v_length = VALUE.length;
  	var strTemp = ""; 
  	if(v_length < 0){ return""; }
  	var iTemp = v_length -1;
  	while(iTemp > -1){ 
  		if(VALUE.charAt(iTemp) == w_space){}
  		else{ strTemp = VALUE.substring(0,iTemp +1); break; } 
  		iTemp = iTemp-1; }
  		return strTemp; }

  	function LTrim(VALUE){
  		var w_space = String.fromCharCode(32);
  		if(v_length < 1){ return""; }
  		var v_length = VALUE.length; 
  		var strTemp = "";
  		var iTemp = 0;
  		while(iTemp < v_length){ if(VALUE.charAt(iTemp) == w_space){} 
  		else{ strTemp = VALUE.substring(iTemp,v_length);
  		break; }
  		iTemp = iTemp + 1; } return strTemp;
  	 }
  	 
  	 
  	 
  	 ///////////
  	 
function doHelp(helpabout,show)
{
	var inpage = new Array('q');
	
	var help_div_id = helpabout + '_helpdiv'; 
	var startwith = el(helpabout).value;
	startwith = encodeURIComponent(startwith);
	startwith = LTrim(startwith);
	

	
	if( show == 0 || startwith.length<3 )
	{
		el(help_div_id).style.display = 'none';
	}
	else
	{
		loadHelp(helpabout);		
	}
}

function st(obj,helpabout)
{
	el(helpabout).value = obj.innerHTML;
	el( helpabout+'_helpdiv' ).style.display = 'none';
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
			} while (obj = obj.offsetParent);
		return [curleft,curtop];
}
}

function createFRequest()
    {
        var a_new_request = false;

        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            a_new_request = new XMLHttpRequest();
            if (a_new_request.overrideMimeType) {
                a_new_request.overrideMimeType('text/xml');
                // See note below about this line
            }
        } else if (window.ActiveXObject) { // IE
            try {
                a_new_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    a_new_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }
        
        return a_new_request;
    }

function loadHelp(helpabout)
{
	ajaxForLoad = createFRequest();	
	
	var reqType = typeof(ajaxForLoad);
	if ( reqType != 'object' ) { return false; }
	
	ajaxForLoad.onreadystatechange = function() { verifyLoadHelpReturnedValue( ajaxForLoad , helpabout ); }

	var startwith = LTrim( encodeURIComponent( el(helpabout).value ) );
	
	actionpage = 'get-places.php?startwith='+startwith+"&helpabout="+helpabout;
	ajaxForLoad.open('GET',actionpage,true);
	ajaxForLoad.send(null);
	
	return false;
}

function verifyLoadHelpReturnedValue( http_req , helpabout )
{
	if (http_req.readyState == 4) {
		if (http_req.status == 200) {

			var t = http_req.responseText;
			var help_div_id = helpabout + '_helpdiv';
			var dim = findPos( el(helpabout) );

			el(help_div_id).style.display = 'block';
			el(help_div_id).style.position = 'absolute';
			el(help_div_id).style.left = (dim[0]) + 'px';
			el(help_div_id).style.top = (dim[1]+17) + 'px';
			if( t.length > 0 )
			{
				el(help_div_id).innerHTML = t;
			}
			else
			{
				el(help_div_id).style.display = 'none';
			}
		}
	}
}

function go(page)
{
	window.location = 'http://www.fexon.com/'+page;
}