$(function(){

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


//=== imgcaption & img lightbox ===
// ===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).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).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).attr('alt','').after('<br />'+captxt);
	});


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


//	$('.otherimg a').colorbox({transition:"fade"});
	$('a[href*=.jpg]').colorbox({transition:"fade", opacity:"0.5"});
	$('a[href*=.gif]').colorbox({transition:"fade", opacity:"0.5"});
	$('a[href*=.png]').colorbox({transition:"fade", opacity:"0.5"});

$('.confirmMsg').each(function(){
	var msg = $(this).html();
	msg = msg.replace('以下の内容で送信しますか','内容をご確認くださり「送信する」ボタンを押してください。');
	$(this).html(msg);
	});

});

