// JavaScript Document

function validation()
{	
		if(isEmpty((document.form1.login_username),'Please Enter User Name')){return false;}
		if(isEmpty((document.form1.conf_login_password),'Please Enter Confirm Password')){return false;}
		if(isEqual((document.form1.login_password),(document.form1.conf_login_password),'Password Mismatch!')){return false;}
		if(isEmail((document.form1.login_email),'Email')){return false;}
		if(isEmpty((document.form1.login_name),'Please Enter Login Name')){return false;}
		if(isEmpty((document.form1.login_contributor_name),'Please Enter Contributor Name')){return false;}
		if(isEmpty((document.form1.Captcha),'Please Enter Captcha')){return false;}
		
}

function add_birds()
{
	if(isSelected((document.mybirds.bird_breed),'Select Bird Breed')){return false;}
	if(isEmpty((document.mybirds.bird_name),'Please Enter Bird Name')){return false;}
	if(isSelected((document.mybirds.bird_sex),'Select Bird Sex')){return false;}
	if(isEmpty((document.mybirds.bird_father),'Please Enter Bird Father Name')){return false;}
	if(isEmpty((document.mybirds.bird_mother),'Please Enter Bird Mother Name')){return false;}
	if(isEmpty((document.mybirds.bird_hatched_date),'Please Enter Hatched Date')){return false;}
	if(isSelected((document.mybirds.bird_ident_type),'Select Bird Identification Type')){return false;}
	if(isNumeric((document.mybirds.bird_ident_number),'Please Enter Bird Identification Number','Bird Identification Number should be numeric')){return false;}
	if(isNumeric((document.mybirds.bird_weight),'Please Enter Bird Weight','Bird Weight should be numeric')){return false;}
	if(isEmpty((document.mybirds.bird_lineage),'Please Enter Bird Lineage')){return false;}
	if(isEmpty((document.mybirds.bird_color),'Please Enter Bird Color')){return false;}
	if(isNumeric((document.mybirds.bird_quantity),'Please Enter Bird Quantity','Bird Quantity should be numeric')){return false;}
	if(isNumeric((document.mybirds.bird_price),'Please Enter Bird Price','Bird Price should be numeric')){return false;}
	if(isEmpty((document.mybirds.bird_short_description),'Please Enter Short Description')){return false;}
}

function isEmpty(var1,var2)
{
	if(var1.value=="")
	 {
		 alert(var2)
		 var1.focus()
	     return true
 	 }
}

function isEqual(var1,var2,var3)
{
	if(var1.value!=var2.value)
	 {
		 alert(var3)
		 var2.focus()
	     return true
 	 }
}

function isEmail(var1,var2)
{
	if(var1.value=="")
	 {
		 alert("Please Enter "+var2+" Address");
		 var1.focus()
	     return true
 	 }
     if(var1.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1)
	{
		alert("Your "+var2+" is not valid");
		var1.focus()
		return true
	}
	 
}

function isSelected(var1,var2)
{
	if(var1.value=="")
	 {
		 alert(var2)
		 var1.focus()
	     return true
 	 }
}

function isNumeric(var1, var2, var3){
	if(var1.value == ""){
		 alert(var2)
		 var1.focus()
		 return true
 	 }
	if(var1.value.search(/^[0-9]+$/) == -1){
		 alert(var3);
		 var1.select();
	     return true
 	 }
}

function loginvalidate()
{
	if(sign > 1 && document.getElementById('login_password').value > 0 )
	{
		return false
	}

}
