<!-- hide from JavaScript-challenged browsers
function openWindow(url,remote) {
  popupWin = window.open(url, remote, 'scrollbars,menubar,resizable,dependent,width=640,height=480,left=100,top=100')
 popupWin.focus();
}

function openPopup(url,remote) {
  popupWin3 = window.open(url, remote, 'resizable,dependent,width=505,height=450,left=2,top=2')
 popupWin3.focus();
}


function openimg(url,remote) {
  popupWin = window.open(url, remote, 'scrollbars,resizable,dependent,width=540,height=540,left=100,top=100')
 popupWin.focus();
}
// done hiding -->
// Auto advance field:  Use onKeyUp="autoTab(this,3)" in field trigger
function autoTab(input,len) {
if(input.value.length >= len)
input.form[(getIndex(input)+1)].focus();
}
 
function getIndex(input) {
var index = -1, i = 0;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}

// Heinle's function for retrieving a cookie.
function getCookie(name){
  var cname = name + "=";               
  var dc = document.cookie;             
  if (dc.length > 0) {              
    begin = dc.indexOf(cname);       
    if (begin != -1) {           
      begin += cname.length;       
      end = dc.indexOf(";", begin);
      if (end == -1) end = dc.length;
        return unescape(dc.substring(begin, end));
    } 
  }
  return null;
}

// An adaptation of Dorcht's function for setting a cookie.
function setCookie(name, value, expires, path, domain, secure) {
  document.cookie = name + "=" + escape(value) + 
  ((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
  ((path == null) ? "" : "; path=" + path) +
  ((domain == null) ? "" : "; domain=" + domain) +
  ((secure == null) ? "" : "; secure");
}

// An adaptation of Dorcht's function for deleting a cookie.
function delCookie (name,path,domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path == null) ? "" : "; path=" + path) +
    ((domain == null) ? "" : "; domain=" + domain) +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

 
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}
 


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function whichOnes(swap) {
	  document.summary.whichButton.value=swap;
	  document.summary.submit();
 }

 function DoTheTest() {
document.cookie = 'TemporaryTestCookie=yes; path=/';
setTimeout('TestIfCookieWasSet()',1000);
}
function TestIfCookieWasSet() {
var testcookie = '';
if(document.cookie.length > 0) {
	var cookiename = 'TemporaryTestCookie=';
	var cookiebegin = document.cookie.indexOf(cookiename);
	var cookieend = 0;
	if(cookiebegin > -1) {
		cookiebegin += cookiename.length;
		cookieend = document.cookie.indexOf(";",cookiebegin);
		if(cookieend < cookiebegin) { cookieend = document.cookie.length; }
		testcookie = document.cookie.substring(cookiebegin,cookieend);
		}
	}
if(testcookie == 'no') { window.location="CookieRequired.p"; }

}

function ClickAgent( name, value, expires, path, domain, secure ) 
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct 
expires time, the current script below will set 
it for x number of days, to make it for hours, 
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
( ( path ) ? ";path=" + path : "" ) + 
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}

//VALIDATE EMAIL ADDRESS
var invalidaddress=new Array();
invalidaddress[0]="rocketmailx";
invalidaddress[1]="zdnetmail";
//extend or shorten this list if necessary
var knownDomsPat=/^(aero|agent|arpa|arts|auction|biz|chat|church|club|com|coop|edu|family|free|game|golf|gov|inc|info|int|kids|law|llc|llp|ltd|love|mil|med|museum|mobi|mp3|name|nato|net|org|pro|school|scifi|shop|soc|sport|travel|tech|tv|video|ae|au|an|at|be|bm|br|bs|bz|ca|ch|cn|cu|cy|de|dk|du|eu|es|fi|fr|gb|gl|gr|gs|gu|hk|ie|il|it|jm|jp|ky|lu|mc|mh|ms|mx|nl|no|nz|pf|pl|pr|pt|se|ru|us|uk|um|va|ve|vi|vg|ws)$/;
var emailresults;
var invalidcheck=0;

function checkemail(emailstr){
        
		emailstr=emailstr.toLowerCase();

        var filter=/^.+@.+\..{2,3}$/
        invalidcheck="";
        emailresults=true;
        if (filter.test(emailstr)){
           var tempstring=emailstr.split("@")
           var domArr=emailstr.split(".");
           tempstring=tempstring[1].split(".")
      
	       //check if an official email address
           for (i=0;i<invalidaddress.length;i++){
              if (tempstring[0]==invalidaddress[i]){
                  invalidcheck=1
              }
           }
      
	       //check if address ends in a well-known domain
           if (domArr[domArr.length-1].length!=2 && 
             domArr[domArr.length-1].search(knownDomsPat)==-1) {
                invalidcheck=2
           }
           
		   if (invalidcheck!=0)
              emailresults=false
           else{         
              emailresults=true
           }
        }
        else{
              invalidcheck=3
              emailresults=false;       
        }
}
			
/*
 * Modifies the Country dropdown box, based on value
 * selected in the state dropdown box.
 */
function ChangeCountryByState(stateCode, countryFieldId) {
    var optionValue = "";

    if (stateCode == "AB" || stateCode == "BC" || stateCode == "MB"
             || stateCode == "NB" || stateCode == "NL" || stateCode == "NS"
             || stateCode == "NT" || stateCode == "NU" || stateCode == "ON"
             || stateCode == "PE" || stateCode == "QC" || stateCode == "SK"
             || stateCode == "YT") {
        optionValue = "CAN";
    } else if (stateCode == "C1" || stateCode == "C2" || stateCode == "C3"
             || stateCode == "C4" || stateCode == "C5" || stateCode == "C6"
             || stateCode == "") {
        optionValue = "";
    } else {
        optionValue = "USA";
    }

    if (document.getElementById) {
        var element = document.getElementById(countryFieldId);

        if (element) {
            element.value = optionValue;
        }
    } else if (document.all) {
        var element = document.all[countryFieldId];

        if (element) {
            element.value = optionValue;
        }
    } else if (document.layers) {
        var element = document.layers[countryFieldId];

        if (element) {
            element.value = optionValue;
        }
    }

//	if (stateCode == "AA" || stateCode == "AE" || stateCode == "AP") {
		// Enable the div.
		// Print the Text "United States is the appropriate choice for military addresses."
//		textDivElement = document.getElementById("millitary_address_text");
//		textDivElement.style.display = "block";
//	} else {
		// Disable the div
		// Remove the Text.
//		textDivElement = document.getElementById("millitary_address_text");
//		textDivElement.style.display = "none";
//	}

}

/*
 * Modifies the State dropdown box, based on value
 * selected in the Country dropdown box.
 */
function ChangeStateByCountry(countryCode, stateFieldId) {
    var optionValue = "";

    if (countryCode == "CAN" || countryCode == "USA" || countryCode == "") {
       optionValue = "";
    } else {
        optionValue = "C6";
    }

    if (document.getElementById) {
        var element = document.getElementById(stateFieldId);

        if (element) {
            element.value = optionValue;
        }
    } else if (document.all) {
        var element = document.all[stateFieldId];

        if (element) {
            element.value = optionValue;
        }
    } else if (document.layers) {
        var element = document.layers[stateFieldId];

        if (element) {
            element.value = optionValue;
        }
    }
}