function CalculateEMPChars(object,CountIndex,limit)
{
	
	var CharCount = eval("document.forms[0].CharCount"+CountIndex)
	
	var objLen = parseInt(object.value.length);
	var maxLen = parseInt(CharCount.value);
	if (objLen> limit)
	{
		CharCount.value = "-1"
		alert("You have exceeded  maximum limit of "+limit+" characters.");
		object.value = object.value.substring(0,2000)
		CharCount.value = object.value.length;
		object.focus();
		return false;
		
	}
	else
		CharCount.value = (limit-objLen);
	

}

function checkValidDate(dayD,monthD,yearD)
{
	
	if( dayD.selectedIndex == 0  )
	{
		alert("Please select day.");
		dayD.focus();
		return false;
	}
	if( monthD.selectedIndex == 0  )
	{
		alert("Please select month.");
		monthD.focus();
		return false;
	}
	if( yearD.selectedIndex == 0  )
	{
		alert("Please select year.");
		yearD.focus();
		return false;
	}
	
	var dValue = dayD.value;
	var mValue = monthD.value;
	var yValue = yearD.value;
	
	if(mValue == 2 ){
		
		if(dValue>29){
			alert("Please select valid Date.");
			dayD.focus();
			return false;
		}
		else if(dValue==29 && yValue%4 != 0 )
		{
			alert("Please select valid Date.");
			dayD.focus();
			return false;
		}
	}
	else if( (mValue==4 || mValue==6 || mValue==9 || mValue==11) && dValue == 31)
	{
		alert("Please select valid Date.");
		dayD.focus();
		return false;
	}
	
	return true;
}
function checkJSEmployer(theForm)
{
	if( isAllSpaces(theForm.email.value))
	{
		alert("Please enter email.");
		theForm.email.focus();
		return false;
		
	}
	if( !isEmail(theForm.email.value))
	{
		alert("Please enter valid email.");
		theForm.email.focus();
		return false;
		
	}
	if( isAllSpaces(theForm.loginPassword1.value))
	{
		alert("Please enter the Password.");
		theForm.loginPassword1.focus();
		return false;
		
	}
	if( isAllSpaces(theForm.userRePassword.value))
	{
		alert("Re-enter your password.");
		theForm.userRePassword.focus();
		return false;
		
	}
	if( theForm.loginPassword1.value != theForm.userRePassword.value )
	{
		alert("Re-entered password does not match. Try again.");
		theForm.userRePassword.focus();
		return false;
	}
	if( isAllSpaces(theForm.group_name.value))
	{
		alert("Please enter the Company Name.");
		theForm.group_name.focus();
		return false;
		
	}
	if( isValidString(theForm.group_name.value,'Company Name') )
	{
		theForm.group_name.focus();
		return false;
	}
	if( isAllSpaces(theForm.dayPhoneCountry.value) )
	{
		alert("Please enter the Country Code.");
		theForm.dayPhoneCountry.focus();
		return false;
	}
	
	if( !isValidPhoneFax(theForm.dayPhoneCountry.value,'Country Code'))
	{
		theForm.dayPhoneCountry.focus();
		return false;
		
	}
	
	if( isAllSpaces(theForm.dayPhoneMobile.value) )
	{
		alert("Please enter the City/Mobile Code.");
		theForm.dayPhoneMobile.focus();
		return false;
	}
	
	if( !isValidPhoneFax(theForm.dayPhoneMobile.value,'City/Mobile'))
	{
		theForm.dayPhoneMobile.focus();
		return false;
		
	}
	
	if( isAllSpaces(theForm.dayPhoneNumber.value) )
	{
		alert("Please enter the Office Number.");
		theForm.dayPhoneNumber.focus();
		return false;
	}
	
	if( !isValidPhoneFax(theForm.dayPhoneNumber.value,'Office Number'))
	{
		theForm.dayPhoneNumber.focus();
		return false;
		
	}
	
	if( isAllSpaces(theForm.nightPhoneCountry.value) )
	{
		alert("Please enter the Country Code.");
		theForm.nightPhoneCountry.focus();
		return false;
	}
	if( !isValidPhoneFax(theForm.nightPhoneCountry.value,'Country Code'))
	{
		theForm.nightPhoneCountry.focus();
		return false;
		
	}
	
	if( isAllSpaces(theForm.nightPhoneMobile.value) )
	{
		alert("Please enter the City/Mobile Code.");
		theForm.nightPhoneMobile.focus();
		return false;
	}
	if( !isValidPhoneFax(theForm.nightPhoneMobile.value,'City/Mobile'))
	{
		theForm.nightPhoneMobile.focus();
		return false;
		
	}
	
	if( isAllSpaces(theForm.nightPhoneNumber.value) )
	{
		alert("Please enter the Office Number.");
		theForm.nightPhoneNumber.focus();
		return false;
	}
	if( !isValidPhoneFax(theForm.nightPhoneNumber.value,'Office Number'))
	{
		theForm.nightPhoneNumber.focus();
		return false;
		
	}
	
	if( theForm.corp_size.selectedIndex == -1 && theForm.corp_size.options.length> 0)
		{
			alert("Please select Employer Size.");
			theForm.corp_size.focus();
			return false;
		}
	if( theForm.corp_type.selectedIndex == -1 && theForm.corp_type.options.length> 0)
		{
			alert("Please select Company Business.");
			theForm.corp_size.focus();
			return false;
		}
	if( theForm.wa_country_code.selectedIndex == -1 && theForm.wa_country_code.options.length> 0)
		{
			alert("Please select Company Location.");
			theForm.wa_country_code.focus();
			return false;
		}
	if( isAllSpaces(theForm.corp_desc.value))
	{
		alert("Please enter Company Profile.");
		theForm.corp_desc.focus();
		return false;
		
	}
	if( isValidString(theForm.corp_desc.value,'Company Profile') )
	{
		theForm.corp_desc.focus();
		return false;
	}
	if( isAllSpaces(theForm.first_names.value))
	{
		alert("Please enter First Name.");
		theForm.first_names.focus();
		return false;
		
	}
	if( isValidString(theForm.first_names.value,'First Name') )
	{
		theForm.first_names.focus();
		return false;
	}
	if( isAllSpaces(theForm.last_name.value))
	{
		alert("Please enter Last Name.");
		theForm.last_name.focus();
		return false;
		
	}
	if( isValidString(theForm.last_name.value,'Last Name') )
	{
		theForm.last_name.focus();
		return false;
	}
	if( isAllSpaces(theForm.contact_title.value))
	{
		alert("Please enter Designation.");
		theForm.contact_title.focus();
		return false;
		
	}
	if( isValidString(theForm.contact_title.value,'Designation') )
	{
		theForm.contact_title.focus();
		return false;
	}
	if( theForm.ha_country_code.selectedIndex == -1 && theForm.ha_country_code.options.length> 0)
		{
			alert("Please select Home Location.");
			theForm.ha_country_code.focus();
			return false;
		}
	
	
	theForm.action = "CreateAccount.aspx"
	
	return true;
}

