/**
 * jQuery 1.2.1
 * 
 * @author Arjen
 * @author Marvin
 */

$(function(){
    // Image preloader
	jQuery.preloadImages = function() {
		for(var i = 0; i<arguments.length; i++) {
			jQuery("<img>").attr("src", arguments[i]);
		}
	}
	
	$('body').addClass('js');
	
	$('#toonActiviteiten').css("display", "none");
	$('#toonNieuws').css("display", "none");
	
	$('#formVoorstellingen select').change(function() {
		$('#formVoorstellingen').submit();
	});
	
	$('#formNieuws select').change(function() {
		$('#formNieuws').submit();
	});
	 
	 /**
	  * Image replacement
	  * adds extra spans after text
	  */
	
	// Single element IR & descendant anchors of an element
	$('.ir, .ir-anchors a').append('<span class="ir-aid"></span>');
    
	// Append another span when it has a hover state
	$('.ir.ir-hover span.ir-aid, .ir-anchors.ir-anchors-hover a span.ir-aid').append('<span></span>');
    
    /**
	 * Binnenkort slideshow
	 */
	var slideshow = $('#voorstellingenOverzicht').innerfade({
		speed: 2000,
		timeout: 5000,
		type: 'sequence',
		containerheight: '300px'
	});
	
if (jQuery.browser.msie && jQuery.browser.version.slice(0, 1) <= 6) {
	// Later weghalen als Lieselot klaar is met stijlen
} else {
    /**
     * Gallery locatie
     */
    if (typeof $('.gallery') == 'object') {
    	var galleryImage = $('.gallery a');
    	var imageRollover = $("#imgHover");
    	
    	// Preload de popup plaatjes
    	galleryImage.each(function() {
	    	var strOverzichtFilename = $(this).children("img").attr("src");
	    	var strPopupFilename = strOverzichtFilename.slice(0, strOverzichtFilename.length-6);
	    	var strExtension = strOverzichtFilename.slice(strOverzichtFilename.length-4, strOverzichtFilename.length);
	    	var intPopupId = $(this).children("img").attr("class");
    		
	    	$.preloadImages(strPopupFilename + intPopupId + strExtension);
	    });
	    
	    galleryImage.click(function() { 
	    	return false; 
	    });
    	
    	galleryImage.hover(
		    function () {
		    	var strOverzichtFilename = $(this).children("img").attr("src");
		    	var strPopupFilename = strOverzichtFilename.slice(0, strOverzichtFilename.length-6);
		    	var strExtension = strOverzichtFilename.slice(strOverzichtFilename.length-4, strOverzichtFilename.length);
		    	var strTitle = $(this).children("img").attr("alt");
		    	var intPopupId = $(this).children("img").attr("class");
		    	
		    	$(this).after(imageRollover);
		    		    	
		    	imageRollover.children("img").attr("src", strPopupFilename + intPopupId + strExtension);
		    	imageRollover.children("p").html(strTitle);
		    	
		    	imageRollover.css("left", "50px");
		    	imageRollover.css("bottom", "50px");
		    	imageRollover.css("display", "block");
		    }, 
		    
		    function () {
		    	imageRollover.css("display", "none");
		    }
	    )
	    
	    imageRollover.hover(
		    function () {
		    	imageRollover.css("display", "block");
		    }, 
		    
		    function () {
		    	imageRollover.css("display", "none");
		    }
	    )
    }
    
    /**
     * Gallery nieuws
     */
    if (typeof $('.galleryNieuws') == 'object') {
    	var galleryImage = $('.galleryNieuws a');
    	var imageRollover = $("#imgHover");
    	
    	// Preload de popup plaatjes
    	galleryImage.each(function() {
	    	var strOverzichtFilename = $(this).children("img").attr("src");
	    	var strPopupFilename = strOverzichtFilename.slice(0, strOverzichtFilename.length-6);
	    	var strExtension = strOverzichtFilename.slice(strOverzichtFilename.length-4, strOverzichtFilename.length);
	    	var intPopupId = $(this).children("img").attr("class");
	    	
	    	$.preloadImages(strPopupFilename + '0' + intPopupId + strExtension);
	    });
	    
	    galleryImage.click(function() { 
	    	return false; 
	    });
    	
    	galleryImage.hover(
		    function () {
		    	var strOverzichtFilename = $(this).children("img").attr("src");
		    	var strPopupFilename = strOverzichtFilename.slice(0, strOverzichtFilename.length-6);
		    	var strExtension = strOverzichtFilename.slice(strOverzichtFilename.length-4, strOverzichtFilename.length);
		    	var strTitle = $(this).children("img").attr("alt");
		    	var intPopupId = $(this).children("img").attr("class");

		    	$(this).after(imageRollover);
		    	
		    	imageRollover.children("img").attr("src", strPopupFilename + '0' + intPopupId + strExtension);
		    	imageRollover.children("p").html(strTitle);
		    	
		    	imageRollover.css("left", "50px");
		    	imageRollover.css("bottom", "50px");
		    	imageRollover.css("display", "block");
		    }, 
		    
		    function () {
		    	imageRollover.css("display", "none");
		    }
	    )
	    
	    imageRollover.hover(
		    function () {
		    	imageRollover.css("display", "block");
		    }, 
		    
		    function () {
		    	imageRollover.css("display", "none");
		    }
	    )
    }
    
    /**
     * Gallery medewerkers
     */
    if (typeof $('.galleryMedewerkers') == 'object') {
    	var galleryImage = $('.galleryMedewerkers dt a');
    	var imageRollover = $("#imgHover");
    	
    	// Preload de popup plaatjes
    	galleryImage.each(function() {
	    	var strOverzichtFilename = $(this).children("img").attr("src");
	    	var strPopupFilename = strOverzichtFilename.slice(0, strOverzichtFilename.length-6);
	    	var strExtension = strOverzichtFilename.slice(strOverzichtFilename.length-4, strOverzichtFilename.length);
	    	var intPopupId = $(this).children("img").attr("class");
	    	
	    	$.preloadImages(strPopupFilename + intPopupId + strExtension);
	    });
	    
	    galleryImage.click(function() { 
	    	return false; 
	    });
    	
    	galleryImage.hover(
		    function () {
		    	var strOverzichtFilename = $(this).children("img").attr("src");
		    	var strPopupFilename = strOverzichtFilename.slice(0, strOverzichtFilename.length-6);
		    	var strExtension = strOverzichtFilename.slice(strOverzichtFilename.length-4, strOverzichtFilename.length);
		    	var strTitle = $(this).children("img").attr("alt");
		    	var intPopupId = $(this).children("img").attr("class");
		    	
		    	$(this).after(imageRollover);
		    	
		    	//alert(strPopupFilename + intPopupId + strExtension);
		    	
		    	
		    	
		    	imageRollover.children("img").attr("src", strPopupFilename + intPopupId + strExtension);
		    	
		    	//alert(imageRollover.children("img").attr("src"));
		    	
		    	imageRollover.children("p").html(strTitle);
		    	
		    	imageRollover.css("left", "50px");
		    	imageRollover.css("bottom", "50px");
		    	imageRollover.css("display", "block");
		    }, 
		    
		    function () {
		    	imageRollover.css("display", "none");
		    }
	    )
	    
	    imageRollover.hover(
		    function () {
		    	imageRollover.css("display", "block");
		    }, 
		    
		    function () {
		    	imageRollover.css("display", "none");
		    }
	    )
    }
}
    
    
	// default teksten voor nieuwsbriefaanmelden.
	sDefaultEmailTxt = 'e-mailadres...';
	$("#formNieuwsbriefAanmeldenEmail").focus(function(){
		if (this.value == sDefaultEmailTxt)
			this.value = '';
	});
	$("#formNieuwsbriefAanmeldenEmail").blur(function(){
		if (this.value == '')
			this.value = sDefaultEmailTxt;
	});
});