/**
 * windowを開く
//@param:
//tar:ターゲット<a>オブジェクト
//win:ウインドウ名
//o:オプションオブジェクト
//o.width:ウインドウ幅 [デフィルト:スクリーン幅 / 2]
//o.height:ウインドウ高 [デフィルト:スクリーン高 / 2]
//o.xpos:x座標 [デフィルト:0]
//o.ypos:y座標 [デフィルト:0]
//o.menu:メニューバーの有無 [デフィルト:no]
//o.tool:ツールバーの有無 [デフィルト:no]
//o.loc:ロケーションバーの有無 [デフィルト:no]
//o.status:ステータスバーの有無 [デフィルト:no]
//o.resize:リサイズの有無 [デフィルト:no]
//o.scroll:スクロールバーの有無 [デフィルト:no]
 */
function openWin(tar, win, o){
	var wo;
	var op="";
	var u = tar.href;
	var w = (win) ? win : "ARICAsub";
	if(o){
		o.width = (typeof o.width == 'undefined') ? screen.width/2 : o.width;
		o.height = (typeof o.width == 'undefined') ? screen.height/2 : o.height;
		o.xpos = (typeof o.xpos == 'undefined') ? (screen.width/2)-(o.width/2) : o.xpos;
		o.ypos = (typeof o.ypos == 'undefined') ? (screen.height/2)-(o.height/2) : o.ypos;
		o.menu = (typeof o.menu == 'undefined') ? 'no' : o.menu;
		o.tool = (typeof o.tool == 'undefined') ? 'no' : o.tool;
		o.loc = (typeof o.tool == 'undefined') ? 'no' : o.loc;
		o.status = (typeof o.status == 'undefined') ? 'no' : o.status;
		o.resize = (typeof o.resize == 'undefined') ? 'yes' : o.resize;
		o.scroll = (typeof o.scroll == 'undefined') ? 'yes' : o.scroll;
		
		o.xpos = (o.xpos == "left") ? o.xpos=0 : (o.xpos == "right") ? screen.width - o.width : o.xpos;
		o.ypos = (o.ypos == "top") ? o.ypos=0 : (o.ypos == "bottom") ? screen.height - o.height : o.ypos;
		
		
		op += 'menubar = '+o.menu+",";
		op += 'toolbar = ' + o.tool + ",";
		op += 'location = ' + o.loc + ",";
		op += 'status = ' + o.status + ",";
		op += 'resizable = ' + o.resize + ","
		op += 'scrollbars = ' + o.scroll + ",";
		op += 'width = ' + o.width + ',height = ' + o.height + ",";
		op += 'top = ' + o.ypos + ',left = ' + o.xpos;
		//alert(op);
	}
	
	wo = (op.length > 0) ? window.open(u,w,op) : window.open(u,w);
	wo.focus();
	return false;
}

/**
 * 親windowを変える
//@param:
//tar:ターゲット<a>オブジェクト
 */
function changeParURL(tar,t){
	if(t == "flash"){
		tar = {href:tar};
	}
	
	var b = CheckParWin();
	if(b){
		window.opener.focus();
		window.opener.location.href = tar.href;
	}else{
		return openWin(tar, 'ARICAmain');
	}
}

/**
 * changeParURLに合わせてAnaryticsのコードをコールする
//@param:
//tar:ターゲット<a>オブジェクト
 */
function changeParURLAndCode(tar,t,code){
	urchinTracker(code);
	if(t == "flash"){
		tar = {href:tar};
	}
	
	var b = CheckParWin();
	if(b){
		window.opener.focus();
		window.opener.location.href = tar.href;
	}else{
		return openWin(tar, 'ARICAmain');
	}
}

/**
 * 親windowの有無を調べる
//@param:
 */
function CheckParWin(){
	var b;
	if ((navigator.userAgent.indexOf("Mac") > -1)){
		if (window.opener){
			b = true;
		}else{
			b = false;
		}
	}else{
		if (window.opener&&!window.opener.closed){
			b = true;
		}else{
			b = false;
		}
	}
	return b;
}
