String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

function findPosX(obj)
	{
	var curleft = 0;
	if(obj.offsetParent)
		while(1) 
			{
			curleft += obj.offsetLeft;
			if(!obj.offsetParent)
				break;
			obj = obj.offsetParent;
			}
	else if(obj.x)
		curleft += obj.x;
	return curleft;
	}
function findPosY(obj)
	{
	var curtop = 0;
	if(obj.offsetParent)
		while(1)
			{
			curtop += obj.offsetTop;
			if(!obj.offsetParent)
				break;
			obj = obj.offsetParent;
			}
		else if(obj.y)
			curtop += obj.y;
	return curtop;
	}
function isEmail(elm) {
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if(!reg.test(elm.value)) {
	  return false;
	}
	return true;
}
function isPhone(elm) {
	var str = elm.value;
	str = str.replace(/[-.()\s]/g,'');
	if(str.length > 10) 
		{
		str = str.substr(1,10);
		}
	str = "1-" + str.substr(0,3) + "-" + str.substr(3,3) + "-" + str.substr(6,4);
	//alert(str);
	if((str.match(/^(1?[-.]?\d{3}[-.]?\d{3}[-.]?\d{4})$/) != null)){
		//str = str.replace(/[-.]/g,'');
		elm.value = str;//"1-" + str.substr(0,3) + "-" + str.substr(3,3) + "-" + str.substr(6,4);
		return true; 
	}
	return false; 
}	
function isUSZIP(elm) {
	return (elm.value.match(/^\d{5}$/) != null); 
}	
function isCAZIP(elm) {
	if(elm.value.match(/^[a-zA-Z]\d[a-zA-Z] ?\d[a-zA-Z]\d$/) != null) {
		var str = elm.value.toUpperCase();
		str = str.replace(/ /g,'');
		elm.value = str.substr(0,3) + " " + str.substr(3,3);
		return true;
	}
	return false;
}	
function isFilled(elm) {
	if (elm.value !="" || elm.value == null)
		return true;
	else return false;
}
function numericValidate(val, label, notReq)
	{
	if(notReq && val == '')
		return true;
	if(val == '' || isNaN(val) == true)
		{
		alert(label + ' value is not a valid number'); 
		return false;
		}
	return true;
	}
