var $timeCubeStatus=["空闲","上课","重置"];

function clearTimeCube(){
	$("#timeCube tr td.selected").html($timeCubeStatus[0]);
	$("#timeCube tr td.selected").removeClass("selected");
	$("#timeTable tr td input.selected").removeAttr(hintKey);
	$("#timeTable tr td input.selected").removeClass("selected");
}

function getTimeCubeString(){
	var string="";
	
	var cubes=$("#timeCube tr td[class='selected']");
	
	var isFirst=true;
	$("#timeCube tr td[class='selected']").each(function(){
		if(isFirst){
			isFirst=false;
		}else{
			string+=itemSplit;
		}
		string+=parseInt($(this).attr("id").split(timeCubeId)[1]);
	});
	
	return string;
}

function renderTimeTableCellOfCube(cube){
	var id=parseInt(cube.attr("id").split(timeCubeId)[1]);
	var cell=$("#"+timeTableId+id);
	
	cell.toggleClass("selected");
	
	if(cell.hasClass("selected")){
		cell.attr(hintKey,"已将此时段纳入查询条件<br>可在 <b>按时间查询</b> 面板中更改");
	}else{
		cell.removeAttr(hintKey);
	}
}

function readyTimeCubeAction(){
	
	$("#timeCube tr th").click(function(){
		if($(this).html()==$timeCubeStatus[2]){
			clearTimeCube();
		}
	});
	
	$("#timeCube tr th").mouseover(function(){
		if($(this).html()==$timeCubeStatus[2]){
			$(this).css({"font-size":"14px"});
		}
	}).mouseout(function(){
		if($(this).html()==$timeCubeStatus[2]){
			$(this).css({"font-size":"12px"});
		}
	});
	
	$("#timeCube tr td").click(function(){
		if($(this).html()==$timeCubeStatus[0] || $(this).html()==$timeCubeStatus[1]){
		
			$(this).toggleClass("selected");
			
			renderTimeTableCellOfCube($(this));
			
			var time=$timeCubeStatus[0];
			if($(this).attr("class")=="selected"){
				time=$timeCubeStatus[1];
			}
			$(this).html(time);
			
		}
	});
	
	$("#timeCube tr td").mouseover(function(){
		if($(this).html()==$timeCubeStatus[0] || $(this).html()==$timeCubeStatus[1]){
			$(this).css({"font-size":"14px","font-weight":"bold"});
		}
	}).mouseout(function(){
		if($(this).html()==$timeCubeStatus[0] || $(this).html()==$timeCubeStatus[1]){
			$(this).css({"font-size":"12px","font-weight":"normal"});
		}
	});

}
