/* Window Open */
function opnOtl(path) {
	if(this.href.lastIndexOf("hoo-sumai.com/outline/") != -1){
		var features = "toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=600,height=700";
		var w = window.open(this.href,"outline",features);
	} else {
		var w = window.open(this.href,"_blank");
	}
	w.focus();
	return false;
}

function opnBukkenMap(path) {
	var features = "toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=600,height=700";
	var w = window.open(this.href,"bukkenMap",features);
	w.focus();
	return false;
}


function opnReq(path) {
	var features = "toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=770,height=700";
	var w = window.open(this.href,"request",features);
	w.focus();
	return false;
}

function opnReqAll(tgt) {
	var features = "toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=770,height=700";
	var w = window.open("",tgt,features);
	w.focus();
	return false;
}

function opnRsv(path) {
	var features = "toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=770,height=700";
	var w = window.open(this.href,"reserve",features);
	w.focus();
	return false;
}

function opnMadori() {
	if(this.href.lastIndexOf("hoo-sumai.com") != -1){
		var features = "toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=600,height=700";
		var w = window.open(this.href,"madori",features);
	} else {
		var w = window.open(this.href,"_blank");
	}
	w.focus();
	return false;
}

function opnHensai() {
	var features = "toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=500,height=700";
	var w = window.open(this.href,"hensai",features);
	w.focus();
	return false;
}

function opnTopics() {
	var features = "toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=600,height=700";
	var w = window.open(this.href,"topics",features);
	w.focus();
	return false;
}

function opnConstPhoto() {
	var features = "toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=682,height=616";
	var w = window.open(this.href,"constphoto",features);
	w.focus();
	return false;
}

function opnBlank() {
	var w = window.open(this.href,"_blank");
	w.focus();
	return false;
}



/* Set Link */
function setExtLink() {
	if(!document.getElementsByTagName) return false;
	var aElm = document.getElementsByTagName("*");
	for(var i=0;i<aElm.length;i++){
		var aElmClass = aElm[i].className.split(/\s+/);
		for (var j=0;j<aElmClass.length;j++){
			if(aElmClass[j] == "extLink"){
				aElm[i].onclick = opnBlank;
			}
		}
	}
}


function setRsvLink() {
	if(!document.getElementsByTagName) return false;
	var aElm = document.getElementsByTagName("a");
	for(var i=0;i<aElm.length;i++){
		if(aElm[i].className == "rsvLink"){
			aElm[i].onclick = opnRsv;
		}
	}
}

function setOtl() {
	if(!document.getElementsByTagName) return false;
	var aElm = document.getElementsByTagName("a");
	for(var i=0;i<aElm.length;i++){
		if(aElm[i].className == "outlineLink"){
			aElm[i].onclick = opnOtl;
		}
	}
}
function setBukkenMap() {
	if(!document.getElementsByTagName) return false;
	var aElm = document.getElementsByTagName("*");
	for(var i=0;i<aElm.length;i++){
		if(aElm[i].className == "bukkenMapLink"){
			aElm[i].onclick = opnBukkenMap;
		}
	}
}


function setReq() {
	if(!document.getElementsByTagName) return false;
	var aElm = document.getElementsByTagName("a");
	for(var i=0;i<aElm.length;i++){
		if(aElm[i].className == "reqLink"){
			aElm[i].onclick = opnReq;
		}
	}
}
function setPDFLink() {
	if(!document.getElementsByTagName) return false;
	var aElm = document.getElementsByTagName("*");
	for(var i=0;i<aElm.length;i++){
		if(aElm[i].className == "pdf"){
			aElm[i].onclick = opnBlank;
		}
	}
}


function setMadori() {
	if(!document.getElementsByTagName) return false;
	var aElm = document.getElementsByTagName("a");
	for(var i=0;i<aElm.length;i++){
		if(aElm[i].className == "madoriLink"){
			aElm[i].onclick = opnMadori;
		}
	}
}

function setHensai() {
	if(!document.getElementsByTagName) return false;
	var aElm = document.getElementsByTagName("a");
	for(var i=0;i<aElm.length;i++){
		if(aElm[i].className == "hensaiLink"){
			aElm[i].onclick = opnHensai;
		}
	}
}

function setTopics() {
	if(!document.getElementsByTagName) return false;
	var aElm = document.getElementsByTagName("a");
	for(var i=0;i<aElm.length;i++){
		if(aElm[i].className == "topicsLink"){
			aElm[i].onclick = opnTopics;
		}
	}
}

function setBukken() {
	if(!document.getElementsByTagName) return false;
	var aElm = document.getElementsByTagName("a");
	for(var i=0;i<aElm.length;i++){
		if(aElm[i].className == "bukkenLink"){
			aElm[i].onclick = opnBlank;
		}
	}
}

function setConstPhoto() {
	if(!document.getElementsByTagName) return false;
	var aElm = document.getElementsByTagName("a");
	for(var i=0;i<aElm.length;i++){
		if(aElm[i].className == "constPhotoLink"){
			aElm[i].onclick = opnConstPhoto;
		}
	}
}



/* Set Close */
function setClose() {
	if(!document.getElementsByTagName) return false;
	var aImg = document.getElementsByTagName("img");
	var oImg = [];
	for(var i=0;i<aImg.length;i++){
		if(aImg[i].id == "btn_close"){
			aImg[i].onclick = function() {
				window.close();
			};
		}
	}
}


/* Set Rollover */
function setRollover() {
	if(!document.getElementsByTagName) return false;
	var aImg = document.getElementsByTagName("img");
	var oImg = [];
	for(var i=0;i<aImg.length;i++){
		if(aImg[i].className == "roimg"){
			aImg[i].orgpath = aImg[i].src;
			var n = aImg[i].orgpath.lastIndexOf(".");
			if(aImg[i].orgpath.substring(0,n-2) != "_o") {
				aImg[i].ropath = aImg[i].orgpath.substring(0,n)+"_o"+aImg[i].orgpath.substring(n);
			}else{
				aImg[i].ropath = aImg[i].orgpath;
			}
			oImg[i] = new Image();
			oImg[i].src = aImg[i].ropath;
			aImg[i].onmouseover = function() {
				this.src = this.ropath;
			};
			aImg[i].onmouseout = function() {
				this.src = this.orgpath;
			};
		}
	}
}

/* Set setReqLabelRollover */
function setReqLabelRollover() {
	if(!document.getElementsByTagName) return false;
	var aLabel = document.getElementsByTagName("label");
	for(var i=0;i<aLabel.length;i++){
		if(aLabel[i].className == "ro"){
			aLabel[i].onmouseover = function() {
				this.className = "mover";
			};
			aLabel[i].onmouseout = function() {
				this.className = "ro";
			};
		}
	}
}

/* Add Event */
function addEvent(elm,eventName,func,cap) {
	if(elm.addEventListener) {
		elm.addEventListener(eventName,func,!!cap);
		return true;
	}
	else if(elm.attachEvent) {
		return elm.attachEvent('on'+eventName,func);
	}
	else{
		var pre = elm["on"+eventName];
		elm["on"+eventName] =
			!pre ? function() {func()} :
			function(){pre(); func()};
	}
}


/* Init Load */
addEvent(window,"load",setRollover,false);
addEvent(window,"load",setClose,false);
addEvent(window,"load",setExtLink,false);
addEvent(window,"load",setReq,false);
addEvent(window,"load",setPDFLink,false);
addEvent(window,"load",setOtl,false);
addEvent(window,"load",setMadori,false);
addEvent(window,"load",setHensai,false);
addEvent(window,"load",setTopics,false);
addEvent(window,"load",setBukken,false);
addEvent(window,"load",setRsvLink,false);
addEvent(window,"load",setConstPhoto,false);
addEvent(window,"load",setBukkenMap,false);
addEvent(window,"load",setReqLabelRollover,false);


/* add favicon */
document.write('<link rel="Shortcut Icon" type="image/ico" href="/favicon.ico" />');