function cc()
{
var now = new Date();
var today = now.getDate() + "-" + parseInt(now.getMonth()+1) + "-"+ parseInt(now.getFullYear());
document.form1.fr_date.value=today;
}

function yr()
{
var now = new Date();
var cyr=parseInt(now.getFullYear());

var y=document.form1.year.value;
var exy= parseInt(y) + 21;
var op12="Year&nbsp;&nbsp;<select name='date_grad' onChange='expert()'>";
for(i=cyr;i>=exy;i--)
{
op12+="<option value="+i+">"+i+"</option>";
}
op12= op12 + "</select>";

obj=document.getElementById('ey');

if(obj)
	{
document.getElementById('ey').innerHTML=op12; 
	}
}

function expert()
{
				var eyr	= document.form1.date_grad.value;
				var todaydate=new Date(); 
				var curmonth=todaydate.getFullYear()
				var i=0;
				if(curmonth > eyr)
				{
				var diff =curmonth - eyr;
				if(diff < 3)
				{
				var op1="<select  name='doc_exp' onChange='cc()'><option value=0.5>0.5</option><option value=1>1</option>";
				diff = diff + 0.5;
				for(i=2;i<=diff;i++)
				{
				 i = i - 0.5;
				 var op1 = op1 + "<option value="+i+">"+i+"</option>";
				 }
				  op1= op1 + "</select>Yrs";
				 }
				 else
				 {
				 var op1="<select  name='doc_exp' onChange='cc()'><option value=0.5>0.5</option><option value=1>1</option>";
				
				for(i=2;i<=3;i++)
				{
				 i = i - 0.5;
				 var op1 = op1 + "<option value="+i+">"+i+"</option>";
				 }
				 for(i=3;i<=diff;i++)
				{
				 var op1 = op1 + "<option value="+i+">"+i+"</option>";
				 }
				  op1= op1 + "</select>Yrs";
				 }
				 document.getElementById('ep123').innerHTML=op1; 
				 }
}
function subform()
	{
		document.form1.typeid.value=document.form1.type.value;
		a=document.form1.type.options[document.form1.type.selectedIndex].value;
		window.location="register.php?typeid=" + a +"&getid=0";
	}
	
	function check_email(e) 
	{
		ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
        for(i=0; i < e.length ;i++)
		{
			if(ok.indexOf(e.charAt(i))<0)
			{
				return (false);
			}
	    }
        if (document.images)
		{
			re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
			re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
			if (!e.match(re) && e.match(re_two))
			{
				return (-1);
            }
        }
	}

	function change()
	{
		if(!check_email(document.form1.email.value)) 
		{
			alert("Email address is not valid.");
			document.form1.email.select();
			return false;
		}
		else{
		return true;
		}
	}
	
function undoNoNum(evt,fldname)
{
	//var charCode = evt.keyCode ? event.keyCode : event.which

	var charCode=evt.keyCode;
	//alert(charCode);
	if (charCode > 31 && (charCode < 48 || charCode > 57) && (charCode <96 || charCode > 105 ))
	 {
		alert("Please Enter Only Numeric");
		document.form1.eval(fldname).select();
		return false
	 } 
	else 
		return true  
}

function exprience(evt,fldname)
{
	//var charCode = evt.keyCode ? event.keyCode : event.which
	var charCode=evt.keyCode;
	// 
	if (charCode > 31 && (charCode < 48 || charCode > 57) && (charCode <96 || (charCode > 105 && charCode<110 || charCode>110)))

	 {
		alert("Please Enter Only Numeric");
		document.form1.eval(fldname).select();
		return false
	 } 
	else 
		
		return true  
}

	
	function validate()
	{
		
		if (document.form1.email.value.length < 1 )
		{
			alert("Email id cannot be left blank");
			document.form1.email.focus();
			return false;
		}
		if(!check_email(document.form1.email.value)) 
		{
			alert("Email address is not valid.");
			document.form1.email.focus();
			return false;
		}
		if (document.form1.email.value.length > 50 )
		{
			alert("Email id should be less than 50 character");
			document.form1.email.focus();
			return false;
		}		
		if (document.form1.mci_reg.value.length < 1 )
		{
			alert("MCI Registration cannot be left blank");
			document.form1.mci_reg.focus();
			return false;
		}
		if(typeof document.form1.password != "undefined")
		{
			if(document.form1.password.value.length<4 || document.form1.password.value.length >12) 
			{
				alert("Password should be between 4-12 character");
				document.form1.password.focus();
				return false; 
			}
			if(document.form1.retype.value!=document.form1.password.value) 
			{
				alert("Password Mismatch");
				document.form1.retype.focus();
				return false; 
			}
		}				
				
		
			
    		if(!isEmpty(document.form1.f_name, "First name can not be left blank."))return false;
		
			if(!isSpecialChar(document.form1.f_name, 'First Name'))return false;
			if(!isFirstCharNum(document.form1.f_name))return false;
			if(document.form1.f_name.value.length > 30) 
			{
				alert("First name should be less than 30 character");
				document.form1.f_name.focus();
				return false; 
			}
				
		
		
					
		
			if(!isEmpty(document.form1.l_name, "Last Name can not be left blank."))return false;
			if(!isSpecialChar(document.form1.l_name, 'Last Name'))return false;
			if(!isFirstCharNum(document.form1.l_name))return false;
			if(document.form1.l_name.value.length >15) 
			{
				alert("Last name should be less than 15 character");
				document.form1.l_name.focus();
				return false;
			}
		

				var year	= document.form1.year.value;
				var month	= document.form1.month.value;
				var day		= document.form1.day.value;
				
															
				var now = new Date();
				
				var today = new Date(now.getYear(),now.getMonth(),now.getDate());
				var mydate = new Date(year,month-1,day);
				if(mydate>now)
				{
					alert("'Date of Birth' can not be greater than current date");
					document.form1.month.focus();
					return false;
				}
						
			var	dateDOB	= document.form1.day.value+"-"+document.form1.month.value+"-"+document.form1.year.value
			if(!checkDate(dateDOB,document.form1.day,"Invalid Date of Birth"))return false;
			
					
		
				if(!isEmpty(document.form1.address, "Address can not be left blank."))return false;
			if(document.form1.address.value.length > 120) 
			{
				alert("Address should be less than 120 character");
				document.form1.address.focus();
				return false; 
			}
    
			if(!isEmpty(document.form1.city, "City can not be left blank."))return false;
			if(!isFirstCharNum(document.form1.city))return false;
			if(document.form1.city.value.length > 25) 
			{
				alert("City should be less than 25 character");
				document.form1.city.focus();
				return false; 
			}

			if(!isEmpty(document.form1.zip_code, "Pin code can not be left blank."))return false;
			if(!isSpecialChar(document.form1.zip_code, 'Pin code'))return false;
			if(!isNumber(document.form1.zip_code,"'Pin code' Invalid format."))return false;								
			if (document.form1.zip_code.value.length < 6 )
			{
				alert("PIN must be 6 digits long");
				document.form1.zip_code.focus();
				return false;
			}
			if(!isEmpty(document.form1.state, "State can not be left blank."))return false;
			if(!isFirstCharNum(document.form1.state))return false;
			if(document.form1.state.value.length > 25) 
			{
				alert("State should be less than 25 character");
				document.form1.state.focus();
				return false; 
			}
		
				if(!isEmpty(document.form1.qualification, "Qualification can not be left blank."))return false;
				if(!isEmpty(document.form1.date_grad, "Please Select year of Passing "))return false;
				if(!isEmpty(document.form1.doc_exp, "Docter Experience cannot be left blank."))return false;	
				
			
			if(document.form1.doc_exp.value.length>3)
			{
				alert("Doctor experience should be less than 3 character");
				document.form1.doc_exp.focus();
				return false;
			}
					var qualyr  = document.form1.date_grad.value;
					var expdate = document.form1.fr_date.value;
					var expyr2	= document.form1.doc_exp.value;
					var mytool_array=expdate.split("-");
					var eyr = mytool_array[2];					
					var   ee1=(parseInt(year) + parseInt(expyr2) + 21);
					
					var expdate1 = new Date(ee1,(mytool_array[1]-1),mytool_array[0]);
					var expdate2 = new Date((mytool_array[2]),(mytool_array[1]-1),mytool_array[0]);
				if(expdate1>expdate2)
				{
					alert("Date of Experience is not valid as per your date of birth and years of exp!");
					document.form1.fr_date.focus();
					return false;
				}
				if(expdate2<mydate)
				{
					alert("Date of Experience cannot be less than Date Of Birth");
					document.form1.fr_date.focus();
					return false;
				}
				if(expdate2>now)
				{
					alert("Date of Experience cannot be greater than current date");
					document.form1.fr_date.focus();
					return false;
				}
				if(qualyr>eyr)
				{
					alert("Experience year cannot be greater than qualification year");
					document.form1.fr_date.focus();
					return false;
				}
    				if(!isEmpty(document.form1.fr_date, "Experience date cannot be left blank."))return false;
					
					if(document.form1.speciality.value =='')
					{ alert("Speciality can not be left blank.");
 					document.form1.speciality.focus();
					return false;
					}
					/*if(!isEmpty(document.form1.fees, "Fees can not be left blank."))return false;*/
		
		return true;
	}
