//This Function Shows Filters
function showFilter(divid) {
	if (document.getElementById(divid).style.display == "none")
		document.getElementById(divid).style.display = "block";
	else
		document.getElementById(divid).style.display = "none";
}

//This function email format to be entered in Text box
function isemail(m) {
	len=m.length;
	i=0;
	// Checking for "@" in the address
	while((i<len) && (m.charAt(i)!="@"))
		i++;
	if((i>=len) || (m.charAt(i)!="@")) return(false);
		i+=2;
	// Checking for "." in the address
	while((i<len) && (m.charAt(i)!="."))
		i++;
	if((i>len-1) || (m.charAt(i)!=".")) return(false);
		return(true)
}

//This function stops non numeric values to be entered in Text box
function AllowNumeric(e, sText)	{ 
	var key, keychar, Char, i, ValidChars;
	ValidChars = "-";
	l = sText;
	if (window.event)
		key = window.event.keyCode;
	else if (e)
		key = e.which;
	else
		return true;
	keychar = String.fromCharCode(key);
	if ((key==null) || (key==0) || (key==8) ||(key==9) || (key==13) || (key==27) || (key==48) || (key==49) || (key==50) ||(key==51) || (key==52) || (key==53) || (key==54) || (key==55) ||(key==56) || (key==57) || (key==45)  ) {
		if(keychar == "-") {
			return false;
		}
		return true;
	}
	else
		return false;
}   

//This function stops non decimal values to be entered in Text box
function AllowDecimal(e, sText) { 
	var key;
	var keychar;
	var Char;
	var i;
	var ValidChars;
	var ValidChars1;
	ValidChars  = ".";
	ValidChars1  = "-";
	l=sText;
	
	if (window.event)
		key = window.event.keyCode;
	else if (e)
		key = e.which;
	else
		return true;
	keychar = String.fromCharCode(key);
		if ((key==null) || (key==0) || (key==8) ||(key==9) || (key==13)  || (key==48) || (key==49) || (key==50) ||(key==51) || (key==52) || (key==53) || (key==54) || (key==55) ||(key==56) || (key==57)  || (key==2) || (key==46) || (key==45)) {
		if(keychar == ".") {
			for (i = 0; i < l.length; i++) { 
				Char = l.charAt(i);
				if (ValidChars.indexOf(Char) != -1) 
					return false;
			}
		}
		if(keychar == "-") {
			return false;
		}
		return true;
	}
	else if (key==22)
		return false;
	else
		return false;
}           

//This function stops wildcards to be entered in Text box
function disallowWildCard(e, sText)	{ 
	var key, keychar, Char, i;
	l = sText;
	if (window.event)
		key = window.event.keyCode;
	else if (e)
		key = e.which;
	else
		return true;
	keychar = String.fromCharCode(key);
	if(keychar == "%")
		return false;
	else
		return true;
}

// Start: Trim Function 
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;
}

