$(function() {
	//SWAP
	if ($("#swap").html()) {
		var A = $("#swap2").html();
		var B = $("#swap").html();

		$("#swap2").html(B);
		$("#swap").html(A);
	}


	//FANCYBOX
	$(".fancybox").fancybox();
	$(".fancybox_inline").fancybox({
		'type' : 'inline'
	});

	$("a.single_image").fancybox({
			titlePosition : 'inside',
			titleFormat   : function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-inside"><span class="floatRight" style="font-size: 10px; color: #333333;">' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span><span class="flaotLeft">'+title+'</span></span>';
			}
	});

	$("#newMedia img").hover(
		function(){
			$("#newMedia img").not(this).stop().fadeTo('fast',0.5);
		},
		function(){
			$("#newMedia img").stop().fadeTo('fast',1);
		}
	);

//	$("#datum").each(function(){
//		var logo = $("#logo").offset();
//		var logoW = $("#logo").width();
//		var datumW = $(this).width();
//		var newPos = logoW + logo.left - datumW - 3;
//		$(this).css('left',newPos).css('top',logo.top + 68);
//	});

	liNewWidth('#mainMenu');
	liNewWidth('#subMenu');
	//CUFON
	Cufon.replace('h1')('h2');
	Cufon.replace('#mainMenu li a',{hover: true});
	Cufon.replace('#subMenu li a',{hover: true});

	//NAVIGATION LAVALAMP
	$('#subMenu').lavaLamp({
		fx: "backout",
		autoResize:true,
		speed: 400
	});

	$("#homeCycle").cycle();

});


function liNewWidth( element ){

	var tW = 0;
	$(element + " li").each(function(){
		tW += $(this).width();
	});

	var newW = ($(element).width() - tW) / $(element).find('li').size()-2;
	$(element + " li").each(function(){
		var liW = $(this).width() + newW;
		$(this).width( liW );
	});

}

