$(function(){

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


	$('#sitemenu li a').hover(function(){
		var imgsrc = $(this).find('img').attr('src').replace(/\_df.(gif|png|jpg|jpeg)$/i,'_ro.$1');
		$(this).find('img').attr('src',imgsrc);
		},function(){
		if($(this).attr('class')=='on'){
		}else{
		var imgsrc = $(this).find('img').attr('src').replace(/_ro\.(gif|png|jpg|jpeg)$/i,'_df.$1');
		$(this).find('img').attr('src',imgsrc);
		}
	});


// ===shopmenu===
	$('#menu li a').each(function(){
		var menuid = 'smenu'+($('#menu li a').index(this)+1);
		var alt = $(this).text();
		$(this).empty();
		if($(this).attr('class')=='on'){
			$('<img src="/_common/_img/shopmenu/'+menuid+'_ro.gif" alt="'+alt+'" />').prependTo(this);
		}else{
			$('<img src="/_common/_img/shopmenu/'+menuid+'_df.gif" alt="'+alt+'" />').prependTo(this);
		}
		});


	$('#menu li a').hover(function(){
		var imgsrc = $(this).find('img').attr('src').replace(/\_df.(gif|png|jpg|jpeg)$/i,'_ro.$1');
		$(this).find('img').attr('src',imgsrc);
		},function(){
		if($(this).attr('class')=='on'){
		}else{
		var imgsrc = $(this).find('img').attr('src').replace(/_ro\.(gif|png|jpg|jpeg)$/i,'_df.$1');
		$(this).find('img').attr('src',imgsrc);
		}
	});

//=== rolloverimage making ===
	$('a.bt').each(function(){
		$(this).removeClass('bt');
		$(this).wrap('<span class="bt">')
	}
	);
	$('.bt a').hover(function(){
		if($(this).attr('class')=='on'){}else{
		var imgsrc = $(this).find('img').attr('src').replace(/\.(gif|png|jpg|jpeg)$/i,'_ro.$1');
		$(this).find('img').attr('src',imgsrc);
}
		},function(){
		if($(this).attr('class')=='on'){}else{
		var imgparent = $(this).find('img').parent();
		var imgsrc = $(this).find('img').attr('src').replace(/_ro\.(gif|png|jpg|jpeg)$/i,'.$1');
		$(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'});
	}
	});


	//==== 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')";
	}

$(".shop tr:even").addClass("odd");
$(".shop tr:odd").addClass("even"); 

	$('#gallery a').lightBox({
		overlayBgColor: '#000',
		overlayOpacity: 0.7,
		txtImage: '',
		txtOf: '/'
		});


});
