function isEmail(strValue)
{
	var re;
//	re = /^[\w-][\w-.]*[\w-]@[\w-][\w-.]*[\w]$/;
	re = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	if (strValue.match(re))
		return true;
	else
		return false;
}
function isEmailValid(strEmail)
{
	/* The following pattern is used to check if the entered e-mail address
		fits the user@domain format.  It also is used to separate the username
		from the domain. 
		
		Now, as you know, email address are always in a particular format:
		username @ domain . extension

		That makes them an ideal candidate to be tested with a regular expression. 
		So let's take a look at an expression I wrote to check the validity of an 
		email address. We'll look at each section of the expression individually. 
		But first, here's the expression itself:
		
		^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.([a-zA-Z]{2,99})$

		Let's split it into sections and make sense of each part individually:

		^[a-zA-Z0-9._-]+@

		This part of the expression validates the 'username' section of the email address. 
		The hat sign (^) at the beginning of the expression represents the start of the 
		string. If we didn't include this, then someone could key in anything they wanted 
		before the email address and it would still validate.

		Contained in the square brackets are the characters we want to allow in this part 
		of the address. Here, we are allowing the letters a-z, A-Z, the numbers 0-9, and 
		the symbols underscore (_), period (.), and dash (-). The order of the character 
		pairs within the brackets doesn't matter.

		The plus (+) sign after the square brackets indicates 'one or more of the contents of 
		the previous brackets'. So, in this case, we require one or more of any of the 
		characters in the square brackets to be included in the address in order for it to 
		validate. Finally, there is the '@' sign, which means that we require the presence of 
		one @ sign immediately following the username.

		[a-zA-Z0-9._-]+\.

		This part of the expression is very similar to the section we looked at. It validates 
		the domain name in the email address. As before, we have a series of characters in 
		square brackets that we'll allow in this part of the address, followed by a plus (+) 
		sign, requiring one or more of those characters.

		At the end of this section, there is a backslash, then a period sign. This tells the 
		expression that a period is required at this point in the expression (ie. [5] between 
		the domain and extension). However, the backslash is slightly more complicated. 
		In a regular expression, a period actually means 'any character'. In order to make 
		this expression take the period's literal value rather than use it as a wildcard for 
		any character, we need to 'escape' it -- this is done by preceding the period with a 
		backslash. 

		[a-zA-Z]{2,4}$

		This is the final part of the expression. At the beginning is another set of 
		characters enclosed in square brackets. This time, I have simply allowed the 
		letters a-z and A-Z, because numbers and other characters are not valid in 
		domain extensions. 

		Instead of the + sign we used before, here we have '{2,99}' immediately following 
		the square brackets. This means that we require between 2 and 99 of the characters 
		from the square brackets to be included in the email address. 
		So com, net, org, uk, au, etc. are all valid, but anything longer than 99 
		will not be accepted. 

		Finally, the $ sign at the end of the expression signifies the end of the string.
		If we didn't include this, then a user could type anything after the end of the 
		email address and it would still validate.

		*/
		var strEmailPat="^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.([a-zA-Z]{2,99})$";


		var arrMatchArray=strEmail.match(strEmailPat);

		if (arrMatchArray==null) {

			//Invalid email syntax
			alert("Email address seems incorrect.");
			return false;
		}else{
			//display each part of the email
			var strUser = arrMatchArray[0];
			var tmp = strUser.split("@");
			var strTLD = "";
			
			strUser = tmp[0];
			var strHost = tmp[1];
			tmp = strHost.split(".");
			
			for(var i=0; i<tmp.length; i++){
				if(i == 0)
					strHost = tmp[i];
				else{
					if(i == tmp.length-1)
						strTLD += tmp[i];
					else
						strTLD += tmp[i] + "|";
				}
			}
			
		}
		
		return true;
}
function isZipCode(strValue)
{
	var re;
	re = /^\d{5}$/;
	if (strValue.match(re))
		return true;
	else
		return false;
}

function isPhoneNumber(strValue)
{
	var re;
	re = /^\d{3}-\d{3}-\d{4}$/;
	if (strValue.match(re))
		return true;
	else
		return false;
}

function isPhoneNumberExt(strValue)
{
	var re;
	re = /^\d{1,5}$/;
	if (strValue.match(re))
		return true;
	else
		return false;
}


function isYearOfExp(strValue)
{
	var re;
	re = /^\d{1,3}$/;
	if(strValue.match(re))
		return true;
	else
		return false;
}

function trim(strValue) {
	return trimRight(trimLeft(strValue));	
}

function trimLeft(strValue) {
	if (strValue == null) return null;
	if (strValue.length == 0) return strValue;
	for (i=0; i<strValue.length; i++) {
		if (strValue.charAt(i) != ' ')
			return strValue.substr(i);
	}
	return "";
}

function trimRight(strValue) {	
	if (strValue == null) return null;
	if (strValue.length == 0) return strValue;
	for (i=strValue.length-1; i>=0; i--) {
		if (strValue.charAt(i) != ' ')
			return strValue.substring(0, i+1);
	}
	return "";
}

function salOpenWindow(strUrl,strWindowName,strWidth,strHeight,strToolbar,strScrollbar,strResizable){		
	var strAttributes;
	strAttributes = "toolbar=" + strToolbar + ",scrollbars=" + strScrollbar + ",resizable=" + strResizable + ",width=" + strWidth + ",height=" + strHeight + ",left=0,top=0";
	 var subWin = window.open(strUrl,strWindowName,strAttributes);		
		
	if(subWin!=null) subWin.focus;
	    	
}	

function openFormWindow(strUrl, strWindowName, strWidth, strHeight){		
			
	 var subWin = window.open(strUrl,strWindowName,
							"toolbar=no,scrollbars=yes," + 
								"resizable=yes,width=" + strWidth + "," +
									"height=" + strHeight + ",left=100,top=50");		
		
	if(subWin!=null) subWin.focus;
	    	
}
