

$(document).ready(function()
{
	$('a').click(function(){
		this.blur();
	});

	$('A[rel="external"]').click(function(){
		window.open($(this).attr('href'));
		return false;
	});
	
	$('A[rel="popup"]').click(function(){
		var href = $(this).attr('href');
		window.open(href, 'popup', 'width=400,height=500,toolbar=no');
		return false;
	});
	
	$('A[rel="player"]').click(function(){
		var href = $(this).attr('href');
		window.open(href, 'popup', 'width=300,height=400,toolbar=no');
		return false;
	});

	$(".accordion").accordion(
	{
		navigation: true
	}
	);

$('input').example(function() {
  return $(this).attr('title');
});

     $('.slideshow').cycle({
		 fx: 'fade',
		 pause: 1,
		 speed:  1500,
		 timeout:  7000
	 });

/**
 * Slideshow on home
 * with image preload to prevent the infamous fuoc.


    var stack = [];
 
    // preload images into an array;
    for (var i = 3; i < 16; i++) { 
        var img = new Image(); 
        img.src = 'contents/uploads/slideshows/1_' + i + '.jpg'; 
        $(img).bind('load', function() { 
            stack.push(this); 
        }); 
    }
 
    // start slideshow 
    $('#page-home .slideshow').cycle({ 
		fx: 'fade',
		pause: 1,
		speed:  1500,
		timeout:  7000,
        before:   onBefore 
    }); 
 
    // add images to slideshow 
    function onBefore(curr, next, opts) { 
        if (opts.addSlide) // <-- important! 
            while(stack.length) 
                opts.addSlide(stack.pop());  
    }; */

	$("a#situatie").fancybox({
		'titleShow'			: false,
	    'padding'           : 0,
		'width'				: 776,
		'height'			: 548,
		'scrolling'			: 'no',
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'swf'				: {wmode: 'transparent', flashvars: 'pad=feed/situatie-data.xml&pdflinks=true'}
	});

	$("a#situatieoverzicht").fancybox({
		'titleShow'			: false,
	    'padding'           : 0,
		'width'				: 776,
		'height'			: 548,
		'scrolling'			: 'no',
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'swf'				: {wmode: 'transparent', flashvars: 'pad=feed/situatie-data.xml&pdflinks=false', typepad: "nl/type/"}
	});

	$("a.koperspremie").fancybox({
		'titlePosition'	: 'inside',
		'width'			: 550,
		'autoDimensions': false
	});

	$("a.startbouw").fancybox({
		'titlePosition'	: 'inside',
		'width'			: 550,
		'autoDimensions': false
	});

	$("a.box-prijzen").fancybox({
		'titlePosition'	: 'inside',
		'width'			: 650,
		'height'		: 500,
		'autoDimensions': false
	});

	$("a.modelbox").fancybox({
		'scrolling'			: 'no'
		//'width'			: 796,
		//'autoDimensions': false
	});

	$('div.expander').expander(
	{
		expandEffect:     'fadeIn',
		expandSpeed:      20000,
		slicePoint: 200, 
		widow: 2,
		expandText: 'lees meer...',
		userCollapseText: 'sluit'
	});

	// http://blog.mirthlab.com/2008/04/18/simple-image-submit-button-rollovers-with-jquery/
	$('.sidebar-item-signup .submit-button').hover(function(){
		$(this).attr({src:'contents/images/btn.submit.over.gif'});
	}, function(){
		$(this).attr({src:'contents/images/btn.submit.gif'});
	});

	$('.sidebar-item-guestbook-form .submit-button').hover(function(){
		$(this).attr({src:'contents/images/btn.add.over.gif'});
	}, function(){
		$(this).attr({src:'contents/images/btn.add.gif'});
	});

	$('.add-comment-form .submit-button').hover(function(){
		$(this).attr({src:'contents/images/btn.submit.over.gif'});
	}, function(){
		$(this).attr({src:'contents/images/btn.submit.gif'});
	});

	$("form").submit(function() {
		$(":submit", this).attr("disabled", "disabled");
	});
});

var closetimer		= 0;
var ddmenuitem      = 0;

function jsddm_open()
{	jsddm_canceltimer();
	jsddm_close();
	ddmenuitem = $(this).find('ul').eq(0).css('visibility', 'visible');}

function jsddm_close()
{
	if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');
}

function jsddm_timer()
{	closetimer = window.setTimeout(jsddm_close, 500);}

function jsddm_canceltimer()
{	if(closetimer)
	{	window.clearTimeout(closetimer);
		closetimer = null;}}

$(document).ready(function()
{
	$('#navigation-1 .menu > li').bind('mouseover', jsddm_open);
	$('#navigation-1 .menu > li').bind('mouseout',  jsddm_timer);});

//document.onclick = jsddm_close;
