
function checkMapSearch(objForm)
{	 
	email	=	trimSpaces(objForm.email.value);
	name	=	trimSpaces(objForm.name.value);
	address	=	trimSpaces(objForm.address.value);
	 
				 
	if(name=="")		
	{alert("Please Enter Your Name");
	objForm.name.focus();
	return false;}
			if(address=="")		
			{alert("Please Enter Your Address");
			objForm.address.focus();
			return false;}
	if(!checkEmail(email))
	{objForm.email.focus();
	return false;}
}

/////////////////////////////////////////////////////////////////////////////////////////
// Checks whether a string is a valid email address.
/////////////////////////////////////////////////////////////////////////////////////////
function checkEmail(emailString) {
	splitVal = emailString.split('@');
	
	if(splitVal.length <= 1) {
		alert("Please enter a valid email address");
		return false;
	}
	if(splitVal[0].length <= 0 || splitVal[1].length <= 0) {
		alert("Please enter a valid email address");
		return false;
	}
	
	splitDomain = splitVal[1].split('.');
	if(splitDomain.length <= 1) {
		alert("Please enter a valid email address");
		return false;
	}
	if(splitDomain[0].length <= 0 || splitDomain[1].length <= 1) {
		alert("Please enter a valid email address");
		return false;
	}
	return true;
}

/////////////////////////////////////////////////////////////////////////////////////////
// Removes the leading and trailing spaces in a strings and returns the trimmed string
/////////////////////////////////////////////////////////////////////////////////////////
function trimSpaces(stringValue) {
	// Checks the first occurance of spaces and removes them
	for(i = 0; i < stringValue.length; i++) {
		if(stringValue.charAt(i) != " ") {
			break;
		}
	}
	if(i > 0) {
		stringValue = stringValue.substring(i);
	}
	
	// Checks the last occurance of spaces and removes them
	strLength = stringValue.length - 1;
	for(i = strLength; i >= 0; i--) {
		if(stringValue.charAt(i) != " ") {
			break;
		}
	}
	if(i < strLength) {
		stringValue = stringValue.substring(0, i + 1);
	}
	
	// Returns the string after removing leading and trailing spaces.
	return stringValue;
}

/*
On key Press check field data...
N - Allows Only Numerics
NDH - Allows Only Numerics, Dot, Hyphen
ND - Allows Only Numerics, Dot
A - Allows Omly Alphabets and spaces
CA - Allows Only capital letters
SA - Allows Only Small letters
AN - Allows Alphabets and numbers but no special charecters..
E - Allows emailaddress only
W - Allows web Url only
ANHD- Allows Alphabets,spaces and numbers but no special charecters except dot,Hyphen..

Eg:--  onKeyPress="return CheckField(this, event, 'ANHD')"
*/
function CheckField(myfield, e, type)
{
    var key;
    var keychar;
 
    if (window.event)
    {
        key = window.event.keyCode;
    }
    else if (e)
    {
        key = e.which;
    }
    else
    {
        return true;
    }
	if(type == 'NDH')
	{
		//key != 0 && key != 8 && key != 32 && 
		if(key != 0 && key != 8 && key != 32 && key != 46 && key != 45 && key > 31 && (key < 48 || key > 57))
		{ return false; }
		else
		{ return true; }
	}
	if(type == 'ND')
	{
		if(key != 0 && key != 8 && key != 32 && key != 46 && (key < 48 || key > 57))
		{ return false; }
		else
		{ return true; }
	}
	if(type == 'N')
	{
		if(key != 0 && key != 8 && key != 32 && (key < 48 || key > 57))
		{ return false; }
		else
		{ return true; }
	}
	if(type == 'A')
	{
		if(key != 0 && key != 8 && key != 32 && (key < 65 || key > 90) && (key < 97 || key > 122))
		{ return false; }
		else
		{ return true; }
	}
	if(type == 'CA')
	{
		if(key != 0 && key != 8 && key != 32 && (key < 65 || key > 90))
		{ return false; }
		else
		{ return true; }
	}
	if(type == 'SA')
	{
		if(key != 0 && key != 8 && key != 32 && (key < 97 || key > 122))
		{ return false; }
		else
		{ return true; }
	}
	if(type == 'AN')
	{
		if(key != 0 && key != 8 && key != 32 && (key < 65 || key > 90) && (key < 97 || key > 122) && (key < 48 || key > 57))
		{ return false; }
		else
		{ return true; }
	}
	if(type == 'ANHD')
	{
		if(key != 0 && key != 8 && key != 32 && key != 46 && key != 45 && (key < 65 || key > 90) && (key < 97 || key > 122) && (key < 48 || key > 57))
		{ return false; }
		else
		{ return true; }
	}
	if(type == 'E')
	{
		if(key != 0 && key != 8 && key != 32 && key != 46 && key != 95 && key != 64 && (key < 65 || key > 90) && (key < 97 || key > 122) && (key < 48 || key > 57))
		{ return false; }
		else
		{ return true; }
	}
	if(type == 'W')
	{
		if(key != 0 && key != 8 && key != 32 && key != 46 && key != 45 && key != 95 && (key < 65 || key > 90) && (key < 97 || key > 122) && (key < 48 || key > 57))
		{ return false; }
		else
		{ return true; }
	}
	if(type == 'TEST')
	{
		alert(key);
		if(key != 0 && key != 8 && key != 32 && (key < 65 || key > 90) && (key < 97 || key > 122) && (key < 48 || key > 57))
		{ return false; }
		else
		{ return true; }
	}
}


