
//Custom API for cross-browser compatible updates of webpages
//Written by Michael Rock, ITD

//****************************************************
// Handles the Netscape Window Resizing bug.  
//****************************************************
//Commented code handles resizing bug in Netscape 4.08
// but it does not handle bug if font size is adjusted.  Second set of code handles resizing bug
// for changing the font size but does not fix a bug in Netscape 4.08 that causes the page
// to continually reload if the content extends past visable screen.

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

/*

function handleResize() {
	location.reload()
	return false
}

if (ns4) {
	
	window.captureEvents(Event.RESIZE);
	window.onresize = handleResize;
}
*/

//****************************************************
//Function runs Search Query to use keywords without user having to input proper formatting
//****************************************************
function RunSearchQuery() {
/*if (is_nav4) {
    if (document.queryForm.queryText.value == "") {
		alert("Please enter one or more keywords on which to search.")
		}
	else {
		query = escape('keywords <contains> ' + document.queryForm.queryText.value);	
		newURL = "http://www.co.alameda.ca.us/search?NS-search-page=results&NS-collection=Site_Search&NS-query=" + query;
				window.location = newURL;
		}
	}	
else {*/
	if (document.queryForm.queryText.value == "") {
		alert("Please enter one or more keywords.")
		}
	else {
		query = escape('keywords <contains> ' + document.queryForm.queryText.value);	
		newURL = "http://www.co.alameda.ca.us/search?NS-search-page=results&NS-collection=Site_Search&NS-query=" + query;
				window.location = newURL;
		}
	//}
 }
//****************************************************
//This function opens a new window with the menubar enabled.
//****************************************************
function NewWindowDoc(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=yes,toolbar=no,resizable=yes'; 
win=window.open(mypage,myname,settings);
win.focus();
}
//****************************************************
//This function opens the new window with the menubar enabled and the height and width set depending upon the parent window size..
//****************************************************
function NewWindowStnd(mypage,myname,pos)  {
	var screenW = screen.availWidth;
	var screenH = screen.availHeight;
	var windowW = screenW * .80;
	var windowH = screenH * .60;
	if	(pos=="center")  {
		LeftPosition=(screenW)?(screenW-windowW)/2:100;
		TopPosition=(screenH)?(screenH-windowH)/2:100;
	}	
	else if ((pos!="center" && pos!="random") || pos==null)  {
		LeftPosition=0;TopPosition=20
	}
	settings='width='+windowW+',height='+windowH+',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,location=yes,directories=no,status=no,menubar=yes,toolbar=yes,resizable=yes'; 
	var win=window.open(mypage,myname,settings);
	win.focus();
} 
//****************************************************
// JavaScript Browser Sniffer
//****************************************************
// convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase();
    var appVer = navigator.appVersion.toLowerCase();

// *** BROWSER VERSION ***

    var is_minor = parseFloat(appVer);
    var is_major = parseInt(is_minor);

// Note: On IE, start of appVersion return 3 or 4
// which supposedly is the version of Netscape it is compatible with.
// So we look for the real version further on in the string

    var iePos  = appVer.indexOf('msie');
    if (iePos !=-1) {
       is_minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)))
       is_major = parseInt(is_minor);
    }

// Netscape6 is mozilla/5 + Netscape6/6.0!!!
// Mozilla/5.0 (Windows; U; Win98; en-US; m18) Gecko/20001108 Netscape6/6.0
    var nav6Pos = agt.indexOf('netscape6');
    if (nav6Pos !=-1) {
       is_minor = parseFloat(agt.substring(nav6Pos+10))
       is_major = parseInt(is_minor)
    }

    var is_getElementById   = (document.getElementById) ? "true" : "false"; // 001121-abk
    var is_getElementsByTagName = (document.getElementsByTagName) ? "true" : "false"; // 001127-abk
    var is_documentElement = (document.documentElement) ? "true" : "false"; // 001121-abk

    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1));
    var is_nav2 = (is_nav && (is_major == 2));
    var is_nav3 = (is_nav && (is_major == 3));
    var is_nav4 = (is_nav && (is_major == 4));
    var is_nav4up = (is_nav && (is_major >= 4));
    var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) ||
                          (agt.indexOf("; nav") != -1)) );

/*	var is_nav6 = (is_nav && (agt.indexOf('netscape6') != -1)); // new 001120 - abk
	var is_nav6up = (is_nav && is_getElementById);              // new 001121 - abk
*/
	var is_nav6   = (is_nav && is_major==6);    // new 010118 mhp
	var is_nav6up = (is_nav && is_minor >= 6) // new 010118 mhp

    var is_nav5   = (is_nav && is_major == 5 && !is_nav6); // checked for ns6
    var is_nav5up = (is_nav && is_minor >= 5);

    var is_ie   = (iePos!=-1);
    var is_ie3  = (is_ie && (is_major < 4));

    var is_ie4   = (is_ie && is_major == 4);
    var is_ie4up = (is_ie && is_minor >= 4);
    var is_ie5   = (is_ie && is_major == 5);
    var is_ie5up = (is_ie && is_minor >= 5);

// KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
// or if this is the first browser window opened.  Thus the
// variables is_aol, is_aol3, and is_aol4 aren't 100% reliable.

    var is_aol   = (agt.indexOf("aol") != -1);
    var is_aol3  = (is_aol && is_ie3);
    var is_aol4  = (is_aol && is_ie4);

    var is_opera = (agt.indexOf("opera") != -1);
    var is_webtv = (agt.indexOf("webtv") != -1);
	
