$(function(){
	// vertically align function
	$.fn.vAlign = function() {
		return this.each(function(i){
		var ah = $(this).height();
		var ph = $(this).parent().height();
			if(ph >= ah){
				var mh = (ph - ah) / 2;
				$("body").css('overflow', 'hidden');	
				$(this).css('margin-top', mh);	
			} else {
				$(this).css('margin-top', 10);
			}
		});
	};

});

/* call jquery on ready */
$(document).ready(function(){
	// valign container
	$("#container").vAlign(); 
	createCookie('cont_top',$("#container").css("margin-top"),7);
	 
	$('#box_bg').pngFix();
	$('#logo').pngFix();
	
	$("#nav_ul li, #sub_nav li").hover(function(){
		if($(this).attr('id').search('_active') == -1){
			$(this).removeClass($(this).attr("id"));
			$(this).addClass($(this).attr("id") + '_active');
		}
	}, function (){
		if($(this).attr('id').search('_active') == -1){
			$(this).removeClass($(this).attr("id") + '_active');
			$(this).addClass($(this).attr("id"));
		}          
	});

	// add scroll
	$('#content-holder').jScrollPane({showArrows:true});

	/* toggle navigation slide buttons */
	$("#seatme a img").hover(function(){
		var src = $(this).attr('src');
		$(this).attr("src", src.replace("_off", "_on"));
	}, function(){
		var src = $(this).attr('src');
		$(this).attr("src", src.replace("_on", "_off"));
	});


	// open seatme
	//$("a[rel='seatme']").colorbox({iframe:true, innerWidth:475, innerHeight:640});

});

/* call jquery onload */
$(window).bind("load", function() { 
	//add text slider  
	var scrollHeight =  $('#content-scroll').innerHeight();
	var itemHeight =  $('#content-holder .content-item').innerHeight();
	//alert( itemHeight + ' > ' + scrollHeight )
	if ( $("#content-holder .content-item").length > 0 && ( ( itemHeight + 25 ) > scrollHeight ) ) {
		$("#content-slider-bg").css({'display' : 'block' });
		$("#content-slider").css({'display' : 'block' });
	}
	// add picture slider
	$("div#slide").slideView({ 
		easeTime: 1200 
	});

	$('.stripTransmitter ul li a').click(function(){
		$('#slide ul li:first div').html('&nbsp;');
	});

	$('.stripTransmitter ul li:first a').click(function(){
		$('#slide ul li:first div').html('<object width="905" height="425" id="player"><param name="movie" value="http://www.youtube.com/v/HM0L9Izy_NI&amp;hl=nl_NL&amp;fs=1?color1=0x3a3a3a&amp;color2=0x999999"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/HM0L9Izy_NI&amp;hl=nl_NL&amp;fs=1?color1=0x3a3a3a&amp;color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="905" height="425"></embed></object>');
	});


}); 

/* call jquery on resize */
$(window).bind('resize', function(){
	$("#container").vAlign();
	createCookie('cont_top',$("#container").css("margin-top"),7);
});

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

Cufon.replace(['#nav_ul li, #sub_nav, h1'], {
    hover: true
});
