if(jQuery.browser.webkit) {
    jQuery(window).load(init);
} else {
    jQuery(window).load(init);
}

$(document).ready(function($){

	$(document).accessibleFormFields({defaultClass: 'text'});
	
	/*
	// Open images in Colorbox instead of a new window
	$('a[target="_blank"]')
	    .filter(function(){return /(jpe?g|png|gif)$/i.test($(this).attr('href'));})
	    .attr('target','')
	    .colorbox();
	*/
	$('a.colorbox').colorbox();
	$('a[rel=blank]').attr('target','_blank');
	
	$('img#background').backscale({
		hideUntilReady: false
	});

	$('div.fade').cycle({
	    timeout: 5000,
	    speed: 1200,
	    slideExpr: 'img'
	});


	
});

function init() {
	var currentTallest = 0;
	$('div.column').each(function(i){
		if ($(this).height() > currentTallest) {currentTallest = $(this).height();}
	});
	
	$('div.column').height(currentTallest);
	$('div.column div.column-inner').height(currentTallest-10);

	var v = parseInt(currentTallest / $('div#performances div.carousel li').height());
	
	$('div#performances div.carousel').jCarouselLite({
		vertical: true,
		visible: v,
		circular: false,
		speed: 800,
		//auto: 3000,
		btnNext: 'div#performances span.next',
		btnPrev: 'div#performances span.prev'
	});

	if($('div#performances div.carousel ul li').length == 4) { // Whole carousel is visible
	    $('div#performances span.next').addClass('disabled');
	}

	
};

function addToFavorites() {
	
    if($.browser.opera) {
	    if ($("a.favorites").attr("rel") != ""){ // don't overwrite the rel attrib if already set
		    $("a.favorites").attr("rel","sidebar");
	    }
    }

    if ($.browser.mozilla) { // Mozilla Firefox Bookmark
	    window.sidebar.addPanel("Koekla", document.location,"");
    } else if( $.browser.msie ) { // IE Favorite
	    window.external.AddFavorite( url, title);
    } else if($.browser.opera) { // Opera 7+
	    return false; // do nothing - the rel="sidebar" should do the trick
    } else { // for Safari, Konq etc - browsers who do not support bookmarking scripts (that i could find anyway)
	     alert('Druk <Control>+D in uw browser om toe te voegen aan favorieten');
    }

    return false;

};

