/*
JavaScript: win_control.js  1.0

last updated on 2007.12.05
(c) 2007 swoop inc. (http://www.swoop.jp/)
*/

var timeID = null;
var wo = null;

/**
 * 親ウィンドウURL変更
 *
 * 親ウインドウが存在しない場合は_blankで開く
 * @param string:url
 */
function parentWinChange(url) {

	if (!is_closed()) {
		wo = window.opener;
		wo.location.href = url;
		this.blur();
	} else {
		wo = window.open(url, 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;
	}
}