// stop BackgroundImageCache voor IE
try	{ document.execCommand("BackgroundImageCache", false, true); } catch(e) { }

/**
 * variabelen met jQuery met een $ beginnen!!!
 */
$(function()
{
	/* submenu effectje en timeout */
	Menu.apply("#menu > li");
    Menu.apply("#header .topmenu > li");
	
	// default value bij formulieren
	$("input:text[title], textarea[title]").each(function() { 
		$(this).defaultvalue( $(this).attr("title") );
	});
	
	// Hovers
	$("#laatste-nieuws li").hoverClick();
	
	// Automatisch textareas vergroten
    $("form").each(function()
    {
        if( $('textarea', this).length == 1 )
        {
            $('textarea', this).css({ display: 'block' }).autoResize().hide().keydown().show();
        }
    });

	// Nieuws carousel in zijbalk
	if( $('#zijbalk #laatste-nieuws ol li').length > 1 )
	{
		$('#zijbalk #laatste-nieuws ol').cycle({
			fx		: 'fade',
			timeout	:  8000 
		});
	}

	if( $('#footer .twitter ul li').length > 1 )
	{
		$('#footer .twitter ul').cycle({
			fx		: 'scrollUp',
			timeout	:  5000,
			pause   : true
		});
	}

    // Call me now popup
    var callbutton = $('ul#vraaghetons li.callmenow');
    var callform = $('ul#vraaghetons li.callmenow > div');

    callbutton.click(function(e)
    {
        if( $(this).hasClass('actief') )    { verbergCallForm(); }
        else                                { toonCallForm(); }
        e.preventDefault();
    });

    function toonCallForm()
    {
        callbutton.addClass('actief');
        callform.css({ opacity: 0, left: 286, top: -20 }).animate({ opacity: 1, top: -5 }, 300, function()
        {
            $("body").one("click", function() { verbergCallForm(); });
            callform.click(function( e ) { e.stopPropagation(); });
        });
    }

    function verbergCallForm()
    {
        callbutton.removeClass('actief');
        callform.animate({ opacity: 0, top: 20 }, 400, function()
        {
            callform.css({ left: '-900em' });
        });
    }
});
