  function bookmarksite(title, url){
    if (document.all)
    	window.external.AddFavorite(url, title);
    else if (window.sidebar)
    	window.sidebar.addPanel(title, url, "")
  }
  
  /****************************************************************/
// Define Variables
/****************************************************************/
var whitespace = " \t\n\r";

/****************************************************************/
// Returns true if the string passed in is empty
/****************************************************************/
function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

/****************************************************************/
// Returns true if the string passed in contains whitespace
/****************************************************************/
function checkEmail( email )
{
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,5})+$/.test(email.value)){
return (true)
}
alert("Invalid E-mail Address! Please re-enter.")
return (false)
}





/****************************************************************/
// Returns true if the a combo box selection has been made
// valid characters : all
/****************************************************************/

function howManyChecked (objField,myMax,myMin,whichQuestion)
/*
  This function takes 4 paramaters:
  objField -- the NAME of the checkbox to be checked, a string
  myMax -- the most you want the user to be able to check, an integer
  myMin -- the least you want the user to be able to check, an integer
  whichQuestion -- a short description of the question, a string
  
*/
{
	var _countChecked = 0;
	var err = 0;
	
	for(i=0;i<objField.length;i++)
	{
		if(objField[i].checked==true)
			{ _countChecked++; }
	}
	if(_countChecked > myMax)
		{ alert('Limit '+myMax+' checks for the '+whichQuestion+' question.');
			err = 1;}
	else if(_countChecked < myMin)
		{ alert('You need to fill out at least '+myMin+' entry(s) for '+whichQuestion+'.');
			err = 1;}
	if (err == 1) {
		return false;
	} else { 
		return true;
	}
}



/****************************************************************/
// Returns true if the string passed in is empty
/****************************************************************/

  function forceRadio(objField, FieldName)
   {
     var strField = new String(objField.value);

     // set var radio_choice to false
     var radio_choice = false;

     // Loop from zero to the one minus the number of radio button selections

     for (counter = 0; counter < objField.length; counter++)
     {

        // If a radio button has been selected it will return true
        // (If not it will return false)
        if (objField[counter].checked)
          radio_choice = true; 
     }

     if (!radio_choice)
     {
        // If there were no selections made display an alert box 
        alert("You need to enter information for " + FieldName);

        return (false);
     } 
     
		 return (true);

}


/****************************************************************/
// Returns true if the string passed in contains whitespace
/****************************************************************/
function isWhitespace (s)
{   var i;

    // Is s empty?
    if (isEmpty(s)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
	// Check that current character isn't whitespace.
	var c = s.charAt(i);

	if (whitespace.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}


/****************************************************************/
// Returns true if the string passed in is not empty
// valid characters : all
/****************************************************************/
function ForceEntry(objField, FieldName)
{
	var strField = new String(objField.value);
	if (isWhitespace(strField)) {
		alert("You need to enter information for " + FieldName);
		objField.focus();
		objField.select();
		return false;
	}

	return true;
}

/****************************************************************/
// Returns true if the a combo box selection has been made
// valid characters : all
/****************************************************************/
function ForceCombo(objField, FieldName)
{
	var strField = new String(objField.value);
	if( strField == "-1" )
	{
		alert("You need to enter information for " + FieldName);
		objField.focus();
		return false;
	}

	return true;
}
		
/****************************************************************/
// Returns true if the string passed in is a valid integer
// valid characters  : -0123456789
// special rules : - : can only appear as the first character
/****************************************************************/
function ForceInteger(objField, FieldName)
{
	var strField = new String(objField.value);
	if (isWhitespace(strField)) return true;
	var i = 0;

	for (i = 0; i < strField.length; i++)
		if ((strField.charAt(i) < '0' || strField.charAt(i) > '9') && (strField.charAt(i) != '.'))
		{
			alert(FieldName + " must be a valid numeric entry.\nYou may only use numbers from 0 to 9.");
			objField.focus();
			return false;
		}
		else
		{
			if (i>0 && strField.charAt(i) == '-')
			{
				alert(FieldName + " can only contain a negative sign '-' as the first character.");
				objField.focus();
				return false;
			}
		}
	return true;
}

/****************************************************************/
// Returns true if the string passed in is a valid float
// valid characters -.0123456789
// special rules : - : can only appear as the first character
//               : . : can only appear once
/****************************************************************/
function ForceFloat(objField, FieldName)
{
	var strField = new String(objField.value);
	var count_decimal = 0;
	if (isWhitespace(strField)) return true;
	var i = 0;

	for (i = 0; i < strField.length; i++)
		if ((strField.charAt(i) < '0' || strField.charAt(i) > '9') && (strField.charAt(i) != '.')  && (strField.charAt(i) != '-')) 
		{
			alert(FieldName + " must be a valid numeric entry.  Please do not use commas or dollar signs or any non-numeric symbols.");
			objField.focus();
			return false;
		} 
		else
		{
			if (i>0 && strField.charAt(i) == '-')
			{
				alert(FieldName + " can only contain a negative sign '-' as the first character.");
				objField.focus();
				return false;
			}
			if (strField.charAt(i) == '.')
			{
				count_decimal++;
				if (count_decimal>1)
				{
					alert(FieldName + " can only contain a single decimal place.");
					objField.focus();
					return false;
				}
			}
		}

	return true;
}


/****************************************************************/
// Returns true if the string is a valid date/month number
// inputs : strNum : The number to be evaluated
// inputs : method : The method to be applied (day or month)
/****************************************************************/
function isDateNumber(strNum,method)
{
	var str = new String(strNum);
	var i = 0;

	if (isNaN(parseInt(str)) || parseInt(str) < 0) return false;

	if (method == 1)
		if (parseInt(str) > 31)
			return false;
	if (method == 2)
		if (parseInt(str) > 12)
			return false;

	for (i = 0; i < str.length; i++)
		if (str.charAt(i) < '0' || str.charAt(i) > '9')
			return false;


	return true;
}

/****************************************************************/
// Displays an alert box with the passed in string...
/****************************************************************/
function PromptErrorMsg(Field,strError)
{
	alert("You have entered an invalid date for " + strError + ".  Please make sure your date format is in DD/MM/YYYY format, and the date and month are valid.");
	//Field.focus();
}

/****************************************************************/
/* PURPOSE: Checks to see if the string is a valid date. 
// valid date formats : DD/MM/YY  DD/MM/YYYY  D/M/YY  D/M/YYYY
//						DD-MM-YY  DD-MM-YYYY  D-M-YY  D-M-YYYY
/****************************************************************/
function ForceDate(strDate,strField)
{
	var str = new String(strDate.value);

    
	if (isWhitespace(str)) {
		return true;
		// if the field is empty, return TRUE... use FORCEENTRY to check if required
	}
  
	var i = 0, count = str.length, j = 0;
	while ((str.charAt(i) != "/" && str.charAt(i) != "-") && i < count)
		i++;

	if (i == count || i > 2) {
		PromptErrorMsg(strDate,strField);
		return false;
	}


	var addOne = false;
	if (i == 2) addOne = true;

	if (!isDateNumber(str.substring(0,i),1)) {
		PromptErrorMsg(strDate,strField);
		return false;
	}

	j = i+1;
	i = 0;

	while ((str.charAt(i+j) != "/" && str.charAt(j+i) != "-") && i+j < count)
		i++;

	if (i+j == count || i > 2) {
		PromptErrorMsg(strDate,strField);
		return false;
	}

	if (!isDateNumber(str.substring(j,i+j),2)) {
		PromptErrorMsg(strDate,strField);
		return false;
	}

	j = i+3;
	i = 0;

	if (addOne) j++;

	while (i+j < count)
		i++;


	if (i != 2 && i != 4) {
		PromptErrorMsg(strDate,strField);
		return false;
	}

	if (!isDateNumber(str.substring(j,i+j),3)) {
		PromptErrorMsg(strDate,strField);
		return false;
	}

	return true;
}


function Clear(theText) {

	if (theText.value == theText.defaultValue) {
    theText.value = ""
	}
}


function clearText(field){

    if (field.defaultValue == field.value) field.value = '';
    else if (field.value == '') field.value = field.defaultValue;

}



