/* checks if an email is a valid email */
function emailCheck(inst){
	var chck = document.getElementById(inst).value;
	if(chck.indexOf("@") == -1 || chck.indexOf(".") == -1 || chck.length < 5 || chck.indexOf(".@") >= 0 || chck.indexOf("@.") >= 0){
		window.alert("Please enter a valid email address. Thank You.");
		return false;
	}
	/*var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
	for (i=0; i<invalidChars.length; i++) {
	   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
	      if (db) alert('The email address contains invalid characters.');
	      return false;
		  
	   }
	}*/
}
/*
[page,name,wt,ht[,scrolls]]
page:string = url of popup;
name:string = variable name popup reference will be assigned to;
wt:int = width of popup;
ht:int = height of popup;
scrolls:boolean = show scroll bar or not;
*/
function popup(page,name,wt,ht,scrolls){
	if(this[name]){
		this[name].close();
	}
	if(scrolls == true){
		scrolls=1;
	}else{
		scrolls=0;
	}
	this[name] = window.open(page,name,"location=0,scrollbars="+scrolls+",width="+wt+",height="+ht+",status=0,resizable=0");
	this[name].focus();
	return false;
}
// Trims whitespace from right/left of string. Got source from http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=3621&lngWId=2
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;
}