if (document.layers)
{
  document.captureEvents(Event.KEYUP);
  document.captureEvents(Event.KEYDOWN);
  document.captureEvents(Event.KEYPRESS);
  document.captureEvents(Event.ONMOUSEUP);
  document.captureEvents(Event.ONMOUSEDOWN);
}
    
function Campus_Map()
{
	window.open('http://www4.nau.edu/parking/images/imgmap_campus.jpg','',
				'top=50,left=50,width=570px,height=600px,toolbar=0,location=0,' +
				'status=0,menubar=0,scrollbars=yes,resizable=yes');
}

function ClearViewState()
{
    if(document.getElementById("__VIEWSTATE"))
        document.getElementById("__VIEWSTATE").value = "";
}
            
function jsCheckBoxList_SelectAll(objForm, objCheckAll, strCheckEachID)
{
	for(i=0;i<objForm.elements.length;i++)
	{
		if (objForm.elements[i].id.indexOf(strCheckEachID) >= 0)
		{ objForm.elements[i].checked = objCheckAll.checked; }
	}
}

function jsSetFocus(objThis)
{
	if (objThis)
		objThis.focus();
}
	
function jstoggle_hideshow_class(strObjectID)
{
	if (document.getElementById)
	{
		if (document.getElementById(strObjectID).className == 'hideit')
		{ document.getElementById(strObjectID).className = 'showit'; }
		else if (document.getElementById(strObjectID).className == 'showit')
		{ document.getElementById(strObjectID).className = 'hideit'; }		
	}
}

function Hide(strObjectID)
{
	if (document.getElementById && document.getElementById(strObjectID))
		document.getElementById(strObjectID).style.display="none";
}

function Search_ITS(objForm)
{
	var SearchURL = 
        "http://google.nau.edu/search?q=" + UrlEncode(objForm.q.value) +
        "&hl=" + UrlEncode(objForm.hl.value) +
        "&as_qdr=" + UrlEncode(objForm.as_qdr.value) +
        "&site=" + UrlEncode(objForm.site.value) +
        "&client=" + UrlEncode(objForm.client.value) +
        "&output=" + UrlEncode(objForm.output.value) +
        "&proxystylesheet=" + UrlEncode(objForm.proxystylesheet.value) +
        "&ie=" + UrlEncode(objForm.ie.value) +
        "&hq=" + UrlEncode(objForm.hq.value);
        
    window.location = SearchURL;
}

function Search_On(objThis, blnOn)
{
	switch (blnOn)
	{
		case true:
			if (objThis.value == "Enter Search Here")
				objThis.value = "";
			break;
		case false:
			if (objThis.value == "")
				objThis.value = "Enter Search Here";
			break;
	}
}

function Search_OnEnterKey(e, strJsCallToProcess)
{
	var charCode;
	
	if (e.keyCode)
	    charCode = e.keyCode;
	else
	    charCode = e.which;

	if (charCode == 13 && strJsCallToProcess != "")
        eval(strJsCallToProcess);
}
         
function Show(strObjectID)
{
	if (document.getElementById && document.getElementById(strObjectID))
		document.getElementById(strObjectID).style.display="block";
}

function ShowHide(strObjectID)
{ 
	if (document.getElementById)
	{
		if (document.getElementById(strObjectID).style.display == 'none')
		{ document.getElementById(strObjectID).style.display = 'block'; }
		else if (document.getElementById(strObjectID).style.display == 'block')
		{ document.getElementById(strObjectID).style.display = 'none'; }		
	}
}

function MetaWrite(metatag, prefix, suffix, defaultstring)
{
	var blnFound = false;
	if (document.getElementsByTagName && document.getElementsByTagName("meta"))
	{
		if (metatag != "")
		{
			for(i=0;i<document.getElementsByTagName("meta").length;i++)
			{
				if (document.getElementsByTagName("meta")[i].name.toLowerCase() == metatag.toLowerCase())
				{
					if (document.getElementsByTagName("meta")[i].content != "")
					{
						document.writeln(prefix + 
							document.getElementsByTagName("meta")[i].content + suffix);
						blnFound = true;
					}
				}
			}
		}
		if (blnFound == false)
		{ document.writeln(defaultstring); }
	}
	else
	{ document.writeln(defaultstring); }
}

function jstrim(strToTrim) 
{ 
	var strTrim = strToTrim.replace(/^\s*/, '').replace(/\s*$/, ''); 
	if (strTrim == "" || strTrim == null)
	{ return ""; }
	else
	{ return strTrim; }
}

function UrlEncode(plaintext)
{
	// The Javascript escape and unescape functions do not correspond with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) 
	{
		var ch = plaintext.charAt(i);
	    if (ch == " ")
		    encoded += "+";				// x-www-urlencoded, rather than %20
		else if (SAFECHARS.indexOf(ch) != -1)
		    encoded += ch;
		else 
		{
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) 
			{
			    alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} 
			else 
			{
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	}
	return encoded;
}