
function OpenInfoWindow(url,name) {
	var myWin;
	myWin = window.open(url, name, "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes");
	myWin.focus();
	return myWin;
}

function GP_popupConfirmMsg(msg) { //v1.0
  document.MM_returnValue = confirm(msg);
}

function MM_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();
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function move_in(img_name, img_src) {
	document[img_name].src=img_src;
}

function move_out(img_name, img_src) {
	document[img_name].src=img_src;
}

function imagelink(imgEnabled, imgDisabled, imgStart, objButton, txtLink, txtCaption){
document.write('<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=0><TR><TD>'
	+ '<A class=xxsmall HREF="' + txtLink + '" '
	+ 'onmouseover="javascript:move_in(' + objButton + ',' + imgEnabled + ')" '
	+ 'onmouseout="javascript:move_out(' + objButton + ',' + imgDisabled + ')"> '
	+ '<img name="' + objButton + '" src="' + imgStart + '" border=0 align=left width=16 height=16>'
	+ '<img src="/images/layout/dot.gif" border=0 width=3 height=2>' + txtCaption + '</A><font class=xxsmallgrey>!</font>'
	+ '</TD></TR></TABLE>');
}

// whitespace characters
var whitespace = " \t\n\r";

/****************************************************************/

// Check whether string s is empty.
function isEmpty(s) { 
	return ((s == null) || (s.length == 0)) 
}

/****************************************************************/

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;
}

// JGG - 1/26/01 - function to handle the "enter" keypress on text inputs
// use in onKeyDown event, e.g.:
//		<input type="text" name="whatever" onKeyDown="return handleEnterSubmission(this, event);">
function handleEnterSubmission (field, evt) {
	var keyCode = evt.which ? evt.which : evt.keyCode;
	if (keyCode == 13) {
		field.form.submit();
		return false;
	}
	else
		return true;
}

// JGG - 2/15/01 - function to format phone numbers to (000) 000-0000
// use in onBlur event, e.g.:
//		<input type="text" name="whatever" onBlur="return formatPhoneNumber(this);">
function formatPhoneNumber(field) {
	var newphone = new String(), count, c;
	var x = new String(), y = new String(), z = new String(), w = new String();
	var phone = field.value;
	if (phone.length > 0) {
		for (count = 0; count < phone.length; count++) {
			c = phone.charAt(count);
			if (isNumber(c))
				newphone += c;
		}
		newphone = LTrim(RTrim(newphone));
		if (newphone.length >= 4)
			z = newphone.substring(newphone.length - 4, newphone.length);
		else
			z = "0000";
		if (newphone.length >= 7)
			y = newphone.substring(newphone.length - 7, newphone.length - 4);
		else
			y = "000";
		if (newphone.length >= 10)
			x = newphone.substring(newphone.length - 10, newphone.length - 7);
		else
			x = "000";
		w = newphone.substring(0, newphone.length - 10);
		if (w)
			newphone = w + " (" + x + ") " + y + "-" + z;
		else
			newphone = "(" + x + ") " + y + "-" + z;
		field.value = newphone;
		return true;
	} else 
		return false;
}

function LTrim(str) {
	var whitespace = new String(" \t\n\r");
	var s = new String(str);
	if (whitespace.indexOf(s.charAt(0)) != -1) {
	    var j=0, i = s.length;
	    while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
	        j++;

	    s = s.substring(j, i);
	}
	return s;
}

function RTrim(str) {
	var whitespace = new String(" \t\n\r");
	var s = new String(str);
	if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
	    var i = s.length - 1;
	    while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
	        i--;
		        
	    s = s.substring(0, i+1);
	}
	return s;
}

function isNumber(str)
{
	if ( (str == "") || isNaN(Math.abs(str)) || (isWhitespace(str)) )
		return false;
	else
		return true;
}


function isNotValidEmail(src) {

	var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
	var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
  		
	// var str = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
	// var reg = new RegExp(str);

	if (isWhitespace(src))
	  return true;
	else {

		if (src.toLowerCase() == "none".toLowerCase()) 
		  return false;
		else {

			if (!reg1.test(src) && reg2.test(src))
			  return false;
			else
			  return true;
		}

	}
}

function limitComments(field, maxlen) {
	if (field.value.length > maxlen) // if too long, trim it
		field.value = field.value.substring(0, maxlen);
	return true;
}

function disableButtons() {
  var inputs = document.all.tags("INPUT");
  for (var i=0; i < inputs.length; i++) {
    if ((inputs[i].type == 'button') || (inputs[i].type == 'submit')) {
      inputs[i].disabled = true;
    }
  }
}

function doBlink() {
  // Blink, Blink, Blink...
  var blink = document.all.tags("BLINK")
  for (var i=0; i < blink.length; i++)
    blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : "" 
}

function startBlink() {
  // Make sure it is IE4
  if (document.all)
    setInterval("doBlink()",500)
}

window.onload = startBlink;