// ___________________________________________________________________________
//
// JavaScript-Funktionen spezifisch fuer KVK-Suchmaske
// ___________________________________________________________________________
//
// Copyright Uwe Dierolf, UB Karlsruhe, 03.07.2002
//
// ---------------------------------------------------------------------------
//
// ACHTUNG:
// Die Funktionen "load_prefs_opts(form, group)" und "save_prefs_opts(form)"
// und der Array "fields" MUESSEN definiert sein (siehe kvk_generic.js und
// kvk_specific.js).
//
// 11.07.2002, Oliver Kern:
//	Auf Bitte von Hr. Moennich VLB aus der Buchhandel-Sammelsuche
//	(Array "buchhandel") entfernt.
//
// 13.12.2002, Uwe Dierolf:
//      2 neue Checkboxen für Österreich und Schweiz werden unterstützt.
// ___________________________________________________________________________
//
// Javascript for the Utah Multi-Catalog Search appearing on the Utah State Library Division web site and including only public libraries


// KVK-spezifische Katalogsatz-Arrays
saltlakecounty = new Array(
	"UTAH_MURRAY",
	"UTAH_SLC",
	"UTAH_SLCO",
	"UTAH_USL"
)
utahcounty = new Array(
	"UTAH_OREM",
	"UTAH_PROVO"
)
northernutah = new Array(
	"UTAH_DAVIS",
	"UTAH_WEBER"
)
allpublic = new Array(
	"UTAH_DAVIS",
	"UTAH_OREM",
	"UTAH_MURRAY",
	"UTAH_PROVO",
	"UTAH_SLC",
	"UTAH_SLCO",
	"UTAH_USL",
	"UTAH_WEBER"
)
// Suchfelder
fields = new Array(
	"TI",
	"AU",
	"CI",
	"PY",
	"ST",
	"SB",
	"SS",
	"PU"
)

// Einstellungs-Knoepfe in die Suchmaske schreiben
function pref_buttons() {
	document.write("<font face=\"arial,helvetica\" size=\"2\"><a href=\"http://www.ubka.uni-karlsruhe.de/hylib/kvk_help.html\#einstellungen\">Einstellungen</a></font></td>")
	document.write("<td align=\"right\" nowrap><font face=\"arial,helvetica\" size=\"-1\">")
	document.write("<input type=\"button\" value=\"Sichern\" onClick=\"save_prefs(this.form)\" title=\"Aktuelle Einstellungen sichern\">&nbsp;")
	document.write("<input type=\"button\" value=\"Laden\" onClick=\"load_prefs(this.form)\" title=\"Gesicherte Einstellungen laden\">")
	document.write("</font>")
}

// Optionen laden. Liest aus der ersten Zeichengruppe des Einstellungs-Cookies
// die Optionen aus und setzt sie in der Suchmaske
function load_prefs_opts(form, group) {
	// Dieses Umschaufeln ist notwendig, da IE im Gegensatz zu NS nicht
	// direkt auf den String wie auf einen Array zugreifen kann
	var bits = new Array()
	bits = group.split("")

	// Nicht genuegend "Bits" vorhanden -> Unbekannte Daten
	if (bits.length < 6) return

	form.saltlakecounty.checked	 = (bits[0] == "1")
	form.utahcounty.checked = (bits[1] == "1")
	form.northernutah.checked     = (bits[2] == "1")
	form.othercounties.checked	 = (bits[3] == "1")
	form.allpublic.checked  = (bits[4] == "1")
	form.allacademic.checked	 = (bits[5] == "1")
	form.bookstores.selectedIndex	 =  bits[6]
	form.target.checked	 = (bits[7] == "1")
}

// Optionen sichern. Liest die im Einstellungs-Cookie zu sichernden Optionen
// aus der Suchmaske und gibt sie als Zeichengruppe zurueck
function save_prefs_opts(form) {
	var prefs = ""
	prefs += read_state(form, "saltlakecounty")
	prefs += read_state(form, "utahcounty")
	prefs += read_state(form, "northernutah")
	prefs += read_state(form, "allpublic")
	prefs += read_state(form, "target")
	return prefs
}

