function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function simplePreload()
{
  var args = simplePreload.arguments;
  document.imageArray = new Array(args.length);
  for(var i=0; i<args.length; i++)
  {
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];
  }
}

var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height,windowname)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, windowname, 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}


function isValidURL(url){
    var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
    if(RegExp.test(url)){
        return true;
    }else{
		alert("Please enter the url in this form: http://www.abc.org.");
        return false;
    }
}

function isValidEmail(address){
	invalidChars = "/:,;"
	for (i=0; i<invalidChars.length; i++){
		badChar = invalidChars.charAt(i)
		if(address.indexOf(badChar,0)>-1){
			alert ("Please enter a valid e-mail address")
			return false
		}
	}
	atPos = address.indexOf("@",1)
	if(atPos == -1){
		alert ("Please enter a valid e-mail address")
		return false
	}
	periodPos = address.indexOf(".",atPos)
	if(periodPos == -1){
		alert ("Please enter a valid e-mail address")
		return false
	}
	if(periodPos+3 > address.length){
		alert ("Please enter a valid e-mail address")
		return false
	}
	return true
}

function isValidZip(zip){
	for (i=0; i < zip.length; i++){
		if(zip.charAt(i) < "0"){
			alert ("Please enter a 5-digit zip code, like this: 55555")
			return false
		}
		if(zip.charAt(i) > "5"){
			alert ("Please enter a 5-digit zip code, like this: 55555")
			return false
		}
	}
	return true
}

function isValidPhone(phone){
   var stripped = phone.replace(/[\(\)\.\-\ ]/g, '')
   if (isNaN(parseInt(stripped))) {
        alert("The phone number contains illegal characters.")
        return false
   }
   if (!(stripped.length == 10)) {
        alert("The phone number is the wrong length. Make sure you included an area code.")
        return false
    }
    return true
}

function isValidFax(fax){
   var stripped = fax.replace(/[\(\)\.\-\ ]/g, '')
   if (isNaN(parseInt(stripped))) {
        alert("The fax number contains illegal characters.")
        return false
   }
   if (!(stripped.length == 10)) {
        alert("The fax number is the wrong length. Make sure you included an area code.")
        return false
    }
    return true
}

//---------------------------------------------------------------------------------------------------------------------
//---------------------------------------- You can call this function with only----------------------------------------
//----------------------------------------   the 'num' object (reference your  ----------------------------------------
//----------------------------------------   field you want to format). If no  ----------------------------------------
//----------------------------------------formats are sent, it will use default----------------------------------------
//----------------------------------------             formats.                ----------------------------------------
//---------------------------------------------------------------------------------------------------------------------
function FormatNumber(num, format, shortformat)
{
	if(format==null)
	{
			// Choose the default format you prefer for the <b style="color:black;background-color:#a0ffff">number</b>.
		//format = "#-(###) ###-#### ";		// Telephone w/ LD Prefix and Area Code
		format = "(###) ###-#### ";			// Telephone w/ Area Code
		//format = "###-###-####";			// Telephone w/ Area Code (dash seperated)
		//format = "###-##-####";			//Social Security <b style="color:black;background-color:#a0ffff">Number</b>
	}
//---------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------
	if(shortformat==null)
	{
		// Choose the short format (without area code) you prefer.
		//If you do not want multiple formats, leave it as "".

		//var shortformat = "###-#### ";
		var shortformat = "";
	}

//---------------------------------------------------------------------------------------------------------------------
//----------------------------------------This code can be used to format any <b style="color:black;background-color:#a0ffff">number</b>. ---------------------------------
//----------------------------------------Simply change the format to a <b style="color:black;background-color:#a0ffff">number</b> format ---------------------------------
//---------------------------------------- you prefer. It will ignore all characters  ---------------------------------
//----------------------------------------  except the #, where it will replace with  ---------------------------------
//----------------------------------------               user input.                  ---------------------------------
//---------------------------------------------------------------------------------------------------------------------

	var validchars = "0123456789";
	var tempstring = "";
	var returnstring = "";
	var extension = "";
	var tempstringpointer = 0;
	var returnstringpointer = 0;
	count = 0;

	// Get the length so we can go through and remove all non-numeric characters
	var length = num.value.length;


	// We are only concerned with the format of the phone <b style="color:black;background-color:#a0ffff">number</b> - extensions can be left alone.
	if (length > format.length)
	{
		length = format.length;
	};

	// scroll through what the user has typed
	for (var x=0; x<length; x++)
	{
		if (validchars.indexOf(num.value.charAt(x))!=-1)
		{
		tempstring = tempstring + num.value.charAt(x);
		};
	};
	// We should now have just the #s - extract the extension if needed
	if (num.value.length > format.length)
	{
		length = format.length;
		extension = num.value.substr(format.length, (num.value.length-format.length));
	};

	// if we have fewer characters than our short format, well default to the short version.
	for (x=0; x<shortformat.length;x++)
	{
		if (shortformat.substr(x, 1)=="#")
		{
			count++;
		};
	}
	if (tempstring.length <= count)
	{
		format = shortformat;
	};


	//Loop through the format string and insert the numbers where we find a # sign
	for (x=0; x<format.length;x++)
	{
		if (tempstringpointer <= tempstring.length)
		{
			if (format.substr(x, 1)=="#")
			{
				returnstring = returnstring + tempstring.substr(tempstringpointer, 1);
				tempstringpointer++;
			}else{
				returnstring = returnstring + format.substr(x, 1);
			}
		}

	}

	// We have gone through the entire format, lets add the extension back on.
		returnstring = returnstring + extension;

	//were done - lets return our value to the field.
	num.value = returnstring;
}




function currencyFormat(fld, milSep, decSep, e) {
  var sep = 0;
  var key = '';
  var i = j = 0;
  var len = len2 = 0;
  var strCheck = '0123456789';
  var aux = aux2 = '';
  var whichCode = (window.Event) ? e.which : e.keyCode;

  if (whichCode == 13) return true;  // Enter
  if (whichCode == 8) return true;  // Delete
  key = String.fromCharCode(whichCode);  // Get key value from key code
  if (strCheck.indexOf(key) == -1) return false;  // Not a valid key
  len = fld.value.length;
  for(i = 0; i < len; i++)
  if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
  aux = '';
  for(; i < len; i++)
  if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
  aux += key;
  len = aux.length;
  if (len == 0) fld.value = '';
  if (len == 1) fld.value = '0'+ decSep + '0' + aux;
  if (len == 2) fld.value = '0'+ decSep + aux;
  if (len > 2) {
    aux2 = '';
    for (j = 0, i = len - 3; i >= 0; i--) {
      if (j == 3) {
        aux2 += milSep;
        j = 0;
      }
      aux2 += aux.charAt(i);
      j++;
    }
    fld.value = '';
    len2 = aux2.length;
    for (i = len2 - 1; i >= 0; i--)
    fld.value += aux2.charAt(i);
    fld.value += decSep + aux.substr(len - 2, len);
  }
  return false;
}

function isValidDate(date){
	for (i=0; i < 4; i++){
		if(date.charAt(i) < "0"){
			alert ("Please use the calendar tool to enter the date like this: 2008-02-16");
			return false;
		}
		if(date.charAt(i) > "9"){
			alert ("Please use the calendar tool to enter the date like this: 2008-02-16");
			return false;
		}
	}
	for (i=5; i < 7; i++){
		if(date.charAt(i) < "0"){
			alert ("Please use the calendar tool to enter the date like this: 2008-02-16");
			return false;
		}
		if(date.charAt(i) > "9"){
			alert ("Please use the calendar tool to enter the date like this: 2008-02-16");
			return false;
		}
	}
	for (i=8; i < 10; i++){
		if(date.charAt(i) < "0"){
			alert ("Please use the calendar tool to enter the date like this: 2008-02-16");
			return false;
		}
		if(date.charAt(i) > "9"){
			alert ("Please use the calendar tool to enter the date like this: 2008-02-16");
			return false;
		}
	}

	return true
}


function swapOptions(the_text, the_form, the_field)
{
	the_field = the_field+"2";
	if (the_text == "other"){
		x ="window.document."+the_form+"."+the_field+".disabled = false";
		eval(x);
	}else{
		x = "window.document."+the_form+"."+the_field+".disabled = true";
		y = "window.document."+the_form+"."+the_field+".value = ''";
		eval(x);
		eval(y);
	}
}



