/**
 * Class blank javascript.
 */

/*========================================
////////////////////////////////////////////////////////
	Author : http://www.yomotsu.net
	created: 2007/02/01
	update : 2008/06/23
	Licensed under the GNU Lesser General Public License version 2.1
///////////////////////////////////////////////////////
=========================================*/
var yomotsuOpenWin = {
	
	conf : {
		className : "blank",//リンク先を別ウインドウで開きたい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();




/**
 * popup window function.
 * window loaded to add function.
 *
 * +:+ rule +:+
 *   class name is popup.
 *   the rel set to {width},{height}.
 *       ex) <a href="http://www.example.com/" class="popup" rel="420,680">link text</a>
 *                                                    ~~~~~       ~~~~~~~
 */
window.onload = function (){
	var node_a = document.getElementsByTagName('a');
		for (var i in node_a) {
			if(node_a[i].className == 'popup'){
				node_a[i].onclick = function() {
					return winOpen(this.href, this.rel)
				};
			}
		}
} ;


function winOpen(url, rel) {
	var x  = ( screen.availWidth / 4 ) ;
	var y  = ( screen.availHeight / 6 ) ;

	var split = rel.split(',') ;
	window.open(
	url,'popup',
	'width='+ split[0] +',height='+ split[1] +
	',toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,left=' + x + ',top=' + y);
	return false;
};

