var messages = [];

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
	    });
	    
	}
}

if (typeof(tinyMCE) != 'undefined') {

	tinyMCE.init({ 
	    mode: "specific_textareas",
	    theme: "advanced",
	    plugins:"paste",
	    editor_selector: "wysiwygeditor-simple",
	    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() {
	
	$('marquee').marquee('pointer').mouseover(function () {
      $(this).trigger('stop');
    }).mouseout(function () {
      $(this).trigger('start');
    }).mousemove(function (event) {
      if ($(this).data('drag') == true) {
        this.scrollLeft = $(this).data('scrollX') + ($(this).data('x') - event.clientX);
      }
    }).mousedown(function (event) {
      $(this).data('drag', true).data('x', event.clientX).data('scrollX', this.scrollLeft);
    }).mouseup(function () {
      $(this).data('drag', false);
    });
    
    bindToolTip(); // het binden van de tooltips
	
	$('#submitCommentForm').click(function() {
		$('#commentForm').submit();
	});
	
	$('#newsletterSubmitForm').click(function() {
		$('#newsletterForm2').submit();
	});
    
    $('.clickable-field').each(function() { 
        messages[$(this).attr('id')] = $(this).val();
    });

    $('.clickable-field').focus(function() { 

        if ($(this).val() == messages[($(this).attr('id'))]) {
            $(this).val('');
        }
    });
    
    $('.clickable-field').blur(function() { 
        if ($(this).val() == '') {
            $(this).val(messages[$(this).attr('id')]);
        }
    });
    
    $('.new-window').click(function() { 
        window.open($(this).attr('href'));
        return false;
    });
    
    $('.inside-window').click(function() { 
        window.location.href = $(this).attr('href');
    });

    $("img[rel]").overlay({
        effect: 'apple',
        expose: {
            color: '#000',
            loadSpeed: 200,
            opacity: 0.7
        }
    });

    MultipleBackgrounds = {
        sources: [],
        elementSelector: '',
        fadeSpeed: 3500,
        fadeBetweenSpeed: 500,
        background: false,
        bindTo: function(selector) {

            $background = this;

            $background.element = $(selector);
            $background.element.hide();

            jQuery.each($background.sources, function(key, $backgroundObject) {

                if ($backgroundObject.width >= $(document).width()) {
                    $background.setBackground($backgroundObject);
                    return false;
                }

            });

            $(window).load(function() {
                $background.element.fadeIn($background.fadeSpeed);
            });

            $(window).resize(function() {
                jQuery.each($background.sources, function(key, $backgroundObject) {

                    if ($backgroundObject.width >= $(document).width() && $backgroundObject.width == $background.background.width) {
                        return false;
                    } else if ($backgroundObject.width >= $(document).width() && $backgroundObject.width != $background.background.width) {

                        $background.element.fadeOut($background.fadeBetweenSpeed, function() {

                            $background.setBackground($backgroundObject);

                            $background.element.load(function() {
                                $background.element.fadeIn($background.fadeBetweenSpeed);
                            });

                        });

                        return false;
                    }

                });
            });
        },
        setBackground: function(selectedBackground) {

            this.background = selectedBackground;
            this.element.attr('src', selectedBackground.source);

        }
    }
     
});
