function doLogin() {
    $.fancybox({
        href: '/aanmelden/inloggen-form',
        type: 'iframe',
        width: 300,
        height: 350
    });
}

function number_format(a, b, c, d) {
    a = Math.round(a * Math.pow(10, b)) / Math.pow(10, b);
    e = a + '';
    f = e.split('.');
    if (!f[0]) f[0] = '0';
    if (!f[1]) f[1] = ',-';
    if (f[1].length < b) {
        g = f[1];
        for (i=f[1].length + 1; i <= b; i++) g += '0';
        f[1] = g;
    }
    if (d != '' && f[0].length > 3) {
        h = f[0];
        f[0] = '';
        for(j = 3; j < h.length; j+=3) {
            i = h.slice(h.length - j, h.length - j + 3);
            f[0] = d + i +  f[0] + '';
        }
        j = h.substr(0, (h.length % 3 == 0) ? 3 : (h.length % 3));
        f[0] = j + f[0];
    }
    c = (b <= 0) ? '' : c;
    return f[0] + c + f[1];
}

function strip_tags(s) {
    return s.replace(/<\/?[^>]+>/gi, '');
}

$(function() {
	// Header
	$('body > header > div > nav.menu > ul > li').hover(function() {
		$(this).find('> ul')
			.stop(true, true)
			.slideDown();
	}, function() {
		$(this).find('> ul')
			.stop(true, true)
			.slideUp({ duration: 250 });
	});
	
	// Fancybox
	$.extend($.fn.fancybox.defaults, {
		titleShow: false
	});
	$.fancybox.setup = function() {
		$('a[class*="modal"]').each(function() {
			var modal_class = $(this).attr('class')
			    .replace(/.*modal-([0-9]+)x([0-9]+).*/, 'modal-$1x$2')
			    .replace(/.*modal-gallery.*/, 'modal-gallery');
			if (modal_class == 'modal') {
				var options = {type: 'iframe', showNavArrows: false};
			} else if (modal_class.substr(5) == '-gallery') {
			    // @TODO Support multiple images
				var options = {
					titleShow: false/*,
					titlePosition: 'inside',
					titleFormat: function(title, currentArray, currentIndex, currentOpts) {
						return 'Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + ' ' + title;
					}*/
				};
			} else {
                var options = {
                    autoDimensions: false,
                    type: 'iframe',
                    showNavArrows: false,
                    width: parseInt(modal_class.substr(6, 3)),
                    height: parseInt(modal_class.substr(10, 3))
                };
			}
			$(this).fancybox(options);
		});
	};

	$.fancybox.setup();
    var isIOS = navigator.platform && navigator.platform.match(/^(iPad|iPhone|iPod)( Simulator)?/) !== null;
    if (!isIOS) {
        if ($('.tiptip').length) $(".tiptip").tipTip();
    }
});

