/*==========================================================
★★☆☆画像置換☆☆★★
============================================================
【機能】
class="image_replace"のものを全て取り出し、それらに指定
されている背景画像CSSを取り出して、<img src="">で書き直す。
------------------------------------------------------------
【画像の指定方法】
.image_replace{}ではなく、セレクタにより指定。
ショートハンドを使用しない。
　×　background:url(〜);
　○　background-image:url(〜);
【その他】
.image_replace{visibility:hidden};
を必ず設定しておく。
==========================================================*/
function image_replace(){
	cs=new Array();
	img_attributes="";
	obj_to_replace=document.getElementsByClassName('image_replace')
	for(i=0; i<obj_to_replace.length; i++){
		if(document.defaultView){
			cs[i]      = document.defaultView.getComputedStyle (obj_to_replace[i], null);
			bg_img     = cs[i].getPropertyValue ('background-image');
			obj_width  = cs[i].getPropertyValue ('width');
			obj_height = cs[i].getPropertyValue ('height');
		}else if(obj_to_replace[i].currentStyle){
			bg_img     = obj_to_replace[i].currentStyle.backgroundImage;
			obj_width  = obj_to_replace[i].currentStyle.width;
			obj_height = obj_to_replace[i].currentStyle.height;
		}
		//背景画像のソースからurl()内部を取り出す
		bg_img.match(/url\((.+)\)/);
		//高さや幅が設定されていたら属性値としてセット(mozilla系動作不可のため使用しない)
		//img_attributes+=(obj_width  != undefined) ? "width:"+obj_width  : "";
		//img_attributes+=(obj_height != undefined) ? "width:"+obj_height : "";
		//obj_to_replace[i].innerHTML="<img src=" + RegExp.$1 + "style='" + img_attributes +"'>";
		//中身を画像と置換
		obj_to_replace[i].innerHTML="<img src=" + RegExp.$1+">";
		//見えなくしている要素を見えるようにする
		obj_to_replace[i].style.visibility="visible";
		//img_src=bg_img.split('"');
		//alert(img_attributes);

	}
}

