// JavaScript Document
function fields(id,flag)
{
	if(id==2)
	{
		document.RegForm.FLancerFirstName.disabled=flag;
		document.RegForm.FLancerLastName.disabled=flag;
		document.RegForm.FLancerSex.disabled=flag;
		document.RegForm.FLancerDOBDate.disabled=flag;
		document.RegForm.FLancerDOBMonth.disabled=flag;
		document.RegForm.FLancerDOBYear.disabled=flag;
		document.RegForm.FLancerJobExp1.disabled=flag;
		document.RegForm.FLancerJobExp2.disabled=flag;
		document.RegForm.FLancerJobExp3.disabled=flag;
		document.RegForm.FLancerEmail.disabled=flag;
		document.RegForm.FLancerPassword.disabled=flag;
		document.RegForm.FLancerConfirmPassword.disabled=flag;
		document.RegForm.FLancerPhone.disabled=flag;
		document.RegForm.FLancerAddressHouseNo.disabled=flag;
		document.RegForm.FLancerAddressPostCode.disabled=flag;
		document.RegForm.FLancerAddressCity.disabled=flag;
		document.RegForm.FLancerAddressCountryID.disabled=flag;
		document.RegForm.FLancerWebsite.disabled=flag;
	}
	
	if(id==1)
	{
		document.RegForm.CompanyTypeID.disabled=flag;
		document.RegForm.CompanyName.disabled=flag;
		document.RegForm.CompanyEmail.disabled=flag;
		document.RegForm.CompanyPassword.disabled=flag;
		document.RegForm.CompanyConfirmPassword.disabled=flag;
		document.RegForm.CompanyContactPerson.disabled=flag;
		document.RegForm.CompanyContactPersonEmail.disabled=flag;
		document.RegForm.CompanyPhone.disabled=flag;
		document.RegForm.CompanyAddressHouseNo.disabled=flag;
		document.RegForm.CompanyAddressPostCode.disabled=flag;
		document.RegForm.CompanyAddressCity.disabled=flag;
		document.RegForm.CompanyAddressCountryID.disabled=flag;
		document.RegForm.CompanyWebsite.disabled=flag;
	}
}

function layer_act(id)
{
	//alert(id);
	var ie=document.all
	var dom=document.getElementById
	var ns4=document.layers
	
	if(id==1 || id=='1')
	{		
		fields(2,true);
		crossobjFL=(dom)?document.getElementById("FreeLancer").style : ie? document.all.FreeLancer : document.FreeLancer
		crossobjFL.display = 'none';
		
		crossobjCP=(dom)?document.getElementById("Company").style : ie? document.all.Company : document.Company
		crossobjCP.display = 'block';
		fields(1,false);
	}
	else
	{
		crossobjFL=(dom)?document.getElementById("FreeLancer").style : ie? document.all.FreeLancer : document.FreeLancer
		crossobjFL.display = 'block';
		fields(2,false);		
		
		fields(1,true);
		crossobjCP=(dom)?document.getElementById("Company").style : ie? document.all.Company : document.Company
		crossobjCP.display = 'none';
	}
}

function address_field(FieldName,Text)
{
	if(eval('document.RegForm.'+FieldName).value==Text)
		eval('document.RegForm.'+FieldName).value="";	
}

function address_field_resume(FieldName,Text)
{
	if(eval('document.RegForm.'+FieldName).value=="")
		eval('document.RegForm.'+FieldName).value=Text;	
}

function setBackgroundColor( color )
{
	document.getElementById( color ).style.background="#FFFFCC";
}	
function setDefaultBackgroundColor( color )	
{
	document.getElementById( color ).style.background="#FFFFFF";
}

function validation()
{
	if(document.RegForm.IAm[1].checked==true)
	{
		if(isBlank(document.RegForm.FLancerFirstName.value))
		{
			alert('Please enter your first name.');
			document.RegForm.FLancerFirstName.focus();
			return false;
		}
			 
		if(isBlank(document.RegForm.FLancerLastName.value))
		{
			alert('Please enter your last name.');
			document.RegForm.FLancerLastName.focus();
			return false;
		}
		
		if(!(document.RegForm.FLancerDOBDate.options[0].selected)|| !(document.RegForm.FLancerDOBMonth.options[0].selected) || !(document.RegForm.FLancerDOBYear.options[0].selected))
		{
			if(document.RegForm.FLancerDOBDate.options[0].selected)
			{
				alert('Please select day.');
				document.RegForm.FLancerDOBDate.focus();
				return false;
			}
			
			if(document.RegForm.FLancerDOBMonth.options[0].selected)
			{
				alert('Please select month.');
				document.RegForm.FLancerDOBMonth.focus();
				return false;
			}
			
			if(document.RegForm.FLancerDOBYear.options[0].selected)
			{
				alert('Please select year.');
				document.RegForm.FLancerDOBYear.focus();
				return false;
			}			
		}
		
		if(document.RegForm.FLancerJobExp1.options[0].selected && document.RegForm.FLancerJobExp2.options[0].selected && document.RegForm.FLancerJobExp3.options[0].selected)
		{
			alert('Please select your job experience.');
			document.RegForm.FLancerJobExp1.focus();
			return false;
		}
			
		if(isBlank(document.RegForm.FLancerEmail.value))
		{
			alert('Please enter your email address.');
			document.RegForm.FLancerEmail.focus();
			return false;
		}
		else
		{
			if(!echeck(document.RegForm.FLancerEmail.value))
			{
				alert('Please enter a valid email address.');
				document.RegForm.FLancerEmail.focus();
				return false;
			}
		}
			
		if(isBlank(document.RegForm.FLancerPassword.value))
		{
			alert('Please enter your password.');
			document.RegForm.FLancerPassword.focus();
			return false;
		}
		
		if(isBlank(document.RegForm.FLancerConfirmPassword.value))
		{
			alert('Please confirm your password.');
			document.RegForm.FLancerConfirmPassword.focus();
			return false;
		}
		
		if(document.RegForm.FLancerPassword.value!=document.RegForm.FLancerConfirmPassword.value)
		{
			alert('Both passwords do not match.');
			document.RegForm.FLancerConfirmPassword.focus();
			return false;
		}
		
		/*
		if(isBlank(document.RegForm.FLancerAddressHouseNo.value) || (document.RegForm.FLancerAddressHouseNo.value=='House Number, Street'))
		{
			alert('Please enter your address "House Number, Street".');
			document.RegForm.FLancerAddressHouseNo.value="";
			document.RegForm.FLancerAddressHouseNo.focus();
			return false;
		}
		
		if(isBlank(document.RegForm.FLancerAddressPostCode.value) || (document.RegForm.FLancerAddressPostCode.value=='Post Code'))
		{
			alert('Please enter your Post Code');
			document.RegForm.FLancerAddressPostCode.value="";
			document.RegForm.FLancerAddressPostCode.focus();
			return false;
		}
		*/
		
		if(isBlank(document.RegForm.FLancerAddressCity.value) || (document.RegForm.FLancerAddressCity.value=='City'))
		{
			alert('Please enter your City.');
			document.RegForm.FLancerAddressCity.value="";
			document.RegForm.FLancerAddressCity.focus();
			return false;
		}
				
		if(document.RegForm.FLancerAddressCountryID.options[0].selected)
		{
			alert('Please select your Country.');
			document.RegForm.FLancerAddressCountryID.focus();
			return false;
		}		
		
		if(document.RegForm.TermsOfUse.checked==false)
		{
			alert('Please read and agree to the terms of use.');
			document.RegForm.TermsOfUse.focus();
			return false;
		}
	}
	else if(document.RegForm.IAm[0].checked==true)
	{
		if(document.RegForm.CompanyTypeID.options[0].selected==true)
		{
			alert('Please select company type.');
			document.RegForm.CompanyTypeID.focus();
			return false;
		}
		
		if(isBlank(document.RegForm.CompanyName.value))
		{
			alert('Please enter company name.');
			document.RegForm.CompanyName.focus();
			return false;
		}
					
		if(isBlank(document.RegForm.CompanyEmail.value))
		{
			alert('Please enter email address.');
			document.RegForm.CompanyEmail.focus();
			return false;
		}
		else
		{
			if(!echeck(document.RegForm.CompanyEmail.value))
			{
				alert('Please enter a valid email address.');
				document.RegForm.CompanyEmail.focus();
				return false;
			}
		}
			
		if(isBlank(document.RegForm.CompanyPassword.value))
		{
			alert('Please enter password.');
			document.RegForm.CompanyPassword.focus();
			return false;
		}
		
		if(isBlank(document.RegForm.CompanyConfirmPassword.value))
		{
			alert('Please confirm password.');
			document.RegForm.CompanyConfirmPassword.focus();
			return false;
		}
		
		if(document.RegForm.CompanyPassword.value!=document.RegForm.CompanyConfirmPassword.value)
		{
			alert('Confirm password have not match to password. Please re-confirm password.');
			document.RegForm.CompanyConfirmPassword.focus();
			return false;
		}
		
		if(isBlank(document.RegForm.CompanyContactPerson.value))
		{
			alert('Please enter contact person name.');
			document.RegForm.CompanyContactPerson.focus();
			return false;
		}
					
		if(isBlank(document.RegForm.CompanyContactPersonEmail.value))
		{
			alert('Please enter contact person email address.');
			document.RegForm.CompanyContactPersonEmail.focus();
			return false;
		}
		else
		{
			if(!echeck(document.RegForm.CompanyContactPersonEmail.value))
			{
				alert('Please enter a valid contact person email address.');
				document.RegForm.CompanyContactPersonEmail.focus();
				return false;
			}
		}
		
		/*
		if(isBlank(document.RegForm.CompanyAddressHouseNo.value) || (document.RegForm.CompanyAddressHouseNo.value=='House Number, Street'))
		{
			alert('Please enter company address "House Number, Street".');
			document.RegForm.CompanyAddressHouseNo.value="";
			document.RegForm.CompanyAddressHouseNo.focus();
			return false;
		}
		
		if(isBlank(document.RegForm.CompanyAddressPostCode.value) || (document.RegForm.CompanyAddressPostCode.value=='Post Code'))
		{
			alert('Please enter Post Code');
			document.RegForm.CompanyAddressPostCode.value="";
			document.RegForm.CompanyAddressPostCode.focus();
			return false;
		}
		*/
		
		if(isBlank(document.RegForm.CompanyAddressCity.value) || (document.RegForm.CompanyAddressCity.value=='City'))
		{
			alert('Please enter City.');
			document.RegForm.CompanyAddressCity.value="";
			document.RegForm.CompanyAddressCity.focus();
			return false;
		}
		
		if(document.RegForm.CompanyAddressCountryID.options[0].selected)
		{
			alert('Please select Country.');
			document.RegForm.CompanyAddressCountryID.focus();
			return false;
		}
				
		if(document.RegForm.TermsOfUse.checked==false)
		{
			alert('Please read and agree to the terms of use.');
			document.RegForm.TermsOfUse.focus();
			return false;
		}
	}
	return true;
}
