$(function(){

// ===Mainmenu===
	$('#sitemenu li a').each(function(){
		var menuid = $(this).attr('id');
		var alt = $(this).text();
		$(this).empty();
		if($(this).attr('class')=='on'){
			$('<img src="/themes/main/images/sitemenu/'+menuid+'_ro.gif" alt="'+alt+'" />').prependTo(this);
		}else{
			$('<img src="/themes/main/images/sitemenu/'+menuid+'_df.gif" alt="'+alt+'" />').prependTo(this);
		}
		});

	$('#sitemenu li a').hover(function(){
		var imgsrc = $(this).find('img').attr('src').replace('_df.gif','_ro.gif');
		$(this).find('img').attr('src',imgsrc);
		},function(){
		if($(this).attr('class')=='on'){
		}else{
		var imgsrc = $(this).find('img').attr('src').replace('_ro.gif','_df.gif');
		$(this).find('img').attr('src',imgsrc);
		}
	});


	//==floatimage margin for FCKeditor==

	$('#CenterWrapper img').each(function(){
	if($(this).attr('align')=='left'){
		$(this).css({'margin':'0 10px 10px 0','float':'left'});
		$(this).removeAttr('align');
	}else if($(this).attr('align')=='right'){
		$(this).css({'margin':'0 0 10px 10px','float':'right'});
		$(this).removeAttr('align');
	}else if($(this).attr('align')=='center'){
		$(this).css({'margin':'0 10px 10px 10px'});
	}
	});

	var movlink = $('#movelink').html();
	$('.d3f_title').after(movlink);
	$('#movelink').remove();


	//==== IE6 png ====
	//http://docs.jquery.com/Tutorials:PNG_Opacity_Fix_for_IE6
	var blank = new Image();
	blank.src = '/images/blank.gif';

	$(document).ready(function() {
	var badBrowser = (/MSIE ((5€.5)|6)/.test(navigator.userAgent) && navigator.platform == "Win32");
	if (badBrowser) {
		// get all pngs on page
		// $('img[src$=.png]').each(function() {
		// get all pngs which has a class 'fixpng'.
		// because this function doen't work for a few small size png.
		$('img.fixpng').each(function() {
			if (!this.complete) {
				this.onload = function() { fixPng(this) };
			} else {
				fixPng(this);
			}
		});
	}
	});

	function fixPng(png) {
		var src = png.src;
		// set width and height
		if (!png.style.width) { png.style.width = $(png).width(); }
		if (!png.style.height) { png.style.height = $(png).height(); }
		// replace by blank image
		png.onload = function() { };
		png.src = blank.src;
		// set filter (display original image)
		png.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
	}


});
