// disable enter key
var nav = window.Event ? true : false; 
if (nav) { 
    window.captureEvents(Event.KEYDOWN); 
    window.onkeydown = NetscapeEventHandler_KeyDown; 
} else { 
    document.onkeydown = MicrosoftEventHandler_KeyDown; 
} 

function NetscapeEventHandler_KeyDown(e) { 
    if (e.which == 13 && e.target.type != 'textarea' && e.target.type != 'submit') { return false; } 
return true; 
} 

function MicrosoftEventHandler_KeyDown() { 
    if (event.keyCode == 13 && event.srcElement.type != 'textarea' && event.srcElement.type != 'submit' && event.srcElement.type != undefined)
    return false; 
    return true; 
} 

function getStyleClass (className) {
	for (var s = 0; s < document.styleSheets.length; s++)
	{
		if(document.styleSheets[s].rules)
		{
			for (var r = 0; r < document.styleSheets[s].rules.length; r++)
			{
				if (document.styleSheets[s].rules[r].selectorText == '.' + className)
				{
					return document.styleSheets[s].rules[r];
				}
			}
		}
		else if(document.styleSheets[s].cssRules)
		{
			for (var r = 0; r < document.styleSheets[s].cssRules.length; r++)
			{

				if (document.styleSheets[s].cssRules[r].selectorText == '.' + className)
				    {
					    return document.styleSheets[s].cssRules[r];
					}
			}
		}
	}
	
	return null;
}

function getCookie(c_name)
{
    if (document.cookie.length>0)
    {
    c_start=document.cookie.indexOf(c_name + "=");
    if (c_start!=-1)
        { 
        c_start=c_start + c_name.length+1; 
        c_end=document.cookie.indexOf(";",c_start);
        if (c_end==-1) c_end=document.cookie.length;
        return unescape(document.cookie.substring(c_start,c_end));
        } 
    }
    return "";
}
    
function setFontFromCookie()
{
    var c = getCookie("font-size");
    if (c != "")
        {
            setFontSize(c);
        }
}
    

	
function setFontSize(x)
{
	document.cookie = "font-size=" + x;
	switch(x)
    {
    case "1":
        getStyleClass('datagrid').style.fontSize = "10px";
        getStyleClass('datagrid TABLE').style.fontSize = "10px";
		getStyleClass('PageOwnText').style.fontSize = "10px";
        break;    
    case "2":
        getStyleClass('datagrid').style.fontSize = "11px";
        getStyleClass('datagrid TABLE').style.fontSize = "11px";
		getStyleClass('PageOwnText').style.fontSize = "11px";
        break;
    case "3":
        getStyleClass('datagrid').style.fontSize = "13px";
        getStyleClass('datagrid TABLE').style.fontSize = "13px";
		getStyleClass('PageOwnText').style.fontSize = "13px";
        break;
    default:
        getStyleClass('datagrid').style.fontSize = "11px";
		getStyleClass('datagrid TABLE').style.fontSize = "11px";
		getStyleClass('PageOwnText').style.fontSize = "11px";
    }   
}
	
if (window.attachEvent) window.attachEvent("onload", setFontFromCookie);


function popupStuff(addr, h, w) {
	var hit=(h?h:200);
	var wit=(w?w:560);
	popupWin = window.open(addr, '_blank', 'height='+hit+',width='+wit+',status=no,toolbar=no,menubar=no,location=no,resizable=no,left=320,top=180'); 
    popupWin.opener.top.name = 'opener';
    popupWin.focus();
}

function popUp(z)
{
    var hgt;
    hgt = 640;	
    window.open('WaterQualityFormView.aspx?zone=' + z,'','scrollbars,width=690,height=' + hgt );
}

sfHover = function() {
    if (document.getElementById("navM"))
    {
	    var sfEls = document.getElementById("navM").getElementsByTagName("LI");
	    for (var i=0; i<sfEls.length; i++) {
		    sfEls[i].onmouseover=function() {
			    this.className+=" sfhover";
		    }
		    sfEls[i].onmouseout=function() {
			    this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		    }
	    }
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
