$(document).ready(function(){
	var navi = [];
	var w = 0;
	$('#header li').each(function(i,e){
		$(e).data('bgcol',$(e).css('background-color'));
		$(e).find('p').css({background:$(e).css('background-color')});
		$(e).mouseover(function(){
			 $(this).css({backgroundColor:$('#header li.active').css('background-color')},{queue:false});
			 $(this).find('p')
			 	.css({display:'block'})
			 	.css({backgroundColor:$('#header li.active').css('background-color')},{queue:false});
		});
		$(e).mouseout(function(){
			 $(this).css({backgroundColor:$(this).data('bgcol')},{queue:false});
			 $(this).find('p')
			 	.css({display:'none',background:$(this).data('bgcol')})
			 	.css({background:$(this).data('bgcol')},{queue:false,duration:0});
		});
		var titsplit = $(e).find('a:first').text().split(' ');
		var dvd = 0;		if(titsplit.length==1){			titsplit = ["<br />",titsplit[0]];			dvd = 99;		} else if(titsplit.length>2) {			dvd = 1;		}		var i = -1;		var titl = '';		while(i++<titsplit.length-1){			titl += titsplit[i];			if(i==dvd) titl +="<br />";			else titl += " ";		}
		$(e).find('a:first').html(titl.toUpperCase());
		$(e).find('p').css({width:'inherit'});
		
		/*$(e).find('a').click(function(){
			$.historyLoad($(this).attr('href'));
			return false;	
		});*/
		Cufon.replace($(e));
		
		w += $(e).width();
	});
	var missin = (parseInt($('#header ul').css('width'))-w);
	var adding = missin/($('#header li').length-1)-2;
	//alert(jQuery.browser.version);
	if(jQuery.browser.msie && parseInt(jQuery.browser.version) <= 6) adding -= 10;
	$('#header li:not(:last)').each(function(i,e){
		$(e).css({width:($(e).width()+adding)});
	});
	//$('#header li').removeClass('active');
});
function loadPage(url){
	$('#header li').removeClass('active');
	$('a[href='+url+']').parent().addClass('active');
	$('#content').load(url+' #content',function(){
		Cufon.refresh();	
	});
}
$(document).ready(function(){
	$.historyInit(loadPage,"/");
    $('#header').pngFix(); 
}); 
