// trim stringfunction trim(str){    if(!str || typeof str != 'string')        return null;    return str.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' ');}// check valid/invalid email addressfunction email_check(str){	var at="@"	var dot="."	var lat=str.indexOf(at)	var lstr=str.length	var ldot=str.indexOf(dot)	if (str.indexOf(at)==-1){	   return false	}	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){	   return false	}	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){		return false	}	 if (str.indexOf(at,(lat+1))!=-1){		return false	 }	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){		return false	 }	 if (str.indexOf(dot,(lat+2))==-1){		return false	 }	 if (str.indexOf(" ")!=-1){		return false	 }	 return true}// create pop-up windowfunction popUp(URL, width, height, left, top) {	day = new Date();	id = day.getTime();	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + "');");}//redirect to given urlfunction redirect(URL){	window.location=URL;}// count text inside textbox/textarea & display it in real timefunction textCounter(field, countfield, maxlimit){	if (field.value.length > maxlimit)		field.value = field.value.substring(0, maxlimit);	else		countfield.value = maxlimit - field.value.length;}// check valid/invalid username addressfunction validateUsername(fld) {    var error = "";    var illegalChars = /\W/; // allow letters, numbers, and underscores    if (fld.value == "") {        error = "&bull; Please enter Username<br>";    } else if ((fld.value.length < 5) || (fld.value.length > 15)) {        error = "&bull; Username must have 5-15 characters<br>";    } else if (illegalChars.test(fld.value)) {		error = "&bull; Please enter valid Username. Use only numbers and alphabets<br>";    } else {        error = "";    }    return error;}//===================== commonly used javascript on admin pages ========================//CHECK ALL RECORDSfunction check_list(){    var theForm = document.frmList;	if(theForm.check_all.checked==true)		a=1;	else		a=0;    for (i=1; i<theForm.elements.length; i++)	{        if (theForm.elements[i].name=='mycheckbox[]')            theForm.elements[i].checked = a;    }}//CHECKS THAT ANY RECORD IS CHECKED OR NOTfunction any_checked(){	var theForm = document.frmList;	var check_flag=0;	for (i=0; i<theForm.elements.length; i++)	{   		if(theForm.elements[i].checked==true)            check_flag=1;    }	if(check_flag==1)		return true;	else		return false;}//========================================================================================function IsNumeric(s){	return (s.toString().search(/^-?[0-9]+$/) == 0);	/*var ValidChars = "0123456789";	var IsNumber=true;	var Char;	for (i = 0; i < sText.length && IsNumber == true; i++)	{		Char = sText.charAt(i);		if (ValidChars.indexOf(Char) == -1)		{			IsNumber = false;		}	}	return IsNumber;*/}function IsDecimal(sText){	var ValidChars = "0123456789.";	var IsDecimal=true;	var Char;	for (i = 0; i < sText.length && IsDecimal == true; i++)	{		Char = sText.charAt(i);		if (ValidChars.indexOf(Char) == -1)		{			IsDecimal = false;		}	}	return IsDecimal;}

function check_search_form()
{
	if(document.frmSearch.keyword.value=="" || document.frmSearch.keyword.value==null)
	{
		alert("Please enter Keyword to search.");
		return false;
	}
	else
	{
		return true;
	}
}
