//to trim spaces
function trim(str) 
{ 
	return str.replace(/^\s*|\s*$/g,""); 
}

// check for no space
function blockChar(e)
{
	var key;
	var keychar;
	var reg;
	
	if(window.event) {
		// for IE, e.keyCode or window.event.keyCode can be used
		key = e.keyCode; 
	}
	else if(e.which) {
		// netscape
		key = e.which; 
	}
	else {
		// no event, so pass through
		return true;
	}

	keychar = String.fromCharCode(key);	

	if (key == 32 )
	{
		return false;
	}
	else
	{
		return true;
	}
}

function blockCharacters(e)
{
	var key;
	var keychar;
	var reg;
	
	if(window.event) {
		// for IE, e.keyCode or window.event.keyCode can be used
		key = e.keyCode; 
	}
	else if(e.which) {
		// netscape
		key = e.which; 
	}
	else {
		// no event, so pass through
		return true;
	}

	keychar = String.fromCharCode(key);	

	if ((key == 13) ||(key == 32) ||(key == 34) ||(key == 39) || ((key >= 48) && (key <= 57)) || ((key >= 65) && (key <= 90)) || ((key >= 97) && (key <= 122)))
	{
		return true;
	}
	else
	{
		return false;
	}
}
//  check for valid numeric strings	
function IsNumeric(strString)
{
	var strValidChars = "0123456789.- ";
	var strChar;
	var blnResult = true;
	
	if (strString.length == 0) return false;
	
	//  test strString consists of valid characters listed above
	for (i = 0; i < strString.length && blnResult == true; i++)
	{
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1)
		{
			blnResult = false;
		}
	}
	
	return blnResult;
}

//  checks that the email address has one (@), atleast one (.). It also makes sure that there are no spaces, extra '@'s or a (.) just before or after the @. It also makes sure that there is atleast one (.) after the @.
function isValidEmail(str) 
{
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	
	if (str.indexOf(at)==-1) return false;
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) return false;
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) return false;
	if (str.indexOf(at,(lat+1))!=-1) return false;
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) return false;
	if (str.indexOf(dot,(lat+2))==-1) return false;
	if (str.indexOf(" ")!=-1) return false;
	
	return true;					
}