// JavaScript Document
function loginvalidate()
{
	if(document.getElementById("login").value=="")
		{
			alert("please enter login name");
			document.getElementById("login").focus();
			return false;
		
		}
		if(document.getElementById("password").value=="")
		{
			alert("please enter password");
			document.getElementById("password").focus();
			return false;
		
		}
	return true;
}
function changePassword()
{
	if(document.getElementById("password").value!=document.getElementById("cpassword").value)
		{
			alert(" Your password doesn't match.  Please make sure you retype in the same password ");
			document.getElementById("password").focus();
			return false;
		}
}

function validate_email(form_id,email) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = document.forms[form_id].elements[email].value;
   if(reg.test(address) == false) {
      alert('Invalid Email Address');
      return false;
   }
   return true;
}
function trimSpace(value)
	{
		var input = value;
		var output = "";
		for (var i = 0; i < input.length; i++)
		 {
		if((input.charAt(i) == " ")) 
			{

			}
			 else
			{
			output += input.charAt(i);
			}
		 }

		return output;
	 }
function addClientValidate()
{
		// alert(document.getElementById("firstname"));
	//	alert("hello");
		var a = document.getElementById('r1');
		var b = document.getElementById('r2');
		
		if(document.getElementById("firstname").value=="")
		{
			alert("please enter first name");
			document.getElementById("firstname").focus();
			return false;
		
		}
		if(document.getElementById("lastname").value=="")
		{
			alert("please enter last name");
			document.getElementById("lastname").focus();
			return false;
		}
		if ( (a.checked == false ) && (b.checked == false ) )
			 {
			alert("please select your gender");
			document.getElementById('r2').focus();
			return false;
			 }
		if(document.getElementById("dob").value=="")
		{
			alert("please enter date of birth ");
			document.getElementById("dob").focus();
			return false;	
		}
		 var emailID;	
		emailID =	trimSpace(document.custregis.email.value);
		
		if(emailID == '' || emailID == null)
		{
			alert("Please fill your email id!");
			document.custregis.email.focus();
			//emailID.focus();
			return false;
		}
	
		var filter=/^.+@.+\..{2,3}$/;
	
		if (!filter.test(emailID))
		{
			alert("Please enter a valid email id !");
			document.custregis.email.focus();
			 
			return false;
		}

		if(document.getElementById("login").value=="")
		{
			alert("please enter login name");
			document.getElementById("login").focus();
			return false;
		
		}
		if(document.getElementById("password").value=="")
		{
			alert("please enter password");
			document.getElementById("password").focus();
			return false;
		
		}
		if(document.getElementById("cpassword").value=="")
		{
			alert("please enter cpassword");
			document.getElementById("cpassword").focus();
			return false;
		
		}/*if(document.getElementById("password").value.length>=10)
		{
		      msg+="* The following required fields must be of less than or eqaul to 10 characters \n";
      		  //document.form1.password.focus();				
      			//return false;
		}*/
		if(document.getElementById("password").value!=document.getElementById("cpassword").value)
		{
			alert(" Your password doesn't match.  Please make sure you retype in the same password ");
			document.getElementById("password").focus();
			return false;
		}

		if(document.getElementById("street").value=="")
		{
			alert("please enter street");
			document.getElementById("street").focus();
			return false;
		}
		if(document.getElementById("postcode").value=="")
		{
			alert("please enter post code");
			document.getElementById("postcode").focus();
			return false;
		}
		if(!(IsNumeric(document.getElementById('postcode').value)))
	    {
		alert("Post code number should have only numbers.");
		document.getElementById("postcode").focus();
			return false;
	    }
		if(document.getElementById("city").value=="")
		{
			alert("please enter city");
			document.getElementById("city").focus();
			return false;
		}
		if(document.getElementById("telephone").value=="")
		{
			alert("please enter telephone number");
			document.getElementById("telephone").focus();
			return false;
		}
		if(!(IsNumeric(document.getElementById('telephone').value)))
	    {
		alert("Phone number should have only numbers.");
		document.getElementById("telephone").focus();
			return false;
	    }
		if(document.getElementById("telephone").value!="")
		{
			if(!(IsNumeric(document.getElementById('fax').value)))
			{
			alert("Fax number should have only numbers.");
			document.getElementById("fax").focus();
				return false;
			}
		}
		
		function IsNumeric(sText)
	{
	   var ValidChars = "0123456789-";
	   var IsNumber=true;
	   var Char;
 
	   for (i = 0; i < sText.length && IsNumber == true; i++) 
       { 
      		Char = sText.charAt(i); 
		    if (ValidChars.indexOf(Char) == -1) 
         	{
		         IsNumber = false;
            }
      }
		   return IsNumber;
    }	

		 
}
function addMemberValidate()
{
		// alert(document.getElementById("firstname"));
	//	alert("hello");
		var a = document.getElementById('r1');
		var b = document.getElementById('r2');
		
		if(document.getElementById("firstname").value=="")
		{
			alert("please enter first name");
			document.getElementById("firstname").focus();
			return false;
		
		}
		if(document.getElementById("lastname").value=="")
		{
			alert("please enter last name");
			document.getElementById("lastname").focus();
			return false;
		}
		if ( (a.checked == false ) && (b.checked == false ) )
			 {
			alert("please select your gender");
			document.getElementById('r2').focus();
			return false;
			 }
		if(document.getElementById("dob").value=="")
		{
			alert("please enter date of birth ");
			document.getElementById("dob").focus();
			return false;	
		}
		 var emailID;	
		emailID =	trimSpace(document.custregis.email.value);
		
		if(emailID == '' || emailID == null)
		{
			alert("Please fill your email id!");
			document.custregis.email.focus();
			//emailID.focus();
			return false;
		}
	
		var filter=/^.+@.+\..{2,3}$/;
	
		if (!filter.test(emailID))
		{
			alert("Please enter a valid email id !");
			document.custregis.email.focus();
			 
			return false;
		}

		/*if(document.getElementById("login").value=="")
		{
			alert("please enter login name");
			document.getElementById("login").focus();
			return false;
		
		}
		if(document.getElementById("password").value=="")
		{
			alert("please enter password");
			document.getElementById("password").focus();
			return false;
		
		}
		if(document.getElementById("cpassword").value=="")
		{
			alert("please enter cpassword");
			document.getElementById("cpassword").focus();
			return false;
		
		}*/
		/*if(document.getElementById("password").value.length>=10)
		{
		      msg+="* The following required fields must be of less than or eqaul to 10 characters \n";
      		  //document.form1.password.focus();				
      			//return false;
		}*/	
			
		/*if(document.getElementById("password").value!=document.getElementById("cpassword").value)
		{
			alert(" Your password doesn't match.  Please make sure you retype in the same password ");
			document.getElementById("password").focus();
			return false;
		}*/

		if(document.getElementById("street").value=="")
		{
			alert("please enter street");
			document.getElementById("street").focus();
			return false;
		}
		if(document.getElementById("postcode").value=="")
		{
			alert("please enter post code");
			document.getElementById("postcode").focus();
			return false;
		}
		if(!(IsNumeric(document.getElementById('postcode').value)))
	    {
		alert("Post code number should have only numbers.");
		document.getElementById("postcode").focus();
			return false;
	    }
		if(document.getElementById("city").value=="")
		{
			alert("please enter city");
			document.getElementById("city").focus();
			return false;
		}
		if(document.getElementById("telephone").value=="")
		{
			alert("please enter telephone number");
			document.getElementById("telephone").focus();
			return false;
		}
		if(!(IsNumeric(document.getElementById('telephone').value)))
	    {
		alert("Phone number should have only numbers.");
		document.getElementById("telephone").focus();
			return false;
	    }
		if(document.getElementById("telephone").value!="")
		{
			if(!(IsNumeric(document.getElementById('fax').value)))
			{
			alert("Fax number should have only numbers.");
			document.getElementById("fax").focus();
				return false;
			}
		}
		
		function IsNumeric(sText)
	{
	   var ValidChars = "0123456789-";
	   var IsNumber=true;
	   var Char;
 
	   for (i = 0; i < sText.length && IsNumber == true; i++) 
       { 
      		Char = sText.charAt(i); 
		    if (ValidChars.indexOf(Char) == -1) 
         	{
		         IsNumber = false;
            }
      }
		   return IsNumber;
    }	

		 
}

function validateTalent()
{
	var a = document.getElementById('gender1');
	var b = document.getElementById('gender2');
	
	if(document.getElementById("firstname").value=="")
		{
			alert("please enter first name");
			document.getElementById("firstname").focus();
			return false;
		
		}
		if(document.getElementById("sname").value=="")
		{
			alert("please enter stage name");
			document.getElementById("sname").focus();
			return false;
		}
		if(document.getElementById("lastname").value=="")
		{
			alert("please enter last name");
			document.getElementById("lastname").focus();
			return false;
		}
		
		if ( (a.checked == false ) && (b.checked == false ) )
			 {
			alert("please select your gender");
			document.getElementById('r2').focus();
			return false;
			 }
		if(document.getElementById("date1").value=="")
		{
			alert("please enter date of birth ");
			document.getElementById("date1").focus();
			return false;	
		}
		 var emailID;	
		emailID =	trimSpace(document.talent.email.value);
		
		if(emailID == '' || emailID == null)
		{
			alert("Please fill your email id!");
			document.talent.email.focus();
			//emailID.focus();
			return false;
		}
		if(!validate_email('talent','email'))
		{
			document.getElementById("email").focus();
		}
	
}
function addSearchTagValidate()
{
		if(document.getElementById("title").value=="")
		{
			alert("please enter title");
			document.getElementById("title").focus();
			return false;
		
		}
		if(document.getElementById("description").value=="")
		{
			alert("please enter description");
			document.getElementById("description").focus();
			return false;
		}
}
