// JavaScript Document
/*function fields(id,flag)
{
	if(id==2)
	{
		document.RegForm.FirstName.disabled=flag;
		document.RegForm.LastName.disabled=flag;
		document.RegForm.Sex.disabled=flag;
		document.RegForm.DOBDate.disabled=flag;
		document.RegForm.DOBMonth.disabled=flag;
		document.RegForm.DOBYear.disabled=flag;
		document.RegForm.JobExp1.disabled=flag;
		document.RegForm.JobExp2.disabled=flag;
		document.RegForm.JobExp3.disabled=flag;
		document.RegForm.Email.disabled=flag;
		document.RegForm.Password.disabled=flag;
		document.RegForm.ConfirmPassword.disabled=flag;
		document.RegForm.Phone.disabled=flag;
		document.RegForm.AddressHouseNo.disabled=flag;
		document.RegForm.AddressPostCode.disabled=flag;
		document.RegForm.AddressCity.disabled=flag;
		document.RegForm.AddressCountryID.disabled=flag;
		document.RegForm.Website.disabled=flag;
		document.RegForm.TermsOfUse.disabled=flag;
	}
	
	if(id==1)
	{
		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;
		document.RegForm.CompanyTermsOfUse.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(isBlank(document.RegForm.FirstName.value))
	{
		alert('Please enter your first name.');
		document.RegForm.FirstName.focus();
		return false;
	}
		 
	if(isBlank(document.RegForm.LastName.value))
	{
		alert('Please enter your last name.');
		document.RegForm.LastName.focus();
		return false;
	}
	
	if(isBlank(document.RegForm.Email.value))
	{
		alert('Please enter your email address.');
		document.RegForm.Email.focus();
		return false;
	}
	else
	{
		if(!echeck(document.RegForm.Email.value))
		{
			alert('Please enter a valid email address.');
			document.RegForm.Email.focus();
			return false;
		}
	}
		
	if(isBlank(document.RegForm.Password.value))
	{
		alert('Please enter your password.');
		document.RegForm.Password.focus();
		return false;
	}
	
	if(isBlank(document.RegForm.ConfirmPassword.value))
	{
		alert('Please confirm your password.');
		document.RegForm.ConfirmPassword.focus();
		return false;
	}
	
	if(document.RegForm.Password.value!=document.RegForm.ConfirmPassword.value)
	{
		alert('Both passwords do not match.');
		document.RegForm.ConfirmPassword.focus();
		return false;
	}
	
	/*
	if(isBlank(document.RegForm.AddressHouseNo.value) || (document.RegForm.AddressHouseNo.value=='House Number, Street'))
	{
		alert('Please enter your address "House Number, Street".');
		document.RegForm.AddressHouseNo.value="";
		document.RegForm.AddressHouseNo.focus();
		return false;
	}
	
	if(isBlank(document.RegForm.AddressPostCode.value) || (document.RegForm.AddressPostCode.value=='Post Code'))
	{
		alert('Please enter your Post Code');
		document.RegForm.AddressPostCode.value="";
		document.RegForm.AddressPostCode.focus();
		return false;
	}
	*/
	
	if(isBlank(document.RegForm.AddressCity.value) || (document.RegForm.AddressCity.value=='City'))
	{
		alert('Please enter your City.');
		document.RegForm.AddressCity.value="";
		document.RegForm.AddressCity.focus();
		return false;
	}
			
	if(document.RegForm.AddressCountryID.options[0].selected)
	{
		alert('Please select your Country.');
		document.RegForm.AddressCountryID.focus();
		return false;
	}
	
	if(isChecked_Radio('RegForm', 'AdDisplayChoice')==-1) {
		alert('Please select a choice of pages on which you want to show your ad.');
		document.RegForm.AdDisplayChoice[0].focus();
		return false;
	}
	
	if(isChecked_Radio('RegForm', 'PackageType')==-1) {
		alert('Please select package cost.');
		document.RegForm.PackageType[0].focus();
		return false;
	}
	
	if(document.RegForm.AdTermsOfUse.checked==false)
	{
		alert('Please read and agree to the terms of use.');
		document.RegForm.AdTermsOfUse.focus();
		return false;
	}

	return true;
}
/* 
  This function checks if a radio button from radio-group has been checked
  # -- arguments -- #
  FormName: name of the form
  RadioButton: name of the radio button
  
  # -- return value -- #
  returns the index of checked radio button, -1 otherwise
*/

function isChecked_Radio(FormName, RadioButton) {
	frmRadio = eval('document.'+FormName+'.'+RadioButton);
	for (var i=0; i < frmRadio.length; i++) {
	   if (frmRadio[i].checked) {
		     return i;
			 break;
	   }		 
	}
	return -1;
}