/* === BASIN MAP POPUPS === */
function callPopUp_fp (formField) {
	var myString;
	var myindex=formField.selectedIndex;
	myString=formField.options[myindex].value;
	if (myString == ''){
		alert('Please Select a Forecast Point');
		return false;
	}
	popUpWindow('popup_fp.asp?'+myString, 'Flood', 490, 180, 'no');
}

function callPopUp_fc (formField) {
	var myString;
	var myindex=formField.selectedIndex;
	myString=formField.options[myindex].value;
	if (myString == ''){
		alert('Please Select a Municipality');
		return false;
	}
	popUpWindow('popup_fc.asp?'+myString, 'Flood', 665, 400, 'yes');
}

function callPopUp_if (formField) {
	var myURL;
	var myindex=formField.selectedIndex;
	myURL=formField.options[myindex].value;
	if (myURL == ''){
		alert('Please Select a County Name');
		return false;
	}
	popUpWindow(myURL, 'IFLOW', 800, 350, 'yes');
}

function popUpWindow(cPopUrl, cPopName, iPopWidth, iPopHeight, bScrollBars) {
//cPopUrl = the name of url to call, bScrollBars = if 'no' or blank, no bars will appear.
	var iPopLeft, iPopTop;
	var oPopWindow = null;
	if (!oPopWindow || oPopWindow.closed){
		//Center popup window inside parent window.
		iPopLeft = (window.screen.width/2) - ((iPopWidth/2) + 10);
		iPopTop = (window.screen.height/2) - ((iPopHeight/2) + 50);
		//Open popup window
		oPopWindow=open(cPopUrl, cPopName,"height="+ iPopHeight +",width="+ iPopWidth +",left=" + iPopLeft + ",top=" + iPopTop + ",screenX=" + iPopLeft + ",screenY=" + iPopTop + ",scrollbars=" + bScrollBars + ", statusbar=no, resizable=yes");
		oPopWindow.location.href = cPopUrl;
		oPopWindow.focus()
    }
	else {
    	oPopWindow.focus()
	}
}

function ValidateOrder(formObj) {
  var warning = ""

  //Check Name
  if (formObj.first_name.value == "") {
    warning += "\n -     First Name";
  }
  if (formObj.last_name.value == "") {
    warning += "\n -     Last Name";
  }
  //Check Address
  if (formObj.address_1.value == "") {
    warning += "\n -     Address 1";
  }
  //Check City
  if (formObj.city.value == "") {
    warning += "\n -     City";
  }
  //Check State
  if (formObj.state.value == "") {
    warning += "\n -     State";
  }
    //Check Zip Code
  if (formObj.zip_code.value == "") {
    warning += "\n -     Zip Code";
  }

  if (warning != "") {
    alert("ERROR:  The form cannot be submitted because\nthe following fields are incomplete or invalid:\n" + warning);
    return false;
  }
  formObj.submit();
}

$(function()
{
	$.localScroll({duration: 500});
	$("a.external").click(function()
	{
		newwindow = window.open($(this).attr("href"),'name','height=600,width=800,location=yes,resizable=yes,scrollbars=yes,titlebar=yes');
		if (window.focus) { newwindow.focus(); }
		return false;
	});
	$("a.modal").click(function()
	{
		link = $(this);
		$("#sitewrapper").append('<div id="modal-layer"></div><div id="modal"></div>');
		scrollTo(0, 0);
		$("#modal").load(link.attr("href"), function()
		{
			$("#modal").prepend('<h2><a class="close" href="#">close</a>' + link.attr("title") + '</h2>');
			$("#modal-layer, #modal").fadeIn(500, function()
			{
				$("#modal-layer").animate({ opacity: .8 }, 0);
			});
		});
		return false;
	});
	$("#modal-layer, #modal a.close").live("click", function()
	{
		$("#modal-layer, #modal").fadeOut(500, function() { $(this).remove(); });
		return false;
	});
	$("ul#nav li:not(ul#nav ul li)").hover(function()
	{
		$("ul", $(this)).show();
	}, function()
	{
		$("ul", $(this)).hide();
	});
	$("input.email_submit").live("click", function(){
		$("#modal-layer, #modal").fadeOut(500, function() { $(this).remove(); });
		return true;
	})
});
