$(function() {
	$("ul.navi li[class!='sel']").hover(function() {
		$("ul.navi li.sel").addClass("noact");
	}, function() {
		$("ul.navi li.sel").removeClass("noact");
	});
	textinInit($("form"));
	$("table.price tr").hover(function() {$(this).addClass("ov");}, function() {$(this).removeClass("ov");});
	if ($(".gal1 li a").length > 0) $(".gal1 li a").lightBox();
	
	if ($(".bimg a").length > 0) {
		$(".gal2 ul li a:gt(0)").each(function() {
			$(".bimg").append('<a href="'+$(this).attr("rel")+'"></a>');
		});
		
		$(".gal2 ul li a").click(function() {
			var th = $(this);
			var ind = $(".gal2 ul li a").index(th);
			$(".bimg img").fadeOut("fast", function() {
				var img1 = new Image();
				$(img1).load(function() {
					$(".bimg a:has(img)").removeClass("cur");
					$(".bimg a:has(img) *").appendTo($(".bimg a").eq(ind).addClass("cur"));
					$(".bimg img").attr("src", $(this).attr("src")).fadeIn();
				}).attr("src", th.attr("href"));
			});
			return false;
		});
		
		$(".bimg a").lightBox();
	}
});

function textinInit(o) {
	$("input, textarea", o).each(function() {
		if ($(this).val() == '') {
			if ($(this).attr("type") == "password") {
				var th = $(this);
				th.after('<input type="text" class="'+$(this).attr("class")+'" value="'+$(this).attr("title")+'" />').hide();
				$("input:text", th.parent()).focus(function() {
					$(this).hide();
					th.show().focus();
				});
			}
			$(this).get(0).value = $(this).attr("title");
		};
		$(this).focus(function() {
			if ($(this).val() == $(this).attr("title")) {
				$(this).get(0).value = '';
			}
		}).blur(function() {
			if ($(this).val() == '') {
				if ($(this).attr("type") == "password") {
					$(this).hide();
					$("input:text", $(this).parent()).show();
				}
				$(this).get(0).value = $(this).attr("title");
			}
		});
	});
}