var winobj = null;
var preobj = null;
var helpobj = null;
var wordobj = null;
/* ポイントバック対応★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆ */
var pbackobj = null;
/* ポイントバック対応★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆ */

var sslurl = 'https://listen.jp/store/ssl/';

function chkBrowser(){
	//check browser
	var wci = window.clientInformation;
	if(wci!=null&&wci.userAgent.indexOf("MSIE")>0&&wci.platform.indexOf("Win")==0){
		if (!navigator.cookieEnabled) {
			alert('申し訳ありません、Cookieが有効ではありません。\n当サイトをご利用頂くには、Cookieを有効にしてください。');
			return false;
		}
		return true;
	}else{
		alert('申し訳ありません、当サイトをご利用頂くには\n　Windows Vista/XP\n　IE 7.0/6.0\n　Windows Media Player 11/10/9\nの環境が必要です。');
		return false;
	}
}

function openMyPage(page){
	if (!chkBrowser())
		return;
	//check opener
	try {
		if (!window.opener || window.opener.closed){
			location.href=sslurl+page;
		}else if (window.opener.name == "preview"){
			window.open(sslurl+page,'');
		}else{
			window.opener.location.href=sslurl+page;
		}
	}catch(e){
		window.open(sslurl+page,'');
	}
}

// ★★★　ユニバーサル会員獲得キャンペーン対応　2007/04/20-2007/04/29　★★★
function openSpPage(page){
	if (!chkBrowser())
		return;
	//check opener
	try {
		if (!window.opener || window.opener.closed){
			location.href=page;
		}else if (window.opener.name == "preview"){
			window.open(page,'');
		}else{
			window.opener.location.href=page;
		}
	}catch(e){
		window.open(page,'');
	}
}
// ★★★　ユニバーサル会員獲得キャンペーン対応　2007/04/20-2007/04/29　★★★

function getpos(){
	var hw = 296;
	var hwplus = hw + 150;
	var x = (event.screenX+hwplus>screen.Width?screen.Width-hwplus:event.screenX);
	var y = (event.screenY+hwplus>screen.Height?screen.Height-hwplus:event.screenY);
	return 'status=yes,scrollbars=no,resizable=no,width=300,height=365,top='+y+',left='+x;
}

// ★★★★★　楽天決済対応（2008/12〜）★★★★★
// 楽天決済時のみ、ウィンドウサイズを通常より大きくする
function getpos2(){
	var hw = 296;
	var hwplus = hw;
	var x = (event.screenX+hwplus>screen.Width?screen.Width-hwplus:event.screenX);
	var y = (event.screenY+hwplus>screen.Height?screen.Height-hwplus:event.screenY);
	return 'status=yes,scrollbars=no,resizable=no,width=300,height=415,top='+y+',left='+x;
}
// ★★★★★　楽天決済対応（2008/12〜）★★★★★

function openBuyWindow(cid){
	if (!chkBrowser())
		return;
		
	// cobrand情報確認
	if (checkCobra() == "store") {
		//open buy window
		if(winobj && !winobj.closed){
			alert('すでにウィンドウが開いています。');
			winobj.focus();
		}else{
			winobj = window.open(sslurl+'ax_login.aspx?cid='+cid+'&jun=buy','',getpos2());
		}
	} else {
		winobj = window.open(sslurl+'ax_login.aspx?cid='+cid+'&jun=buy','',getpos2());
	}
}

// ★★★ トラックまとめ買い対応（2007/6） ★★★
function openAllBuyWindow(cid){
	if (!chkBrowser())
		return;
		
	// cobrand情報確認
	if (checkCobra() == "store") {
		//open buy window
		if(winobj && !winobj.closed){
			alert('すでにウィンドウが開いています。');
			winobj.focus();
		}else{
			winobj = window.open(sslurl+'ax_login.aspx?cid='+cid+'&jun=allbuy','',getpos2());
		}
	} else {
		winobj = window.open(sslurl+'ax_login.aspx?cid='+cid+'&jun=allbuy','',getpos2());
	}
}
// ★★★ トラックまとめ買い対応（2007/6） ★★★

// アフィリエイト用購入
function openBuyWindowAf(cid, afid){
	if (!chkBrowser())
		return;
		
	// cobrand情報確認
	if (checkCobra() == "store") {
		//open buy window
		if(winobj && !winobj.closed){
			alert('すでにウィンドウが開いています。');
			winobj.focus();
		}else{
			winobj = window.open(sslurl+'ax_login.aspx?cid='+cid+'&af='+afid+'&jun=buy','',getpos2());
		}
	} else {
		winobj = window.open(sslurl+'ax_login.aspx?cid='+cid+'&af='+afid+'&jun=buy','',getpos2());
	}
}

function openGiftWindow(cid){
	if (!chkBrowser())
		return;
		
	// cobrand情報確認
	if (checkCobra() == "store") {
		//open gift window
		if(winobj && !winobj.closed){
			alert('すでにウィンドウが開いています。');
			winobj.focus();
		}else{
			winobj = window.open(sslurl+'ax_login.aspx?cid='+cid+'&jun=send','',getpos2());
		}
	} else {
		winobj = window.open(sslurl+'ax_login.aspx?cid='+cid+'&jun=send','',getpos2());
	}
}

function openReGetWindow(cid, tid, jun){
	if (!chkBrowser())
		return;
		
	// cobrand情報確認
	if (checkCobra() == "store") {
		//open redl window
		if(winobj && !winobj.closed){
			alert('すでにウィンドウが開いています。');
			winobj.focus();
		}else{
			winobj = window.open(sslurl+'ax_login.aspx?cid='+cid+'&tid='+tid+'&jun='+jun,'',getpos());
		}
	} else {
		winobj = window.open(sslurl+'ax_login.aspx?cid='+cid+'&tid='+tid+'&jun='+jun,'',getpos());
	}
}

// ★★★★★　楽天決済対応（2008/12〜）★★★★★
function openRakutenDLWindow(cid, tid, jun){
	if (!chkBrowser())
		return;
		
	// cobrand情報確認
	if (checkCobra() == "rakuten") {
		//open redl window
		if(winobj && !winobj.closed){
			alert('すでにウィンドウが開いています。');
			winobj.focus();
		}else{
			winobj = window.open(sslurl+'ax_login.aspx?cid='+cid+'&tid='+tid+'&jun='+jun,'',getpos());
		}
	} else {
		winobj = window.open(sslurl+'ax_login.aspx?cid='+cid+'&tid='+tid+'&jun='+jun,'',getpos());
	}
}
// ★★★★★　楽天決済対応（2008/12〜）★★★★★

function openPreviewWindow(url){
	if (!chkBrowser())
		return;

	// cobrand情報確認
	if (checkCobra() == "store") {
		//open Preview window
		//***** modified on 2006.2.28 
		preobj = window.open(url + "&tm=" + new Date().getTime(),'preview','scrollbars=no,status=no,menubar=no,resizable=yes,width=470,height=621,top=10,left=30');
		preobj.focus();
	} else {
		// previewからviewAsxに置換
		url = url.replace("preview", "viewAsx");
		preobj = window.open(url + "&tm=" + new Date().getTime(),'_self','directions=no,location=no,status=no,menubar=no,toolbar=no,width=0,height=0,top=10000,left=10000');
	}
}

// 動画用試聴Window表示
function openVideoPreviewWindow(url){
	if (!chkBrowser())
		return;
		
	preobj = window.open(url + "&tm=" + new Date().getTime(), '_self', 'directions=no,location=no,status=no,menubar=no,toolbar=no,width=0,height=0,top=10000,left=10000');
}

function openHelpWindow(url){
	if (!chkBrowser())
		return;
	//open Help window
	helpobj = window.open(url,'help','location=no,menubar=no,left=10,top=30');
}

function openWordWindow(url){
	if (!chkBrowser())
		return;
	//open Kashi window
	wordobj = window.open(url,'word','scrollbars=yes,resizable=yes,location=no,menubar=no,width=635,left=10,top=30');
}

/* ポイントバック対応★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆ */
function openRegistPointBackWindow(){
	if (!chkBrowser())
		return;
		
	//open buy regist pointback window
	if(pbackobj && !pbackobj.closed){
		alert('すでにウィンドウが開いています。');
		pbackobj.focus();
	}else{
		pbackobj = window.open(sslurl+'my_pointback1.aspx?cobra=store','',getpos());
	}
}
/* ポイントバック対応★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆ */

function CheckOs() {
	//check browser
	var wci = window.clientInformation;
	if(wci!=null&&wci.userAgent.indexOf("MSIE")>0&&wci.platform.indexOf("Win")==0){
		window.open(arguments[0]+'/help/navi/navi00.html','win1','scrollbars=yes,resizable=yes,width=500,height=510');
	} else {
		window.open(arguments[0]+'/help/navi/navi00n.html','win1','scrollbars=yes,resizable=yes,width=500,height=510');
	}
}

// cobrand情報確認(wmp)
function checkCobra() {
	theData = "store";
	theName   = "cobra=";
	theCookie = document.cookie+";";
	start = theCookie.indexOf(theName);
	if (start != -1)
	{
		end = theCookie.indexOf(";",start);
		theData = unescape(theCookie.substring(start+theName.length,end));
	}
	return theData;
}
