// JavaScript Document


function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}
	
function nextbox(fldobj,nbox)
	{		
		if(fldobj.value.length>=3)
		{			
			document.getElementById(nbox).focus();
		}
	}
	
function ValidateForm(){
	if(parseInt(document.cast_category.Age.value)>=parseInt(document.cast_category.to_Age.value))
	{
		alert("Please select valid age range.");
		document.cast_category.Age.focus();
		return false;
	}
	
	if(document.cast_category.HairTypeID.value==0)
	{
		alert("Please select hair type.");
		document.cast_category.HairTypeID.focus();
		return false;
	}

	if(document.cast_category.EyesTypeID.value==0)
	{
		alert("Please select eyes type.");
		document.cast_category.EyesTypeID.focus();
		return false;
	}

	if(document.cast_category.BuildTypeID.value==0)
	{
		alert("Please select build type.");
		document.cast_category.BuildTypeID.focus();
		return false;
	}

	if(document.cast_category.EthnicityID.value==0)
	{
		alert("Please select ethnicity type.");
		document.cast_category.EthnicityID.focus();
		return false;
	}
	
	var emailID=document.cast_category.AgentEmail;
	
	/* if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	} */
	if(emailID.value!="")
	{
		 if (echeck(emailID.value)==false)
		 {
			emailID.value=""
			emailID.focus()
			return false
		}
	}
	
	if(document.cast_category.AgentPhone1.value!="" || document.cast_category.AgentPhone2.value!="" || document.cast_category.AgentPhone3.value!="")
	{
		if(!isAllNumerics(document.cast_category.AgentPhone1.value))
		{
			alert("Pleae enter valid phone number.");
			document.cast_category.AgentPhone1.value="";
			document.cast_category.AgentPhone1.focus();
			return false;
		}
		
		if(!isAllNumerics(document.cast_category.AgentPhone2.value))
		{
			alert("Pleae enter valid phone number.");
			document.cast_category.AgentPhone2.value="";
			document.cast_category.AgentPhone2.focus();
			return false;
		}
		
		if(!isAllNumerics(document.cast_category.AgentPhone3.value))
		{
			alert("Pleae enter valid phone number.");
			document.cast_category.AgentPhone3.value="";
			document.cast_category.AgentPhone3.focus();
			return false;
		}
	}
	
	var obj = document.cast_category.TalentAgency_details;		
	if (obj.value.length>=500 )
	{
	alert("Upto 500 characters are allowed in TalentAgency details field.");
	document.cast_category.TalentAgency_details.focus="";
	return false;
	}
	
	return true
 }
 
 function show(id)
{
	el = document.getElementById(id);
	if (el.style.display == 'none')
	{
		el.style.display = '';
		el = document.getElementById('more' + id);
		el.innerHTML = 'less...';
	} else {
		el.style.display = 'none';
		el = document.getElementById('more' + id);
		el.innerHTML = '#popup for fill out gender specific information...';
	}
}


function isAllNumerics(objValue)
{
		var characters="0123456789."
		var tmp
		var lTag
		lTag = 0
		temp = (objValue.length)
		//alert(objValue);
		for (var i=0;i<temp;i++)
		{
			tmp=objValue.substring(i,i+1)
			if (characters.indexOf(tmp)==-1)
			{
				lTag = 1
			}
		}
		if(lTag == 1)
			return false
		else
		  if(objValue<=0)
		   {
			return false
		   }else{ 	
			return true
		  }
}


function show_hide1(id)
{	 
	 el = document.getElementById('m');
 	 e2 = document.getElementById('f');
	if(id=="f")
	 {
	 e2.style.display = 'block';
	 e1.style.display = 'none';
	}
	else
	{
	e1.style.display = '';
	 e2.style.display = 'none';
	}	
}

function change_div(id,id1,str)
{
	 
	 el = document.getElementById(id);
	 e2= document.getElementById(id1);
	
	//document.getElementById(Gender).checked=true;
	 el.style.display = '';
	 e2.style.display = 'none';
	/* alert(str);
	if(str=="F")
	{ document.cast_category.Gender[1].checked=true;
	}
	else
	{ document.cast_category.Gender[0].checked=true;
	} */	
}

