//
// Author : http://www.yomotsu.net
// Licensed under the GNU Lesser General Public License version 2.1


//* 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;
	}
}
