$.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(){
	$('#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.clone()).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;
}

function submitform() {
    document.bf_form.submit();
}

function vote(id) {
    if (!isNaN(id)) {
        var woahd = $('span#w'+id).html();
        SetCookie('vote',woahd);
        window.location.href = '/haum.php';
    }
}

function SetCookie(cookieName,cookieValue,nDays) {
     var today = new Date();
     var expire = new Date();
     if (nDays==null || nDays==0) nDays=1;
     expire.setTime(today.getTime() + 3600000*24*nDays);
     document.cookie = cookieName+"="+cookieValue
                     + ";expires="+expire.toGMTString();
}