<!--
var button = 0;

function Press(val)
{
	button = val;
}

function ToggleSelectAll(oMasterCheckBox, oCheckBoxArray)
{
	if (typeof(oMasterCheckBox) == "undefined") return;
	if (typeof(oCheckBoxArray) == "undefined") return;

	if (typeof(oCheckBoxArray[0]) == "undefined") {
		oCheckBoxArray.checked = oMasterCheckBox.checked;
		return;
	}

	var i;
	for (i = 0; i < oCheckBoxArray.length; i++) {
		if (oCheckBoxArray[i].defaultChecked == false){
			oCheckBoxArray[i].checked = oMasterCheckBox.checked;
		}
	}
}

function CancelSelectAll(oMasterCheckBox)
{
	if (typeof(oMasterCheckBox) == "undefined") return;
	oMasterCheckBox.checked = false;
}

function ValidateCompanyNotFound(oFrm)
{
	if (!ValidateTextAsEmail(oFrm.Email, gsErrMessage4)) return false;
	return true;
	
}	

function ValidateEmailAFriends(oFrm)
{
	if (!ValidateText(oFrm.ToFriendsName, /^.{1,}$/, gsErrMessage1)) return false;
	if (!ValidateTextAsEmail(oFrm.ToEmailAddress, gsErrMessage2)) return false;
	return true;
	
}	

function ValidateContactUs(oFrm)
{
	if (!ValidateText(oFrm.FromName, /^.{1,}$/, gsErrMessage1)) return false;
	if (!ValidateTextAsEmail(oFrm.FromEmailAddress, gsErrMessage2)) return false;
	if (!ValidateText(oFrm.Message, /^[\w\s\.\,\;\-\&\*\(\)\<\>\?\!\@\\\/\+\$\%\#\|\{\}\[\]\"\'\:]+$/m, gsErrMessage3)) return false;
	return true;
	
}	

function ValidateRegistration(oFrm, CompanySelected)
{
    if (button == 'cancel') return false;

	if (!CompanySelected)
		if (!ValidateCombo(oFrm.CompanyIdString, gsErrMessage1)) return false;
	if (!IsRedirection(oFrm)){
		if (!ValidateText(oFrm.HolderId, /^.{1,}$/, gsErrMessage2)) return false;
	
		if (!ValidateCombo(oFrm.CountryCode, ""))
			if (!ValidateText(oFrm.Postcode, /^.{1,}$/, gsErrMessage3)) return false;
								

		if (!ValidateTextAsEmail(oFrm.Email, gsErrMessage4)) return false;
		if (!ValidateTextAsEmail(oFrm.ConfirmEmail, gsErrMessage4)) return false;
		if (oFrm.Email.value != oFrm.ConfirmEmail.value) {
			alert(gsErrMessage7);
			oFrm.Email.focus();
			return false;
		 }
	}
	if (!ValidateCombo(oFrm.ReferrerMethod, gsErrMessage5)) return false;

	if (typeof(oFrm.AgreeTC) != "undefined") {
		if (!oFrm.AgreeTC.checked) {
			alert(gsErrMessage8);
			oFrm.AgreeTC.focus();
			return false;
		}
	}

	return true;
}


function EnableInputs(oFrm)
{
	var bIsRedir = IsRedirection(oFrm);
	var bDisableState = HasCountrySelected(oFrm);
	if (bIsRedir) bDisableState = true;

	DisableThis(oFrm.HolderId, bIsRedir);
	DisableThis(oFrm.Postcode, bIsRedir);
	DisableThis(oFrm.CountryCode, bIsRedir);
	DisableThis(oFrm.Email, bIsRedir);
	DisableThis(oFrm.ConfirmEmail, bIsRedir);
	if (oFrm.CountryState) {DisableThis(oFrm.CountryState, bDisableState);}
	return true;
}

function DisableThis(oThis, bDisabled)
{
	var sColour = "white";
	if (bDisabled) sColour = "silver";
	oThis.disabled = bDisabled;
	oThis.style.backgroundColor = sColour;
	return true;
}

function IsRedirection(oFrm)
{
	var oRegEx = /^.{1,};REDIRECT$/;
	var sIdString;
	if (typeof(oFrm.CompanyIdString.selectedIndex) == "undefined")
	{
		if (typeof(oFrm.CompanyIdString) == "undefined") return false;
		sIdString = oFrm.CompanyIdString.value;
	} else {
		sIdString = oFrm.CompanyIdString[oFrm.CompanyIdString.selectedIndex].value
	}
	if (oRegEx.test(sIdString)) return true;
	return false;
}

function HasCountrySelected(oFrm)
{
	if (typeof(oFrm.CountryCode.selectedIndex) != "undefined")
	{
		if (oFrm.CountryCode.selectedIndex != 0)
			return true;
	}
	return false;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
-->
