//========================================================================================
//
//
//
//
//
//
//
//
//
//
//
//
//========================================================================================
  var dclickLock  = false;
  var art_id      = "";
  var art_ja      = "";
  var XMLroot     = "/xml/art/";

  // 引数分解
  var buffer = location.search.replace(/\?/,"");
  buffer = buffer.split(/&/);

  for (var i=0 ; i<buffer.length ; i++) {
	var query = buffer[i].split(/=/);
	art_id = query;
  }

  //送信用関数
  function loadFile()
  {
	if(!chkAjaBrowser()){ location.href='http://www.sonymusic.co.jp/otoframe/#spec' }
	var url = XMLroot + art_id + "/artist.xml";

	sendRequest(on_loadedXML,'','GET',url,true,true) 
  }
  
  
  //コールバック関数 ( 受信時に実行されます )
  function on_loadedXML(oj)
  {
    //responseXMLでレスポンスを取得
    var res  =  oj.responseXML

    //OPTION書き換え作業用オブジェクト
    resOj = new chgXMLtoHTMLOptions(res)
    
    resOj.addOptions()
  }

  //
  //読み込んだXMLのデータをもとにOPTIONを書き換えるメソッドを作成
  //
  function chgXMLtoHTMLOptions(xdoc){
  
    return {
    
      //XMLのtitleを連想配列で返します
      setItems : function (){

		var artist = xdoc.getElementsByTagName("artist");
		//var art_ja = artist[0].getElementsByTagName("art_ja");
		art_ja = artist[0].getElementsByTagName("art_ja");
		var art_dir  = artist[0].getElementsByTagName("art_dir");

        return { 'art_ja':art_ja,'art_dir':art_dir };
      
      },
  
      //XMLのデータからオプションを生成します
      addOptions : function (){
      
        //XMLデータのオブジェクトを受け取ります
        var data = this.setItems()

		// アーティスト名
        document.getElementById("aname").innerHTML= data.art_ja[0].firstChild.nodeValue;
 	    document.getElementById("hidden").innerHTML = '<input type="hidden" name="art_dir" value="' + data.art_dir[0].firstChild.nodeValue + '">' + 
		                                              '<input type="hidden" name="art_id" value="' + art_id + '">';

      }
      
      
    }

  }

  function confirCheck(){

	var exec_print = true;

	for( var i=0 ; i<document.main.elements.length ; i++ ){
			if ( document.main.elements[i].type == "radio" ||
					 document.main.elements[i].type == "button" ||
					 document.main.elements[i].type == "reset" || 
					 document.main.elements[i].type == "tflash" ) continue;
			document.main.elements[i].style.background = "#ffffff";
	}

	// User Domain Check 
	var url = "";
	for( var i=0 ; i<document.main.kubun.length ; i++ ){
		if ( document.main.kubun[i].checked ){
			var kubun = document.main.kubun[i].value;
			if ( kubun == 1 ){
				if ( document.main.domain1.selectedIndex == 0 ){
					document.main.domain1.style.background = "#ffff66";
					exec_print = false;
				}
				else {
				}
				if ( document.main.hp1.value == "" ){
					document.main.hp1.style.background     = "#ffff66";
					exec_print = false;
				}
			  if ( document.main.domain1.selectedIndex != 0 && document.main.hp1.value != "" ){
					url = 'http://' +
					  document.main.domain1[document.main.domain1.selectedIndex].text + "/" +
					  document.main.hp1.value + "/";
				}
			}
			else if ( kubun == 2){
				if ( document.main.subdomain.value == "" ){
					document.main.subdomain.style.background = "#ffff66";
					exec_print = false;
				}
				if ( document.main.domain2.selectedIndex == 0 ){
					document.main.domain2.style.background   = "#ffff66";
					exec_print = false;
				}
//				if ( document.main.hp2.value == "" ){
//					document.main.hp2.style.background       = "#ffff66";
//					exec_print = false;
//				}

				if ( document.main.subdomain.value != "" && document.main.domain2.selectedIndex != 0 ){
					url = 'http://' +
					  document.main.subdomain.value + "." +
					  document.main.domain2[document.main.domain2.selectedIndex].text + "/";
//				  document.main.hp2.value + "/";
				}
			}
			else if ( kubun == 3){
				if ( document.main.domain3.value == '' ||
							document.main.domain3.value.length < 4 ||
							document.main.domain3.value.indexOf(".")<0 ){
					document.main.domain3.style.background = "#ffff66";
					exec_print = false;
				}
				else {
					url = 'http://' + document.main.domain3.value + "/";
					if ( document.main.hp3.value != "" ){
						url = url + document.main.hp3.value;
					} 
				}
			}
			break;
		}
	}
	if ( i == document.main.kubun.length || url == "" ){
		url = '<font color="#ff0000">' +"登録するURLを選択または、入力してください" + '</font>';
		exec_print = false;
	}

	// User e-mail Adress Check
//	var email = "";
//	if ( document.main.email.value == "" ){
//		document.main.email.style.background = "#ffff66";
//		email = '<font color="#ff0000">' +"メールアドレスを入力してください" + '</font>';
//		exec_print = false;
//	}
//	else {
//		email = document.main.email.value;
//	}

	// Skin CHeck
	var skin = 1;
	for (var i=0 ; i<document.main.skin.length ; i++ ){
		if ( document.main.skin[i].checked ) {
			skin = document.main.skin[i].value;
			break;
		}
	}
	//check flash type and set size
	var flash_width=320;
	var flash_height=107;
	var confirm_img=1;
	if(skin > 6 && skin <= 9){
		flash_width=140;
		flash_height=215;
	}else if(skin > 100 && skin <= 109){
		flash_width=142;
		flash_height=268;
		confirm_img=2;
	}else if(skin > 200 && skin <= 202){
	//エアロスミス
		flash_width=142;
		flash_height=268;
		confirm_img=2;
	}else if(skin > 202 && skin <= 204){
	//オアシス
		flash_width=142;
		flash_height=268;
		confirm_img=2;
	}else if(skin > 204 && skin <= 206){
	//ジャミロクワイ
		flash_width=142;
		flash_height=326;
		confirm_img=2;
	}else if(skin > 206 && skin <= 207){
	//オレンジレンジ
		flash_width=138;
		flash_height=374;
		confirm_img=2;
	}else if(skin > 208 && skin <= 210){
	//奥田民生
		flash_width=142;
		flash_height=272;
		confirm_img=2;
	}else if(skin > 210 && skin <= 212){
	//SunSet Swish
		flash_width=142;
		flash_height=289;
		confirm_img=2;
	}else if(skin > 212 && skin <= 214){
	//DEPAPEPE
		flash_width=142;
		flash_height=301;
		confirm_img=2;
	}else if(skin > 214 && skin <= 216){
	//L'Arc～en～Ciel
		flash_width=142;
		flash_height=303;
		confirm_img=2;
	}else if(skin > 216 && skin <= 218){
	//YUKI
		flash_width=138;
		flash_height=374;
		confirm_img=2;
	}else if(skin > 218 && skin <= 220){
	//YUKIファイブスター
		flash_width=138;
		flash_height=374;
		confirm_img=2;
	}else if(skin > 220 && skin <= 222){
	//「民カバ」「ユニトリ」スペシャルブログパーツ
		flash_width=143;
		flash_height=356;
		confirm_img=2;
	}else{
		//他のサイズを随時追加
	}
	//
	document.getElementById("confirm").innerHTML  = "" + 
			'<a name="kakunin"></a><img src="/common/image/bar_kakunin.gif" alt="登録内容確認" border="0" width="730" height="17" class="bars" /><br />' +
			'<div class="detail"><span class="touroku_kakunin">登録内容を確認してください。<br />やり直す場合は、入力し直してもう一度「登録確認」ボタンを押してください。<br /></span></div>' +
			'<table cellpadding="0" cellspacing="0" border="0" class="confirm_steps">' +
			'<tr><td class="confirm_01_l"><img src="/common/image/confirm_01_' + confirm_img +'.gif" border="0" /></td><td class="confirm_01_r">' +
				art_ja[0].firstChild.nodeValue +
			'</td></tr>' + 
			'<tr>' +
			'<td class="confirm_02_l"><img src="/common/image/confirm_02.gif" alt="登録URL" border="0" width="53" height="11" /></td><td class="confirm_02_r">' +
				url +
			'</td></tr>' +
			'<tr>' +
			'<td class="confirm_03_l"><img src="/common/image/confirm_03.gif" alt="デザイン" border="0" width="48" height="11" /></td><td class="confirm_03_r">' +
				'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+flash_width+'" height="'+flash_height+'" id="sendmovie" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"><param name="wmode" value="transparent" /><param name="movie" value="/common/sample_otoframe/l_' + skin + '.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#000000" /><param name="allowScriptAccess" value="movieid=sendmovie" /><param name="menu" value="false"><embed src="/common/sample_otoframe/l_' + skin + '.swf" FlashVars="movieid=sendmovie" quality="high" bgcolor="#000000" width="'+flash_width+'" height="'+flash_height+'" name="sample_otoframe" aligh="middle" quality="high" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent"></embed></object>' +
			'</td></tr>' +
			'</table>';


	// 全てOKならば登録実行ボタンの表示
	if ( exec_print ){
		var execButton = '<img src="/common/image/bar_kiyaku.gif" alt="利用規約" border="0" width="730" height="17" class="bars" /><br /><iframe src="kiyaku.html" width="530" height="200" frameborder="0" marginheight="0" marginwidth="0" scrolling="auto" name="kiyaku" id="kiyaku" class="kiyaku"><noframes><p class="noFrame">このブラウザは対応していないため、このコンテンツを表示することができません。<br />ご覧になる場合は、<a href="m_disco.html">こちら</a>からご覧ください。</p></noframes></iframe><br /><input type="image" src="/common/image/btn_agreee.gif" name="" value="同意して登録">';
		document.getElementById("exec").innerHTML  = execButton;
	}
   scrollTo(0,document.getElementById("confirm").offsetTop); 
  }


  function focusIn(kubun){
		document.getElementById("confirm").innerHTML  = "";
		document.getElementById("exec").innerHTML     = "";

		for( var i=0 ; i<document.main.kubun.length ; i++ ){
			if ( document.main.kubun[i].value == kubun ){
				document.main.kubun[i].checked = true;
				break;
			}
		}
  }

  function selectSkin(my){
		for (var i=0 ; i<document.images.length ; i++ ){
			if ( document.images[i].name == my ){
				document.images[i].style.border = "1px solid #ff0000";
			}
			else {
				document.images[i].style.border = "0px solid #000000";
			}
		}
		focusIn(0);
	}

  function clearAll(){
		document.getElementById("confirm").innerHTML  = "";
		document.getElementById("exec").innerHTML     = "";
		for (var i=0 ; i<document.images.length ; i++ ){
				document.images[i].style.border = "0px solid #000000";
		}

		for( var i=0 ; i<document.main.elements.length ; i++ ){
			if ( document.main.elements[i].type == "radio" ||
					 document.main.elements[i].type == "button" ||
					 document.main.elements[i].type == "reset" ||
					 document.main.elements[i].type == "tflash" ) continue;
			document.main.elements[i].style.background = "#ffffff";
	}
  }

