// JavaScript Document

function username_change()
{
		missinginfo = "";
		
		if (document.user_change.new_email.value == "")
		{
			missinginfo += "\n     -  New Email";
		}
		
		if (missinginfo != "")
		{
			missinginfo ="You failed to correctly fill in your:\n" +
			missinginfo + "\n_____________________________" +
			"\nPlease re-enter and save again!";
			alert(missinginfo);
			return false;
	    }
}



function password_change()
{
		missinginfo = "";
		if (document.pass_change.curr_pass.value == "")
		{
			missinginfo += "\n     -  Current Password";
		}
		if (document.pass_change.new_pass.value == "")
		{
			missinginfo += "\n     -  New Password";
		}
		if (document.pass_change.re_pass.value == "")
		{
			missinginfo += "\n     -  Re-Type Password";
		}
		if (missinginfo != "")
		{
			missinginfo ="You failed to correctly fill in your:\n" +
			missinginfo + "\n_____________________________" +
			"\nPlease re-enter and save again!";
			alert(missinginfo);
			return false;
	    }
}


function searchcheck()
{
	if(document.searchform.searchval.value=="")
	{
		alert("Invalid Search");
		document.searchform.searchval.focus();
		return false;
	}
}



function disable()
{	
	if(document.complaint.presenter_yes.checked==true)
	{			
		document.complaint.p_name.disabled=true;		
		document.complaint.p_add.disabled=true;		
		document.complaint.p_phone.disabled=true;		
		document.complaint.p_email.disabled=true;		
		document.complaint.other_sign.disabled=true;	
		document.complaint.date1.disabled=true;
		return ;	
	}
	
	if(document.complaint.presenter_yes.checked==false)
	{		
		document.complaint.p_name.disabled=false;		
		document.complaint.p_add.disabled=false;		
		document.complaint.p_phone.disabled=false;		
		document.complaint.p_email.disabled=false;		
		document.complaint.other_sign.disabled=false;	
		document.complaint.date1.disabled=false;
		return ;	
	}
}


function othername()
{	
	if(document.complaint.other_name.checked==true)
	{		
		document.complaint.name_owner.disabled=true;		
		return ;	
	}
	
	if(document.complaint.other_name.checked==false)
	{		
		document.complaint.name_owner.disabled=false;	
		
		return ;	
	}
}



function validate()
{
		missinginfo = "";
		if (document.complaint.o_name.value == "")
		{
			missinginfo += "\n     -  Name";
		}
		
		if(document.complaint.other_name.checked!=true)
		{
			if (document.complaint.name_owner.value == "")
			{
				missinginfo += "\n     -  Owner name";
			}			
		}
		
	if(document.complaint.presenter_yes.checked!=true)
	{
		if(document.complaint.p_name.value=="")
		{
			 missinginfo += "\n     -  Presenter's Name";
		}
		if(document.complaint.p_add.value=="")
		{
			 missinginfo += "\n     -  Presenter's Address";
		}		
	}	
		
		
		
	if (document.complaint.a_name.value == "")
		{
			missinginfo += "\n     -  Animal's Name";
		}
		
	if (document.complaint.a_type.value == "")
		{
			missinginfo += "\n     -  Animal's type";
		}	
	
	
	if (document.complaint.vet_name.value == "")
		{
			missinginfo += "\n     - Vet's name";
		}
		
	if (document.complaint.vet_clinic.value == "")
		{
			missinginfo += "\n     - Vet's Clinic";
		}
		
	if (document.complaint.vet_add.value == "")
		{
			missinginfo += "\n     - Vet's Address";
		}
		
	if (document.complaint.date_incident.value == "")
		{
			missinginfo += "\n     -  Date of Incidence";
		}
		
	if(document.complaint.sign.value=="")
		{
			 missinginfo += "\n     -  Declaration Name1";
		}
	
	if(document.complaint.presenter_yes.checked!=true)
	{	
		
		if(document.complaint.other_sign.value=="")
		{
			 missinginfo += "\n     -  Declaration Name2";
		}
		
	}
	
	if(document.complaint.sp_issues.value == "")
	  {
		  missinginfo += "\n     -  Specific Issue";
	  }
	
	
	if(document.complaint.sp_invest.value == "")
	  {
		  missinginfo += "\n     -  Achieve from Investigation";
	  }
	if (missinginfo != "") {
		missinginfo ="You failed to correctly fill in your:\n" +
		missinginfo + "\n_____________________________" +
		"\nPlease re-enter and save again!";
		alert(missinginfo);
		return false;
	}

		
			
		if(document.complaint.o_name.value!="")
		{
			length_name=document.complaint.o_name.value.length;
			text=document.complaint.o_name.value;
			for ( c=0; c < length_name; c ++ )
			{
				  alpha = ( text.charCodeAt ( c ) >= 65 &&
					 text.charCodeAt ( c ) <=90 ) ||
					 text.charCodeAt ( c ) ==32  ||
					 ( text.charCodeAt ( c ) >= 97 &&
					 text.charCodeAt ( c ) <=122 )
				  if ( !alpha )
				  {				 
					 alert ( 'Enter a valid Name.' );
					 document.complaint.o_name.focus( );
					 return false;
				  }
		  	 }
		}
		
		if(document.complaint.other_name.checked!=true)
		{
			if (document.complaint.name_owner.value != "")
			{
				length_name=document.complaint.name_owner.value.length;
			    text=document.complaint.name_owner.value;
				for ( c=0; c < length_name; c ++ )
				{
					  alpha = ( text.charCodeAt ( c ) >= 65 &&
						 text.charCodeAt ( c ) <=90 ) ||
						 text.charCodeAt ( c ) ==32  ||
						 ( text.charCodeAt ( c ) >= 97 &&
						 text.charCodeAt ( c ) <=122 )
					  if ( !alpha )
					  {				 
						 alert ( 'Enter a valid Name.' );
						 document.complaint.name_owner.focus( );
						 return false;
					  }
				 }
			}
		}
		
/*	if( document.complaint.o_phone.value!= "" )
	{
		var string=document.complaint.o_phone.value;
		var length=document.complaint.o_phone.value.length;
		 for(var i=0;i<length;i++)
		{
			var str=string.substring(i,(i+1));
			var s=parseInt(str);
			if(isNaN(s))
			{
			   alert("Invalid Phone Number.");
				document.complaint.o_phone.focus();
				return false;		
			}		
		}
	}
*/	
	
			
	if( document.complaint.o_email.value!= "" )
	{
	   if((document.complaint.o_email.value.indexOf('@') == -1) || (document.complaint.o_email.value.indexOf('.') == -1))
		 {
		   alert("Enter Valid Email Address");
			document.complaint.o_email.focus();
			return false;   
		}    
	} 
	
	
	if( document.complaint.a_age.value!= "" )
	{
		age_animal=document.complaint.a_age.value.length;
			var string=document.complaint.a_age.value;
			for(var i=0;i<age_animal;i++)
			{
				var str=string.substring(i,(i+1));
				var s=parseInt(str);
				if(isNaN(s))
				{
				   alert("Enter a valid Age.");
					document.complaint.a_age.focus();
					return false;		
				}				
			}
	}
    
	
	if(document.complaint.vet_name.value!="")
		{
			length_name=document.complaint.vet_name.value.length;
			text=document.complaint.vet_name.value;
			for ( c=0; c < length_name; c ++ )
			{
				  alpha = ( text.charCodeAt ( c ) >= 65 &&
					 text.charCodeAt ( c ) <=90 ) ||
					 text.charCodeAt ( c ) ==32  ||
					 ( text.charCodeAt ( c ) >= 97 &&
					 text.charCodeAt ( c ) <=122 )
				  if ( !alpha )
				  {				 
					 alert ( 'Enter a valid Vets Name.' );
					 document.complaint.vet_name.focus( );
					 return false;
				  }
		  	 }
		}


	if(document.complaint.a_sex.value!="")
		{
			length_name=document.complaint.a_sex.value.length;
			text=document.complaint.a_sex.value;
			for ( c=0; c < length_name; c ++ )
			{
			  alpha = ( text.charCodeAt ( c ) >= 65 &&
				 text.charCodeAt ( c ) <=90 ) || 			  
				 ( text.charCodeAt ( c ) >= 97 &&
				 text.charCodeAt ( c ) <=122 )
			  if ( !alpha )
			  {				 
				 alert ( 'Enter a valid Sex.' );
				 document.complaint.a_sex.focus( );
				 return false;
			  }
		   }
		  
		}
  
  
      if(document.complaint.presenter_yes.checked!=true)
	  {
		  if (document.complaint.p_name.value != "")
			{
				length_name=document.complaint.p_name.value.length;
			    text=document.complaint.p_name.value;
				for ( c=0; c < length_name; c ++ )
				{
					  alpha = ( text.charCodeAt ( c ) >= 65 &&
						 text.charCodeAt ( c ) <=90 ) ||
						 text.charCodeAt ( c ) ==32  ||
						 ( text.charCodeAt ( c ) >= 97 &&
						 text.charCodeAt ( c ) <=122 )
					  if ( !alpha )
					  {				 
						 alert ( 'Enter a Valid Presenters Name.' );
						 document.complaint.p_name.focus( );
						 return false;
					  }
				 }
			}	  
		  
		  
			if (document.complaint.other_sign.value != "")
			{
				length_name=document.complaint.other_sign.value.length;
			    text=document.complaint.other_sign.value;
				for ( c=0; c < length_name; c ++ )
				{
					  alpha = ( text.charCodeAt ( c ) >= 65 &&
						 text.charCodeAt ( c ) <=90 ) ||
						 text.charCodeAt ( c ) ==32  ||
						 ( text.charCodeAt ( c ) >= 97 &&
						 text.charCodeAt ( c ) <=122 )
					  if ( !alpha )
					  {				 
						 alert ( 'Enter a Valid Name.' );
						 document.complaint.other_sign.focus( );
						 return false;
					  }
				 }
			}
	  }
	  
	  
	  if(document.complaint.sign.value!="")
	  {
		 length_name=document.complaint.sign.value.length;
			    text=document.complaint.sign.value;
				for ( c=0; c < length_name; c ++ )
				{
					  alpha = ( text.charCodeAt ( c ) >= 65 &&
						 text.charCodeAt ( c ) <=90 ) ||
						 text.charCodeAt ( c ) ==32  ||
						 ( text.charCodeAt ( c ) >= 97 &&
						 text.charCodeAt ( c ) <=122 )
					  if ( !alpha )
					  {				 
						 alert ( 'Enter a Valid Name.' );
						 document.complaint.sign.focus( );
						 return false;
					  }
				 }	  
	  }
   
}




function new_window()
{
	window.open("info.php","Information","resize=1,scrollbars=1,toolbar=0,width=580,height=500");
}


function login_validate()
{
	if( document.add_user.email.value != "" )
	{
	   if((document.add_user.email.value.indexOf('@') == -1) || (document.add_user.email.value.indexOf('.') == -1))
		 {
		   alert("Enter Valid Email Address");			
		   document.add_user.email.focus();
		   return false;   
		}    
	} 
	
	
	if(document.add_user.passwrd.value !=document.add_user.re_passwrd.value)
	{
		alert("Passwords do not match");
		document.add_user.re_passwrd.value="";
		document.add_user.re_passwrd.focus( );
		return false;
	}
	
	
	missinginfo = "";
		if (document.add_user.f_name.value == "")
		{
			missinginfo += "\n     -  First Name";
		}
		
		if (document.add_user.email.value == "")
		{
			missinginfo += "\n     -  Email Address";
		}			
		
		if (document.add_user.user_id.value == "")
		{
			missinginfo += "\n     -  Username";
		}	
		
		if (document.add_user.passwrd.value == "")
		{
			missinginfo += "\n     -  Password";
		}	
		if (document.add_user.re_passwrd.value == "")
		{
			missinginfo += "\n     -  Re-enter Password";
		}	
		
		
		
		if (document.add_user.category_reg.value == "0")
		{
			missinginfo += "\n     -  Category of Registration";
		}	
		
		if (missinginfo != "")
		{
			missinginfo ="You failed to correctly fill in your:\n" +
			missinginfo + "\n_____________________________" +
			"\nPlease re-enter and save again!";
			alert(missinginfo);
			return false;
		}
	
	
	if(document.add_user.f_name.value!="")
		{
			length_name=document.add_user.f_name.value.length;
			text=document.add_user.f_name.value;
			for ( c=0; c < length_name; c ++ )
			{
			  alpha = ( text.charCodeAt ( c ) >= 65 &&
				 text.charCodeAt ( c ) <=90 ) || 			  
				 ( text.charCodeAt ( c ) >= 97 &&
				 text.charCodeAt ( c ) <=122 )
			  if ( !alpha )
			  {				 
				 alert ( 'Enter a valid First Name.' );
				 document.add_user.f_name.focus( );
				 return false;
			  }
		   }		  
		}
		
	if(document.add_user.l_name.value!="")
		{
			length_name=document.add_user.l_name.value.length;
			text=document.add_user.l_name.value;
			for ( c=0; c < length_name; c ++ )
			{
			  alpha = ( text.charCodeAt ( c ) >= 65 &&
				 text.charCodeAt ( c ) <=90 ) || 			  
				 ( text.charCodeAt ( c ) >= 97 &&
				 text.charCodeAt ( c ) <=122 )
			  if ( !alpha )
			  {				 
				 alert ( 'Enter a valid Last Name.' );
				 document.add_user.l_name.focus( );
				 return false;
			  }
		   }		  
		}
}


	
		
function show_descr()
{		
		
	 if(document.bill.payment[0].checked==true)
	 {		
		 	document.getElementById('lay').style.display ='block';		  			
		    document.getElementById('layer').style.display ='none';
			document.getElementById('layer1').style.display ='none';
	}
	
	 
	  if(document.bill.payment[1].checked==true)
	   {		
	 		 document.getElementById('layer').style.display ='block';
			 document.getElementById('lay').style.display ='none';	
			 document.getElementById('layer1').style.display ='none';
	  }
			   
	
					 if(document.bill.payment[2].checked==true)
	 {		
		 	document.getElementById('layer1').style.display ='block';		  			
		    document.getElementById('layer').style.display ='none';
			document.getElementById('lay').style.display ='none';
	 }
		
	
	
}
		
		
		
		
		
		function show_descr1()
	{		
		
	 if(document.form2.type_reg[0].checked==true)
	 {		
		 	document.getElementById('lay').style.display ='block';		  			
		    document.getElementById('layer').style.display ='none';
			document.getElementById('layer1').style.display ='none';
	}
	
	if(document.form2.type_reg[1].checked==true)
	 {		
		 	document.getElementById('lay').style.display ='block';		  			
		    document.getElementById('layer').style.display ='block';
			document.getElementById('layer1').style.display ='none';
	}
	
	if(document.form2.type_reg[2].checked==true)
	 {		
		 	document.getElementById('lay').style.display ='none';		  			
		   document.getElementById('layer').style.display ='none';
			document.getElementById('layer1').style.display ='none';
	}
	
	if(document.form2.type_reg[3].checked==true)
	 {		
		 	document.getElementById('lay').style.display ='none';		  			
		  document.getElementById('layer').style.display ='none';
			document.getElementById('layer1').style.display ='none';
	}
	if(document.form2.type_reg[4].checked==true)
	 {		
		 	document.getElementById('lay').style.display ='none';		  			
		   document.getElementById('layer').style.display ='none';
			document.getElementById('layer1').style.display ='none';
	}
}

	function show_textbox()
	{		
		 if((document.ins_declare.found_guilty[0].checked==true) || (document.ins_declare.act_offence[0].checked==true))
		 {		
				document.getElementById('show_text').style.display ='block';		  			
		 }	
		
		 if((document.ins_declare.found_guilty[1].checked==true) && (document.ins_declare.act_offence[1].checked==true))
		 {		
				document.getElementById('show_text').style.display ='none';		  			
		 }	
	}
	
	function show_textbox_mob_disaster()
	{		
		 if((document.ins_declare.mob_disaster[0].checked==true))
		 {		
				document.getElementById('show_text_mob_disaster').style.display ='block';		  			
		 }	
		
		 if((document.ins_declare.mob_disaster[1].checked==true))
		 {		
				document.getElementById('show_text_mob_disaster').style.display ='none';		  			
		 }	
	}
	
	function show_textboxfitnessyes()
	{		
		document.getElementById('fitness_text').style.display ='block';		  			 
	}
	function show_textboxfitnessno()
	{		
		document.getElementById('fitness_text').style.display ='none';		  			 
	}
	
	function show_notdeclare()
	{		
		document.getElementById('not_declare').style.display ='block';	
		document.getElementById('main_declare').style.display ='none';	
	}
	function dont_display()
	{		
		document.getElementById('not_declare').style.display ='none';	
		document.getElementById('main_declare').style.display ='block';	
	}