// 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");

    var projectitem = '', to;
	$("#projectmenu > ul > li").hoverClick();
	$("#projectmenu > ul > li").hover(
		function()
		{
            $("#projectmenu > ul ul").hide();
            projectitem = this;

            $("#projectmenu").css({zIndex: 30}); // dit wordt gedaan om de submenus op de detailpagina over de content heen te leggen.
			//$(this).stop().css({height: 152}).animate({height: 180}, 300, 'easeOutQuad');
			$(">a", this).stop().css({height: 92}).animate({height: 120}, 300, 'easeOutQuad');

            to = setTimeout(function()
            {
                $('ul', projectitem).show();
            }, 150);


            if( !$(this).hasClass("actief") )
				$("img.kleur", this).stop().hide().fadeIn(300);
		},
		function()
		{
            $("#projectmenu").css({zIndex: 10});
			//$(this).stop().animate({height: 152}, 300, 'easeOutQuad');
			$(">a", this).stop().animate({height: 92}, 300, 'easeOutQuad');

            clearTimeout(to);
            $("ul", projectitem).hide();

			if( !$(this).hasClass("actief") )
				$("img.kleur", this).stop().fadeOut(300);
		}
	);
	
	/* Fotoslider */
	if( $("#fotoslider ul li").length > 1 )
	{
		$("#fotoslider").after('<a class="fotoprev" href="#" title"Vorige foto">Vorige</a><a class="fotonext" href="#" title"Volgende foto">Volgende</a>');	
		$("#fotoslider ul").cycle({ 
			fx:     'fade', 
			speed:  3000, 
			timeout: 9000,
			delay:	-4000, 
			next:   '#main .fotonext', 
			prev:   '#main .fotoprev',
			easing:	'easeOutQuad' 
		});
	}
	
	// default value bij formulieren
	$("input:text[title], textarea[title]").each(function() { 
		$(this).defaultvalue( $(this).attr("title") );
	});
	
	// Formulier focus op velden
	$(":input").not("input[type=button], input[type=submit], input[type=radio], input[type=checkbox]")
		.focus(function() 	{ $(this).addClass("sfFocus"); })
		.blur(function() 	{ $(this).removeClass("sfFocus"); });

});

window.onload = function()
{
	setTimeout( function()
		{
			$.preLoadImages(submap + "/img/background/contact.jpg",
							submap + "/img/background/groenprojecten.jpg",
							submap + "/img/background/homepage.jpg",
							submap + "/img/background/links.jpg",
							submap + "/img/background/onderhoud.jpg",
							submap + "/img/background/ontwerp.jpg",
							submap + "/img/background/visie.jpg" );		
		}, 1000
	);
}

/* Preloadimages */
var cache = [];
// Arguments are image paths relative to the current page.
$.preLoadImages = function() 
{
  	var args_len = arguments.length;
    for (var i = args_len; i--;) 
	{
     	var cacheImage = document.createElement('img');
      	cacheImage.src = arguments[i];
      	cache.push(cacheImage);
   	}
}

