/*====================================================================================================
//////////////////////////////////////////////////////////////////////////////////////////////////////

	Author : http://www.metaphase.co.jp
	created: 2007/02/01
	update : 2008/06/23
	
	hrefの内容が .pdf など、JS内で設定したファイルになっていると自動で window.open

//////////////////////////////////////////////////////////////////////////////////////////////////////
====================================================================================================*/
var metaphase_openWin = {
	
	conf : {
		className : "external",//リンク先を別ウインドウで開きたいa要素につけるclass名
		fileTypes : ["pdf","doc","xls","ppt"]//リンク先を別ウインドウで開きたいファイルの拡張子
	},

	main : function(){
		var fileTypesReg = "/";
		for(i = 0; i <metaphase_openWin.conf.fileTypes.length; i++){
			fileTypesReg += "\\."+metaphase_openWin.conf.fileTypes[i]+"$|";
		}
		fileTypesReg=fileTypesReg.slice(0, -1)+"/";
	
		var a = document.links;
		for (i = 0; i < a.length; i++) {
			if (new RegExp("\\b" + metaphase_openWin.conf.className + "\\b").exec(a[i].className)||
		    	(new RegExp(fileTypesReg).exec(a[i].getAttribute("href")))){
				a[i].onclick = metaphase_openWin.openWin;
				a[i].onkeypress = metaphase_openWin.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);
		}
	}
	
}

var openSubWin = function(path, w, h){
	var newWindow = window.open(path, 'syosai', 'width = ' + w + ', height = ' + h + ', scrollbars = 1, resizable = 1');
	newWindow.focus();
}

metaphase_openWin.addEvent();



