
// Homebanner

$(function() {
	$('#cycleImages').before('<ul id="jQul">').cycle({
		fx:						'fade',
		speed:					800,
		timeout:				6000,
		pager:					'#jQul',
		pagerEvent:				'mouseover',
		pauseOnPagerHover:		true,
		allowPagerClickBubble:	true,
					
		pagerAnchorBuilder: function(idx, slide) {
			return '<li><a href="'+slide.alt+'" onFocus="this.blur()">'+slide.title +'</a></li>';
		}
	});
});


function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};


$(document).ready(function(){

	$("ul#jQul li:last").css('border','none');

	$('a.lightbox').colorbox();

// carousel

    jQuery('#carousel').jcarousel({
        duration: 'slow',
        scroll: 5,
        auto: 5,
        wrap: 'last',
        easing: 'swing',
        initCallback: mycarousel_initCallback
    });

    jQuery('#openhuis_carousel').jcarousel({
        duration: 'slow',
        scroll: 5,
        auto: 5,
        wrap: 'last',
        easing: 'swing',
        initCallback: mycarousel_initCallback
    });


// layout

	$(".fColumn:first").css("margin-left", "23px");

// menu
	$("ul#mainnav ul li:has(ul)").find("a:first").append("&nbsp;&raquo;");



// actions

	$("div.clickable").click(function(event) {
	  event.preventDefault();
	  window.location = $(this).attr("url");
	});

/* GALLERY ROW */

	$(".row").hover(function() {
		$(this).stop().animate({ backgroundColor: "#fff" }, 100);
	},function() {
		$(this).animate({ backgroundColor: "#f4f4f4" }, 300);
	});


/* GALLERY GALBOX */

	$(".galbox").hover(function() {
		$(this).stop().animate({ backgroundColor: "#fff" }, 100);
	},function() {
		$(this).animate({ backgroundColor: "#f4f4f4" }, 300);
	});
	
	$('div.galbox:nth-child(3n)').css("margin-right","0");
	$('div.galbox:nth-child(3n)').after("<br clear='all' />");


	if ($('.div.galbox img').length > 1) {
		$(".adres").css("margin-top","20px");
	}


// animations

	$("#verhuisbus").css("left","700px").css("top","48px").css('opacity', 0);
	$("#verhuisbus").everyTime(15000, function(){
		$(this)
		.animate({opacity: 1}, {duration: 'slow'})
		.animate({left:"220px"}, 8000, 'linear')
		.animate({opacity: 0}, {duration: 'slow'})
		.animate({left:"700px"})
	});


//	aanbod rechterkolom
	$("#accordion_rechts").accordion( { autoHeight: false, clearStyle: false, active: 0 });
	$("#accordion_news").accordion( { autoHeight: false, clearStyle: false, active: 0 });
//	jScroll( 'aanbodScroller' );
//	jScroll( 'openhuisScroller', Array("ohp_up", "ohp_down") );




// simple accordion
		jQuery('#list1a').accordion();
		jQuery('#list1b').accordion({
			autoheight: false
		});
		
		// second simple accordion with special markup
		jQuery('#navigation').accordion({
			active: false,
			header: '.head',
			navigation: true,
			event: 'mouseover',
			fillSpace: true,
			animated: 'easeslide'
		});
		


/* CLEAR INPUT ON FOCUS */

	var clearMePrevious = "";
	
	// clear input on focus
	$('.clearMeFocus').focus(function()	{
		if($(this).val() == $(this).attr('title')) {
			clearMePrevious = $(this).val();
			$(this).val("");
		}
	});	
	
	// if field is empty afterward, add text again
	$('.clearMeFocus').blur(function() {
		if($(this).val() == "") {
			$(this).val(clearMePrevious);
		}
	});


});
