//CSS振り分け
function envSet() {
	// ブラウザ判別
	var ua = navigator.userAgent;
	this.NN4  = (document.layers);
	this.IE5 = (ua.indexOf("MSIE 5") != -1);
	this.IE50 = (ua.indexOf("MSIE 5.0") != -1);
	this.IE55 = (ua.indexOf("MSIE 5.5") != -1);
	this.IE6 = (ua.indexOf("MSIE 6") != -1);
	this.IE7 = (ua.indexOf("MSIE 7") != -1);
	this.IE8 = (ua.indexOf("MSIE 8") != -1);
	this.IE   = (ua.indexOf("MSIE") != -1);
	this.Moz  = (ua.indexOf("Gecko") != -1);
	this.Saf  = (ua.indexOf("Safari") != -1);
	this.Op  = (ua.indexOf("Opera") != -1);
	this.Op6  = (ua.match(/Opera.6/) != null); // Opera "6" only
	// OS判別
	this.Win98  = (ua.indexOf("Windows 98") != -1);
	this.WinMe  = (ua.indexOf("Windows Me") != -1);
	this.Win  = (ua.indexOf("Windows") != -1);
	this.Mac  = (ua.indexOf("Mac") != -1);
	if (this.Op6) this.IE50 = this.IE = false; // WinIE を騙っていた時の対策
	if (this.Omn) this.NN4            = false; // document.layers に反応してるので
	// CSS ファイルのあるディレクトリ（絶対パス）
	this.cssDir = "http://www.sonymusic.co.jp/common2/css/";
	
	// 各ブラウザ用補正 CSS のファイル名
	if (this.IE55 && this.Win) this.patchCSS = "base_win_ie55.css";
	if (this.IE6 && this.Win) this.patchCSS = "base_win_ie6.css";
	if (this.IE7 && this.Win) this.patchCSS = "base_win_ie7.css";
	if (this.IE8 && this.Win) this.patchCSS = "base_win_ie8.css";
	if (this.Moz && this.Win)  this.patchCSS = "base_moz.css";
	if (this.Op)              this.patchCSS = "base_opera.css";
	if (this.IE5 && this.Mac)  this.patchCSS = "base_mac_ie5.css";
	if (this.Saf)              this.patchCSS = "base_safari.css";
	if (this.Win98) this.patchCSS = "base_win98.css";
	if (this.WinMe) this.patchCSS = "base_winme.css";
	// DOM 処理関係
	this.DOMenabled =  (document.getElementsByTagName) ? true : false;
	this.firstLoad = n2.isFirstLoad;
	return this;
}
function nyan2Func() {}
nyan2Func.prototype = {
	getAfter : function(_str, _word) {
		// 文字列 _str 中から _word 以降の残りを抽出する\
		var offset = _str.indexOf(_word)
		if (offset == -1) return _str;
			else return _str.substring(offset + _word.length, _str.length);
	},
	makeTag : function() {
		// makeTag( tagName, [attr=value, ... ] , content|null )
		var me = this.makeTag;
		var n = me.arguments.length;
		var tag = "<" + me.arguments[0];
		for (var i=1; i<n-1; i++) {
			if (!me.arguments[i]) continue;
			var attrs = me.arguments[i].split("=");
			var attr = attrs[0];
			var value = attrs.slice(1, attrs.length).join("=");
			tag += ' ' + attr + '="' + value + '"';
		}
		if (me.arguments[n-1]) tag += ">" + me.arguments[n-1] + "</" + me.arguments[0] + ">";
			else tag += " />";
		return tag;
	},
	loadCSS : function(_file) {
		if (!_file) return;
		// NN4, Opera6 は document.styleSheets を理解不能
		var title = (document.styleSheets && document.styleSheets.length > 0) ? document.styleSheets[0].title : null;
		title = (title) ? "title=" + title : null;
		var media = (!env.NN4) ? "media=screen,tv" : null;
		var cLINK = this.makeTag(
			"link",
			"rel=styleSheet",
			"type=text/css",
			"href=" + env.cssDir + _file,
			media,
			title,
			null
		);
		document.write(cLINK);
	}
}
var n2 = new nyan2Func();
var env = new envSet();
n2.loadCSS(env.patchCSS);

//クリックでFlash音停止

// Univeral method for javascript->flash setvariable
/* ------Supporting Browsers----------
PC:IE 5 and higher Netscape 6 and higher Moz/Firebird all Opera 7 and higher
Mac OSX:IE 5.2 Safari all Netscape 6 and higher Moz/Firebird/Camino all Opera 6 and higher
Linux: Konqueror assumed
----------------------------------------------------------- */
// Detection snippet from http://www.dithered.com/javascript/browser_detect/index.html

/* -----------------------------------------------------------
function setFlashVariables(movieid, flashquery)
movieid: id of object tag, name of movieid passed in through FlashVars
flashquery: querystring of values to set. example( var1=foo&var2=bar )
----------------------------------------------------------- */
var divcontainer;
function setFlashVariables(movieid, flashquery){
	//gateway.swfを呼び出している
	divcontainer = "flash_setvariables_"+movieid;
	if(!document.getElementById(divcontainer)){
		var divholder = document.createElement("div");
		divholder.id = divcontainer;
		document.body.appendChild(divholder);
	}
	//getElementById=ドキュメントの指定された識別子のエレメントオブジェクトを獲得します。
	document.getElementById(divcontainer).innerHTML = "";
	var divinfo = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width='1' height='1' id='gateway' align='middle'><param name='FlashVars' value='lc="+movieid+"&fq="+escape(flashquery)+"' /><param name='movie' value='/common2/pickup/gateway.swf' /><embed src='/common2/pickup/gateway.swf' FlashVars='lc="+movieid+"&fq="+escape(flashquery)+"' width='0' height='0' type='application/x-shockwave-flash'></embed></object>";
	document.getElementById(divcontainer).innerHTML = divinfo;
}

//top 別ウィンドウ
function openwin(url) {
 w = window.open(url, 'win','status=yes,location=yes,scrollbars=yes,directories=yes,menubar=yes,resizable=yes,toolbar=yes');
}


//このサイトの使い方　メニューオンマウス
if (document.images)
{
otoiawaseon = new Image();otoiawaseon.src = "/howtouse/img/btn_otoiawase_ov.gif";
otoiawaseoff = new Image();otoiawaseoff.src = "/howtouse/img/btn_otoiawase.gif";
suishoon = new Image();suishoon.src = "/howtouse/img/btn_suisho_ov.gif";
suishooff = new Image();suishooff.src = "/howtouse/img/btn_suisho.gif";
pluginon = new Image();pluginon.src = "/howtouse/img/btn_plugin_ov.gif";
pluginoff = new Image();pluginoff.src = "/howtouse/img/btn_plugin.gif";
baitaion = new Image();baitaion.src = "/howtouse/img/btn_baitai_ov.gif";
baitaioff = new Image();baitaioff.src = "/howtouse/img/btn_baitai.gif";
}
function imgOn(imgName){
if (document.images){
document[imgName].src = eval(imgName + "on.src");
}
}
function imgOff(imgName){
if (document.images){
document[imgName].src = eval(imgName + "off.src");
}
}

//aip mobileポップアップ
function mobileWin(){
	window.open("index_m.html","mobile","width=238,height=350,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no");
}

//aip iframeサイズ
function frame_check(){
 if(frame.document.body){
    f=frame.document.body.scrollHeight;
    if(f)
    document.getElementById("frame").height=f;
    setTimeout("frame_check()",100);
    }
    else{
    setTimeout("frame_check()",100);
 }
}
function locationReturn(){
	var str = top.location.search;
	var i = str.indexOf("?");
	var j = str.indexOf("&");
	if ( j != -1 ) {
		strkey = str.substr(j+1,str.length);
		str = str.substr(i+1,j-1);
	} else {
		str = str.substr(i+1,str.length);
	}
	if ( i != -1 ){
		if ( str == "sound" ){
			url = "frame.html";
		} else if ( str == "info" ) {
			if ( j != -1 ) {
				url = "m_info.html#" + strkey;
			} else {
				url = "m_info.html";
			}
		} else if ( str == "download" ) {
			url = "download/d1.html";
		} else if ( str == "uta" ) {
			url = "m_disco_uta.html";
		} else if ( str == "bio" ) {
			url = "m_bio.html";
		} else if ( str == "links" ) {
			url = "m_links.html";
		} else if ( str == "live" ) {
			url = "m_live.html";
		} else if ( str == "media" ) {
			url = "m_media.html";
		} else if ( str == "mobile" ) {
			url = "frame_mobile.html";
		} else if ( str.match(/^(http|https|ftp|file):\/\//) ){
			url = "frame.html";
			//str = "";
			//i = -1;
		} else {
			url = "frame.html";
		}
	} else {
		url = "frame.html";
	}
	return url;
}
function Agent(){
	myID = navigator.userAgent;
	if(myID.indexOf("Win") >= 0){
		document.write('<iframe src="'+locationReturn()+'" name="frame" id="frame" width="760" frameborder="0" scrolling="no"><noframes><p class="noFrame">このブラウザは対応していないため、このコンテンツを表示することができません。<br />ご覧になる場合は、<a href="m_disco.html">こちら</a>からご覧ください。</p></noframes></iframe>');
		setTimeout("frame_check()",10);
	}else{
		document.write('<iframe src="'+locationReturn()+'" name="frame" id="frame" width="760" height="800" frameborder="0" scrolling="auto"><noframes><p class="noFrame">このブラウザは対応していないため、このコンテンツを表示することができません。<br />ご覧になる場合は、<a href="m_disco.html">こちら</a>からご覧ください。</p></noframes></iframe>');
	}
}
top_html="/common/blank_aip.html";
function locationReturnRight(){
	str = top.location.search;
	i = str.indexOf("?");
	j = str.indexOf("&");
	if ( j != -1 ) {
		strkey = str.substr(j+1,str.length);
		str = str.substr(i+1,j-1);
	} else {
		str = str.substr(i+1,str.length);
	}
	pkg_str = location.search;
	pkg_i = pkg_str.indexOf("?");
	pkg_j = str.indexOf("&");
	if ( pkg_j != -1 ) {
		pkg_strkey = pkg_str.substr(pkg_j+1,pkg_str.length);
		pkg_str = pkg_str.substr(pkg_i+1,pkg_j-1);
	} else {
		pkg_str = pkg_str.substr(pkg_i+1,pkg_str.length);
	}
	if ( i != -1 ){
		if( str == "info" ||
			str == "sound" ||
			str == "download" ||
			str == "uta" ||
			str == "vc" ||
			str == "bio" ||
			str == "links" ||
			str == "live" ||
			str == "media" ||
			str == "mobile" ||
			str.match(/^(http|https|ftp|file):\/\//) ||
			str.match(/^(OVRAW)/)
		){
			url = top_html;
		}
		else{
			url = str + "/index.html";
		}
	} else {
		url = top_html;
	}
	if ( url == "/index.html" ) {
		if ( pkg_i > 0 && !pkg_str.match(/^(http|https|ftp|file):\/\//) ){
			url = pkg_str + "/index.html";
		} else {
			url = top_html;
		}
	}
	return url;
}
function AgentRight(){
	myID = navigator.userAgent;
	if(myID.indexOf("Win") >= 0){
		document.write('<iframe src="'+locationReturnRight()+'" width="520" height="800" frameborder="0" marginheight="0" marginwidth="0" scrolling="auto" name="main_right" id="main_right"><noframes><p class="noFrame">このブラウザは対応していないため、このコンテンツを表示することができません。<br />ご覧になる場合は、<a href="m_disco.html">こちら</a>からご覧ください。</p></noframes></iframe>');
	}else{
		document.write('<iframe src="'+locationReturnRight()+'" width="520" height="800" frameborder="0" marginheight="0" marginwidth="0" scrolling="auto" name="main_right" id="main_right"><noframes><p class="noFrame">このブラウザは対応していないため、このコンテンツを表示することができません。<br />ご覧になる場合は、<a href="m_disco.html">こちら</a>からご覧ください。</p></noframes></iframe>');
	}
}

// aip ディスコポップアップ
function subwin_disco(url){
wo=window.open(url,"mobile_subwin","width=545,height=485,left=0,top=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,favorites=no,resizable=no");
wo.focus();
}

function openInfo( hinban,dhinban,kind ){

	var url = "";	
	var mora_root   = "http://mora.jp/package/80307744/";
	var mora_win_root   = "http://morawin.jp/package/80312130/";

	var zeronum = new Array("","0","00","000","0000");

	if ( dhinban != "" ) {
		dhinban = dhinban.replace("-",zeronum[10 - dhinban.length]);
	} else {
		dhinban = hinban.substr(0,9);
	}

	// mora
	if( kind == "m" ) {
		url = mora_root + dhinban + "/";
		objWin = window.open( url, 'userWindow', '' );
		objWin.focus();
	}
	// mora win
	else if ( kind == "w" ){
		url = mora_win_root + dhinban + "/";
		objWin = window.open( url, 'userWindow', '' );
		objWin.focus();
	}
}

//for mobile
function doMail_hp(URL){

	window.location.href="mailto:?subject=ケータイサイト&body=あなたの携帯メールアドレスに送って、携帯からアクセスしよう!%0D%0A"+URL+"%0D%0A";

}

function doMail_uta_url(i, e, v){
	var url;

	url = "mailto:?subject=着うた(R)%20ダウンロードサイト&body=";
	if ( i != "" ){
		url += "●i-mode→%20http%3A%2F%2Fwww.sonymusicsound.jp%2Fsch%2Fuser%2FArtistPage%3Fs%3D30200%26c%3D0%26p%3D51%2B1%26at%3D" + i +"%26uid%3DNULLGWDOCOMO%0d%0a";
	}
	if ( e != "" ){
		url += "●EZweb→%20http%3A%2F%2Fwww.sonymusicsound.jp%2Fsch%2Fuser%2FArtistPage%3Fs%3D30200%26c%3D1%26p%3D51%2B1%26at%3D" + e +"%0d%0a";
	}
	if ( v != "" ){
		url += "●Yahoo!ケータイ→%20http%3A%2F%2Fwww.sonymusicsound.jp%2Fsch%2Fuser%2FArtistPage%3Fs%3D30200%26c%3D2%26p%3D51%2B1%26at%3D" + v +"%0d%0a";
	}

	window.location.href=url;
}

function doMail_full_url(i, e, v){
	var url;

	url = "mailto:?subject=着うたフル(R)%20ダウンロードサイト&body=";
	if ( i != "" ){
		url += "●i-mode→%20http%3A%2F%2Fwww.sonymusicsound.jp%2Fsch%2Fuser%2FArtistPage%3Fs%3D30201%26c%3D0%26p%3D51%2B1%26at%3D" + i +"%26uid%3DNULLGWDOCOMO%0d%0a";
	}
	if ( e != "" ){
		url += "●EZweb→%20http%3A%2F%2Fwww.sonymusicsound.jp%2Fsch%2Fuser%2FArtistPage%3Fs%3D30201%26c%3D1%26p%3D51%2B1%26at%3D" + e +"%0d%0a";
	}
	if ( v != "" ){
		url += "●Yahoo!ケータイ→%20http%3A%2F%2Fwww.sonymusicsound.jp%2Fsch%2Fuser%2FArtistPage%3Fs%3D30201%26c%3D2%26p%3D51%2B1%26at%3D" + v +"%0d%0a";
	}

	window.location.href=url;
}

function doMail_movie_url(i, e, v){
	var url;

	url = "mailto:?subject=着ムービー%2F着モーション%20ダウンロードサイト&body=";
	if ( i != "" ){
		url += "●i-mode→%20http%3A%2F%2Fwww.sonymusicsound.jp%2Fsch%2Fuser%2FArtistPage%3Fs%3D30200%26c%3D0%26p%3D51%2B1%26at%3D" + i +"%26uid%3DNULLGWDOCOMO%0d%0a";
	}
	if ( e != "" ){
		url += "●EZweb→%20http%3A%2F%2Fwww.sonymusicsound.jp%2Fsch%2Fuser%2FArtistPage%3Fs%3D30200%26c%3D1%26p%3D51%2B1%26at%3D" + e +"%0d%0a";
	}
	if ( v != "" ){
		url += "●Yahoo!ケータイ→%20http%3A%2F%2Fwww.sonymusicsound.jp%2Fsch%2Fuser%2FArtistPage%3Fs%3D30200%26c%3D2%26p%3D51%2B1%26at%3D" + v +"%0d%0a";
	}

	window.location.href=url;
}

function doMail_video_url(i, e, v){
	var url;

	url = "mailto:?subject=ビデオクリップ%20ダウンロードサイト&body=";
	if ( i != "" ){
		url += "●i-mode→%20http%3A%2F%2Fwww.sonymusicsound.jp%2Fsch%2Fuser%2FArtistPage%3Fs%3D30202%26c%3D0%26p%3D51%2B1%26at%3D" + i +"%26uid%3DNULLGWDOCOMO%0d%0a";
	}
	if ( e != "" ){
		url += "●EZweb→%20http%3A%2F%2Fwww.sonymusicsound.jp%2Fsch%2Fuser%2FArtistPage%3Fs%3D30202%26c%3D1%26p%3D51%2B1%26at%3D" + e +"%0d%0a";
	}
	if ( v != "" ){
		url += "●Yahoo!ケータイ→%20http%3A%2F%2Fwww.sonymusicsound.jp%2Fsch%2Fuser%2FArtistPage%3Fs%3D30202%26c%3D2%26p%3D51%2B1%26at%3D" + v +"%0d%0a";
	}

	window.location.href=url;
}

function doMail_call_url(i, e, v){
	var url;

	url = "mailto:?subject=待うた%2Fメロディコール%20ダウンロードサイト&body=";

	if ( i != "" ){
		url += "●i-mode→%20http%3A%2F%2Fsonymusiccall.jp%2Fmob%2Farti%2FartiShw.php%3Fsite%3Dcall%26cd%3D" + i +"%26uid%3DNULLGWDOCOMO%0d%0a";
	}
	if ( e != "" ){
		url += "●EZweb→%20http%3A%2F%2Fsonymusiccall.jp%2Fmob%2Farti%2FartiShw.php%3Fsite%3Dcall%26cd%3D" + e +"%0d%0a";
	}
	if ( v != "" ){
		url += "●Yahoo!ケータイ→%20http%3A%2F%2Fsonymusiccall.jp%2Fmob%2Farti%2FartiShw.php%3Fsite%3Dcall%26cd%3D" + v +"%0d%0a";
	}

	window.location.href=url;
}

function doMelody(ART_ID){

	window.location.href="mailto:?subject=着メロ%20ダウンロードサイト&body=●i-mode→%20http://i.labelmobile.com/lmi/src/a1/pa1_00_01.php%3fartid%3D003"+ART_ID+"%26uid%3DNULLGWDOCOMO%0D%0A●EZweb→%20http://ez.labelmobile.com/lme/src/a1/pa1_00_01.php%3fartid%3D003"+ART_ID+"%0D%0A●Yahoo!ケータイ→%20http://j.labelmobile.com/lmj/src/a1/pa1_00_01.php%3fartid%3D003"+ART_ID+"%26uid%3D1%26sid%3DAEZ9%0D%0A";

}

function doMail_uta(i, e, v){
	var url;

	url = "mailto:?subject=着うた(R)%20ダウンロードサイト&body=";
	if ( i != "" ){
		url += "●i-mode→%20http%3a%2f%2futa%2esonymusicsound%2ejp%2f30100%2f01%2f" + i +"%2f%3fuid%3dNULLGWDOCOMO%0d%0a";
	}
	if ( e != "" ){
		url += "●EZweb→%20http%3a%2f%2futa%2esonymusicsound%2ejp%2f30100%2f01%2f" + e +"%0d%0a";
	}
	if ( v != "" ){
		url += "●Yahoo!ケータイ→%20http%3a%2f%2futa%2esonymusicsound%2ejp%2f30100%2f01%2f" + v +"%0d%0a";
	}

	window.location.href=url;
}

function doMail_full(i, e, v){
	var url;

	url = "mailto:?subject=着うたフル(R)%20ダウンロードサイト&body=";
	if ( i != "" ){
		url += "●i-mode→%20http%3a%2f%2ffull%2esonymusicsound%2ejp%2f30100%2f01%2f" + i +"%2f%3fuid%3dNULLGWDOCOMO%0d%0a";
	}
	if ( e != "" ){
		url += "●EZweb→%20http%3a%2f%2ffull%2esonymusicsound%2ejp%2f30100%2f01%2f" + e +"%0d%0a";
	}
	if ( v != "" ){
		url += "●Yahoo!ケータイ→%20http%3a%2f%2ffull%2esonymusicsound%2ejp%2f30100%2f01%2f" + v +"%0d%0a";
	}

	window.location.href=url;
}

function doMail_movie(i, e, v){
	var url;

	url = "mailto:?subject=着ムービー%2F着モーション%20ダウンロードサイト&body=";
	if ( i != "" ){
		url += "●i-mode→%20http%3a%2f%2futa%2esonymusicsound%2ejp%2f30100%2f01%2f" + i +"%2f%3fuid%3dNULLGWDOCOMO%0d%0a";
	}
	if ( e != "" ){
		url += "●EZweb→%20http%3a%2f%2futa%2esonymusicsound%2ejp%2f30100%2f01%2f" + e +"%0d%0a";
	}
	if ( v != "" ){
		url += "●Yahoo!ケータイ→%20http%3a%2f%2futa%2esonymusicsound%2ejp%2f30100%2f01%2f" + v +"%0d%0a";
	}

	window.location.href=url;
}

function doMail_video(i, e, v){
	var url;

	url = "mailto:?subject=ビデオクリップ%20ダウンロードサイト&body=";
	if ( i != "" ){
		url += "●i-mode→%20http%3a%2f%2fmov%2esonymusicsound%2ejp%2f30100%2f01%2f" + i +"%2f%3fuid%3dNULLGWDOCOMO%0d%0a";
	}
	if ( e != "" ){
		url += "●EZweb→%20http%3a%2f%2fmov%2esonymusicsound%2ejp%2f30100%2f01%2f" + e +"%0d%0a";
	}
	if ( v != "" ){
		url += "●Yahoo!ケータイ→%20http%3a%2f%2fmov%2esonymusicsound%2ejp%2f30100%2f01%2f" + v +"%0d%0a";
	}

	window.location.href=url;
}

function doMail_call(i, e, v){
	var url;

	url = "mailto:?subject=待うた%2Fメロディコール%20ダウンロードサイト&body=";
	if ( i != "" ){
		url += "●i-mode→%20http%3a%2f%2fcall%2esonymusiccall%2ejp%2f30100%2f01%2f" + i +"%2f%3fuid%3dNULLGWDOCOMO%0d%0a";
	}
	if ( e != "" ){
		url += "●EZweb→%20http%3a%2f%2fcall%2esonymusiccall%2ejp%2f30100%2f01%2f" + e +"%0d%0a";
	}
	if ( v != "" ){
		url += "●Yahoo!ケータイ→%20http%3a%2f%2fcall%2esonymusiccall%2ejp%2f30100%2f01%2f" + v +"%0d%0a";
	}

	window.location.href=url;
}


//for shop
function openShop( url_shop ){
	data = url_shop.match(/^http:\/\//gi);
	if (! data){
		url_shop= "http://www.sonymusicshop.jp/detail.asp?associate=SMO&goods="+url_shop;
	}
	objWin = window.open( url_shop, 'shopWindow', '' );
	objWin.focus();
}
//for otoframe
function openOtoframe( of_hinban ){
	of_hinban = "http://otoframe.sonymusic.co.jp/ui/otoframe.html?" + of_hinban;
	objWin = window.open(of_hinban, 'otoframe','');
}

//for otoframeA
function openOtoframeA( of_artid ){
	of_artid = "http://otoframe.sonymusic.co.jp/ui/otoframe_a.html?" + of_artid;
	objWin = window.open(of_artid, 'otoframe','');
}

