

function searchFocus() {
	if (document.getElementById("searchdata1")) {
		document.getElementById("searchdata1").focus();
	}
}

// image rollover
function swapImg(imgName,imgState,imgPath) {
	document.images[imgName].src = imgPath + imgName + imgState + ".gif";
}

// Generic pop up
var pop_win = "";
function newWindow(URL,width,height) {
	var params = 'width=' + width + ',height=' + height + ',resizable=yes,scrollbars=yes';
	//alert(params);
	pop_win = window.open(URL,"pop_win",params);
	if (pop_win != null && pop_win != '') {
		pop_win.focus();
	} else {
		alert("You appear to be using a popup blocker,\nwhich may impede the functionality of the site.\nYou may wish to allow popups on this site.\n\nSee the \"Help\" section for more information.");
	}
}

// Pop-up w/ cookie
var alerted = 0;
function newCookieWindow(URL,width,height,cookieName) {
	var theURL = URL;
	var params = 'width=' + width + ',height=' + height + ',screenX=10,left=10,screenY=200,top=200,resizable=yes,scrollbars=yes';
	var doIt = 'no';
	if (cookieName != null && cookieName != '') {
		var date = new Date(2005,04,15);
		date = date.toGMTString();
		var theCookie = document.cookie;
		theCookie = theCookie.indexOf(cookieName);
		if (theCookie == -1) {
			document.cookie = cookieName + "=yes;";// expires=" + date;
			doIt = 'yes';
		} else {
			return;
		}
	} else {
		doIt = 'yes';
	}
	if (doIt == 'yes') {
		//alert(params);
		pop_win = window.open(URL,"pop_win",params);
		if (pop_win != null && pop_win != '') {
			if (URL == '') {
				pop_win.close();
			} else {
				pop_win.focus();
			}
		} else if (alerted == 0) {
			alert("You appear to be using a popup blocker,\nwhich may impede the functionality of the site.\nYou may wish to allow popups on this site.\n\nSee the \"Help\" section for more information.");
			alerted = 1;
		}
	}
}

// pop-up help
var help_win = "";
var map_pop = "";
var dewey_win = "";
function helpWindow() {
	var show = arguments[0];
	if (document.getElementById(show).style.display == 'block') {
		document.getElementById(show).style.display = 'none';
	}
	else {
		document.getElementById(show).style.display = 'block';
		document.getElementById(show).style.zIndex = 99;
	}
	for (i = 1; i < arguments.length; i ++ ) {
		var hide = arguments[i];
		document.getElementById(hide).style.display = 'none';
	}
}
function helpHide() {
	var hide = arguments[0];
	document.getElementById(hide).style.display = 'none';
	for (i = 1; i < arguments.length; i ++ ) {
		var hide = arguments[i];
		document.getElementById(hide).style.display = 'none';
	}
}

function openHelpWindow(help) {
	var theCookie = document.cookie;
	theCookie = theCookie.indexOf('site_pop');
	if (theCookie == -1) {
		document.cookie = "site_pop=yes;";
	} else {
		alerted = 1;
	}
	url = "/help/pop_help/pop_help.php?help=" + help;
	help_win = window.open(url,"pop_win",'width=300,height=250,resizable=yes,scrollbars=yes');
	if (help_win != null && pop_win != '') {
		help_win.focus();
	} else if (alerted == 0) {
		alert("You appear to be using a popup blocker,\nwhich may impede the functionality of the site.\nYou may wish to allow popups on this site.\n\nSee the \"Help\" section for more information.");
		alerted = 1;
	}
}

function history_pop(theImage) {
	var theCookie = document.cookie;
	theCookie = theCookie.indexOf('site_pop');
	if (theCookie == -1) {
		document.cookie = "site_pop=yes;";
	} else {
		alerted = 1;
	}
	var theURL = "/about_the_library/history_pop.php?image=" + theImage;
	historyPop = window.open(theURL, "historyPop", "width=520, height=460");
	if (historyPop != null && pop_win != '') {
		historyPop.focus();
	} else if (alerted == 0) {
		alert("You appear to be using a popup blocker,\nwhich may impede the functionality of the site.\nYou may wish to allow popups on this site.\n\nSee the \"Help\" section for more information.");
		alerted = 1;
	}
}

function openPCRes() {
	var doIt = 'no';
	var theCookie = document.cookie;
	theCookie = theCookie.indexOf('site_pop');
	if (theCookie == -1) {
		document.cookie = "site_pop=yes;";
	} else {
		alerted = 1;
	}
	url = "/redirect/redirect.php?db_name=pcres";
	pcres_win = window.open(url,"pcres_win",'width=630,height=470,resizable=yes,scrollbars=yes');
	pcres_win.focus();
	if (pcres_win != null && pop_win != '') {
		pcres_win.focus();
	} else if (alerted == 0) {
		alert("You appear to be using a popup blocker,\nwhich may impede the functionality of the site.\nYou may wish to allow popups on this site.\n\nSee the \"Help\" section for more information.");
		alerted = 1;
	}
}

function closePop() {
	if (help_win != "" && help_win != null) {
		help_win = help_win.close();
	}
	if (map_pop != "" && map_pop != null) {
		map_pop = map_pop.close();
	}
	if (dewey_win != "" && dewey_win != null) {
		dewey_win = dewey_win.close();
	}
	if (pop_win != "" && pop_win != null) {
		if (pop_win.win_open == 1) {
			pop_win = pop_win.close();
		}
	}
}

//***** FRUSTRATE SPAMMERS *****
var recipients = new Array();
	recipients[0] = new Array();
	recipients[0][0] = "websupport";
	recipients[0][1] = "websupport";
	recipients[0][2] = "kdowd";
	recipients[0][3] = "dburroughs";
	recipients[0][4] = "shirsch";
	recipients[0][5] = "YouthServices-Internet";
	recipients['other'] = new Array();
	//recipients['branches']['library_director'] = "shirsch";
function spamVex(type,addressee,text,subject,bcctype,bccaddressee) {
	var vex01 = "<a href=\"ma";
	var theBrowser = navigator.appName + navigator.appVersion;
	var thePlatform = navigator.platform;
	vex01 += "ilto:";
	vex01 += recipients[type][addressee];
	vex01 += "@acli";
	vex01 += "b.us";
	if (subject == "New Web Site Bug Report") {
		subject += ": " + theBrowser + "/" + thePlatform;
	}
	if (subject != null){
		vex01 += "?subject=" + subject;
		if (bcctype != null && bccaddressee != null){
			vex01 += "&bcc=";
			vex01 += recipients[bcctype][bccaddressee];
			vex01 += "@acli";
			vex01 += "b.us";
		}
	} else if (bcctype != null && bccaddressee != null){
		vex01 += "&bcc=";
		vex01 += recipients[bcctype][bccaddressee];
		vex01 += "@acli";
		vex01 += "b.us";
	}
	title = text.replace("<br />", "");
	title = title.replace("Email ", "");
	title = title.replace("Email", addressee);
	title = title.replace(/_/g, " ");
	vex01 += "\" title=\"Send email to " + title + "\"" ;
	if (title == "Bug Report") {
		vex01 += " onClick=\"alert('Please supply as much information as possible in your bug report: What were you attempting to do? What went wrong? Browser/platform info, etc.')\"";
	}
	vex01 += ">" + text + "</a>";
	document.write(vex01);
}

function openShut(whichElement) {
	var theElement = whichElement;
	var theFormField = "document." + theElement + "Form." + theElement + "Input.value";
	var theImg = theElement + "Img";
	theElement = document.getElementById(theElement);
	var fieldVal;
	eval("fieldVal = " + theFormField);
	if (fieldVal == 0) {
		theElement.style.display = 'block';
		eval("document." + theImg + ".src = '/images/common/minus.gif'");
	} else {
		theElement.style.display = 'none';
		eval("document." + theImg + ".src = '/images/common/plus.gif'");
	}
	eval(theFormField + " = 1 - " + theFormField);
}

function popMap(whichMap) {
	var theURL = 'acld_map.php?map=' + whichMap;
	var theAttributes = "width=500,height=520,resizable=yes";
	map_pop = window.open(theURL, 'mapPop', theAttributes);
	map_pop.focus();
}

function showMap(whichMap,whatMap,whichSched) {
	if (document.getElementById(whichMap)) {
		document.getElementById(whichMap).style.display = 'block';
	}
	if (document.getElementById(whatMap)) {
		document.getElementById(whatMap).style.display = 'none';
	}
	if (document.getElementById(whichSched)) {
		document.getElementById(whichSched).style.display = 'none';
	}
}

function hideMap(whichMap,whatMap,whichSched) {
	document.getElementById(whichMap).style.display = 'none';
	document.getElementById(whatMap).style.display = 'block';
	document.getElementById(whichSched).style.display = 'block';
}

function newWin(newLocation) {
	window.open(newLocation);
}

var checkvalue = 0;
function checkForm() {
	var n = document.askRef.elements.length;
	for (i = 0; i < n; i++) {
		if (document.askRef.elements[i].checked) {
			checkvalue++;
		} 
	}
	if (document.askRef.patron_name.value == "") {
		alert("Please enter a Name");
		document.askRef.patron_name.focus();
		return false;
	} else if (document.askRef.patron_phone.value == "" && document.askRef.patron_email.value == "") {
		alert("Please enter a Phone Number or E-Mail Address");
		document.askRef.patron_phone.focus();
		return false;
	} else if (document.askRef.patron_question.value == "") {
		alert("Please enter a Question");
		document.askRef.patron_question.focus();
		return false;
	} else {
		return true;
	}
}

function kidNav(imgName, imgState) {
	document.images[imgName].src = "/images/just_for_kids/" + imgName + "_" + imgState + ".gif";
	if (imgState == "ON") {
		document.images.kids_C.src = "/images/just_for_kids/" + imgName + "_C.gif";
	} else {
		document.images.kids_C.src = "/images/just_for_kids/kids_C.gif";
	}
}

function urgentShow(show,hide) {
		document.getElementById(hide).style.display = 'none';
		document.getElementById(show).style.display = 'block';
}

function deweyWindow() {
	url = "http://www.oclc.org/dewey/resources/tour/ddc1.html";
	dewey_win = window.open(url,'','height=420,width=600,toolbar=yes,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
	dewey_win.focus();
	//new_win.onBlur = new_win.alert("HHH");
}

function clearPCRes() {
	if (document.forms.pcresForm && document.forms.pcresForm.user_id) {
		document.forms.pcresForm.user_id.value = '';
	}
}

