// JavaScript Document





function checkemail(str)

{

 var str=document.ff.email.value;



var at="@"

var dot="."

var lat=str.indexOf(at)

var lstr=str.length

var ldot=str.indexOf(dot)

if (str.indexOf(at)==-1)

{

   document.getElementById('email1').innerHTML="Enter valid Email Address..!!";

   document.ff.email.value="";

   document.ff.email.focus();

   return false;

}



if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)

{

    document.getElementById('email1').innerHTML="Enter valid Email Address..!!";

 	document.ff.email.value="";

  	document.ff.email.focus();

   return false;

}

if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)

{

   document.getElementById('email1').innerHTML="Enter valid Email Address..!!";

   document.ff.email.value="";

   document.ff.email.focus();

   return false;

}

if (str.indexOf(at,(lat+1))!=-1)

 {

   document.getElementById('email1').innerHTML="Enter valid Email Address..!!";

   document.ff.email.value="";

   document.ff.email.focus();

   return false;

 }

if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)

 {

     document.getElementById('email1').innerHTML="Enter valid Email Address..!!";

  	 document.ff.email.value="";

  	 document.ff.email.focus();

     return false;

 }

 if (str.indexOf(dot,(lat+2))==-1)

 {

    document.getElementById('email1').innerHTML="Enter valid Email Address..!!";

	document.ff.email.value="";

  	document.ff.email.focus();

    return false;

 }

 if (str.indexOf(" ")!=-1)

 {

    document.getElementById('email1').innerHTML="Enter valid Email Address..!!";

	document.ff.email.value="";

  	document.ff.email.focus();

    return false;

 }

}







function FormatNumber(num, format, shortformat)

{

	 if(format==null)

		 {

			 format = "#-###-###-####";   // Telephone w/ Area Code

		 }

	if(shortformat==null)

		 {

			var shortformat = "";

		 }

			 var validchars = "0123456789";

			 var tempstring = "";

			 var returnstring = "";

			 var extension = "";

			 var tempstringpointer = 0;

			 var returnstringpointer = 0;

			 count = 0;



	 // Get the length so we can go through and remove all non-numeric characters

			 var length = num.value.length;





	 // We are only concerned with the format of the phone number - extensions can be left alone.

	 if (length > format.length)

		 {

			 length = format.length;

		 };





	 // scroll through what the user has typed

	 for (var x=0; x<length; x++)

		 {

			  if (validchars.indexOf(num.value.charAt(x))!=-1)

				  {

					 tempstring = tempstring + num.value.charAt(x);

				  };

		 };



	 // We should now have just the #'s - extract the extension if needed

	 if (num.value.length > format.length)

		 {

			length = format.length;

			extension = num.value.substr(format.length, (num.value.length-format.length));

		 };



	// if we have fewer characters than our short format, we'll default to the short version.

	for (x=0; x<shortformat.length;x++)

		{

			if (shortformat.substr(x, 1)=="#")

				{

					count++;

				};

		}

	if (tempstring.length <= count)

	 {

		format = shortformat;

	 };



	

	//Loop through the format string and insert the numbers where we find a # sign

	for (x=0; x<format.length;x++)

		{

			if (tempstringpointer <= tempstring.length)

			   {

				if (format.substr(x, 1)=="#")

					{

						returnstring = returnstring + tempstring.substr(tempstringpointer, 1);

						tempstringpointer++;

					}

				else

					{

						returnstring = returnstring + format.substr(x, 1);

					}

				}

		}

	

	// We have gone through the entire format, let's add the extension back on.

		returnstring = returnstring + extension;

	

	//we're done - let's return our value to the field.

		num.value = returnstring;

	}


function validate()

{
document.getElementById('fname1').innerHTML="";
if(document.getElementById('fname').value=="")

 {

 	document.getElementById('fname1').innerHTML="Please Enter the First name";

    //alert('Please Enter the old Username');

    document.getElementById('fname').focus();

    return false;

 }



if(document.getElementById('lname').value=="")

 {

   document.getElementById('fname1').innerHTML="Please Enter the last name";

   //alert('Please Enter the new Username');

   document.getElementById('lname').focus();

   return false;

 }



if(document.getElementById('email').value=="")

 {

 document.getElementById('fname1').innerHTML="Please Enter the Email";

   //alert('Please Enter the new Username');

  document.getElementById('email').focus();

   return false;

 }
	//return true;

}









