var license_desc_show = false;

function ShowLicenseDesc() {
	if (license_desc_show) {
		document.getElementById("license_desc").innerHTML = "";
		license_desc_show = false;
	} else {
		document.getElementById("license_desc").innerHTML = "";
		license_desc_show = true;
	}
}

var winobj = null;
var preobj = null;
var helpobj = null;
var wordobj = 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/2000/Me/98SE\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,'');
	}
}

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=296,height=296,top='+y+',left='+x;
}

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','',getpos());
		}
	} else {
		winobj = window.open(sslurl+'ax_login.aspx?cid='+cid+'&jun=buy','',getpos());
	}
}

// アフィリエイト用購入
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','',getpos());
		}
	} else {
		winobj = window.open(sslurl+'ax_login.aspx?cid='+cid+'&af='+afid+'&jun=buy','',getpos());
	}
}

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','',getpos());
		}
	} else {
		winobj = window.open(sslurl+'ax_login.aspx?cid='+cid+'&jun=send','',getpos());
	}
}

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());
	}
}

function openPreviewWindow(url){
	if (!chkBrowser())
		return;

	// cobrand情報確認
	if (checkCobra() == "store") {
		//open Preview window
		preobj = window.open(url + "&tm=" + new Date().getTime(),'preview','scrollbars=no,status=no,menubar=no,resizable=yes,width=430,height=585,top=10,left=30');
		preobj.focus();
	} else {
		// previewからviewAsxに置換
		url = url.replace("preview", "viewAsx");
		preobj = window.open(url + "&tm=" + new Date().getTime(),'preview','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 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;
}

function listen_file_open(URL,windowname,status){
	if(navigator.appName.indexOf("Netscape") != -1){
		window.alert('申し訳ありません、該当コンテンツをご利用頂くには\n　　IE 5.5以上、6.0推奨\n　の環境が必要です。');
	}else{
		window.open(URL,windowname,status);
	}
}