$(function(){
	// ===addimage===
	$("h1").prepend('<img src="/style/images/h1_marker.gif" alt="" />');
	$("h2").prepend('<img src="/style/images/h2_marker.gif" alt="" />');
	$("h3").prepend('<img src="/style/images/h3_marker.gif" alt="" />');

	// ===addclass===
	$("tr:even").addClass("even");
	$("tr:odd").addClass("odd");
	$("form :submit").addClass("button");

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

	//==== a.rollover img ====
	$('a.rollover').hover(function(){
		var imgsrc = $(this).find('img').attr('src').replace('_df.gif','_ro.gif');
		$(this).find('img').attr('src',imgsrc);
		},function(){
		var imgsrc = $(this).find('img').attr('src').replace('_ro.gif','_df.gif');
		$(this).find('img').attr('src',imgsrc);
	});

	//==== a.current img ====
	$('a.current img').each(function(){
		var imgsrc = $(this).find('img').attr('src').replace('_df.gif','_ro.gif');
		$(this).find('img').attr('src',imgsrc);
	});

	//==== input.rollover ====
	$('input.rollover').hover(function(){
		var imgsrc = $(this).attr('src').replace('_df.gif','_ro.gif');
		$(this).attr('src',imgsrc);
		},function(){
		var imgsrc = $(this).attr('src').replace('_ro.gif','_df.gif');
		$(this).attr('src',imgsrc);
	});

	// ===captionblock===
	$('img.fcr').each(function(){
		var captxt = $(this).attr('alt').replace('[/url]','</a>').replace(']','">').replace('[url=','<a class="noicon" href="');
		var capwidth = $(this).attr('width');
		capwidth=capwidth+10;
//		$(this).wrap('<span style="width:'+capwidth+'px;font-size:90%;float:right;margin:0 0 10px 10px;text-align:center;dispay:block;">');
		$(this).wrap('<div style="width:'+capwidth+'px;font-size:90%;float:right;margin:0 0 10px 10px;text-align:center;">');
		$(this).attr('alt','').after('<br />'+captxt);
	});

	$('img.fcl').each(function(){
		var captxt = $(this).attr('alt').replace('[/url]','</a>').replace(']','">').replace('[url=','<a class="noicon" href="');
		var capwidth = $(this).attr('width');
		capwidth=capwidth+10;
//		$(this).wrap('<span style="width:'+capwidth+'px;font-size:90%;float:left;margin:0 10px 10px 0;text-align:center;dispay:block;">');
		$(this).wrap('<div style="width:'+capwidth+'px;font-size:90%;float:left;margin:0 10px 10px 0;text-align:center;">');
		$(this).attr('alt','').after('<br />'+captxt);
	});


	$('img.fcc').each(function(){
		var captxt = $(this).attr('alt').replace('[/url]','</a>').replace(']','">').replace('[url=','<a class="noicon" href="');
//		$(this).wrap('<span style="text-align:center;font-size:90%;margin:0 10px 10px 0;clear:both;dispay:block;">');
		$(this).wrap('<div style="text-align:center;font-size:90%;margin:0 10px 10px 0;clear:both;">');
		$(this).attr('alt','').after('<br />'+captxt);
	});

	//===datepicker===
	$(".begin").datepicker({dateFormat: 'yy-mm-dd', duration: 'fast'});

	// ===lightbox===
	$('a.lb').each(function(){
		var capwidth = $(this).find('img').attr('width');
		capwidth=capwidth+10;
		var altx = $(this).find('img').attr('alt');
		var altx = 'enlearge image (to back to press x)' + altx;
		$(this).find('img').attr('alt',altx);
		$(this).lightBox();
	});

});

