$(document).ready(function(){
	$('div#cameraMolen').html('<img src="'+webroot+'img/molen_camera/snapshot.JPG" style="width:480px" />');
	setInterval(refreshCamera, 10000);
	
});

function centsToEur(cents){
	var eur = cents / 100; // cents to euros
	eur = eur.toFixed(2); // two number after .
	return eur.replace('.', ','); // replace . with ,
}

function createSortable(id, itemsClass, action){
	$("#"+id).sortable({ 
        items: "."+itemsClass,
        delay: 10,
        distance: 0,
        axis: 'both',
        opacity: 0.5,
        placeholder: 'ui-placeholder',
        handle: '.handle',
		update: function(e, ui){
            $.ajax({
                type: "POST",
                url: webroot+action,
                data: "itemId=&newOrder="+$("#"+id).sortable('toArray'),
                error: function(msg){
                    $("#JQresult").html(msg);
                },
                success: function(msg){
                    $("#JQresult").html(msg);
                }
            });
		}
    });
}

function refreshCamera() {
	var d = new Date();
	$time = d.getTime();
	$('div#cameraMolen img').fadeOut('slow', function() {
		$('div#cameraMolen').html('<img src="'+webroot+'img/molen_camera/snapshot.JPG?'+$time+'" style="display:none; width:480px" />');
		$('div#cameraMolen img').fadeIn('slow');
	});
}