$.fn.hoverClass = function(c) {
	return this.each(function(){
		$(this).hover( 
			function() { $(this).addClass(c);  },
			function() { $(this).removeClass(c); }
		);
	});
};

// Opacity stuff
$(document).ready(function(){
	$(".thickbox").bind("click", function(e){
		if(jQuery.browser.mozilla) {
			$(".TB_overlayBG").attr("style","-moz-opacity: 0.75;");
			$("#TB_HideSelect").attr("style","-moz-opacity: 0;");
		} 
		else if(jQuery.browser.msie) {
			$(".TB_overlayBG").attr("style","filter:alpha(opacity=75);");
			$("#TB_HideSelect").attr("style","filter:alpha(opacity=0);");
		}
		else if(jQuery.browser.safari) {
			$(".TB_overlayBG").attr("style","-khtml-opacity: 0.75;");
			$("#TB_HideSelect").attr("style","-khtml-opacity: 0;");
		} else {
			$(".TB_overlayBG").attr("style","opacity: 0.75;");
			$("#TB_HideSelect").attr("style","opacity: 0;");
		}
		
	});
});

$(document).ready(function(){
	// navigation
	$("#nav-one li").hover(
		function(){ $("ul", this).fadeIn("fast"); }, 
		function() { } 
	);
	if (document.all) {
		$("#nav-one li").hoverClass ("sfHover");
	}
	$('#shop-container ul').tabs();
	
	$(".product").draggable({
			helper: 'clone'
		}
	);
	
	$(".droppable").droppable({
		accept: '.product',
		activeClass: 'droppable-active',
		hoverClass: 'droppable-hover',
		drop: function(ev, ui) {
            var prd_id = parseInt($('.prd_id', ui.draggable.element).text());
            if(!isNaN(prd_id)) {
                $.post('/shop/add.php', {'id': prd_id}, function(data) {
                    $('.droppable').html(data);
                });
                return false;
            } else {
                $('.droppable').html("<p>Er is een fout opgetreden.<br/>Ververs uw browser en probeert u het opnieuw</p>");
            }
		}
	});
});

function removePrd(id) {
    if (!isNaN(id)) {
        $.post('/shop/del.php', {'id': id}, function(data) {
            $('.droppable').html(data);
        });
        return false;
    } else {
        return false;
    }
}

function submitform() {
    document.bf_form.submit();
}
