
function ChkNum(strNum)
{
	//This function will check if the string passed is a number
	var strBase1="48|49|50|51|52|53|54|55|56|57|"; //For nos
	
	var strcode;
	var i;
	
	
	for(i=0;i<strNum.length;i++)
	{
		strcode=strNum.charAt(i);
		if (strBase1.search(strNum.charAt(i))==-1)
		{
			alert("Please enter a valid zip code.");
			return false;
		}
	}
	return true;
	
}

function validatePhoneFax(strPhoneFax,choice)
{
	//This function will check for valid characters entered  in the phone and fax text
	
	var strBase1="48|49|50|51|52|53|54|55|56|57|"; //For nos
	
	var strcode;
	var i;
	
	for(i=0;i<strPhoneFax.length;i++)
	{
		strcode=strPhoneFax.charAt(i);
		if (strBase1.search(strPhoneFax.charCodeAt(i))==-1)
		{
			if(strcode != "-")
			{
				if (choice == "P")
					alert("Please enter a vaild Phone number. (e.g : 91-20-5449683)");
				else if (choice=="F")	
					alert("Please enter a valid Fax. (e.g : 91-20-5449683)")
					
				return false;
			}
		}
		
	}
	return true;

}
	
function validateEmailAddr(straddr)	
{

	var strBase1="48|49|50|51|52|53|54|55|56|57|"; //For nos
	var strBase2="65|66|67|68|69|70|71|72|73|74|75|75|76|77|78|79|78|79|80|81|82|83|84|85|86|87|88|89|90|";//for caps alphabets
	var strBase3="97|98|99|100|101|102|103|104|105|106|107|108|109|110|111|112|113|114|115|116|117|118|119|120|121|122|";//for small alphabets
	var strSpecialChar="45|95" //minus , underscore
	var strBaseString=strBase1 + strBase2 + strBase3
	
	
	var strcode;
	
	
	var IndAtRate;
	var IndDot;
	
	
	var i;
	
	IndAtRate=0;
	IndDot=0;
	
	
	for (i=0;i<straddr.length;i++)
	{
		strcode=straddr.charAt(i)
		
		if(strBaseString.search(straddr.charCodeAt(i))==-1)
		{
			if (strcode=="@" )
			{
				IndAtRate=i;
			}else if(strcode==".")
			{
				IndDot=i;
			}else if(strSpecialChar.search(straddr.charCodeAt(i))!=-1)
			{
				
			}
			else
			{
				alert("Please enter a vaild email Id.");
				return false;
			}
		}  
			
		
		
	}
	if ((IndDot != 0) && (IndAtRate !=0))
	{
		if ((IndDot > IndAtRate) )//&& (IndAtRate > IndUnderscore)
		{
			return true;
		}else
		{
			alert("Please enter a vaild email Id.");
			return false;
		}
	}
	else
	{
		alert("Please enter a vaild email Id.");
		return false;
	}
}


	function jsTrim(sInputString) {
		// Removes leading and trailing spaces from the passed string. Also removes
		// consecutive spaces and replaces it with one space. If something besides
		// a string is passed in (null, custom object, etc.) then return the input.

		if (typeof sInputString != "string") { 
			return sInputString; 
		}

		var retValue = sInputString;
		var ch = retValue.substring(0, 1);

		while (ch == " ") { // Check for spaces at the beginning of the string
		   retValue = retValue.substring(1, retValue.length);
		   ch = retValue.substring(0, 1);
		}

		ch = retValue.substring(retValue.length-1, retValue.length);

		while (ch == " ") { // Check for spaces at the end of the string
		   retValue = retValue.substring(0, retValue.length-1);
		   ch = retValue.substring(retValue.length-1, retValue.length);
		}

	return retValue; // Return the trimmed string back to the user

	} // Ends the "trim" function
