// JavaScript Document

function smartRollover() {
	if(document.getElementsByTagName) {
		var images = document.getElementsByTagName("img");

		for(var i=0; i < images.length; i++) {
			if(images[i].getAttribute("src").match("_f."))
			{
				images[i].onmouseover = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_f.", "_n."));
				}
				images[i].onmouseout = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_n.", "_f."));
				}
			}
		}

		var input = null;
		var inputs = document.getElementsByTagName("input");

		for(var i=0; input=inputs[i]; i++){

			if(input.type.toLowerCase() == "submit" && input.className == "cartButton"){
				input.style.backgroundImage = getStyle(input, "backgroundImage");

				if(input.style.backgroundImage.match(/_f\./)){
					input.value = "";

					input.onmouseover = function(){
						this.style.backgroundImage = this.style.backgroundImage.replace("_f.", "_n.");
						this.style.cursor = "pointer";
					}

					input.onmouseout = function(){
						this.style.backgroundImage = this.style.backgroundImage.replace("_n.", "_f.");
						this.style.cursor = "default";
					}
				}
			}
		}
	}
}

function getStyle(element, style){
	if(!element) return null;

	var value = element.style[style];

	if(!value){
		var css = element.currentStyle || document.defaultView.getComputedStyle(element, null);
		value = css ? css[style] : null;
	}

	return (style == "opacity" ? (value ? parseFloat(value) : 1.0) : value);
}

function loadFlash(){
	var flash = document.getElementById("flashContainer");

	if(flash){
		var swf = new SWFObject("file/flash/top.swf", "flashContainer", 778, 358, "8");

		swf.addParam("allowfullscreen", false);
		swf.addParam("quality", "high");
		swf.addParam("base", "file/");

		swf.write("flashContainer");
	}
}

if(window.addEventListener) {
	window.addEventListener("load", smartRollover, false);
	window.addEventListener("load", loadFlash, false);
}
else if(window.attachEvent) {
	window.attachEvent("onload", smartRollover);
	window.attachEvent("onload", loadFlash);
}

///--------------------------------------------------------------------
/// カラーセラピーウィンドウオープン
///
///
///	#Author NATSU
/// #date	2010/08/24
///--------------------------------------------------------------------
function openColorTherapy(color){
	var screenW = screen.width;
	var screenH = screen.height;
	var w_positon = Math.round(screenW / 2 ) - 160;
	var h_positon = Math.round(screenH / 2 ) - 120;
	var url = 'file/colortherapy/'+color+'.html';
	window.open(url,color+"_win", "width=320, height=415,scrollbars=no,location=no, menubar=no,left="+w_positon+",top="+h_positon);
}



