	$(document).ready(function() {
	
		$(".toggle").toggleVal();
		if ($("#picbox").length > 0) setupcrossfade();
		
	});
	
	
	function setCat(newcat)
	{
		$("#catval").html(newcat);
	}
	
	function doSearch()
	{
		$("#searchbox").removeClass("searchbox_error");
		var curval = $("#searchval").val();
		if (curval == '' || curval == 'Search...') 
		{
			$("#searchbox").addClass("searchbox_error");
			var x = $("#searchbox").position()['left'] + 15;
			var y = $("#searchbox").position()['top'] + 35;
			$("#search_error_div").css({"top":y+"px","left":x+"px"}).slideDown("fast",null);
			return false;
		}
		else 
		{
			var cat = $("#catval").html();
			window.location='/search.php?key='+curval+'&cat='+cat;
		}
	}
	
	function clearSearchError()
	{
		var e = $("#searchbox").attr("class");
		var curval = $("#searchval").val();
		if (e == 'searchbox_error' && curval != '') 
		{
			$("#searchbox").removeClass("searchbox_error");
			$("#search_error_div").slideUp("fast",null);
		}
	}
	
	function keepalive()
	{
		clearTimeout(keeptimer);
		$.ajax({
			type: "POST",
			url: "ajax.php",
			data: "",
			success: function(resp) 
			{ 
				keeptimer = setTimeout("keepalive()",180000);
			}
		});
	}
	var keeptimer = setTimeout("keepalive()",180000);