//
// Author : http://www.yomotsu.net
// Licensed under the GNU Lesser General Public License version 2.1


// rollover デフォルトの画像名の最後に"_n"、ロールオーバー画像名の最後に"_r"
//--------------------------------------------------------------------------------

function yomotsuRollover() {
	
	var img = document.getElementsByTagName("img");
	
	for(i=0;i<img.length;i++){

		var src   = img[i].getAttribute("src");
		var ftype = src.substring(src.lastIndexOf("."), src.length);
		
		if(new RegExp("_n"+ ftype + "\\b").exec(src)) {
			
			img[i].onmouseover = function() {
				if(this.style.filter){/*for IE5.5-6 && png*/
					roSrc = this.style.filter.slice(this.style.filter.indexOf("src='")+5,-8)+"_r.png"
					this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=crop,src='"+roSrc+"')";
				}
				else {
					var curSrc   = this.getAttribute("src");
					var curFtype = curSrc.substring(curSrc.lastIndexOf("."), curSrc.length);
					this.setAttribute("src", curSrc.slice(0, -1*(curFtype.length + 2)) + "_r" + curFtype);
				}
			}	
			
			img[i].onmouseout = function() {
				if(this.style.filter){/*for IE5.5-6 && png*/
					outSrc = this.style.filter.slice(this.style.filter.indexOf("src='")+5,-8)+"_n.png"
					this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=crop,src='"+outSrc+"')";
				}
				else {
					var curSrc   = this.getAttribute("src");
					var curFtype = curSrc.substring(curSrc.lastIndexOf("."), curSrc.length);
					this.setAttribute("src", curSrc.slice(0, -1*(curFtype.length + 2)) + "_n" + curFtype);
				}
			}
		}
	}
}

addEvent(window, "load", yomotsuRollover);


/* ie png
----------------------------------------*/

function yomotsuIePng(){
	if (document.all && !window.opera && !window.XMLHttpRequest && (typeof document.getElementsByTagName("body")[0].style.outline == "undefined"))/* IE+Opera - opera - ie7up - macIE */{
		for (var i = 0; i <document.getElementsByTagName("img").length; i++) { 
		
		if (document.getElementsByTagName("img")[i].getAttribute("src").lastIndexOf(".png") != -1){
			
			var pngSrc = document.getElementsByTagName("img")[i].getAttribute("src");
			var blankSrc = pngSrc.slice(0, pngSrc.lastIndexOf("/")+1) + "png-blank.gif";
			
			document.getElementsByTagName("img")[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+pngSrc+"')";
			document.getElementsByTagName("img")[i].setAttribute("src",blankSrc);
			
			}
		}
	}
}

addEvent(window, 'load', yomotsuIePng);

/* IE BG png
----------------------------------------*/

function yomotsuIeBgPng(){
	if ((typeof document.documentElement.style.filter != "undefined")&&(typeof document.documentElement.style.msInterpolationMode == "undefined"))/* IE5.5&6*/ {
		element = document.getElementsByTagName("*");
		for(i=0;i<element.length;i++){
			bgImg = element[i].currentStyle.getAttribute("backgroundImage");
			bgRepeat = element[i].currentStyle.getAttribute("backgroundRepeat");
			bgRepeat="repeat"?"scale":"crop";
			
			if(bgImg.lastIndexOf(".png")!=-1){
				bgSrc = bgImg.slice(5,-2);
				element[i].style.backgroundImage = "none";
				element[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod="+bgRepeat+",src='"+bgSrc+"')";

			}
		}
	}
}

addEvent(window, 'load', yomotsuIeBgPng);


//* Open new win
//----------------------------------------*/


yomotsuOpenWinConf = {
	className : "external",//リンク先を別ウインドウで開きたいa要素につけるclass名
	fileTypes : ["pdf","doc","xls","ppt"]//リンク先を別ウインドウで開きたいファイルの拡張子
}

var fileTypesReg = "";
for(i = 0; i <yomotsuOpenWinConf.fileTypes.length; i++){
	fileTypesReg += "."+yomotsuOpenWinConf.fileTypes[i]+"|"
}
fileTypesReg=fileTypesReg.slice(0, -1);

function yomotsuOpenWin() {
var a = document.getElementsByTagName("a");
	for (i = 0; i <a.length; i++) {
		if (new RegExp("\\b" + yomotsuOpenWinConf.className + "\\b").exec(a[i].className)||
		(new RegExp(fileTypesReg).exec(a[i].getAttribute("href")))){

			a[i].onclick = function() {
				var href = this.getAttributeNode("href").value;
				this.setAttribute("href","javascript:;");	
				window.open(href, "", "toolbar=yes, location=yes, directories=yes, status=yes, menubar=yes, scrollbars=yes, resizable=yes, close=yes");
				this.setAttribute("href",href);
				return false;
			}
			a[i].onkeypress = function() {
				var href = this.getAttributeNode("href").value;
				this.setAttribute("href","javascript:;");	
				window.open(href, "", "toolbar=yes, location=yes, directories=yes, status=yes, menubar=yes, scrollbars=yes, resizable=yes, close=yes");
				this.setAttribute("href",href);
				return false;
			}
			
		}
		
		
		if (a[i].className=="chart"){

			a[i].onclick = function() {
				var href = this.getAttributeNode("href").value;
				this.setAttribute("href","javascript:;");	
				window.open(href, "", "width=700, toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=yes, close=yes");
				this.setAttribute("href",href);
				return false;
			}
			a[i].onkeypress = function() {
				var href = this.getAttributeNode("href").value;
				this.setAttribute("href","javascript:;");	
				window.open(href, "", "width=700, toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=yes, close=yes");
				this.setAttribute("href",href);
				return false;
			}
			
		}
	}
}

addEvent(window, 'load', yomotsuOpenWin);


//add event
//----------------------------------------

function addEvent(obj, evType, fn){
	if (obj.addEventListener){
		obj.addEventListener(evType, fn, false);
		return true;
	}
	else if (obj.attachEvent){
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	}
	else {
		return false;
	}
}


//opensubwindow
function openSubWin(path, w, h){
newWindow = window.open(path, "syosai", "width=" + w + ",height=" + h + ",scrollbars=yes");
newWindow.focus();
}

//openwindow
function Open_40B(){
win=window.open("../roomplan/40B.html","","scrollbars=yes,resizable=yes,width=680,height=680");
}

function Open_55B(){
win=window.open("../roomplan/55B.html","","scrollbars=yes,resizable=yes,width=680,height=680");
}

function Open_70B(){
win=window.open("../roomplan/70B.html","","scrollbars=yes,resizable=yes,width=680,height=680");
}

function Open_70I(){
win=window.open("../roomplan/70I.html","","scrollbars=yes,resizable=yes,width=680,height=680");
}

function Open_80A(){
win=window.open("../roomplan/80A.html","","scrollbars=yes,resizable=yes,width=680,height=680");
}

function Open_95B(){
win=window.open("../roomplan/95B.html","","scrollbars=yes,resizable=yes,width=680,height=680");
}