
	function BlankCheck(val)
		{
			var char1,vals;
			vals = val.value;
			
			for (var i=0;i<vals.length;i++)
			{	
				char1 = vals.substring(i,i+1); 
					if ((char1==" "))
					{
						return false;
					}
			}
			return true;
		}	
	function LengthCheck(val)
	{
		var vals;
		vals = val.value;
			if (vals.length < 8 )
			{
				return false;
			}
		return true;
	}	
function SpaceCheck(val)
	{
	var char1,vals,flag;
	vals=val.value;
				
	if(vals != "") 
	{
	for (var i=0;i<vals.length;i++)
	{	 
		char1 = vals.substring(i,i+1); 
		if(char1==" ")
		{
			flag=1;
		}	
		else
		{
			flag=0;
			break;
		}	
	}		
	if (flag==1)
	{
		val.focus();
		return false;
	}
	else
	{
		return true;
	}
	}		
	else
	{	
	val.focus();	
	return false;
	}			
} 
function bTrim(orgValue)
	{
		tValue="";
		i=0;
		j=0;
		if(!(orgValue.charAt(i)==' '))          
			tValue=tValue.concat(orgValue.charAt(i));
		for(j=1;j<orgValue.length;j++) {
			if((orgValue.charAt(j-1)==' ') && (orgValue.charAt(j)==' ')) continue;
			else tValue=tValue.concat(orgValue.charAt(j));
		}       
		return tValue;
	}
	function isEmail(mailValue)
	{
		tEmail="";
		tEmail=bTrim(mailValue);
		if (tEmail.indexOf("@")>0 && tEmail.indexOf(".")>0 && tEmail.length>=5 && tEmail.length-1 != tEmail.lastIndexOf(".") && tEmail.length != tEmail.lastIndexOf("@"))
		{
			tIndex1=tEmail.indexOf("@");
			tIndex2=tEmail.indexOf(".");
			/* This condition is to check, if first character of the email address
			   is either .(dot) or @ and if the character followed by .(dot) or @ is
			   @/.(dot) respectively then email address is not correct. Email will also
			   not correct if there are no or more than one @ sign in email and if 
			   there is a .(dot) or @ sign at the end of the email address and there 
			   is no character after it.
			*/
			if ((tEmail.charAt(0)!='@' || tEmail.charAt(0) !='.') && tEmail.charAt(tIndex1+1)!= '.'  && tEmail.charAt(tIndex1+1)!= ' ' && tEmail.indexOf("@") == tEmail.lastIndexOf("@") && tEmail.lastIndexOf("@") < tEmail.lastIndexOf("."))
			{
				var flag=0;
				for (i=0;i<tEmail.length;i++){
					/* This condition is to check, if there is any space in email or 
					   any @ sign followed by .(dot) then email address is not correct
					*/
					if (tEmail.charAt(i)== ' ' ||( tEmail.charAt(i)== '.' && tEmail.charAt(i+1)=='@'))
					{
						flag=1;
						break;
					}
				}
				if (flag==1)
					return false;
				else
					return true;
			}
			else 
				return false;
		}
		else
			return false;
	}
function SpCharCheck(val)
{
	var char1,vals,fla;
	vals=val.value;
	for (var i=0;i<vals.length;i++)
		{	
		char1 = vals.substring(i,i+1); 
		
		if ((char1=='>')||(char1=='"')||(char1=="'")||(char1=='<')||(char1=='<')||(char1=='!')||(char1=='~')||(char1=='#')||(char1=='$')||(char1=='%')||(char1=='&')||(char1=='*'))
		{
			fla=1;
			break;	
		}	
		else
		{
			fla=0;
		}	
		}		
	if (fla==1)
	{
		val.focus();
		return false;
	}
	else
	{
		return true;
	}
} 


function CheckDate(Day,Mon,Year) 
 {
   
   var iDD = parseInt(Day);
   var iMM = parseInt(Mon);
   var iYYYY = parseInt(Year);
   var iLeep;
   var Tiyyyy = " ";
   var TDate = " ";
   var Flag = true;
   
   
  
  
   //CheckDate = False;
      if ((iMM > 12) || (iMM <= 0)) 
           return false;
            
      if ((iYYYY < 1000) || (iYYYY > 9999)) 
              return false;
         
     
      if ((iDD > 31) || (iDD <= 0))
              return false;
      
     
      if ((iMM == 4) || (iMM == 6) || (iMM == 9) || (iMM == 11)) 
         {
          if (iDD > 30) 
            return false;
            
         }
     
      if (iMM == 2) 
         {
          
          if (iDD > 29) 
              return false;
          else
             {
               iLeep = iYYYY % 4;
               if (iLeep == 0) 
                 {
                   if ((iYYYY % 1000 == 0) || (iYYYY % 100 == 0))
                   {
                     iLeep = iYYYY % 400;
                   } 
                 }  
               if ((iLeep != 0) && (iDD > 28)) 
                   return false;
             }    
         }
     if (iDD < 10)						//For making 1 -> 01
         TDate = "0" + iDD;
     else
         TDate = iDD;
    
    
     if (iMM < 10) 					//For making 1 -> 01
         TDate = TDate + "/0" + iMM;
     else
         TDate = TDate + "/" + iMM;
    
    //MEdBox.Text = TDate & "/" & iYYYY
     return true;
   } 

 function focus()
       {
	document.frmApp.cmbDay.focus();
	}	

function validation()
	{
		

		if(bTrim(document.frmApp.password.value)==false)
		{
			alert("Password can't be left blank");	
			document.frmApp.password.focus();
			return false;
		}


		if(bTrim(document.frmApp.password2.value)==false)
		{
			alert("Password can't be left blank");	
			document.frmApp.password2.focus();
			return false;
		}

		if(SpCharCheck(document.frmApp.password2)==false)
		{
			alert("Password can't contain special characters");	
			document.frmApp.password2.focus();
			return false;
		}

		
		if (document.frmApp.password2.value != document.frmApp.password3.value)
		{
			alert("The Password you keyed and the Reconfirmation Password doesn't match.\n They should be same and in case-sensitive.");
			document.frmApp.password3.focus();
			return false;
		}	
	
	return true;
}

function validationLogin()
{

		if(bTrim(document.frmApp.username.value)==false)
		{
			alert("Username can't be left blank");	
			document.frmApp.username.focus();
			return false;
		}

		if(SpCharCheck(document.frmApp.username)==false)
		{
			alert("Username can't contain special characters");	
			document.frmApp.username.focus();
			return false;
		}


		if(bTrim(document.frmApp.password.value)==false)
		{
			alert("Password can't be left blank");	
			document.frmApp.password.focus();
			return false;
		}

		if(SpCharCheck(document.frmApp.password)==false)
		{
			alert("Password can't contain special characters");	
			document.frmApp.password.focus();
			return false;
		}



return true;

}
