function checkBlank(fieldElement, fieldDesc)
{
if (fieldElement.value.length == 0) 
  {
     alert("You must fill in the '" + fieldDesc + "' entry");
     fieldElement.focus();
     return false;
  }
else
  {
     return true;
  }
}

function checkSelect(selectObject,selectName)
{
var selectObj = selectObject
if (selectObj.selectedIndex != 0) {return true}
alert("You must choose an option from '" + selectName + "'");
selectObj.focus();
return false;
}

function checkPasswordMatch(pwd1Object,pwd2Object)
{
if (pwd1Object.value == pwd2Object.value) {return true}
alert("Your password confirmation was incorrect");
pwd1Object.focus();
return false;
}

function checkEmailMatch(pwd1Object,pwd2Object)
{
if (pwd1Object.value == pwd2Object.value) {return true}
alert("Your email confirmation was incorrect");
pwd1Object.focus();
return false;
}

function checkRadio(radioObject,radioName)
{
var chkSelect = false
var radioGrp = radioObject
for (var i = 0; i < radioGrp.length; i++) {
   if (radioGrp[i].checked == true) {return true}
}
alert("Please select an option for '" + radioName + "'");
radioObject[0].focus();
return false;
}

function isLetter (c)
{   return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) )
}


function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}

function isAlphanumeric (fieldElement,fieldDesc)

{   var i;
	var s = fieldElement.value;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number or letter.
        var c = s.charAt(i);
        if (! (isLetter(c) || isDigit(c) ) )
		{
		alert("'" + fieldDesc + "' can only be made up of letters and numbers");
		fieldElement.focus();
        return false;
		}
    }
	return true;
}

function isNumeric (fieldElement,fieldDesc)

{   var i;
	var s = fieldElement.value;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (! (isDigit(c) ) )
		{
		alert("'" + fieldDesc + "' can only be made up of numbers");
		fieldElement.focus();
        return false;
		}
    }
	return true;
}

function checkMinLength(minLength,fieldElement,fieldDesc)
{
	if (fieldElement.value.length < minLength) 
	{
	alert("'" + fieldDesc + "' must be at least " + minLength + " characters in length");
	fieldElement.focus()
	return false;
	}
	return true;			
}

function checkEmail(checkThisEmail)
{
var myEMailIsValid = true
var myAtSymbolAt = checkThisEmail.indexOf('@')
var myLastDotAt = checkThisEmail.lastIndexOf('.')
var mySpaceAt = checkThisEmail.indexOf(' ')
var myLength = checkThisEmail.length


// at least one @ must be present and not before position 2
// @yellow.com : NOT valid
// x@yellow.com : VALID

if (myAtSymbolAt < 1 ) 
{myEMailIsValid = false}


// at least one . (dot) afer the @ is required
// x@yellow : NOT valid
// x.y@yellow : NOT valid
// x@yellow.org : VALID

if (myLastDotAt < myAtSymbolAt) 
{myEMailIsValid = false}

// at least two characters [com, uk, fr, ...] must occur after the last . (dot)
// x.y@yellow. : NOT valid
// x.y@yellow.a : NOT valid
// x.y@yellow.ca : VALID

if (myLength - myLastDotAt <= 2) 
{myEMailIsValid = false}


// no empt<y space " " is permitted (one may trim the email)
// x.y@yell ow.com : NOT valid

if (mySpaceAt != -1) 
{myEMailIsValid = false}


if (myEMailIsValid == true)
{
//alert("true")
}

return myEMailIsValid
}

function confirmLink(theLink, theMsg)
{
    var is_confirmed = confirm(theMsg);
    if (is_confirmed) {
        theLink.href += '&confirmed=1';
    }

    return is_confirmed;
}


function reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
reloadPage(true);
