$(document).ready(function(){

	// Center problem
	// alert(navigator.userAgent);
	if(navigator.userAgent.indexOf("Chrome") != -1)
	$('body').css('backgroundImage', 'url(/images/grad_margins_white.png)');
	
	

	changeColor();
	setInterval(changeColor, 20000);
	
	$(".menu_item").live("click", function(){
		if($(this).attr('target') != undefined) window.open( $(this).attr('menu_href'), $(this).attr('target') );
		else window.location = $(this).attr("menu_href");
	});
	
	
	/*
	$(".fontwriter").each(function(){
		var fw = this;
		if(!$(fw).hasClass("fontwritten")){
			$(fw).addClass("fontwritten");
			$(fw).html("<img src=\"/font/fontwriter.php?text="+ urlencode($(fw).html()) +"&color="+ urlencode($(fw).attr("color")) +"&size="+ $(fw).attr("size") +"&shadow="+ $(fw).attr("shadow") +"\" border=\"0\" />").show();
		}
	});
	*/
	
	
	var delay = 0;
	
	$(".photo_slide").each(function(){
		var obj = this;
		setTimeout( function(){
			$(obj).innerfade({
				speed: 1000,
				timeout: 8000,
				type: 'sequence',
				containerheight: '0px'
			});
		}, (delay++) * 100);
	});
	
	$("#photo_bar").hide().css("visibility", "visible").fadeIn(500);
	
	
	$('.agenda_blok')
		.live('mouseover', function(){ $(this).addClass('agenda_blok_hover'); })
		.live('mouseout', function(){ $(this).removeClass('agenda_blok_hover'); })
		.live('click', function(){
			$('.agenda_blok_selected').removeClass('agenda_blok_selected');
			$(this).addClass('agenda_blok_selected');
			$.get('/agenda.asp', {id:$(this).attr('agenda_id')}, function(html){ $('#contents').html(html); });
		});
	
	$('.hideaway').show();
});


function changeColor(){
	var new_r = Math.floor(Math.random() * 127);
	var new_g = Math.floor(Math.random() * 127);
	var new_b = Math.floor(Math.random() * 127);

	$("#gradient").animate({backgroundColor:'rgb('+ new_r +', '+ new_g +', '+ new_b +')'}, 19000);
}

function urlencode(str) {
	return escape(str).replace('+', '%2B').replace('%20', '+').replace('*', '%2A').replace('/', '%2F').replace('@', '%40');
}
