jQuery(document).ready(function($) {

//Use Vars = g,a,b,r,i

	//Menu
	$('div#sidebar ul li.current_page_item ul').show();
	$('div#sidebar ul li.current-cat-parent ul').show();
	$('div#sidebar ul li.current_page_parent ul').show();


	//Put Galerry into #Column
	$('.gallery').prependTo('#column');
	
	//Corrections Layout
	$('ul#news li:first,ul#archive li:first,ul#archive li:eq(4)').css({paddingLeft:"0px"});
	$('ul#news li:last,ul#archive li:eq(3),ul#archive li:eq(7)').css({borderRight:"none",paddingRight:"0px"});
	$('#top-right ul li:last').css({borderRight:"none"});

	//Opacity
	$('ul#news li strong, ul#archive li strong').fadeTo(1, 0.85);
	$('ul#news li span, ul#archive li span').hover(function(){
		$(this).find('strong').fadeTo(500, 0);
	},function(){
		$(this).find('strong').fadeTo(500, 0.75);
	});
	
	//Reorder Menu
	$('li.cat-item').insertBefore('#sidebar ul li:contains("Links")');
	
	//Array for Menu
	var g = $("#sidebar ul li");
	for (var a = 0; a < g.length; a++) {
		$("#sidebar ul li").eq(a).css({zIndex:g.length-a});
	}

	//Fix 1st Menu item
	$('#sidebar ul li:eq(0) a:eq(0)').css({marginTop:"-60px",paddingTop:"65px"});
	
	//Fancybox - ,'overlayShow': true
	$('.gallery a').fancybox({ 'hideOnContentClick': true, 'padding': 0 });
	$('.internal #content a:has(img)').fancybox({ 'hideOnContentClick': true });	
	
	//Strip Table
	$("tr:nth-child(odd)").addClass("odd");
	
	//FUNCTION: Replace DOM Elements V1.0B
	jQuery.fn.RE = function(replacement) {
		return this.each(function(){
			element = $(this);
			//alert('tet');

			if($(this).attr('class') == '' && $(this).attr('id') != '') {
			$(this)
			.after(replacement).next()
			.attr('id',element.attr('id'))
			.html(element.html())
			.prev().remove();
			
			} if ($(this).attr('class') != '' && $(this).attr('id') == '') {
			$(this)
			.after(replacement).next()
			.attr('class',element.attr('class'))
			.html(element.html())
			.prev().remove();

			} if ($(this).attr('class') != '' && $(this).attr('id') != '') {
			$(this)
			.after(replacement).next()
			.attr('id',element.attr('id'))
			.attr('class',element.attr('class'))
			.html(element.html())
			.prev().remove();			

 			} if ($(this).attr('class') == '' && $(this).attr('id') == '') {
			$(this)
			.after(replacement).next()
			.html(element.html())
			.prev().remove();			

			}
		});
	};
		
	$('#content table tr:eq(0) td').RE('<th></th>');	

});