function checking(ctrl)
{
 var i=ctrl.value.length;
 
 var j=ctrl.value;
 
if(i==3|| i==6)
	{
	 ctrl.value=j+"-";

	}
	

}

function isDateTimetemp(t)
{ 	var c,e;
   
    if(!e)
	   e=window.event
	if(e.keyCode)
	  c=e.keyCode;
	if(e.which)
	   c=e.which;
	alert(c); 
	 ch=String.fromCharCode(c);
		
	 l=t.value.length;
	 if(l==4 || l==7)
	 {
	   t.value=t.value+'-';
	   return false;
	   }
	   else
	 if(l==3 || l==6)
	 { 
		if( (ch>='0' && ch<='9'))
	      t.value=t.value+ch+'-';
	   
		 return false;
	 }
	 else
	   if(l==0 || l<=2 || l==5 || l==8 || l==11 || l==14 || l==17)
	   {	
			if( (ch>='0' && ch<='9'))
	 	       return true;
	
			return false;
	   }
	  else if(l==9)
		{
		    if( (ch>='0' && ch<='9'))
	          t.value=t.value+ch+' ';
	 	    return false;
		 }
	  else if(l==12 || l==15)
	    {
		   if( (ch>='0' && ch<='9'))
	          t.value=t.value+ch+':';
	 	  return false;
	   }
	   else if(l==18)
	   {
			if( (ch>='0' && ch<='9'))
	 	         return true;
		    return false;
	   }   
	  
}
function isDateTime(e)
{ 	var c;
    if(!e)
	   e=window.event
	if(e.keyCode)
	  c=e.keyCode;
	if(e.which)
	   c=e.which;
	ch=String.fromCharCode(c);
	if( (ch>='0' && ch<='9') || ch=='-' || ch==':' || ch=='/' || ch==' ')
	 	  return true;
	else
		  return false;
 }

function  isName(e)
{  var c;
	if(!e)
	   e=window.event
	if(e.keyCode)
	  c=e.keyCode;
	if(e.which)
	   c=e.which;
	ch=String.fromCharCode(c);
	if( (ch>='a' && ch<='z') || (ch>='A' && ch<='Z') || ch==' ' || ch=='.')
	 	  return true;
	else
		  return false;
 }

function isFloat(t)
{  
		 ch=String.fromCharCode(t);
		 alert(ch);
    var c,e;
	if(!e)
	   e=window.event
   	alert("c="+c);
	if(e.keyCode)
	  c=e.keyCode;
	 ch=String.fromCharCode(c);
	 if( (ch>='0' && ch<='9'))
	 	  return true;
	else if( ch=='.' && t.value.indexOf('.')==-1)
	    return true;
	else
		  return false;
}
function isNum(e)
{  var c,e;
	if(!e)
	   e=window.event
	if(e.keyCode)
	  c=e.keyCode;
	if(e.which)
	   c=e.which;
	 ch=String.fromCharCode(c);
	 if( (ch>='0' && ch<='9'))
	 	  return true;
	else
		  return false;
 }

function isAddrs(e)
{  var c;
	if(!e)
	   e=window.event
	if(e.keyCode)
	  c=e.keyCode;
	if(e.which)
	   c=e.which;
	 ch=String.fromCharCode(c);
	if( (ch>='0' && ch<='9') || ch=='&'|| ch==',' || ch=='-' || ch=='/' || ch==' '||  (ch>='a' && ch<='z') || (ch>='A' && ch<='Z'))
	 	  return true;
	else
		  return false;
 }

function isPhone(e)
{  var c;
	if(!e)
	   e=window.event
	if(e.keyCode)
	  c=e.keyCode;
	if(e.which)
	   c=e.which;
	 ch=String.fromCharCode(c);
	if( (ch>='0' && ch<='9') || ch=='-')
	 	  return true;
	else
		  return false;
 }



function  getTimeNow()
{
  var dt=new Date;
  mts=dt.getMinutes();
	hrs=dt.getHours();
	scs=dt.getSeconds()
		if(mts<10)
		mts="0"+""+mts;
	if(hrs<10)
		hrs="0"+""+hrs;
	if(scs<10)
		scs="0"+""+scs;
       return  hrs+":"+mts+":"+scs;
}
function putDateTime(ctrl)
{
	var dt=new Date;
	mm=dt.getMonth()+1;
	dd=dt.getDate();
	mts=dt.getMinutes();
	hrs=dt.getHours();
	scs=dt.getSeconds()
	if(mm<10)
		mm="0"+""+mm;
	if(dd<10)
		dd="0"+""+dd;
	if(mts<10)
		mts="0"+""+mts;
	if(hrs<10)
		hrs="0"+""+hrs;
	if(scs<10)
		scs="0"+""+scs;
	//alert(mm+":"+dd);
	ctrl.value=dd+"-"+mm+"-"+dt.getYear()+" "+hrs+":"+mts+":"+scs;
}

function chknum(f,str)
{
	n=f.value;
	if(isNaN(n))
	{
		alert(str+' should be in number format');
		f.focus();
		return false;
	}
	return true;
}
function chknumber(n,str)
{  alert('in chknumber');
	if(isNaN(n))
	{
		alert(str+' should be in number format');
	    return false;
	}
	else
		return true;
}

function  isvalidCR(c)
{
	cr=c.value;
	if(cr=="")
	{
		alert("CR Number can't be empty");
		f.crno.focus();
		return;
	}
	if(cr.length!=9)
	{
		alert("CR Number should be of length 9");
		f.crno.focus();
		return;
	}
	no=cr.substr(3);//from index 3
	dept=cr.substr(0,3);//from index 0 to 3 characters
	if(isNaN(cr))
	{
	  alert(" characters not allowed here");
	  f.crno.focus();
		return;
	}
	
	/*for(i=0;i<=2;i++)
	{
		if(!((dept.charAt(i)>='a' && dept.charAt(i)<='z') || (dept.charAt(i)>='A' && dept.charAt<='Z')))
		 {
		  alert("The first 3 characters should be alphabets");
		  return false;
		  }
 	}*/
	return true;
}
function chkDate(dt)
{
	alert("Hello"+dt.value);
	now=new Date();
	hrs=now.getHours();
    mns= now.getMinutes();
    snds= now.getSeconds();
    date= now.getDate();
    month= now.getMonth()+1;
    year= now.getYear();
	date=((date < 10) ? "0" : "") + date;
	month=((month < 10) ? "0" : "")+ month;

	if(dt.value.substr(6,9) <= year )
	 if(dt.value.substr(3,2) <= month )
	   if(dt.value.substr(0,2) <= date ) 
		return ;
	    else
	 alert("Date should not be Gretarthan the Current Date");
	else
		alert("Date should not be Gretarthan the Current Date");
	else
	alert("Date should not be Gretarthan Current Date");
}
function chkDateTime(dt)
{
	alert("Hello"+dt.value);
	now=new Date();
	hrs=now.getHours();
    mns= now.getMinutes();
    snds= now.getSeconds();
    date= now.getDate();
    month= now.getMonth()+1;
    year= now.getYear();
	date=((date < 10) ? "0" : "") + date;
	month=((month < 10) ? "0" : "")+ month;
	hours= now.getHours();
    minutes= now.getMinutes();
    seconds= now.getSeconds();
        
	if(dt.value.substr(6,9) <= year )
	 if(dt.value.substr(3,2) <= month )
	   if(dt.value.substr(0,2) <= date ) 
		 if(dt.value.substr(11,2) <=hours )
			if(dt.value.substr(14,2) <= minutes )
			 if(dt.value.substr(17,2) <= seconds)
			return ;
	    else
	 alert("DateTime should not be Gretarthan the Current DateTime");
	else
		alert("DateTime should not be Gretarthan the Current DateTime");
	else
	alert("Date should be Lassthan the Current Date");
		    else
	 alert("DateTime should not be Gretarthan the Current DateTime");
	else
		alert("DateTime should not be Gretarthan the Current DateTime");
	else
	alert("Date should be Lassthan the Current Date");

}
function isnull(f,actn)
{
	alert(name);

	name=actn.value;
	if((name==""))
	{
		alert("field should be entered");
		actn.focus();
		return true;
	}
}
function isnull(f,a1,a2)
{
	

	if (a1.value=="") 
	{
		alert("field should be entered");
		a1.focus();
		
	}else
	 if(a2.options[0].selected )
	{
		alert("field should be entered");
		a2.focus();
		
	}

}


function isValidCrno(f,actn)
  {  
    cr=actn.value;
	
	if(cr=="")
	{
		alert("CR Number can't be empty");
		actn.focus();
		return false;
	}
    if(isNaN(cr))
	{
	  alert(" Enter numeric values 0-9 only ");
	  actn.select();
	 actn.focus();
	  return false;
	}
	if(cr.length!=9)
	{
		alert("CR Number should be of length 9");
		actn.select();
		actn.focus();
		return false;
	}
	//no=cr.substr(3);//from index 3
	//dept=cr.substr(0,3);//from index 0 to 3 characters
	
	
	/*for(i=0;i<=2;i++)
	{
		if(!((dept.charAt(i)>='a' && dept.charAt(i)<='z') || (dept.charAt(i)>='A' && dept.charAt<='Z')))
		 {
		  alert("The first 3 characters should be alphabets");
		  f.op_pat_hist_crno.focus();
		  return;
		  }
 	}*/
	return true;
}
function isValidYear(f,actn)
{  
  
	yr=f.yy.value;
	if(yr=="")
	{
		alert("Year can't be empty");
		f.yy.focus();
		return;
	}
	if(yr.length!=4)
	{
		alert("Year should be of length 4");
		f.yy.focus();
		return;
	}
	if(isNaN(yr))
	{
		alert("Year should be in number format");
		f.yy.focus();
		return;
	}
	f.action=actn;
	f.submit();
}


/*function isvaliddate(ctrl)
{
	dt=ctrl.value;
     
		 if(dt==null)
		 {  alert("Please Enter the Date  in the format: <dd-mm-yyyy>");
			     ctrl.focus();
				 return false;
		 }
		if(dt.length!=10)
		{
			alert("Please Enter the Date in the format: <dd-mm-yyyy>");
			     ctrl.focus();
				 return false;
		}
		if(dt.indexOf('-')==2 || dt.indexOf('/')==2)
		{
			 if((dt.indexOf('-')==5 )
				 return true;
			 else
			{    alert("Please Enter the Date in the format: <dd-mm-yyyy>");
			     ctrl.focus();
				 return false;
			}
		}
}*/


function isValidDateTime(ctrl)
{   dt=ctrl.value;
     
		 if(dt==null)
		 {  alert("Please Enter the Date & Time in the format: <dd-mm-yyyy hh:mm:ss>");
			     ctrl.focus();
				 return false;
		 }
		 if(dt.length!=19)
		{
			alert("Please Enter the Date & Time in the format: <dd-mm-yyyy hh:mm:ss>");
			     ctrl.focus();
				 return false;
		}
		if(dt.indexOf('-')==4 || dt.indexOf('/')==4)
		{
			 if((dt.lastIndexOf('-')==7 || dt.lastIndexOf('/')==7) && dt.indexOf(':')==13 && dt.lastIndexOf(':')==16)
				 return true;
			 else
			{    alert("Please Enter the Date & Time in the format: <dd-mm-yyyy hh:mm:ss>");
			     ctrl.focus();
				 return false;
			}
		}
		else
			if(dt.indexOf('-')==2 || dt.indexOf('/')==2)
			{
				if((dt.lastIndexOf('-')==5 || dt.lastIndexOf('/')==5) && dt.indexOf(':')==13 && dt.lastIndexOf(':')==16)
					 return true;
				 else
				{   alert("Please Enter the Date & Time in the format: <dd-mm-yyyy hh:mm:ss>");
			     ctrl.focus();
				 return false;
				}
			}
			else
			{	
				    alert("Please Enter the Date & Time in the format: <dd-mm-yyyy hh:mm:ss>");
			     ctrl.focus();
				 return false;
			}
			
	}