function textSearch() {
	var searchText = $('search').value;
	searchText = searchText.replace(/(<([^>]+)>)/ig, "");
	searchText = searchText.replace (/['\.\,\?!]/g, "");
	// searchText = searchText.replace (/[\s]/g, "%20");

	if (!searchText) {
		alert("You must enter at least 2 alphanumeric characters as a search pattern.");
		return;
	}
	if (searchText.length == 1) {
		alert("Please enter more than 1 alphanumeric character for your search pattern.");
		return;
	}
	window.location="/browse.php?txt=" + searchText;
}

function key(e) {
	e = e || window.event;
	var code = e.keyCode || e.which;
	if (code == 13){ 
		textSearch();
	} else {
		return e;
	}
}

function GPAT_select() {
	var sel = 0;
	sel = $('genre').selectedIndex;
	var genre = $('genre')[sel].text; 

	sel = $('pub').selectedIndex;
	var pub = $('pub')[sel].text; 

	sel = $('author').selectedIndex;
	var author = $('author')[sel].text; 

	sel = $('title').selectedIndex;
	var title = $('title')[sel].text; 

	new Ajax.Updater('gpat', 'gpat.php', { parameters: {
		genre: genre, 
		pub: pub,
		author: author,
		title: title} } );
}

function do_gpat_reset() {
	$('genre').selectedIndex = 0;
	$('pub').selectedIndex = 0;
	$('title').selectedIndex = 0;
	$('author').selectedIndex = 0;
	GPAT_select();
}

function do_gpat_browse() {
	var sel = 0;
	sel = $('genre').selectedIndex;
	var genre = $('genre')[sel].text; 

	sel = $('pub').selectedIndex;
	var pub = $('pub')[sel].text; 

	sel = $('author').selectedIndex;
	var author = $('author')[sel].text; 

	sel = $('title').selectedIndex;
	var title = $('title')[sel].text; 

	$('search').value = '';

	new Ajax.Updater('browse_covers', 'browse_covers.php', { parameters: {
		genre: genre, 
		pub: pub,
		author: author,
		title: title} } );
}

function getID(getIDobj) {
	return document.getElementById(getIDobj);
}

function clean_unicode(str_data) {
	// Basic trim left and right
	return str_data.replace(/^\s+|\s+$/g,"");
}

