﻿$(function () {
    var z;

    $("#iphone").draggable({ scroll: false, start: function (event, ui) { z = $(this).css('z-index'); $(this).css({ 'z-index': '1000' }); }, stop: function (event, ui) { $(this).css({ 'z-index': z }); } });
    $("#koekje").draggable({ scroll: false, start: function (event, ui) { z = $(this).css('z-index'); $(this).css({ 'z-index': '1000' }); }, stop: function (event, ui) { $(this).css({ 'z-index': z }); } });
    $("#potlood").mousedown(function (event, ui) { $(this).css({ 'top': event.pageY + 'px' }); });
    $("#potlood").draggable({ scroll: false, start: function (event, ui) { z = $(this).css('z-index'); $(this).css({ 'z-index': '1000' }); }, stop: function (event, ui) { $(this).css({ 'z-index': z }); } });
    $("#duimstok").draggable({ scroll: false, start: function (event, ui) { z = $(this).css('z-index'); $(this).css({ 'z-index': '1000' }); }, stop: function (event, ui) { $(this).css({ 'z-index': z }); } });
    $("#hamer").draggable({ scroll: false, start: function (event, ui) { z = $(this).css('z-index'); $(this).css({ 'z-index': '1000' }); }, stop: function (event, ui) { $(this).css({ 'z-index': z }); } });

    $("#kop").draggable({ scroll: false, start: function (event, ui) { z = $(this).css('z-index'); $(this).css({ 'z-index': '1000' }); },
        stop: function (event, ui) {
            var Stoppos = $(this).position();
            var topPos = Stoppos.top + 21;
            var topLeft = Stoppos.left + 64;
            var newStain = $('.kring').clone();
            var randomnumber = Math.floor(Math.random() * 4);

            if (topLeft > 280 && topLeft < 560 && topPos > 120 && topPos < 495) {

                newStain.css({ 'background-color': 'transparent', 'background-position': '0px -' + (randomnumber * 110) + 'px', 'top': topPos + 'px', 'left': topLeft + 'px' });
                $('.container').append(newStain);

            }

            $(this).css({ 'z-index': z });
        }
    });

    $('img').mousedown(function (e) { if (e.preventDefault) { e.preventDefault(); } });

    Cufon.replace('h1');
    Cufon.replace('.cufon');
    Cufon.now();

    $("a[rel='galerij']").colorbox({ 'current': 'afbeelding {current} van {total}', 'previous': 'vorige', 'next': 'volgende', 'close': 'sluiten' });
});

