jQuery(document).ready(function($){
	$(".content table tr:nth-child(odd)").addClass("odd");
	$(".content table tr:nth-child(even)").addClass("even");
	/* // done with php now
	$("#text_size_large").click(function(){
	   $("body").css("font-size","14px");
	   return false;
	});
	$("#text_size_medium").click(function(){
	   $("body").css("font-size","11px");
	   return false;
	});
	$("#text_size_small").click(function(){
	   $("body").css("font-size","9px");
	   return false;
	});
	*/
	// project functions for leftnav
	$("#potatoes .project").hover(
		function(){
			if($(this).hasClass("activeProject")==false){
				$(this).css({
					"background-color":"#fff",
					"border":"1px solid #657999",
					"border-width":"1px 0 1px 0",
					"padding":"9px 40px 4px 29px",
					"cursor":"pointer"
				})
			}
		},
		function(){
			if($(this).hasClass("activeProject")==false){
				$(this).css({
					"background-color":"transparent",
					"border":"none",
					"padding":"10px 40px 5px 29px",
					"cursor":"default"
				})
			}
		}			
	)
	$("#potatoes .project").click(function(){
		var myURL = $(this).find(".seeMore").attr('href');
		window.location = myURL;
	});
	
	// function for connecting leftcol to right on active projects.
	if($("#potatoes .activeProject").length > 0){
		$("#potatoes .activeProject").append('<div id="activeConnector"></div>');
		
		var activeProjPos = $("#potatoes .activeProject").position();
		var activeProjTop = activeProjPos.top + 1; // add for border height
		var activeProjLeft = activeProjPos.left + 320; // add width of column
		var activeProjHeight = $("#potatoes .activeProject").height() + 13; // add padding

		$("#activeConnector").css({
			"display":"block",
			"position":"absolute",
			"background-color":"#fff",
			"width":"13px",
			"height": activeProjHeight+"px",
			"top": activeProjTop +"px",
			"left": activeProjLeft +"px"
		});
	}
	
	//do height correction for meat column 
	if($("#potatoes").height()>400){
		$("#meat").css("min-height","750px");
	}
	
	// project search function
	$("#project_search input.project_search").click(function() {

		var dataString = 'market=' + $('#project_search input[name="market"]').val() + '&urlbit=' + $('#project_search input[name="urlBit"]').val();   
		$('#project_search select').each(function() {            
			if ($(this).val()!="") {
				dataString += '&'+$(this).attr("name")+'='+$(this).val();
            }
        });
		if(dataString!="?"){
			$.ajax({
				type: "POST",
				url: "/lib/ajax/ajax_do_project_search.php",
				data: dataString,
				success: function(html) {
					$('#project_search form').hide();
					$('#project_search_details').append(html);
				}
			});		
		}else{
			alert("Please select at least one project category.");
		}

		return false;
	});
});

function do_clear_search(){
	$('#project_search .results').remove();
	$('#project_search form').show();
	$('#project_search select').each(function() {            
		$(this).val("");
       });
	return false;
}