// LastUpdate : 2003/9/22/5:38:02 PM
// このスクリプトは変数設定に合わせた同じ表示領域のサブウィンドウを開くものです。
// 対応ブラウザはバージョン4以上です。

function winOpen(wurl,wname,wwidth,wheight,wtop,wleft,wtb,wlb,wdir,wstb,wmb,wscb,wres){
	
	// 初期設定
	
	pref= "no";
	
	if(wurl == "url" || wurl == null){
		wurl = "http://www.google.com/";
	}
	if(wwidth == "width" || wwidth == null){
		wwidth = 500;
	}
	else{
		wwidth = parseInt(wwidth)
	}
	if(wheight == "height" || wheight == null){
		wheight = 500;
	}
	else{
		wheight = parseInt(wheight)
	}
	if(wtb == "toolbar" || wtb == null){
		wtb = pref;
	}
	if(wlb == "location" || wlb == null){
		wlb = pref;
	}
	if(wdir == "directories" || wdir == null){
		wdir = pref;
	}
	if(wstb == "status" || wstb == null){
		wstb = pref;
	}
	if(wmb == "menubar" || wmb == null){
		wmb = pref;
	}
	if(wscb == "scrollbars" || wscb == null){
		wscb = pref;
	}
	if(wres == "resizable" || wres == null){
		wres = pref;
	}
	
	// 表示領域オフセット
	
	var pf = navigator.platform.charAt(0);
	var an = navigator.appName.charAt(0);
	var ua = navigator.userAgent;
	
	if(pf == "M"){
		
		if(an == "N"){
			
			if(wtb =="yes" || wlb == "yes"){
				
				if(ua.indexOf("Gecko",0) > -1 && ua.indexOf("Safari",0) <= -1){
					wheight += 79;
				}
				if(wlb == "yes" && ua.indexOf("Safari",0) > -1){
					wheight += 72;
				}
				if(wscb != "no" && ua.indexOf("Safari",0) > -1){
					wwidth += 15;
					wheight += 15;
				}
				
			}
			
			if(wstb == "yes"){
				
				if(ua.indexOf("Safari",0) > -1){
					wheight += 15;
				}
				if(ua.indexOf("Gecko",0) > -1 && ua.indexOf("Safari",0) <= -1){
					wheight += 18;
				}
				
			}
			
			if(wscb == "yes"){
				
				if(ua.indexOf("Gecko",0) > -1 && ua.indexOf("Safari",0) <= -1){
					wwidth += 18;
					wheight += 18;
				}
				else{
					
					if(wstb != "yes" && ua.indexOf("[",0) <= -1){
						wwidth += 15;
						wheight += 15;
					}
					
				}
				
			}
			
		}
		
	}
	else{
		
		if(wmb == "yes"){
			
			if(ua.indexOf("MSIE",0) > -1){
				
				if(wtb == "yes" && wlb == "yes" && wdir == "yes" && wstb == "yes"){
					wheight += 123;
				}
				else{
					wheight -= 20;
				}
				
			}
			
		}
		if(wscb == "yes"){
			wwidth += 15;
			wheight += 15;
		}
		
	}
	
	// 表示位置（デフォルトは中央）
	
	var sw = screen.availWidth / 2;
	var sh = screen.availHeight / 2;
	var ww = wwidth / 2;
	var wh = wheight / 2;
	
	if(wtop == "top" || wtop == null){
		wtop = parseInt(sh - wh);
	}
	
	if(wleft == "left" || wleft == null){
		wleft = parseInt(sw - ww);
	}
	
	var wopt = "width=" + wwidth;
	wopt += ",height=" + wheight;
	wopt += ",top=" + wtop;
	wopt += ",left=" + wleft;
	wopt += ",toolbar=" +  wtb;
	wopt += ",location=" + wlb;
	wopt += ",directories=" + wdir;
	wopt += ",status=" + wstb;
	wopt += ",menubar=" + wmb;
	wopt += ",scrollbars=" + wscb;
	wopt += ",resizable=" + wres;
	
	ow = window.open(wurl,wname,wopt);
	ow.focus();
	return;
	
}

// Author : Kenta Nakae