$(document).ready(function(){
	$("#menu li:eq(0)").addClass('first');

	/* MENU BUTTONS */
	$('#menu ul li a').not($("#menu ul ul li a")).each(function(){
    	t = $(this).html();
		if(t){
			
			$(this).html("<img class=\"buttonImg\" src=\"/domains/nirve.nl/generate/button.php?txt=" + t + ($("#header").is(":visible") ? "&home=true" : "")+ "\" border=\"0\" />");
	
			//hover
			$("#menu img.buttonImg").parent('a').hover(
				function(){
					if(!$(this).children('.buttonImg').attr('origSrc'))
						$(this).children('.buttonImg').attr('origSrc',$(this).children('.buttonImg:eq(0)').attr('src'));
	
					s = $(this).children('.buttonImg').attr('origSrc');
					$(this).children('.buttonImg').attr('src',s + '&over=1');
				},
				function(){
					s = $(this).children('.buttonImg').attr('origSrc');
					$(this).children('.buttonImg').attr('src',s);
				}
			);
		}
    });
	
	/* SUB MENUS */
	var zIndex = 2;
	$("#menu ul li").hover(
		 function(){
			 if($(this).children('ul:eq(0)').is(':hidden')){
				  $(this).children('ul:eq(0)').css('z-index',zIndex++).slideDown('normal');
			 }
		 },
		 function(){
			 if($(this).children('ul:eq(0)').is(':visible'))
				  $(this).children('ul:eq(0)').slideUp('normal');
			 }
	);
	
	//kill emtpy stuff
	$(".article,.title").each(function(){
		if(!$.trim($(this).text())){
			$(this).remove();
		}
	});
	
	//hide blank br
	$(".article .content .module_contents,#left > .module_contents").each(function(){
		if($(this).prev('br').length == 1){
			$(this).prev('br').remove();
		}
	});

	//change margins of every image
	$(".article div.content img[align]").each(function(){
		if(!$(this).next().is("img[align=" + $(this).attr('align') + "]") && $(this).attr('hspace')){
			$(this).css('margin-' + ($(this).attr('align') == 'left' ? 'right' : 'left'), $(this).attr('hspace') + 'px').removeAttr('hspace');
		}
	});
	
		$('#header .bikes').animate({backgroundPosition:'600px 43px'},3000);

});
