function Flash_Call(swf,widht,height){
quality = 'high';
scale = 'noscale';

document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" WIDTH="'+widht+'" HEIGHT="'+height+'" id="flash" ALIGN="middle"><PARAM NAME=movie VALUE="'+swf+'"><param name="salign" value="lt" /><PARAM NAME=quality VALUE='+quality+'><param name="scale" value="'+scale+'" /> <PARAM NAME=bgcolor VALUE=#FFFFFF><EMBED src="'+swf+'" quality='+quality+' bgcolor=#FFFFFF scale='+scale+' salign="lt" WIDTH="'+widht+'" HEIGHT="'+height+'" NAME="flash" ALIGN="middle" TYPE="application/x-shockwave-flash"></EMBED></OBJECT>')
}

/* ============================================================================ */
/*   Popup Viewer                                                               */
/* ============================================================================ */

function  ProductImagePopup() {
	this.initialize.apply(this, arguments);
}
ProductImagePopup.prototype = {
	initialize:function(id, bgAlpha, fadeSpeed, isNextBack) {
		this._imgList = new Array()
		this.id = id+'_Popup';
		this._bg = document.createElement("div");
		this._bg.id = this.id+'Bg';
		this._bg.style.zIndex = -100;
		this._bg.setAttribute("class", "ProductImagePopupBg");
		this._bg.setAttribute("className", "ProductImagePopupBg");	//IE

		this._bgAlpha = bgAlpha;
		this._fadeSpeed = fadeSpeed;
		this._windowId = this.id+'Window';

		this._popup = document.createElement("div");
		this._popup.id = this._windowId;
		this._popup.style.zIndex = -100;
		this._popup.setAttribute("class", "ProductImagePopup");
		this._popup.setAttribute("className", "ProductImagePopup");	//IE

		this._imgArea = document.createElement("div");
		this._imgArea.id= this.id+'ImageArea';
		this._imgArea.setAttribute("class", "ProductImagePopupImageArea");
		this._imgArea.setAttribute("className", "ProductImagePopupImageArea");	//IE

		var obj1 = document.createElement("div");
		obj1.id = this.id+'CloseBtArea';
		obj1.setAttribute("class", "ProductImagePopupCloseBtArea");
		obj1.setAttribute("className", "ProductImagePopupCloseBtArea");	//IE
		var obj2 = document.createElement("a");
		var myObj = this;
		obj2.onclick = function() {
			myObj.closePopup();
			return false;
		};
		obj2.href = "javascript:void(0);";
		var obj3 = document.createElement("span");
		obj3.id = this.id+'CloseBt';
		obj3.appendChild(document.createTextNode("閉じる"));
		obj3.setAttribute("class", "ProductImagePopupCloseBt");
		obj3.setAttribute("className", "ProductImagePopupCloseBt");	//IE
		obj2.appendChild(obj3);
		obj1.appendChild(obj2);
		this._popup.appendChild(obj1);
		this._popup.appendChild(this._imgArea);

		this._imgIdList = new Array()
		if(isNextBack) {
			this._nowImgId = null;

			var btAreaObj = document.createElement("div");
			btAreaObj.setAttribute("class", "ProductImagePopupBtArea");
			btAreaObj.setAttribute("className", "ProductImagePopupBtArea");	//IE

			var nextObj = document.createElement("div");
			nextObj.setAttribute("class", "ProductImagePopupNextBtArea");
			nextObj.setAttribute("className", "ProductImagePopupNextBtArea");	//IE
			var nextLinkObj = document.createElement("a");
			nextLinkObj.onclick = function() {
				myObj.next()
				return false;
			};
			nextLinkObj.href = "javascript:void(0);";
			var spanObj = document.createElement("span");
			spanObj.id = this.id+'NextBt';
			spanObj.appendChild(document.createTextNode("次へ"));
			spanObj.setAttribute("class", "ProductImagePopupNextBt");
			spanObj.setAttribute("className", "ProductImagePopupNextBt");	//IE
			nextLinkObj.appendChild(spanObj);
			nextObj.appendChild(nextLinkObj);
			btAreaObj.appendChild(nextObj);

			var backObj = document.createElement("div");
			backObj.setAttribute("class", "ProductImagePopupBackBtArea");
			backObj.setAttribute("className", "ProductImagePopupBackBtArea");	//IE
			var backLinkObj = document.createElement("a");
			backLinkObj.onclick = function() {
				myObj.back();
				return false;
			};
			backLinkObj.href = "javascript:void(0);";
			var spanObj = document.createElement("span");
			spanObj.id = this.id+'BackBt';
			spanObj.appendChild(document.createTextNode("前へ"));
			spanObj.setAttribute("class", "ProductImagePopupBackBt");
			spanObj.setAttribute("className", "ProductImagePopupBackBt");	//IE
			backLinkObj.appendChild(spanObj);
			backObj.appendChild(backLinkObj);
			btAreaObj.appendChild(backObj);

			this._popup.appendChild(btAreaObj);
		}

		var obj = document.getElementById(id);
		obj.appendChild(this._bg);
		obj.appendChild(this._popup);

		this._bg.style.visibility="hidden";
		this._bg.style.position="absolute";
		this._bg.style.filter = "alpha(opacity=0)";
		this._bg.style.opacity = 0;

		this._popup.style.visibility="hidden";
		this._popup.style.position="absolute";
		this._popup.style.filter = "alpha(opacity=0)";
		this._popup.style.opacity = 0;

	}
	,_redraw:function() {
		this._setPos();
		this._fadeIn(this._bg, this._bgAlpha, this._bgAlpha);
		this._fadeIn(this._popup, 100, 100);
	}
	,_setPos:function() {
		var width = 0;
		var height = 0;
		var scroll = 0;
		if(document.documentElement.clientWidth) {
			width = document.documentElement.clientWidth;
			height = document.documentElement.clientHeight;
		} else if(document.body.clientWidth){
			width = document.body.clientWidth;
			height = document.body.clientHeight;
		} else {
			width = window.innerWidth;
			height = window.innerHeight;
		}
		scroll = (document.body.scrollTop || document.documentElement.scrollTop);

		var maxHeight = height;
		if (typeof document.documentElement.style.msInterpolationMode != "undefined") {
			//IE7
			if(document.documentElement.clientHeight && document.documentElement.clientHeight > maxHeight) {
				maxHeight = document.documentElement.clientHeight;
			}
			if(document.body.clientHeight && document.body.clientHeight > maxHeight) {
				maxHeight = document.body.clientHeight;
			}
			if(window.innerWidth && window.innerWidth > maxHeight) {
				maxHeight = window.innerWidth;
			}
			maxHeight -= scroll;
		}

		this._bg.style.width=width+"px";
		if(maxHeight >= 0) {
			this._bg.style.height=maxHeight+"px";
		}
		this._bg.style.left = "0px";
		this._bg.style.top = scroll+"px";

		if(this._popup.offsetWidth > width) {
			this._popup.style.left = "0px";
		} else {
			this._popup.style.left = ((width-this._popup.offsetWidth)/2)+"px";
		}
		if(this._popup.offsetHeight > height) {
			this._popup.style.top = scroll+"px";
		} else {
			this._popup.style.top = scroll+((height-this._popup.offsetHeight)/2)+"px";
		}
	}
	,onPopup:function(imageId) {
		this._nowImgId = imageId;
		var myObj = this;
		window.onscroll=function() {
			myObj._redraw();
		};
		window.onresize=function() {
			myObj._redraw();
		};

		this._popup.style.zIndex = 100;
		this._popup.style.position="absolute";
		this._popup.style.filter = "alpha(opacity=0)";
		this._popup.style.opacity = 0;

		this._imgArea.style.width=this._imgList[imageId].width+'px';
		this._imgArea.style.height=this._imgList[imageId].height+'px';
		this._imgArea.style.backgroundImage = 'url('+this._imgList[imageId].src+')';

		//消す
		this._bg.style.zIndex = 50;
		this._bg.style.position="absolute";
		this._bg.style.filter = "alpha(opacity=0)";
		this._bg.style.opacity = 0;

		this._setPos();

		this._fadeIn(this._bg, this._bgAlpha, 0);
		this._fadeIn(this._popup, 100, 0);

		//位置ずれ補正
		this._setPos();
	}
	,closePopup:function() {
		window.onscroll=null;
		window.onresize=null;

		this._fadeOut(this._popup, 0, 100, 100);
		this._fadeOut(this._bg, 0, this._bgAlpha, this._bgAlpha);

	}
	,_fadeIn:function (obj, max, now) {
		obj.style.visibility="visible";
		if(max > now) {
			var next = now + (max / this._fadeSpeed);
			obj.style.filter = "alpha(opacity=" + next + ")";
			obj.style.opacity = next/100;
			var myObj = this;
			setTimeout(
				function() {
					myObj._fadeIn(obj, max, next);
				}
			, 100);
		} else {
			obj.style.filter = "alpha(opacity=" + max + ")";
			obj.style.opacity = max/100;
		}
	}
	,_fadeOut:function(obj, min, start, now) {
		if(min < now) {
			var next = now - ((start-min) / this._fadeSpeed);
			obj.style.filter = "alpha(opacity=" + next + ")";
			obj.style.opacity = next/100;
			var myObj = this;
			setTimeout(
				function() {
					myObj._fadeOut(obj, min, start, next);
				}
			, 100);
		} else {
			obj.style.filter = "alpha(opacity=" + min + ")";
			obj.style.opacity = min/100;
			if(min <= 0) {
				obj.style.visibility="hidden";
			}
		}
	}
	,next:function() {
		for(var cnt = 0; cnt < this._imgIdList.length; cnt++) {
			if(this._imgIdList[cnt] == this._nowImgId) {
				var newId = null;
				if(cnt < this._imgIdList.length - 1) {
					this._nowImgId = this._imgIdList[cnt+1];
				} else {
					this._nowImgId = this._imgIdList[0];
				}
				this._nowImgSet();
				break;
			}
		}
	}
	,back:function() {
		for(var cnt = 0; cnt < this._imgIdList.length; cnt++) {
			if(this._imgIdList[cnt] == this._nowImgId) {
				var newId = null;
				if(cnt === 0) {
					this._nowImgId = this._imgIdList[this._imgIdList.length-1];
				} else {
					this._nowImgId = this._imgIdList[cnt-1];
				}
				this._nowImgSet();
				break;
			}
		}
	}
	,_nowImgSet:function() {
		this._imgArea.style.width=this._imgList[this._nowImgId].width+"px";
		this._imgArea.style.height=this._imgList[this._nowImgId].height+"px";
		this._imgArea.style.backgroundImage = "url("+this._imgList[this._nowImgId].src+")";
	}
	,setImg:function (id, src) {
		this._imgList[id] = new Image();
		this._imgList[id].src = src;
		this._imgIdList.push(id);
	}
}

/**
 * onmouseove/onmouseoutに自動で関数を設定する
 * @param {Object} tagName 設定したいタグ名（画像をつけられるもの）
 * @param {Object} className 関数を設定するタグにつけるクラス名
 */
function initOnMouseFunc(tagName, className) {
	var elements = document.getElementsByTagName(tagName);
	
	for(cnt = 0; cnt < elements.length; cnt++) {
		obj = elements[cnt];
		if(obj.className == className) {
			var defImg = obj.src;
			var dotPos = defImg.lastIndexOf(".");
			var onImg  = defImg.substr(0, dotPos)+"o"+defImg.substr(dotPos);
			
			obj.setAttribute('defImg', defImg);
			obj.setAttribute('onImg' , onImg);
			obj.onmouseover = function() {
				this.src = this.getAttribute('onImg');
			};
			
			obj.onmouseout = function() {
				this.src = this.getAttribute('defImg');
			};

			obj.onerror = function() {
				this.src = this.getAttribute('defImg');
			};
		}
	}
}

function init() {
	initOnMouseFunc('img', 'roimage');
	initOnMouseFunc('input', 'roimage');
}

window.onload = init

