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
	    });
	    
	}

        if ($('div.team-message').length > 0) {

            $('div.team-message').tooltip({
                delay:100,
                bodyHandler: function() {
                    return $('div#team-' + $(this).attr('id') + '-html').html();
                },
                track:true,
                top:-125,
                left:10,
                showURL: false
            });
        }
		
        if ($('div.cloud-message').length > 0) {

            $('div.cloud-message').tooltip({
                delay:100,
                bodyHandler: function() {
                    return $('div#cloud-' + $(this).attr('id') + '-html').html();
                },
                track:true,
                top:-125,
                left:10,
                showURL: false
            });
        }

        if ($('span.help-message').length > 0) {

            $('span.help-message').tooltip({
                delay:100,
                bodyHandler: function() {
                    return $('div#help-' + $(this).attr('id') + '-html').html();
                },
                extraClass:'blue-help-message',
                showURL: false
            });
        }
}

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

    $('.newsletter-submit').click(function() {

        $('form#newsletterForm').submit();
        return false;
    });

    $('.tell-a-friend').click(function() {

        $('form#tellAFriend').submit();
        return false;
    });

    $('.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');
    });    

    $('#add-question').click(function(){

        $('#discussionBoard').submit();
        return false;
    });

});
