
//defaults for overlays
var winOpen = false;
var win;
function openOverlay(url,pgTitle,pgWidth,pgHeight) {

	/*		
	if(!winOpen){
			win = new Window({className: "fema", resizable:false, draggable:false,  width:pgWidth, height:pgHeight, top:50, destroyOnClose: true,  recenterAuto: false });
	
			
			lastID = win.getId();
			win.setZIndex(9999999);
			win.setURL(url);
			win.setDestroyOnClose();
			win.showCenter(false, 50);
			win.updateHeight();
			win.setCloseCallback(function(win) {
				win.destroy();
				winOpen = false;
			});
			winOpen = true;
		}
		return;
*/
	//alert(url+"?TB_iframe=true&height="+pgHeight+"&width="+pgWidth+"&modal=true");
	tb_show( pgTitle, url+"?TB_iframe=true&height="+pgHeight+"&width="+pgWidth+"&modal=true",""); 
}

function printpage() {
	window.print();  
}

function RandomizeImage() {

	var dirPath = "/floodsmart/images/floodfacts/";
		
	images = new Array("floodfacts20.gif","floodfacts1.gif","floodfacts2.gif","floodfacts3.gif","floodfacts4.gif","floodfacts5.gif","floodfacts6.gif","floodfacts7.gif","floodfacts8.gif","floodfacts9.gif","floodfacts10.gif","floodfacts11.gif","floodfacts12.gif","floodfacts13.gif","floodfacts14.gif","floodfacts15.gif","floodfacts16.gif","floodfacts17.gif","floodfacts18.gif","floodfacts19.gif");
	
	var randomnumber = Math.floor(Math.random()*(images.length));
	
	document.images.someimage.src = dirPath+images[randomnumber];

}

var errorHidden = true;
function displayError(formNode, validators){
	var errorHTML = "";
	var errorMSG = "<p style='padding:4px;'><strong>The following errors need to be corrected:</strong></p>";
	for(var i=0;i<validators.length;i++){
		errorHTML += "<li><strong>" + validators[i].message + "</strong></li>";
	}
	document.getElementById("errorDisplay").style.display = "block";
	document.getElementById("errorDisplay").innerHTML = errorMSG + "<ul style='padding-top:0px;'>" + errorHTML + "</ul>";
	if(!errorHidden) {
		toggleLayer('errorDisplay');
		errorHidden = false;
	}
	
}

function toggleLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
	elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
	elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
	vis = elem.style;

	// if the style.display value is blank we try to figure it out here
	if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined) {
    	vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
	}
	if(vis.display==''){
		vis.display='none';
	}
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}