function showFTPAgreement () {
	if (window.showModalDialog) {
          var result;

          result = window.showModalDialog("http://www.thmp.info/scripts/FTPDialog.html","","dialogHeight: 362px; dialogWidth: 752px; center: yes; scroll: no; resizeable: yes; status: no;");
	     		
	    if (result == 1) { 
             alert("Thank you. You have accepted the agreement for downloading 1-Percent Flood Risk Zones (FEMA) data."); 
	       return true;
	     }
	    else if (result == 2) {
	       alert("Thank you. You have indicated your intention to download other data."); 
	       return true;  
	    }
	    else {
	      alert("You have declined the agreement. To download the data you must accept the agreement, or indicate that you will download other data.");
            return false;
	   }
      } 
	else {
	   var agreement = "Note: If you are intending to download from the 1-Percent Flood Risk Zones (FEMA) layer please note that there are use restrictions that limit its usability in commercial endeavors. Specifically: 'User Agreement: The flood risk data provided on this site is for planning purposes only and not for commercial use. In order to download this data you must agree that you will not resell or use this data for commercial purposes. Rights to the commercial use of this product are retained and enforceable by FAFDS (First American Flood Data Services).'  (This is included in the README file as well). To proceed you must either agree to this restriction or indicate that you do not intend to download this layer, but instead will download other data.";

	   if ( confirm(agreement) ) { 
         	 alert("Thank you. You have accepted the agreement, or indicated your intention to download other data."); 
		 return true;
	   }
	   else {   
	 	 alert("You have declined the agreement. To download the data you must accept the agreement, or indicate that you will download other data.");
             return false;
	   }
	}		
} 

function UL2Menu_ShowHead(){
	var li=this;
	AddClass(li,'active');
	var xy=FindXYWH(li);
	if (li.isTop){
		li.sub.style.left=(xy.x+(!li.isHorizontal?xy.w:0))+'px';
		li.sub.style.top=(xy.y+(li.isHorizontal?xy.h:0)-(li.isTop?0:1))+'px';
	} else {
		li.sub.style.left=li.offsetWidth+'px';
		li.sub.style.top=li.offsetTop+'px';
	}
	li.sub.style.visibility='visible';
}
function UL2Menu_HideHead(){
	var li=this;
	li.sub.style.visibility='hidden';
	KillClass(li,'active');
}
function UL2Menu_ConvertMenu(){
	var menu=document.getElementById('menu');
	if (!menu) return;
	var menuIsHorizontal=HasClass(menu,'horizontal');
	var lis = menu.getElementsByTagName('li');
	for (var i=0,len=lis.length;i<len;i++){
		var li=lis[i];
		var uls = li.getElementsByTagName('ul');
		if (!uls || uls.length==0) continue;
		var ul=uls[0];
		li.sub=ul;
		li.onmouseover=UL2Menu_ShowHead;
		li.onmouseout=UL2Menu_HideHead;
		li.isTop = li.parentNode==menu;
		li.isHorizontal = (menuIsHorizontal && li.isTop);

		if (li.addedArrow || li.isTop) continue;
		var arrow=document.createElement('span');
		arrow.innerHTML='&nbsp;&rArr;';
		var a = li.getElementsByTagName('a');
		if (a && a.length>0 && a[0].parentNode==li) a[0].innerHTML+='&nbsp;&rArr;';
		else li.insertBefore(arrow,li.childNodes[1]);
		li.addedArrow=true;
	}
}

AttachEvent(window,'load',UL2Menu_ConvertMenu,true);


//***Generic Library Functions Follow
	function FindXY(obj){
		var x=0,y=0;
		while (obj){
			x+=obj.offsetLeft - (obj.scrollLeft || 0);
			y+=obj.offsetTop - (obj.scrollTop || 0);
			obj=null;
		}
		return {x:x,y:y};
	}

	function FindXYWH(obj){
		if (!obj) return { x:0, y:0, w:0, h:0 };
		var objXY = FindXY(obj);
		return { x:objXY.x, y:objXY.y, w:obj.offsetWidth||0, h:obj.offsetHeight||0 };
	}

	function AttachEvent(obj,evt,fnc,useCapture){
		if (obj.addEventListener){
			obj.addEventListener(evt,fnc,useCapture);
			return true;
		} else if (obj.attachEvent) return obj.attachEvent("on"+evt,fnc);
		else obj['on'+evt]=fnc;
		return true;
	}

	function HasClass(obj,cName){ return (!obj || !obj.className)?false:(new RegExp("\\b"+cName+"\\b")).test(obj.className) }
	function AddClass(obj,cName){ if (!obj) return; if (obj.className==null) obj.className=''; return obj.className+=(obj.className.length>0?' ':'')+cName; }
	function KillClass(obj,cName){ if (!obj) return; return obj.className=obj.className.replace(RegExp("^"+cName+"\\b\\s*|\\s*\\b"+cName+"\\b",'g'),''); }
