$(document).ready(function(){

	var $category = $("body").attr("class");
	var $path = $("body").attr("id");
	var $search = "#buttons #" + $category + " a";

	$($search).each(function(){
	     if ($(this).attr("href") == $path)
	     {
	          document.title = $(this).attr("rel");
		}
	});

	$("#buttons div.category").mouseover(function(){
		$("div.nav-wrapper", this).show();
	});

	$("#buttons div.category").mouseout(function(){
	    $(this).children('div.nav-wrapper').hide();
	});

	$('.toggle').live('click', function() {
          $("#news_article").hide('fast');
	});

     $(".news-button").click(function(){
          var url = "http://www.mtchs.org/assets/ajax/news_article.php?n=" + $(this).attr('id');

          $("#news_article").show('fast');

		$.get(url, function(content){
			$("#news_article").html(content);
		});

	});
	
	$("#class-list tr:nth-child(even)").css("background-color", "#DDD");
     $("#docs-list tr:nth-child(even)").css("background-color", "#DDD");
     
     $(function() {
		var zIndexNumber = 1000;
		
		$('div').each(function() {
			$(this).css('zIndex', zIndexNumber);
			zIndexNumber -= 10;
		});
	});
});


$(document).ready(function() {
	$(".tab").hide();
	$("ul#tabs li:first").addClass("active").show();
	$(".tab:first").show();

	$("ul#tabs li").click(function() {

		$("ul#tabs li").removeClass("active");
		$(this).addClass("active");
		$(".tab").hide();

		var activeTab = $(this).find("a").attr("href");
		$(activeTab).fadeIn();
		return false;
	});
});

/*
 * =Validation
 */
$(document).ready(function() {

	$(".date").datepicker({
		dateFormat: "yy-mm-dd"
	});

     $(".student-news").validate({
		errorLabelContainer: $(".error"),
		onfocusout: false,
		onkeyup: false,
		onclick: false
	});
	
	$(".projects").validate({
		errorLabelContainer: $(".error")
	});
	
	$(".contact").validate({
		errorLabelContainer: $(".error")
	});
});
