$(document).ready(function() {
	
	$('html').addClass('js-on');  
	
	$("input").focus(function () {
	if ($(this).val() == $(this).attr("title")){
		$(this).val("");
	}
	});
	$("input").blur(function () {
		if ($(this).val() == ""){
			$(this).val($(this).attr("title"));
		}
	});

	$("a#open-login").fancybox();
	
	/* fotoboek */
	$(".fancybox-view-01 ul a").fancybox();
	
	$(".fancybox-view-02 ul a").fancybox({
			titlePosition: 'over'
	});
	
	if($("table.maintenanceButtons").length > 0) {
		$("span.delete").css('display','block');
		$("span.edit").css('display','block');
		$("a.add-item").css('display','block');
	}

	/* smoelenboek */
	$(".smoelenboek a").fancybox();
		
	/* nieuws slide */
	$(".news .item h3").click(function () { 
		$(this).next('a').slideToggle("slow").next('div').slideToggle("slow");
	});
   
	$(".uitklappen").click(function () { 
		$(".item div").slideDown("slow");
		$(".item a").slideUp("slow");
	});
   
	$(".inklappen").click(function () { 
		$(".item div").slideUp("slow");
		$(".item a").slideDown("slow");
	});
	
	/* nieuws slide */
	$(".faq .item h3").click(function () { 
		$(this).next('div').slideToggle("slow");
	});
	
		/*itembank pop-up*/
	$("a.close-button").click(function() {
		$(".item-container").slideUp("fast");
	});
	$('a.more-info').click(function() {
		$(".item-container").slideDown("fast");
		$(".item-container .clone-text").remove();
		$(this).next().clone().removeClass().addClass("clone-text").insertAfter(".close-button");
	});
	
		/* Poll */
	$("#PollItem").iframeAutoHeight();
	$("#PollItem").attr("allowTransparency",true).after("<div class='poll-container rounded' id='poll-container'></div>");
	$("#PollItem").appendTo($("#poll-container"));
	
		/* catch IE console.log error */
	if (!window.console) {
		console = { log : function(){} };
	}
	
		/*random img*/
	    // minimum 3 images !!!
       $('.random-foto').imgRandom ({
           image_width: 720,
           image_height: 208,
           // not mandatory if you use the full URL on the image path below
           images_path: '/extranet_c02/Design/style1075501/images/dummy/',
           images: [
               [
                   '',   		// link
                   '',       	// link title
                   '01.jpg'     // image or image with path
               ],
               [
                   '',
                   '',
                   '01.jpg'
               ],
               [
                   '',
                   '',
                   '01.jpg'
               ]
            ]
        });
	
});

/* 	
    Plugin: iframe autoheight jQuery Plugin 
    Author: original code by NATHAN SMITH; converted to plugin by Jesse House
    File: jquery.iframe-auto-height.plugin.js
    Description: when the page loads set the height of an iframe based on the height of its contents
    Remarks: original code from http://sonspring.com/journal/jquery-iframe-sizing    
    Version: 1.0.0 - see README: http://github.com/house9/jquery-iframe-auto-height
*/
(function ($) {
    $.fn.iframeAutoHeight = function (options) {
        // set default option values
        var options = $.extend({
            heightOffset: 0
        }, options);

        // iterate over the matched elements passed to the plugin
        $(this).each(function () {
            // Check if browser is Opera or Safari(Webkit so Chrome as well)
            if ($.browser.safari || $.browser.opera) {
                // Start timer when loaded.
                $(this).load(function () {
                    var iframe = this;
                    var delayedResize = function () {
                        resizeHeight(iframe);
                    };
                    setTimeout(delayedResize, 0);
                });

                // Safari and Opera need a kick-start.
                var source = $(this).attr('src');
                $(this).attr('src', '');
                $(this).attr('src', source);
            }
            else {
                // For other browsers.
                $(this).load(function () {
                    resizeHeight(this);
                });
            }

            // resizeHeight
            function resizeHeight(iframe) {
                // Set inline style to equal the body height of the iframed content plus a little
                var newHeight = iframe.contentWindow.document.body.offsetHeight + options.heightOffset;
                iframe.style.height = newHeight + 'px';
            }

        }); // end
    }
})(jQuery);
