$(function(){
	$("div.logo a").focus(function(){
		$(this).blur();return false;
	});
	$("div.nav li").hover(
		function(){
			$(this).stop().animate({
				"backgroundColor":"#696969"
			}, 200);
		}, function(){
			$(this).stop().animate({
				"backgroundColor":"#363636"
			}, 'slow');
    	}
	);
	$("ul.itemslist li").hover(
		function(){
			if($("#pof").attr('checked') == false){return false;}
			items_preview(this,jQuery(this).attr("id"));
		}, function(){
			if($("#pof").attr('checked') == false){return false;}
			var id = jQuery(this).attr("id");
			$("#popwin").css("display","none");
			$("#popwin .frmc").html("");
    	}
	);
	$("ul.itemslist div.price,ul.itemslist div.headline,ul.itemslist div.description").click(
		function(){
			if($("#pof").attr('checked') == false){
				preview_off_flag();
				$("#pof").attr({ checked: "checked" });
				items_preview(
					jQuery(this).parent().parent().parent("li"),
					jQuery(this).parent().parent().parent("li").attr("id")
				);
			}
		}
	);
});

function items_preview(obj,id){
	$("#popwin .frmc").html("");
	var pos = id.match("([0-9]+)$")[1];
	var body = "";
	body = '<div class="title">'+$("dt a",obj).html()+'</div>';
	if($("dd div.headline",obj).html()){
		body += '<div class="headline">'+$("dd div.headline",obj).html()+'</div>';
	}
	if($("dd div.description",obj).html()){
		body += '<div class="description">'+$("dd div.description",obj).html()+'</div>';
	}
	if(pos%3 == 0){
		$("#popwin div.a1").css("background-image","url(/img/popfrm/ba.png)");
		$("#popwin div.a2").css("background-image","url(/img/popfrm/bb.png)");
		$("#popwin div.a3").css("background-image","url(/img/popfrm/bb.png)");
	}
	if(pos%3 == 1){
		$("#popwin div.a1").css("background-image","url(/img/popfrm/bb.png)");
		$("#popwin div.a2").css("background-image","url(/img/popfrm/ba.png)");
		$("#popwin div.a3").css("background-image","url(/img/popfrm/bb.png)");
	}
	if(pos%3 == 2){
		$("#popwin div.a1").css("background-image","url(/img/popfrm/bb.png)");
		$("#popwin div.a2").css("background-image","url(/img/popfrm/bb.png)");
		$("#popwin div.a3").css("background-image","url(/img/popfrm/ba.png)");
	}
	$("#popwin .frmc").html(body);
	$("#popwin").css({
		"top":$(obj).position().top - $("#popwin").height()+22,
		"display":"block"
	});
}

function preview_off_flag(ipt){
	if($(ipt).attr('checked') == false){
		$.cookie("pof",1,{expires: 365,path:'/'});
	}
	else{
		$.cookie("pof", '0', { expires: -1,path:'/' });
	}
}

