/*
@update 2007-02-20
*/

/* ウィンドウ&ロケーション */
function ezwin_open(){
	var url = arguments[0];
	var tgt = arguments[1];
	newWin = window.open(url,tgt,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=400,height=300');
	newWin.focus();
}

/* QUICK 自動更新時価用 */

function quickwin_open(url){
	var w_height = 1200;
	if ( window.screen.availHeight < w_height ) {w_height = window.screen.availHeight -30;}
	var quickNewWin = window.open(url, 'ezTrade_quickAT', 'width=690,height='+w_height+',scrollbars=yes,resizable=yes,top=0');
	quickNewWin.focus();
}

/* QUICK 自動更新時価用 リスト一覧 */
function quickwin_open_list(){
	var w_height = 1200;
	if ( window.screen.availHeight < w_height ) {w_height = window.screen.availHeight -30;}
	var quickNewWin = window.open('/InvestmentInformation/0/meigtork/tork/main?jidou=1', 'ezTrade_quickAT', 'width=690,height='+w_height+',scrollbars=yes,resizable=yes,top=0');
	quickNewWin.focus();
}

/* QUICK 自動更新時価用 リスト一覧（簡易版）2007/09/03 add */
function quickwin_open_list2(){
	var w_height = 1200;
	if ( window.screen.availHeight < w_height ) {w_height = window.screen.availHeight -30;}
	var quickNewWin = window.open('/InvestmentInformation/0/meigtork/tork/kani?jidou=1', 'ezTrade_quickAT', 'width=690,height='+w_height+',scrollbars=yes,resizable=yes,top=0');
	quickNewWin.focus();
}

/* QUICK 自動更新時価用 株価ボード */
function quickwin_open_board(){
	var w_height = 1200;
	if ( window.screen.availHeight < w_height ) {w_height = window.screen.availHeight -30;}
	var quickNewWin = window.open('/InvestmentInformation/0/meigtork/tork/board/inv?jidou=1', 'ezTrade_quickAT', 'width=690,height='+w_height+',scrollbars=yes,resizable=yes,top=0');
	quickNewWin.focus();
}

/* イメージオブジェクト */
function class_imglib(){
	this.preloadImg = new Array();
	this.setObj = setObj;
	this.changeSrc = changeSrc;
	this.getTargetObj = getTargetObj;
	
	function setObj(pid,srcPath){
		this.preloadImg[pid] = new Image();
		this.preloadImg[pid].src = srcPath;
	}
	function getTargetObj(id){
		return (document.getElementById(id) ? document.getElementById(id) : document.images[id]);
	}
	function changeSrc(obj,pid){
		var id = (typeof(obj.id) != 'undefined' ? obj.id : obj);
		if(typeof(this.getTargetObj(id)) != 'undefined' && typeof(this.preloadImg[pid]) != 'undefined'){
			(this.getTargetObj(id)).src = this.preloadImg[pid].src;
		}
	}
}
var ezimg = new class_imglib();
ezimg.preloadImgEvt = new Array();
function ezimg_set(){
	if(arguments.length > 2){
		if(arguments[1]){
			ezimg.setObj((arguments[0] + ':mouseout'),arguments[1]);
		}
		if(arguments[2]){
			ezimg.setObj((arguments[0] + ':mouseover'),arguments[2]);
		}
		if(arguments[3]){
			ezimg.setObj((arguments[0] + ':mousedown'),arguments[3]);
		}
		
		ezimg.preloadImgEvt = array_push(ezimg.preloadImgEvt, arguments[0]); //update 2003-01-29
	}
	else{
		ezimg.setObj(arguments[0],arguments[1]);
	}
}
function ezimg_change(){
	ezimg.changeSrc(arguments[0],arguments[1]);
}
function ezimg_onmouseoverhandler(){
	ezimg.changeSrc(this.id,(this.id + ':mouseover'));
}
function ezimg_onmouseouthandler(){
	ezimg.changeSrc(this.id,(this.id + ':mouseout'));
}
function ezimg_onmousedownhandler(){
	ezimg.changeSrc(this.id,(this.id + ':mousedown'));
}
function ezimg_sethandler(id){
	if(typeof(ezimg.getTargetObj(id)) != 'undefined'){
		if(ezimg.preloadImg[(id + ':mouseover')]
		&& (ezimg.getTargetObj(id)).onmouseover == null){
			(ezimg.getTargetObj(id)).onmouseout = ezimg_onmouseouthandler;
		}
		if(ezimg.preloadImg[(id + ':mouseout')]
		&& (ezimg.getTargetObj(id)).mouseout == null){
			(ezimg.getTargetObj(id)).onmouseover = ezimg_onmouseoverhandler;
		}
		if(ezimg.preloadImg[(id + ':mousedown')]
		&& (ezimg.getTargetObj(id)).mousedown == null){
			(ezimg.getTargetObj(id)).onmousedown = ezimg_onmousedownhandler;
		}
	}
}
function ezimg_init(){
	for(var i = 0; i < ezimg.preloadImgEvt.length; i++){
		ezimg_sethandler(ezimg.preloadImgEvt[i]);
	}
}
window.imgSwap = ezimg_change;
window.setImgObj = ezimg_set;

/* ウィンドウクローズ */
function winClose(){
	var _userAgent = navigator.userAgent;

	if(_userAgent.indexOf('MSIE') != -1) {
		if(_userAgent.indexOf('MSIE 5.0') == -1) {
			top.opener = '';
		}
	} else if(_userAgent.indexOf('Gecko') != -1 || _userAgent.indexOf("Safari") != -1) {
		top.name = 'WIN_CLOSE';
		wid = window.open('','WIN_CLOSE');
	}

	top.close();
}

/* ウィンドウオープン */
function WinOpen(URL,WN,F) {
	if(sbwin_clsed(window.WN)){
		newwin = window.open(URL,WN,F);
		newwin.focus();
	}else{
		newwin.location.href = URL;
		newwin.focus();
	}
}

function WinOpenFocus(URL,WN,F) {
	if(sbwin_clsed(window.WN)){
		newwin = window.open(URL,WN,F);
		newwin.focus();
	}else{
		newwin.focus();
	}
}

function sbwin_clsed(winVar) {
	var ua = navigator.userAgent;
	if( !!winVar ){
		if( gck || ( ua.indexOf('MSIE 4')!=-1 && ua.indexOf('Win')!=-1 ) ) return winVar.closed;
		else return typeof winVar.document != 'object';
	}else return true;
}
