/*--------------------------------------------------------------------
Basic Javascript Sheet - Frontoffice

Version: 2.0
Copyright: 2011, dicode® VOF - understanding internet
W: www.dicode.nl
E: info@dicode.nl
T: 0570-750680
--------------------------------------------------------------------*/

/* Global
--------------------------------------------------------------------*/

var windelay = 100;
var wintrigger = false;
var windate = 0;

function fixWindow() {

	if ( new Date() - windate < windelay ) {
		setTimeout(fixWindow, windelay);
		return;
	}
	
	wintrigger = false;
	
	var len = Math.round($(window).height() - $('#footer').position().top);
	
	if ( len > 18 + 54 ) {
		$('#footer').height( len ); //- $('#footer').height() + 18 + 54 );
		$('.footer_bg').height( len ); //- $('#footer').height() + 18 + 54 );
	}
	else
		$('#footer').css('height', 'auto');

}


$(document).ready(function() {
	
	$('a').bind('focus', function() {
		this.blur();
	});
	
	$('*').ifixpng();
	
	$('.eo').emptyonclick();
	
	/* index thumbs */
	$("div#content div.thumbs div.item").bind('click', function() {
		$("div#content div.thumbs div.item").css('top', 0);
		$(this).css('top', -10);
		$("div.indeximage").fadeOut(1200);
		$("div#content div.thumbs div.thumb div.txt").fadeOut();
		$("div.indeximage").eq( $(this).parent().index() ).fadeIn(1200);
		$( $.sprintf("div#content div.thumbs div.thumb:eq(%d) div.txt", $(this).parent().index() ) ).fadeIn(1200);
	});
	
	$nr = 0;
	(function(){
    	$("div#content div.thumbs div.item").eq($nr).trigger('click');
    	if( $nr == 2 )
    		$nr = -1;
    	$nr++;
	    setTimeout(arguments.callee, 5000);
	})();
	
	/* Eq heights */
	//$('.eq').equalHeights();
	
	
	/* footer */
	$("div.slider div.scrollable").scrollable({
		size: 1,
		clickable: false,
		keyboard: false,
		circular: true,
		speed: 600,
		onBeforeSeek: function(curr, next) {
			$('div.controls div.item').removeClass('active');
			$('div.controls div.item').eq(next).addClass('active');
		}
	});
	

	$(window).bind('resize.footer', function() {

		windate = new Date();

		if ( ! wintrigger ) {
			wintrigger = true;
			setTimeout(fixWindow, windelay);
		}
	});
	
	setTimeout(fixWindow, 50);
});

