// the asp.net modify the id (add the name of ascx plus underscore) of button to avoid id conflict!
var searchParam = '';

// Set text field value
/*
var oInput = document.getElementById(searchParam+'txtSearch');
//if (oInput == null){
//	oInput = document.getElementById("SearchBox_" + ObjName); // the asp.net modify the id (add the name of ascx plus underscore) of button to avoid id conflict!

var query = window.location.search.substring(1);
var parms = query.split('&');
var iBegin = query.indexOf('q=');
if (iBegin > -1) {
	iBegin +=5
	var iEnd = query.indexOf('&', iBegin);
	if (iEnd > -1) {
		oInput.value = decodeURI(query.substring(iBegin, iEnd));
	} else {
		oInput.value = decodeURI(query.substring(iBegin));		
	}
}
*/

function SearchBoxEnterKey(e, ObjName, setFocus){
	// sample: <INPUT type="text" id="myInput" onkeydown="return EnterKeyControl(event, 'myInput2', true);"/> 'move focue to next control 'myInput2'
	// sample: <INPUT type="text" id="myInput" onkeydown="return EnterKeyControl(event, 'myBtn', false);"/> 'run myBtn.click()
	// this sample will stop the automatically clientside postback
	var bRtn = true;

	if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)){
	    ObjName = searchParam + ObjName;
		var oInput = document.getElementById(ObjName);
		//if (oInput == null){
		//	oInput = document.getElementById("SearchBox_" + ObjName); // the asp.net modify the id (add the name of ascx plus underscore) of button to avoid id conflict!
		//	}
			
		if (oInput != null){
			if (setFocus == true){
				oInput.focus();
				}
			else {
				//alert("trigger oInput.click();")
				oInput.click();
				}
			bRtn = false;
			}
		} 
		
	return bRtn;
	}

function SearchButton(ObjName) {
    ObjName = searchParam + ObjName;
	var oInput = document.getElementById(ObjName);
	//if (oInput == null){
	//	oInput = document.getElementById("SearchBox_" + ObjName); // the asp.net modify the id (add the name of ascx plus underscore) of button to avoid id conflict!
	//	}
	// if search box is empty, do nothing!
	if (oInput.value != "") {	
		parent.location='SearchResult.aspx?srtid=0&q='+escape(oInput.value)+LangIDQueryString();
		}
	}

function LangIDQueryString() {
	///*
	var o = document.getElementById(searchParam+"hdnLangID");
	var s = "";
	//if (o == null){
	//	o = document.getElementById("SearchBox_hdnLangID"); // the asp.net modify the id (add the name of ascx plus underscore) of button to avoid id conflict!
	//	}
	if (o.value != "") {	
		s="&langid="+o.value;
		}
	else {
		s="";
		}
	return s;
	//*/
	//return '';
	}


