function sortSubmit(sortValue) {
		document.q.curSort.value=sortValue;
		document.q.submit();
		return true;
}
	
// call onsubmit on the search form
function doSearch(oldSearchQuery) {
    if (document.q.q.value == "") {
        new Effect.Highlight($('underline_q'),{ startcolor: '#DD5200', endcolor: '#E4F7FB' });
        return false;
    }
	// if the search terms are changed lets redirect the user to the first page
	if (oldSearchQuery != document.q.q.value) {
		newSearch();
	}
	return true;
}

// resets the curent page, and submits the search form
function goPage( noPage ){
document.q.pagerCurrentRow.value = noPage;
document.q.submit();
return false;
}

// resets the curent page, and submits the search form
function newSearch( ){

return goPage( 0 );
}


// change the perPage select for the main search
function changePerPage( perPage ){
document.q.max_display.value = perPage;

return goPage( 0 );
}




	
	function IsImageOk(img)
	{
		// During the onload event, IE correctly identifies any images that
		// weren't downloaded as not complete. Others should too. Gecko-based
		// browsers act like NS4 in that they report this incorrectly.
		if (!img.complete)
			return false;

		// However, they do have two very useful properties: naturalWidth and
		// naturalHeight. These give the true size of the image. If it failed
		// to load, either of these should be zero.
		if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0)
			return false;

		// No other way of checking: assume it's ok.
		return true;
	}

	function addEvent(obj, evType, fn){ 
		if (obj.addEventListener){ 
			obj.addEventListener(evType, fn, false); 
			return true; 
		} else if (obj.attachEvent){ 
			var r = obj.attachEvent("on"+evType, fn); 
			return r; 
		} else { 
			return false; 
		}
	}

	function imgcheck()
	{
		for (var i = 0; i < document.images.length; i++)
			if (!IsImageOk(document.images[i]))
				document.images[i].style.visibility = "hidden";
	}
	// addEvent(window, "load", imgcheck );
	
	// another solution to fight the broken images is here
	// onerror="img_e(this)"
	function img_e(source)
	{
		source.src = "/images/search/n.gif";
		// disable onerror to prevent endless loop
		source.onerror = "";
		return true;
	}





function addEngine(name,ext,cat) {
	if (
		(typeof window.sidebar == "object") && 
		(typeof window.sidebar.addSearchEngine == "function")
	) {
		window.sidebar.addSearchEngine("http://www.cenite.com/js/search/"+name+".search.src", "http://www.cenite.com/js/search/"+name+".search."+ext, name, cat);
	}
	else {
		alert("Mozilla or Mozilla Firefox is needed to install this search plugin");
	}
}




