////////////////////////////////  MAIN CALLING FUNCTION  START HERE //////////////////////
//TO check for blank fields 
function CheckBlankField(x,y)
{
	
	if (isBlank(x.value))
	{
		alert("Please enter the "+y+".");
		x.focus();
		return(false);
	}     

return (true);
}

// to check for numeric fields 
function CheckNumberField(x,y)
{
	if (isNumber(x.value)==false)
	{
		alert("Please enter numeric numbers for "+y+".");
		x.select();
		return(false);
	}     

return (true);
}

// to check for Telephone fields 
function CheckTelephoneField(x,y)
{
	if (isTel(x.value)==false)
	{
		alert("Please enter numeric numbers for "+y+".");
		x.select();
		return(false);
	}     

return (true);
}

// to check for Email fields 
function CheckEmailField(x,y)
{
	if (EmailCheck(x.value)==false)
	{
		x.focus();
		x.select();
		return(false);
	}      

return (true);
}

////////////////////////////////  MAIN CALLING FUNCTION  ENDS HERE //////////////////////



//fuctions to check for blank feild.
function isBlank(s)
 {
  var len=s.length;
  var i;
  for (i=0;i<len;i++)
  {
    if (s.charAt(i)!=" ") return (false);
  }
  return (true);
 }
 
 // to check if the telephone number entered is valid and has the characteres below

function isTel(theInput)
{
		var len;
		len = theInput.length;
		for (var nCnt = 0; nCnt < len; nCnt++)
			{
			 if ((theInput.charAt(nCnt)=="-" || theInput.charAt(nCnt)=="+" )||
				(theInput.charAt(nCnt)=="(" || theInput.charAt(nCnt)==")" )||
				(theInput.charAt(nCnt) =="'" || theInput.charAt(nCnt) ==" ")||
				(theInput.charAt(nCnt) >= "0" && theInput.charAt(nCnt) <= "9"))
				{
				}
			 else
				{
				return false;
				break;
				}	
		     }
}
// is number 
function isNumber(theInput)
{
		var len;
		len = theInput.length;
		for (var nCnt = 0; nCnt < len; nCnt++)
			{
			 if ((theInput.charAt(nCnt) >= "0" && theInput.charAt(nCnt) <= "9"))
				{
				}
			 else
				{
				return false;
				break;
				}	
		     }
}


///////////////////////// Bookmark This Site  ////////////////////////
						


///////////////////////////////////////////// THIS IS TO CHECK THE EMAIL ADDRESS IS VALID  STARTS HERE

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 Email Address")

return false

}

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

alert("Invalid Email Address")

return false

}

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

alert("Invalid Email Address")

return false

}

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

alert("Invalid Email Address")

return false

}

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

alert("Invalid Email Address")

return false

}

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

alert("Invalid Email Address")

return false

}


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

alert("Invalid Email Address")

return false

}

return true 

}
///////////////////////////////////////////// THIS IS TO CHECK THE EMAIL ADDRESS IS VALID  STARTS HERE							