function validatePassword(password,confirmPassword)
{
	if( (password.value != confirmPassword.value) || (password.value=='') || (confirmPassword.value =='') )
	{
		
		return false;
	}
	else 
	 return true;
}


function echeck(str) 

{



		var at="@"

		var dot="."

		var lat=str.indexOf(at)

		var lstr=str.length

		var ldot=str.indexOf(dot)

		if (str.indexOf(at)==-1){

		   alert("Invalid E-mail ID")

		   return false

		}



		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){

		   alert("Invalid E-mail ID")

		   return false

		}



		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){

		    alert("Invalid E-mail ID")

		    return false

		}



		 if (str.indexOf(at,(lat+1))!=-1){

		    alert("Invalid E-mail ID")

		    return false

		 }



		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){

		    alert("Invalid E-mail ID")

		    return false

		 }



		 if (str.indexOf(dot,(lat+2))==-1){

		    alert("Invalid E-mail ID")

		    return false

		 }

		

		 if (str.indexOf(" ")!=-1){

		    alert("Invalid E-mail ID")

		    return false

		 }



 		 return true					

	}



function validateEmail(emailID)

{

	if ((emailID.value==null)||(emailID.value=="")){

		alert("Please Enter your Email ID")

		emailID.focus()

		return false

		

	}

	if (echeck(emailID.value)==false){

		emailID.value=""

		emailID.focus()

		return false

	}

	

	

	return true

 }

function validateReg()
{
	
	
	var email = document.getElementById('email');
	var name = document.getElementById('name');
	var password = document.getElementById('firstPassword');
	var confirmPassword = document.getElementById('confirmPassword');
	var phoneNumber = document.getElementById('phoneNumber');
	
	
	if(validateEmail(email))
	{
		 if(name.value=='' )
		 {
		 	alert("Please fill the name field");
			return false;
		 }
		 else if(validatePassword(password,confirmPassword))
		 {
			if(phoneNumber.value!='')
			{
				
				if(phoneNumber.value.indexOf(" ") != -1 || phoneNumber.value.length != 10)
				{
					alert('Incorrect Mobile Number');
					return false;
				}
				
				return true;
			}
			else
			{
				alert('Fill the Phone Number');
				return false;
			}
		 }
		else
		{
			alert('Passwords are not matching');
				return false;
		}
	
	}
	else
	{
		
		return false;
	}
	
	
	
}


function forgotPassword()
{
	
	divId = document.getElementById("forgotDiv");
	elem = document.getElementById("displayForgot");
	
	if(divId.style.display == 'none')
	{
		var offsets = Position.cumulativeOffset(elem);
			
			divId.style.top = (offsets[1] - 7)+"px";
			divId.style.left = (offsets[0] - 35)+"px";
			divId.style.display = "block";
	}
	else
	{
		
		if(document.getElementById('invalidDiv'))
		{
			document.getElementById('invalidDiv').innerHTML = '';	
		}
		
		divId.style.display = "none";
	}
}

