function chk_phone(validator, field, name)
{
	var phoneNum
		= field.form.phoneNumA.value
		+ field.form.phoneNumB.value
		+ field.form.phoneNumC.value
		;
		
	if( phoneNum.length < 10 ) {
		validator.alert(field, name, 'free' , 'Please supply a value for "Telephone" in the following format: 123-555-9876');
		return false;
	}

	return true;
}

function a_radioset(validator, field, name)
{
   var group = field.form[field.name];
   var i;
   for(i = 0; i < group.length; ++i)
      if( group[i].checked )
         return true;

   validator.alert(field, name, 'free' , 'Please specify if you would like to receive future communications');

   return false;
}

function chk_captchasupplied(validator, field, name)
{
	if( field.value.length < 1 ) {
		validator.alert(field, name, 'free' , 'Please specify the value of the character graphic');
		return false;
	}

	return true;
}

function resetCaptcha(offset)
{
	var conn = getXmlHttpObject();	
	if( conn == null ) {
		return;
	}

	if( ! offset )
		offset = '';

	var url = offset + "../cgi-bin/render_captcha?format=js";

	conn.open("GET", url, false);
	conn.send(null);
	
	var resp = eval('(' + conn.responseText + ')'); 
	document.getElementById("captcha_gif").src = offset + "../gifs/" + resp.frmctl_m + ".gif";
	document.getElementById("frmctl_m").value = resp.frmctl_m;
	document.getElementById("frmctl_h").value = "";
	
}
function howOld(field)
{
   var prov = field.form.regionCode.options[field.form.regionCode.selectedIndex].value;

   if( prov == 'AB'
    || prov == 'MB'
    || prov == 'SK'
    || prov == 'ON'
    || prov == 'QC'
    || prov == 'PE' )
      return 18;
   else if( prov == 'BC'
    || prov == 'NB'
    || prov == 'NU'
    || prov == 'NT'
    || prov == 'NS'
    || prov == 'YT'
    || prov == 'NF' )
      return 19;
   else
      return 0;
}

// NOTA BETA: don't call a function "consent", one of the browers doesn't like it.  Perhaps it overrides an internal function
function consentChecked(validator, field, name)
{
	if( field.checked )
		return true;

    validator.alert(field, name, 'free' , "Please indicate that you agree with the rules of this contest");
	return false;
}

function privacyChecked(validator, field, name)
{
	if( field.checked )
		return true;

    validator.alert(field, name, 'free' , "Please indicate that you have read and understood the Privacy Policy");
	return false;
}

function getXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				return null;
			}
		}
	}
	return xmlHttp;
}

