function setup(i){
	var sendData = $("#searchForm").serialize();
	window.location = "/classes/?" + sendData + "&date_offset=" + i;
};

$(document).ready(function(){
	
	$("#scheduletype_id option[value="+ getQueryVariable("scheduletype_id") +"]").attr("selected","selected");
	$("#instructor_id option[value="+ getQueryVariable("instructor_id") +"]").attr("selected","selected");
	$("#class_id option[value="+ getQueryVariable("class_id") +"]").attr("selected","selected");
	$("#location_id option[value="+ getQueryVariable("location_id") +"]").attr("selected","selected");

	Date.format = 'yyyy-mm-dd';
	$('.date-pick').datePicker().bind('change',function(){ setup(""); });
	
	$("tr:not(.day):odd > td").css("background-color","#e5e5e5");
	if ( $("tr.day:first").text() == $("#displayDate").text() ){
		$("tr.day:first").remove();
	}
	else{
		$("tr.day:first").before("<tr class=\"noclass\"><td colspan=\"5\">No classes scheduled</td></tr> ");
	}
	
	$("tr.day").prev("tr").children("td").css("background-image","none");
	
	var fsh = $("#tableWrap table:first").height();
	if ( fsh < 280 ){ $("#fakeScroll").css("height",fsh); }
	else{ $("#fakeScroll").css("height",280); };
	

	$(".td4 > div:contains('Wolf Willow')").css("color","#006a71");
	$(".td4 > div:contains('Downtown')").css("color","#b51019");

	//schedule form
	$("#searchGo").click(function(){ setup(null); });
	$("#dateJump a").each(function(){
		$(this).css({
			cursor:"pointer",
			display:"block",
			height: $(this).parent().height(),
			width: $(this).parent().width(),
			textIndent: "-9999px"
		});
	});
	$("#datePrev").click(function(){ setup(-1); });
	$("#dateToday").click(function(){ setup(0); });
	$("#dateNext").click(function(){ setup(1); });

});

$(window).load(function(){
	setTimeout(function(){
		$("#subMenu").fadeIn("slow");
	},1000);
})