/*====================================================================================================
//////////////////////////////////////////////////////////////////////////////////////////////////////

	Author : http://www.yomotsu.net
	created: 2007/02/01
	update : 2007/11/15
	Licensed under the GNU Lesser General Public License version 2.1

//////////////////////////////////////////////////////////////////////////////////////////////////////
====================================================================================================*/
var yomotsuOpenWin = {
	
	conf : {
		className : "external",//リンク先を別ウインドウで開きたいa要素につけるclass名
		fileTypes : ["pdf","doc","xls","ppt"]//リンク先を別ウインドウで開きたいファイルの拡張子
	},

	main : function(){
		var fileTypesReg = "";
		for(i = 0; i <yomotsuOpenWin.conf.fileTypes.length; i++){
			fileTypesReg += "."+yomotsuOpenWin.conf.fileTypes[i]+"|";
		}
		fileTypesReg=fileTypesReg.slice(0, -1);
	
		var a = document.links;
		for (i = 0; i < a.length; i++) {
			if (new RegExp("\\b" + yomotsuOpenWin.conf.className + "\\b").exec(a[i].className)||
		    	(new RegExp(fileTypesReg).exec(a[i].getAttribute("href")))){
				a[i].onclick = yomotsuOpenWin.openWin;
				a[i].onkeypress = yomotsuOpenWin.openWin;
			}
		}
	},
		
	openWin : function(){
		window.open(this.href, "", "toolbar=yes, location=yes, directories=yes, status=yes, menubar=yes, scrollbars=yes, resizable=yes, close=yes");
		return false;
	},
	
	addEvent : function(){
		try {
			window.addEventListener('load', this.main, false);
		} catch (e) {
			window.attachEvent('onload', this.main);
		}
	}
	
}

yomotsuOpenWin.addEvent();