/*
	--------------------------------
	Created: 2007.09.11
	Last Modified: 2010.02.21
	--------------------------------
	- Table of Contents -

	Configurations

	Classes
		- DesignatedWindow()
	--------------------------------
*/



/* --------------------------------
	Configurations
-------------------------------- */

var linkToBrandstory = new DesignatedWindow('brandstory');
var linkToBlanchir = new DesignatedWindow('blanchir');
var linkToSpecial = new DesignatedWindow2('blanchir_sp');




/* --------------------------------
	Classes
-------------------------------- */

/* 指定されたリンクを所定のウインドウ内に開く ---------------- */
function DesignatedWindow2(name) {
	this.name = name;
	this.win = null;
		
	this.open = function(url) {
		if (this.win && !this.win.closed ) { // 所定のウインドウが存在する場合
			//alert("opened");
			this.win.location.href = url; // アドレス変更
			this.win.focus();

		} else { // 所定のウインドウが存在しない場合
			//alert("new");
			this.win = window.open(url, this.name);
			this.win.focus();
			
		}
	}
	
}

/* 指定されたリンクを所定のウインドウ内に開く ---------------- */
function DesignatedWindow(name) {
	this.name = name;
	this.win = null;
		
	this.open = function(url, topFlag) {
		var ancFlag = (url.split('#').length > 1)? true : false;
		
		if (window.opener && !window.opener.closed) { // 親ウインドウが存在する場合
			//alert("parent");
			if(topFlag) { window.opener.location.href = (url + topFlag); } // トップページEnter後の画面を表示
			else if(ancFlag) { window.opener.location.href = url; } // アンカーリンクならアドレス変更
			
			window.opener.focus();
			

		} else if (this.win && !this.win.closed ) { // 所定のウインドウが存在する場合
			//alert("opened");
			if(topFlag) { this.win.location.href = (url + topFlag); } // トップページEnter後の画面を表示
			else if(ancFlag) { this.win.location.href = url; } // アンカーリンクならアドレス変更
			
			this.win.focus();
			

		} else { // 所定のウインドウが存在しない場合
			//alert("new");
			this.win = window.open(url, this.name);
			this.win.focus();
			
		}
	}
	
}

