/*****************************************
 * JavaScript: window.js  1.0
 * 
 * last updated on 2008.10.14
 * (c) 2007 swoop inc. (http://www.swoop.jp/)
 *****************************************/
 var wo = null;
 
// contents URL
var url = new Array();
url[0] = 'trivia/index.html';
url[1] = 'http://www.shcl.co.jp/recruite/index.html';
url[2] = 'http://rikunabi2010.yahoo.co.jp/bin/KDBG00100.cgi?KOKYAKU_ID=0191328001';
url[3] = 'http://www.shcl.co.jp/corporate/environment.html'; // Q7

var popup = 0;
var blank = 0;
var pw = 980;
var ph = 700;
var bh = window.screen.availheight;

function popupWinOpen(idx) {
	var w,h;
	var param;
	w = pw;
	h = ph;
	x = (screen.width - w) / 2;
	y = (screen.height - h) / 2;
	param = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width='+pw+',height='+ph+',left='+x+',top='+y;
	popup = window.open(url[idx],'popup',param);
	popup.focus();
}

function winCheck(idx) {
	if(popup) {
		if(!popup.closed) {
			popup.close();
		}
	}
	popupWinOpen(idx);
}

function blankWinOpen(idx) {
	if(popup) {
		if(!popup.closed) {
			popup.close();
		}
	}
	blank = window.open(url[idx],'blank','');
	blank.focus();
}

function winClose(){
	window.close();
}

/*****************************************
 * 親ウィンドウURL変更
 *
 * 親ウインドウが存在しない場合は_blankで開く
 * @param string:url
 *****************************************/
function parentWinChange(idx) {
	if (!is_closed()) {
		wo = window.opener;
		wo.location.href = url[idx];
		this.blur();
	} else {
		wo = window.open(url[idx], null);
	}
	//timeID = setTimeout("setFocus()", 3000);
	setFocus();
}

/*****************************************
 * 親ウィンドウフォーカスセット
 *
 *****************************************/
 function setFocus() {
	 	//clearTimeout(timeID);
		wo.focus()
 }

/*****************************************
 * 親ウィンドウ確認
 *
 * @return boolean:closed true/opend false
 *****************************************/
function is_closed() {
	var pw = window.opener;
	var ua = navigator.userAgent;
	if( !!pw ) {
			if( ( ua.indexOf('Gecko')!=-1 || ua.indexOf('MSIE 4')!=-1 )
					 && ua.indexOf('Win')!=-1 ) {
					 return pw.closed;
			} else {
				return typeof pw.document  != 'object';
			}
	} else {
		return true;
	}
}