// JavaScript Document
$(document).ready(function(){
	showContent("getafreelancer",30,"gaftable");
	showContent("eufreelance",30,"euftable");
	showContent("outsourcetoday",20,"osttable");
	//showContent("scriptlance",30,"sltable");
});

function showContent(id,count,container){
	$("#"+container+" tbody tr.error").remove();
	$("#"+container+" tbody tr.loading").show();
	$.get("indexcontent.php", { id: id, count : count},
	  	function(data){
			$("#"+container+" tbody tr.loading").hide();
			if(data == ""){				
				$("#"+container+" tbody").append("<tr class='error'><td colspan='5'>载入失败! <span style='cursor:pointer;color:blue' onclick='showContent(\""+id+"\","+count+",\""+container+"\")'>重新载入</span></td></tr>");
			}else {
				$("#"+container+" tbody").append($(data).find("#content").html());
				mark("#"+container+" tbody");
			}
	});
}

function mark(id) {
	var rollovercolor = "#ffbfbf";
	$(id + " tr.mark").each(function(){
		$(this).attr("obgcolor",$(this).attr("bgcolor"));
	});
	$(id + " tr.mark")
		.hover(function(){
				if(typeof $(this).attr("mark") == "undefined" || $(this).attr("mark") !="1"){
					$(this).attr("bgcolor",rollovercolor).css("background-color",rollovercolor).css("color","#9e3e22");					
				}
			},
			function(){
				if(typeof $(this).attr("mark") == "undefined" || $(this).attr("mark") !="1"){ 
					var oc = $(this).attr("obgcolor");
					$(this).attr("bgcolor",oc)
						.css("background-color",oc).css("color","#000000");
				}
			})
		.click(function(){//alert($(this).find("td").attr("bgcolor"));
			/*if($(this).attr("mark")=="1") {
				var oc = $(this).attr("obgcolor");
				$(this).attr("bgcolor",oc)
					.css("background-color",oc);
				$(this).attr("mark","0");
			} else {*/
				$(this).attr("bgcolor","#FFD0A0").css("background-color","#FFD0A0");
				$(this).attr("mark","1");
				window.open($(this).find("a").attr("href"));
			//}
		});
}