/*
  **Author				:	
  **Start Date			:	
  **Name				:	regscript.js
  **Purpose				:	
  **
  **************************************************************************************************************************************
  **														Change History														
  **************************************************************************************************************************************
  **	Date		Author		Code		Description
  **	________________________________________________________________________________________________________________________________
  **	11/08/2005	AnilKumar	 a1			Placed one condition in submit1() function
  */

function checkNumbers(e)
{
			if(!((e.keyCode>64 && e.keyCode<91)||(e.keyCode>96 && e.keyCode<123)||(e.keyCode>47 && e.keyCode<58)|| (e.keyCode==95) ))
			{
				e.keyCode=0;
			}
}

function checkPassSA()
{
 if(document.changepwd.txtoldpassword.value=='')
     {
	       alert("Enter Old Password ! ");
  	       document.changepwd.txtoldpassword.focus(); 
	       return;
	 }
	 else if(document.changepwd.txtnewpassword.value=='')
     {
	       alert("Enter New Password ! ");
  	       document.changepwd.txtnewpassword.focus(); 
	       return;
	 }
	 else if(document.changepwd.txtconfirmpassword.value=='')
     {
	       alert("Enter Confirm Password ! ");
  	       document.changepwd.txtconfirmpassword.focus(); 
	       return;
	 }
	 else  if(document.changepwd.txtnewpassword.value!=document.changepwd.txtconfirmpassword.value)
	 {
	       alert("Check Confirm Password! ");
		    document.changepwd.txtconfirmpassword.value= ""; 
		   document.changepwd.txtconfirmpassword.focus(); 
		  	  return;
	 }
	 else
	{
		document.changepwd.submit();
	}
}


function submit1()
{

    var i=0 ;
    val= new Array(25); 
    if(document.reg.userid.value=='')
   {
		 val[i]="User Id!\n";
         i+=1;
   }
    if(document.reg.password.value=='')
   {
		    val[i]="Password!\n";
			i+=1;
   }
     if(document.reg.reenterpwd.value=='')
    {
	       val[i]="Confirm Password!\n";
	       i+=1;
    }
    if(document.reg.hintquestion.value=='')
   {
		   val[i]="Hint Quation!\n";
			i+=1;
   }
   if(document.reg.hintans.value=='')
  {
	        val[i]="Hint Answer!\n";
 			i+=1;
  }
   if(document.reg.fname.value=='')
  {
           val[i]="First Name!\n";
	       i+=1;
  } 
   if(document.reg.lname.value=='')
  {
           val[i]="Last Name!\n";
	       i+=1;
  }
  if(document.reg.email.value=='')
  {
          val[i]="Email Id!\n";
	      i+=1;
  }
  if(document.reg.address1.value=='')
  {
	      val[i]="Address!\n";
          i+=1;
  }
  if(document.reg.city.value=='')
 {
	      val[i]="City!\n";
          i+=1;
 }
  if(document.reg.state.value=='')
  {
	      val[i]="State!\n";
          i+=1;
  }
  if(document.reg.country.value=='')
  {
	      val[i]="Country!\n";
          i+=1;
  }
   if(document.reg.zipcode.value=='')
  {
	      val[i]="ZipCode!\n";
           i+=1;
  }
  if(document.reg.usertype.value=='')
  {
	      val[i]="User Type!\n";
          i+=1;
  }
   if(document.reg.regtype.value=='')
  {
          val[i]="Registration type!\n";
		  i+=1;
  }

  if(i==0)
  {
       if(document.reg.userid.value.length<6)
 	  {
		   alert(" User Id Should be minimum 6 letter");
	  }
      else if(document.reg.userid.value.length>32)
      {
		   alert(" User Id Should be Maximum 32 letter");
	  }
      else  if(document.reg.email.value.indexOf('@') == -1 || document.reg.email.value.indexOf('@') == 0 || document.reg.email.value.indexOf('.') == -1 ||document.reg.email.value.indexOf('.') == 0)
      {
			alert("Please provide your E-mail Address correctly!");
   	        document.reg.email.value.focus(); 
			return;
	   }
       else if(document.reg.email.value != document.reg.email2.value)
       {
            alert("Check Your Confirm Email Address ");
	        document.reg.email2.focus(); 
		    return;
	   }
       else  if(document.reg.password.value != document.reg.reenterpwd.value)
       {
	        /*val[i]="Verify Your  Password!\n";
	        i+=1;*/
			alert("password is not matched with Confirm password ");
			 document.reg.reenterpwd.value='';
             document.reg.reenterpwd.focus(); 
       }
	    else if(document.reg.userid.value==document.reg.password.value) // ***   a1   (Modification Begins)***
		{
			 alert("UserId and Password Should Not be Equal");
			 document.reg.password.value='';
			 document.reg.reenterpwd.value='';
             document.reg.password.focus(); 
			 return false;
		}// ***   a1   (Modification Ends)***
       else
       {
			   	document.reg.submit(); 
	  }
 	}
	else 
	{
		if(i==1)
	   {
			 a= new String("Please Enter ");
	   }
	   else
      {
			  a= new String("Please Enter the following fields\n");
	   }
	 
	   for(k = 0;k < i; k++)
		    a += val[k];
        alert(a);
	}
}
function Msubmit1()
{

    var i=0 ;
    val= new Array(25); 
   if(document.reg.fname.value=='')
  {
           val[i]="First Name!\n";
	       i+=1;
  } 
   if(document.reg.lname.value=='')
  {
           val[i]="Last Name!\n";
	       i+=1;
  }
  if(document.reg.email.value=='')
  {
          val[i]="Email Id!\n";
	      i+=1;
  }
  if(document.reg.address1.value=='')
  {
	      val[i]="Address!\n";
          i+=1;
  }
  if(document.reg.city.value=='')
 {
	      val[i]="City!\n";
          i+=1;
 }
  if(document.reg.state.value=='')
  {
	      val[i]="State!\n";
          i+=1;
  }
  if(document.reg.country.value=='')
  {
	      val[i]="Country!\n";
          i+=1;
  }
   if(document.reg.zipcode.value=='')
  {
	      val[i]="ZipCode!\n";
           i+=1;
  }
  if(document.reg.usertype.value=='')
  {
	      val[i]="User Type!\n";
          i+=1;
  }
   if(document.reg.regtype.value=='')
  {
          val[i]="Registration type!\n";
		  i+=1;
  }

  if(i==0)
  {
    if(document.reg.email.value.indexOf('@') == -1 || document.reg.email.value.indexOf('@') == 0 || document.reg.email.value.indexOf('.') == -1 ||document.reg.email.value.indexOf('.') == 0)
      {
			alert("Please provide your E-mail Address correctly!");
   	        document.reg.email.value.focus(); 
			return;
	   }
       else if(document.reg.email.value != document.reg.email2.value)
       {
            alert("Check Your Confirm Email Address ");
	        document.reg.email2.focus(); 
		    return;
	   }
      
         else
		 {
			   	document.reg.submit(); 
		  }
 	}
	else 
	{
		if(i==1)
	   {
			 a= new String("Please Enter ");
	   }
	   else
      {
			  a= new String("Please Enter the following fields\n");
	   }
	 
	   for(k = 0;k < i; k++)
		    a += val[k];
        alert(a);
	}
}

function instructions()
{
		window.open('/medwrite_html/instructions.html','Instructions','toolbar=no,scrollbars=yes,resizable=no,width=500,height=400');
}
function forgotpassword()
{
		window.open('/medwrite_html/forgotpwd.html','ForgotPassword','toolbar=no,scrollbars=no,resizable=no,width=450,height=300');
}

function registrationtype()
{
	doctor=new Array("","Add to Group","Add to Organization","Create Group","Create Organization","Individual Member");
	doctorvalues=new Array("","addg","addo","cg","co","i");
mt=new Array("Create Organization");
mtvalues=new Array("co");

qa=new Array("Create Organization");
qavalues=new Array("co");


  document.reg.regtype.options.length=0;
  m=0;
  op1= new Option;
  op1.text="Select Registration Type";
  op1.value="";
  document.forms['reg'].regtype.options[m]=op1;
  m++;
   var op=document.reg.usertype.value;
   if(op=="doctor")
   {
      
	  for(k=1;k<doctor.length;k++)
	  {
	  
	   op=new Option;
	   op.text=doctor[k];
	   op.value=doctorvalues[k];
       document.forms['reg'].regtype.options[m]=op;
	   m=m+1;
	  }
   }
   else if(op=="mt")
   {
    for(k=0;k<mt.length;k++)
	  {
	  
	   op=new Option;
	   op.text=mt[k];
	   op.value=mtvalues[k];
       document.forms['reg'].regtype.options[m]=op;
	   m=m+1;
	  }

   }
   else if(op=="qa")
   {
     for(k=0;k<qa.length;k++)
	  {
	  
	   op=new Option;
	   op.text=qa[k];
	   op.value=qavalues[k];
       document.forms['reg'].regtype.options[m]=op;
	   m=m+1;
	  }
   }
}

function submitLogin()
{
	if(document.frmRegister.txtuserid.value=='')
	{
		   alert("Enter User  Id! ");
		   document.frmRegister.txtuserid.focus(); 
		   return false;
	}
	else if(document.frmRegister.txtpassword.value=='')
	{
	alert("Enter Password! ");
		   document.frmRegister.txtpassword.focus(); 
		   return false;
	}
	else
	{
		return true;
//		document.frmRegister.submit();
	}
}

function CreateGroup()
{
		  if(document.creategroup.gname.value=='')
	     {
	       alert("Enter Group Name ! ");
		   document.creategroup.gname.focus(); 
		   return;
		 }
		 else if(document.creategroup.gdescription.value=='')
	     {
	       alert("Enter Groud Description ");
		   document.creategroup.gdescription.focus(); 
		   return;
		 }
    	 else
		 {
                	document.creategroup.submit(); 
		 }
}
function CreateOrg()
{
	  if(document.createorg.orgname.value=='')
     {
	       alert("Enter Organization Name ! ");
  	       document.createorg.orgname.focus(); 
	       return;
	 }
	 else if(document.createorg.orgdescription.value=='')
     {
	       alert("Enter Organization Description ");
	 	   document.createorg.orgdescription.focus(); 
		   return;
	 }
		  else if(document.createorg.orgaddress1.value=='')
	     {
	       alert("Enter Address! ");
		   document.createorg.orgaddress1.focus(); 
		   return;
		 }
		else if(document.createorg.orgcity.value=='')
	     {
	       alert("Enter City! ");
		   document.createorg.orgcity.focus(); 
		   return;
		 }
		 else if(document.createorg.orgstate.value=='')
	     {
	       alert("Enter State! ");
		   document.createorg.orgstate.focus(); 
		   return;
		 }
		 else if(document.createorg.orgcountry.value=='')
	     {
	       alert("Enter Country! ");
		   document.createorg.orgcountry.focus(); 
		   return;
		 }
		 else if(document.createorg.orgzipcode.value=='')
	     {
	       alert("Enter ZipCode! ");
		   document.createorg.orgzipcode.focus(); 
		   return;
		 }
    	 else
		 {
                	document.createorg.submit(); 
		 }
}

function submit2()
{

    var i=0 ;
    val= new Array(25); 
   if(document.reg.fname.value=='')
  {
           val[i]="First Name!\n";
	       i+=1;
  } 
   if(document.reg.lname.value=='')
  {
           val[i]="Last Name!\n";
	       i+=1;
  }
  if(document.reg.email.value=='')
  {
          val[i]="Email Id!\n";
	      i+=1;
  }
  if(document.reg.address1.value=='')
  {
	      val[i]="Address!\n";
          i+=1;
  }
  if(document.reg.city.value=='')
 {
	      val[i]="City!\n";
          i+=1;
 }
  if(document.reg.state.value=='')
  {
	      val[i]="State!\n";
          i+=1;
  }
  if(document.reg.country.value=='')
  {
	      val[i]="Country!\n";
          i+=1;
  }
   if(document.reg.zipcode.value=='')
  {
	      val[i]="ZipCode!\n";
           i+=1;
  }
  
  if(i==0)
  {
       if(document.reg.email.value.indexOf('@') == -1 || document.reg.email.value.indexOf('@') == 0 || document.reg.email.value.indexOf('.') == -1 ||document.reg.email.value.indexOf('.') == 0)
      {
			alert("Please provide your E-mail Address correctly!");
   	        document.reg.email.value.focus(); 
			return;
	   }
       else
	   {
	     	document.reg.submit(); 
	   }
  }
  else 
 {
		if(i==1)
	   {
			 a= new String("Please Enter ");
	   }
	   else
      {
			  a= new String("Please Enter the following fields\n");
	   }
	 
	   for(k = 0;k < i; k++)
		    a += val[k];
        alert(a);
	}
}

function checkPass()
{
	 if(document.changepwd.txtnewpassword.value=='')
     {
	       alert("Enter New Password ! ");
  	       document.changepwd.txtnewpassword.focus(); 
	       return;
	 }
	 else if(document.changepwd.txtconfirmpassword.value=='')
     {
	       alert("Enter Confirm Password ! ");
  	       document.changepwd.txtconfirmpassword.focus(); 
	       return;
	 }
	 else  if(document.changepwd.txtnewpassword.value!=document.changepwd.txtconfirmpassword.value)
	 {
	       alert("Check Confirm Password! ");
		    document.changepwd.txtconfirmpassword.value= ""; 
		   document.changepwd.txtconfirmpassword.focus(); 
		  	  return;
	 }
	 else
	{
		document.changepwd.submit();
	}
}

function ChangePwd()
{
	  if(document.changepwd.txtoldpassword.value=='')
     {
	       alert("Enter Old Password ! ");
  	       document.changepwd.txtoldpassword.focus(); 
	       return;
	 }
	 else if(document.changepwd.txtnewpassword.value=='')
     {
	       alert("Enter New Password ");
	 	   document.changepwd.txtnewpassword.focus(); 
		   return;
	 }
     else if(document.changepwd.txtconfirmpassword.value=='')
	 {
	       alert("Enter Confirm Password! ");
		   document.changepwd.txtconfirmpassword.focus(); 
		   return;
	 }
	  else if(document.changepwd.txtnewpassword.value!=document.changepwd.txtconfirmpassword.value)
	 {
	       alert("Check Confirm Password! ");
		    document.changepwd.txtconfirmpassword.value= ""; 
		   document.changepwd.txtconfirmpassword.focus(); 
		  	  return;
	 }
     else if(document.changepwd.txtoldpassword.value==document.changepwd.txtnewpassword.value)
	 {
		 if (confirm('Your New password is same as of old password.Do you want keep the same!'))
		 {
               	document.changepwd.submit(); 
		 }
		 else
		 {
			 	   return;
		 }
	 }
   	 else
	 {
                	document.changepwd.submit(); 
	 }
}

function submitMt()
{
    var i=0 ;
    val= new Array(25); 
    if(document.reg.userid.value=='')
   {
		 val[i]="User Id!\n";
         i+=1;
   }
    if(document.reg.password.value=='')
   {
		    val[i]="Password!\n";
			i+=1;
   }
     if(document.reg.reenterpwd.value=='')
    {
	       val[i]="Confirm Password!\n";
	       i+=1;
    }
    if(document.reg.hintquestion.value=='')
   {
		   val[i]="Hint Quation!\n";
			i+=1;
   }
   if(document.reg.hintans.value=='')
  {
	        val[i]="Hint Answer!\n";
 			i+=1;
  }
   if(document.reg.fname.value=='')
  {
           val[i]="First Name!\n";
	       i+=1;
  } 
   if(document.reg.lname.value=='')
  {
           val[i]="Last Name!\n";
	       i+=1;
  }
  if(document.reg.email.value=='')
  {
          val[i]="Email Id!\n";
	      i+=1;
  }
  if(document.reg.address1.value=='')
  {
	      val[i]="Address!\n";
          i+=1;
  }
  if(document.reg.city.value=='')
 {
	      val[i]="City!\n";
          i+=1;
 }
  if(document.reg.state.value=='')
  {
	      val[i]="State!\n";
          i+=1;
  }
  if(document.reg.country.value=='')
  {
	      val[i]="Country!\n";
          i+=1;
  }
   if(document.reg.zipcode.value=='')
  {
	      val[i]="ZipCode!\n";
           i+=1;
  }

  if(i==0)
  {
       if(document.reg.userid.value.length<6)
 	  {
		   alert(" User Id Should be minimum 6 letter");
	  }
      else if(document.reg.userid.value.length>32)
      {
		   alert(" User Id Should be Maximum 32 letter");
	  }
      else  if(document.reg.email.value.indexOf('@') == -1 || document.reg.email.value.indexOf('@') == 0 || document.reg.email.value.indexOf('.') == -1 ||document.reg.email.value.indexOf('.') == 0)
      {
			alert("Please provide your E-mail Address correctly!");
   	        document.reg.email.value.focus(); 
			return;
	   }
       else if(document.reg.email.value != document.reg.email2.value)
       {
            alert("Check Your Confirm Email Address ");
	        document.reg.email2.focus(); 
		    return;
	   }
       else  if(document.reg.password.value != document.reg.reenterpwd.value)
       {
	        alert("Password is Not Matched with Confirm password");
			document.reg.reenterpwd.value='';
			document.reg.reenterpwd.focus();
       }
       else
	  {
			   	document.reg.submit(); 
	  }
 	}
	else 
	{
		if(i==1)
	   {
			 a= new String("Please Enter ");
	   }
	   else
       {
			  a= new String("Please Enter the following fields\n");
	    }
	    for(k = 0;k < i; k++)
		    a += val[k];
        alert(a);
	}
}

function DelConfirm(usid)
{
	
  if (confirm("Are you sure you want to delete user "+usid))
	{
	 window.location.href("/medwrite_jsp/MtNewUser.jsp?rel=del&usid="+usid);

    }
  else 
	{
	  window.location.replace("/medwrite_jsp/UsersMenu.jsp");

	}
}
function DoctorDelConfirm(usid,hospitalid,siteid)
{
	
  if (confirm("Are you sure you want to delete Details  "+usid+siteid+hospitalid))
	{
	 window.location.replace("/jsp/DoctorNewUser.jsp?rel=del&usid="+usid+"&hospitalid="+hospitalid+"&siteid="+siteid+"");

    }
  else 
	{
	  window.location.replace("/jsp/UsersMenu.jsp");

	}
}
function searchtype()
{
	alert(document.sf.styp.value);
		if (document.sf.styp.value =='')
		{
			 alert("Select Search Item");
			document.sf.styp.focus();
		}
else
		window.location.href("/medwrite_jsp/MTSearch.jsp?sitem="+document.sf.styp.value)
}

function ValidateSearch()
{
	if (document.sf.styp.value=='')
	{
		 alert("Select Search Item");
		document.sf.styp.focus();
	}
	else if (document.sf.stm.value=='')
	{
		 alert("Select Search ID");
		document.sf.stm.focus();
	}
	else
		window.location.href("/medwrite_jsp/MTSearch.jsp?sitem="+document.sf.styp.value+"&siteval="+document.sf.stm.value+"&startpage=1&orderno=0")
}

function Specialities(spec)
{
	alert("in specialities of regscript");
	alert ("spec:"+spec);
	special=new Array("Select Speciality","ALLERGY/IMMUNOLOGY","ANESTHESIOLOGY","CARDIOLOGY","DERMATOLOGY","ENDOCRINOLOGY/DIABETES","EMERGENCY MEDICINE","FAMILY/GENERAL PRACTICE","FAMILY MEDICINE","GASTROENTEROLOGY","GERIATRICS","INTERNAL MEDICINE","NEURO SURGERY","NEUROLOGY","OBSTETRICS/GYNECOLOGY","ONCOLOGY","OPHTHALMOLOGY","ORTHOPEDICS","OTHER SPECIALTY","OTOLARYNGOLOGY","PATHOLOGY","PEDIATRICS","PEDIATRIC CARDIOLOGY","PHYSICAL MEDICINE & REHAB","PLASTIC SURGERY","PODIATRICS","PSYCHIATRY","PULMONOLOGY/CRITICAL CARE","PULMONARY DISEASE","RADIOLOGY","SURGERY","UROLOGY","VASCULAR SURGERY");
	specialvalues=new Array("","ALLERGY/IMMUNOLOGY","ANESTHESIOLOGY","CARDIOLOGY","DERMATOLOGY","ENDOCRINOLOGY/DIABETES","EMERGENCY MEDICINE","FAMILY/GENERAL PRACTICE","FAMILY MEDICINE","GASTROENTEROLOGY","GERIATRICS","INTERNAL MEDICINE","NEURO SURGERY","NEUROLOGY","OBSTETRICS/GYNECOLOGY","ONCOLOGY","OPHTHALMOLOGY","ORTHOPEDICS","OTHER SPECIALTY","OTOLARYNGOLOGY","PATHOLOGY","PEDIATRICS","PEDIATRIC CARDIOLOGY","PHYSICAL MEDICINE & REHAB","PLASTIC SURGERY","PODIATRICS","PSYCHIATRY","PULMONOLOGY/CRITICAL CARE","PULMONARY DISEASE","RADIOLOGY","SURGERY","UROLOGY","VASCULAR SURGERY");
	for(k=0;k<special.length;k++)
   {
	   op=new Option;
	   op.text=special[k];
	   op.value=specialvalues[k];			   
	   document.forms['reg'].speciality.options[k]=op;
       	if(spec==special[k])
	   {
	   	   document.forms['reg'].speciality.options[k].selected=true;
	   }
	   else
	   {
		   if(k == 0)
				document.forms['reg'].speciality.options[k].selected=true;
	   }
   }
}
