$(document).ready(function() {
	if ($("table#myTable tbody").length>0){
		$("table#myTable").chromatable({
			width: "100%",
			height: "100%",
			scrolling: "yes"
		});
		$("table#myTable").tablesorter({
			sortInitialOrder: "desc",
			sortList: [[4,1]]
		});
	}

	if ($("table#myTable2 tbody").length>0){
		$("table#myTable2").tablesorter({
			sortInitialOrder: "desc",
			sortList: [[0,1]]
		});
	}
	if ($("table#myTable3 tbody").length>0){
		$("table#myTable3").tablesorter({
			sortInitialOrder: "desc",
			sortList: [[4,1]]
		});
	}
	if ($("table#myTable4 tbody").length>0){
		$("table#myTable4").tablesorter({
			sortInitialOrder: "desc",
			sortList: [[4,1]]
		});
	}
});

function tablefilter(){
	var name=$("#filter").val();
	var type=$("#filtertype").val();
	var value=$("#filtervalue").val();
	if (type==0){
		$("table#myTable tbody tr").show();
		return;
	}
	var text;
	if (type==1){
		$("table#myTable tbody tr td."+name).filter(":not(:contains('"+value+"'))").parent().hide();
	} else if (type==2){
		$("table#myTable tbody tr td."+name).filter(":contains('"+value+"')").parent().hide();
	}else if (type==3){
		$("table#myTable tbody tr td."+name).each(function(){
			if (isNaN(parseFloat($(this).text()))){
				return;
			}
			if (parseFloat($(this).text())<=parseFloat(value)){
				$(this).parent().hide();
			}
		});
	}else if (type==4){
		$("table#myTable tbody tr td."+name).each(function(){
			if (isNaN(parseFloat($(this).text()))){
				return;
			}
			if (parseFloat($(this).text())!=parseFloat(value)){
				$(this).parent().hide();
			}
		});
	}else if (type==5){
		$("table#myTable tbody tr td."+name).each(function(){
			if (isNaN(parseFloat($(this).text()))){
				return;
			}
			if (parseFloat($(this).text())>=parseFloat(value)){
				$(this).parent().hide();
			}
		});
	}
	
}

$(document).ready(function() {
	$(".filter").toggle()
	$(".tab_content").hide();
	$("ul.tabs li.table:last").addClass("active").show();
	$(".tab_content:last").show();
	$("ul.tabs li.table").click(function() {
		$("ul.tabs li.table").removeClass("active");
		$(this).addClass("active");
		$(".tab_content").hide();
		var activeTab = $(this).find("a").attr("href");
		$(activeTab).fadeIn();
		return false;
	});
});

$(document).ready(function() {
	$("table tbody tr").click(function(){
		if( !$(this).hasClass("mark") ){
			$("tr.mark").removeClass("mark");
			$(this).addClass("mark");
		}
		else 
			$(this).removeClass("mark");
	});
});