function coord_is(x,y,l,t,w,h){
	return ( (l<x) & (x<(l+w)) & (t<y) & (y<(t+h)) );
}
function step1(nextfunc) {
	$("#row-3-light")
		.css("background-image","url(/images/bg_header_x998_light_left.jpg)")
		.animate({"opacity": "1"}, "fast")
		.animate({"opacity": "0"}, "normal", "", nextfunc?nextfunc:step3);
}
function step2(nextfunc) {
	$("#row-3-light")
		.css("background-image","url(/images/bg_header_x998_light_right.jpg)")
		.animate({"opacity": "1"}, "fast")
		.animate({"opacity": "0"}, "normal", "", nextfunc?nextfunc:step3);
}
function step3() {
	$("#row-3-light")
		.css("background-image","url(/images/bg_header_x998_light.jpg)")
		.animate({"opacity": "1"}, "fast")
		.animate({"opacity": "0"}, "normal")
		.animate({"opacity": "1"}, "fast")
		.animate({"opacity": "0"}, "normal")

		;
}
function click_light(event){
	var x = event.clientX - $(this).offset().left;
	var y = event.clientY - $(this).offset().top;
	if (coord_is(x,y,120,190,110,50)) 
	{
		step1(step2);

	}
	else {
		if (coord_is(x,y,490,170,90,50)) 
		{
			step2(step1);
	
		}
	}
}
function move_event(event){
	var x = event.clientX - $(this).offset().left;
	var y = event.clientY - $(this).offset().top;
	if (coord_is(x,y,120,190,110,50) || coord_is(x,y,490,170,90,50)) 
	{
		$("#row-3-light").css("cursor","help")
	}
	else
	{
		$("#row-3-light").css("cursor","auto")
	}
}
$(document).ready(function(){
	$("#row-3-light")
		.click(click_light)
	//	.mousemove(move_event)
		;
	jQuery('<img src="/images/bg_header_x998_light.jpg" />');
	jQuery('<img src="/images/bg_header_x998_light_left.jpg" />');
	jQuery('<img src="/images/bg_header_x998_light_right.jpg" />');

	$(window).load(function () {
		$("#row-3-light")
			.css("background-image","url(/images/bg_header_x998_light.jpg)")
			.animate({"opacity": "1"}, "fast")
			.animate({"opacity": "0"}, "slow");
	});

	$(".img_zoom a").fancybox();
	$(".alarm_table a").fancybox();

});

