$(document).ready(function(){
	$("#menu ul li a[class!='active']").mouseover(function(){
		$(this).css({ backgroundPosition: "bottom" });
	}).mouseout(function(){
		$(this).css({ backgroundPosition: "top" });
	});
	
	$("#verstuursubmit").mouseover(function(){
		$(this).attr({ src: "img/verstuur.gif" });
	}).mouseout(function(){
		$(this).attr({ src: "img/verstuur2.gif" });
	});
	
	$("#brochureHover").mouseover(function(){
		$(this).attr({ src: "img/brochure2.png" });
	}).mouseout(function(){
		$(this).attr({ src: "img/brochure.png" });
	});	
	
	$(".cat_container .product").mouseover(function(){
		$(this).addClass('hover');
	}).mouseout(function(){
		$(this).removeClass('hover');
	});
	
	$(".cat_container .JQlink").click(function () {
		var target = $(this).children('div').children('p').children('a').attr('href');
        location.href=target;
	});
	
	$(".JQ_show_bigger").click(function () {
		$("#overlay_photo").remove();
		var img = $(this).attr('href');
		$("body").prepend("<div id=\"overlay_photo\"><img src=\""+img+"\" /><br /><a>Sluiten</a></div>");
		close_show_bigger();
        return false;
	});
	
	
});

function close_show_bigger() {
	$("#overlay_photo a, #overlay_photo img").click(function () {
		$("#overlay_photo").remove();
        return false;
	});
}

function createSortable(id, itemsClass, handler, action, direction){
	$(id).sortable({ 
        items: itemsClass,
        delay: 10,
        distance: 0,
        axis: direction,
        opacity: 0.5,
        placeholder: 'ui-placeholder',
        handle: handler,
		update: function(e, ui){
            $.ajax({
                type: "POST",
                url: action,
                data: "itemId=&newOrder="+$(id).sortable('toArray'),
                error: function(msg){
                    $("#JQresult").html(msg);
                },
                success: function(msg){
                    $("#JQresult").html(msg);
                }
            });
		}
    });
}

function fancyBox() {
	$("a.fancybox").fancybox();
}