
function checkempty(theform,thestr)
{
var dispstr=thestr;
var count=0,i;
var str=theform.value;
var len=theform.value.length;
    if (len<=0)
    {
    alert(thestr);
    theform.select();
    return false;
    }
    for (i=0;i<=len;i++)
    {
    if(str.charAt(i)==" ")
	  {
	  count=count+1;
	  }
    }
	
    if(count>=len)
   {
   alert('No Blank Space');
   theform.select();
   return false;
   }
   return true;
}




function checkSelect(theform,thestr)
{
if(theform.value=="")
  {
  alert(thestr);
  theform.focus();
  return false;
  }
  else
  {
    return true;
  }
}

function checkradio(theform,thestr,radioname)
{

var bool=false;
var i;

	for(i=1;i<=theform.elements.length-1;i++)
	{

   		   if(theform.elements[i].name=radioname)
		    {
     	     if(theform.elements[i].checked)
	           {
        	   bool=true;
		       }
            }
  
  }
  if(!bool)
  {
  alert(thestr);
  return bool;
  }
  else
  {
  return bool;
  }
  
}



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 checkemail(theform){
	var emailID=theform;
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter valid Email ID")
		emailID.select()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.select()
		return false
	}
	return true
 }





function checkvalidID(theform,errstr)
{
var checkit = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_";
var allValid =true;
var checkStr=theform.value;

	for (i = 0; i < checkStr.length; i++)
	{
		ch1 = checkStr.charAt(i);
		for (j = 0; j < checkit.length; j++)
		if(ch1 == checkit.charAt(j))
			break;
		if (j == checkit.length)
		{
			allValid = false;
			alert(errstr);
			theform.select();
			break;
		}
		
	}
return allValid;

}


function checkminimumsize(theform,size,errstr)
{
var flag=true;
	if(theform.value.length<size)
	{
	alert(errstr);
	theform.select();
	flag=false;
	}
return flag;	
}