/*
This function loops through all the forms on the page
and adds a hidden param which contains the value (if any)
of the url anchor. Javascript is the ONLY way to get that
anchor value.

Then that value is picked up on post and added to the return
url. In cases where a page simply posts to itself, we have
to orchestrate a refresh of the page a 2nd time to put the
anchor back in the url. Not pretty, but it works.
*/
function persistAnchors () {

	var urlArray = document.URL.split("#");

	for (var i = 0; i < document.forms.length; i++) {
		var newInput = document.createElement("input");
		newInput.name="theAnchor";
		newInput.type="hidden";
		newInput.value=urlArray[1];
		document.forms[i].appendChild(newInput);
	}

}

function openWin(theURL,adtParams){
window.open(theURL,'ThirdFederal',adtParams+',scrollbars=yes,location=no,menubar=no,status=yes,titlebar=yes,toolbar=no,resizable=yes');
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,'width=775,height=500,resizable=yes');
}

function valEntry(A_,B_,C_){
	if(IsCookieDisabled())return false;
	var D_=true;
	var E_=B_.zipcode.value;
	var F_;
	var G_=0;
	if (A_=="zip"){
		F_="Please enter a valid 5 character U.S. zip code.";
	} else {
		F_="Please enter a valid 5 character U.S. zip code or choose a region and city.";
		var H_=B_.region;
		var I_=B_.CITYCODE;
	}
    if(E_!=""){
        var J_=E_.length;
        var K_=parseFloat(E_);
        if((J_!=5)||(K_<1)||(K_>99999)){
			D_=false;
		}
        if(D_==true){
			for(G_=0;G_<J_;G_++){
				if((E_.charAt(G_)<"0")||(E_.charAt(G_)>"9")){
					D_=false;break;
				}
			}
		}
	} else {
		if(A_=="zip"){
			D_=false;
		} else {
			if(!C_&&((H_.selectedIndex==0)||(I_.selectedIndex==0))){
				D_=false;
			} else {
				H_=H_.value;I_=I_.value;
			}
		}
	}
	if(D_==false){
		alert(F_);
	}
    return D_;
}

function IsCookieDisabled(){
	if(navigator.cookieEnabled!=null){
		if(navigator.cookieEnabled==false&&navigator.appName.indexOf("WebTV")==-1){
			alert("You have configured your browser to disable cookies. With cookies disabled, we are unable to personalize your home page.");
			return true;
		}
	}
}

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.01
  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 && d.getElementById) x=d.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];}
}