/**************************************************************
Method Name	:	ValidateEmailAddress
Description	:	Validate for the Email address
Parameter	:	1.	Email address (string)
Return		:	True if email address is correct else false.
**************************************************************/
function ValidateEmailAddress(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;
}

/**************************************************************
Method Name	:	checkKeyforCharacters
Description	:	Allow of only numerical characters
Parameter	:	1.	character 
Return		:	allows the character :  if the character is numerical
**************************************************************/
function checkKeyforCharacters(obj)
{				
	if (((window.event.keyCode >=65  && window.event.keyCode <=92)||
		(window.event.keyCode >=97  && window.event.keyCode <=123)||
		(window.event.keyCode == 45)|| (window.event.keyCode==46)||
		(window.event.keyCode == 95)))
		{
			window.event.keyCode = 0;			
		}
}

function checkKeyforCharactersfordecimal(obj)
{					
	if (((window.event.keyCode >=65  && window.event.keyCode <=92)||
		(window.event.keyCode >=97  && window.event.keyCode <=123)||
		(window.event.keyCode == 45)|| (window.event.keyCode==39)||
		(window.event.keyCode == 95)))
		{
			window.event.keyCode = 0;			
		}
}

function checkKeyforCharactersforPhone(obj)
{			
	if (((window.event.keyCode >=65  && window.event.keyCode <=92)||
		(window.event.keyCode >=97  && window.event.keyCode <=123)||
		(window.event.keyCode==46)||
		(window.event.keyCode == 95)))
		{
			window.event.keyCode = 0;			
		}
}

function countdown(main,totval) {
	if (totval-main.value.length <=0) {
		main.value = main.value.substr(0,totval);						
		return false;
	}				
}
