var messages = new Array();

function hideClass(className) {
    $("div." + className).hide("slow");
}

function bindToolTip() {
	
	if ($('span.help-message').length > 0) {
	
	    $('span.help-message').tooltip({
	        delay:100
	    });
	    
	    $('.no-content').tooltip({ 
	        delay:200,
	        showURL: false
	    });
	    
	}
}

function createSlideShow() {

	$.fn.cycle.defaults = { 
		    timeout:       4000,  // milliseconds between slide transitions (0 to disable auto advance) 
		    speed:         1000,  // speed of the transition (any valid fx speed value) 
		    next:          null,  // id of element to use as click trigger for next slide 
		    prev:          null,  // id of element to use as click trigger for previous slide 
		    before:        null,  // transition callback (scope set to element to be shown) 
		    after:         null,  // transition callback (scope set to element that was shown) 
		    height:       'auto', // container height 
		    sync:          1,     // true if in/out transitions should occur simultaneously 
		    fit:           0,     // force slides to fit container 
		    pause:         0,     // true to enable "pause on hover" 
		    delay:         0,     // additional delay (in ms) for first transition (hint: can be negative) 
		    slideExpr:     null   // expression for selecting slides (if something other than all children is required) 
	}; 
	
	setTimeout(function() { 
		
		$('#load-message').remove();
		$('#loaderImage').remove();
		
		
	}, 2000);
	
	setTimeout(function() {
		$('#image-container').cycle();
	}, 2000);

}

if (typeof(tinyMCE) != 'undefined') {

	tinyMCE.init({ 
	    mode: "specific_textareas",
	    theme: "advanced",
	    plugins:"paste",
	    editor_selector: "wysiwygeditor-advanced",
	    theme_advanced_buttons1: "bold,italic,underline,strikethrough,|,undo,redo,|,pastetext,bullist,numlist,",
	    theme_advanced_buttons2: "",
	    theme_advanced_buttons3: "",
	    theme_advanced_toolbar_align:"left",
	    theme_advanced_toolbar_location:"top"
	});
	
}

$(document).ready(function() {	
	
    bindToolTip(); // het binden van de tooltips
    createSlideShow(); 
    
    $('.clickable-field').each(function() { 
        messages[$(this).attr('id')] = $(this).val();
    });

    $('.clickable-field').focus(function() { 

        if ($(this).val() == messages[($(this).attr('id'))]) {
            $(this).val('');
        }
    });
    
    $('.button').click(function() { 
    	$('#' + $(this).attr('rel')).submit();
    	return false;
    });
    
    $('.clickable-field').blur(function() { 
        if ($(this).val() == '') {
            $(this).val(messages[$(this).attr('id')]);
        }
    });
    
    $('.new-window').click(function() { 
        window.open($(this).attr('href'));
        return false;
    });
    
    $('.popup-link').click(function() {
    	var dateObj = new Date();
    	
    	window.open($(this).attr('href'), dateObj.getTime(), 'toolbar=0,scrollbars=1,location=1,statusbar=0,menubar=0,resizable=1,width=800,height=550');
    	return false;
    });
    
    $('.inside-window').click(function() { 
        window.location.href = $(this).attr('href');
    });

    /**
     * De hover voor het overzicht
     */
    $('.box-item').mouseover(function(){
    	$(this).addClass('mouse-over');
    });
    
    $('.box-item').mouseout(function(){
    	$(this).removeClass('mouse-over');
    });
     
});