$(function() {
	$(".tab_img").hover(
		function(){
			var img_src = $(this).attr("src");
			$(this).attr("src", img_src.replace("_off", "_hover"));
		},
		function(){
			var img_src = $(this).attr("src");
			$(this).attr("src", img_src.replace("_hover", "_off"));
		}
	);
	
	$(".tab_img").click(
		function(){
			if ($(".tab_" + $(this).attr("id")).css("display") == "none"){
				setTab($(this).attr("id"));
			}
		}
	);
});

function setTab(obj)
{
	$(".tab").removeClass('cellnormal');
	$(".tab").removeClass('cellfault');
	hideTab();
	showTab(obj);
	
	if (obj == "normal"){
		$("#co_employ").val("regular");
		$(".tab").addClass('cellnormal');
	} else {
		$("#co_employ").val("arbeit");
		$(".tab").addClass('cellfault');
	}
}

function showTab(obj)
{
	var img_src = $("#" + obj).attr("src");
	
	$(".tab_" + obj).show();
	$("#" + obj).attr("src", img_src.replace("_hover", "_active"));
}

function hideTab()
{
	$(".tab_target").hide();
	$(".tab_img").each(
		function(){
			var img_src = $(this).attr("src");
			$(this).attr("src", img_src.replace("_active", "_off"));
		}
	);
}

function setTabInitialize(obj)
{
	var img_src = $("#" + obj).attr("src");
	
	setTab(obj);
	$("#" + obj).attr("src", img_src.replace("_off", "_active"));
}
