<!--

//ページ読み込み時のログイン状態(true=ログイン中/false=未ログイン)
var type1LoginStatusOnLoad = false;
try{
  type1LoginStatusOnLoad = window.external.userLoggedIn;
}catch(e){
}

///---------- Time Format -----------///

function timeformat(time){
    
    if (time!="&nbsp;" && time>0){
    tm=parseInt(time);
    n=Math.ceil(tm/60)-1;
    m=tm%60;
    if(m == 0){
        n=n+1;
    }
    if(m<10){ m = "0"+m; }
        document.write(n+":"+m);
    }else{
        document.write("-");
    }
}

///------ Search Request Header -------///
function search_request_header(TYP,evt){
  var Form = document.search_form_header;
  
  if(evt){
    if(Form.NAME_WORD.value == "" || Form.NAME_WORD.value == 'キーワード入力'){
      Form.NAME_WORD.value = 'キーワード入力';
      Form.NAME_WORD.select();
      if(evt.preventDefault){
        evt.preventDefault();
      }else{
        evt.returnValue = false;
      }
    }
  }
  
  if(TYP == 'ARTIST'){
    Form.action = "/servlet/ArtistFinder";
    Form.TEMPLATE.value = "art_srch_nm_rslt.html";
  }else if(TYP == 'PACKAGE'){
    Form.action = "/servlet/PackageFinder";
    Form.TEMPLATE.value = "package_search_result.html";
    Form.TITLE_WORD.value = Form.NAME_WORD.value;
    Form.NAME_WORD.name = "";
    Form.WORD_KIND.name = "";
    Form.GENERAL_WORD.name = "";
  }else if(TYP == 'TITLE'){
    Form.action = "/servlet/TrackFinder";
    Form.TEMPLATE.value = "track_search_result.html";
    Form.WORD_KIND.value = 'TITLE';
    Form.GENERAL_WORD.value = Form.NAME_WORD.value;
    Form.NAME_WORD.name = "";
    
  }else if(TYP == 'TITLE_AUDIO'){
    Form.action = "/servlet/TrackFinder";
    Form.TEMPLATE.value = "track_search_result.html";
    Form.WORD_KIND.value = 'TITLE_AUDIO';
    Form.GENERAL_WORD.value = Form.NAME_WORD.value;
    Form.AV_FLG.value = "0";
    Form.NAME_WORD.name = "";
    
  }else if(TYP == 'TITLE_VIDEO'){
    Form.action = "/servlet/TrackFinder";
    Form.TEMPLATE.value = "track_search_result.html";
    Form.WORD_KIND.value = 'TITLE_VIDEO';
    Form.GENERAL_WORD.value = Form.NAME_WORD.value;
    Form.AV_FLG.value = "1";
    Form.NAME_WORD.name = "";
    
  }else if(TYP == 'KEYWORD'){
    Form.action = "/servlet/TrackFinder";
    Form.TEMPLATE.value = "track_search_result.html";
    Form.WORD_KIND.value = 'KEYWORD';
    Form.GENERAL_WORD.value = Form.NAME_WORD.value;
    Form.NAME_WORD.name = "";
  }else{
    Form.action = "/servlet/TrackFinder";
    Form.TEMPLATE.value = "track_search_result.html";
    Form.WORD_KIND.value = 'KEYWORD';
    Form.GENERAL_WORD.value = Form.NAME_WORD.value;
    Form.NAME_WORD.name = "";
  }
  
  return true;
}


///------ Search Request Footer -------///
function search_request_footer(TYP,evt){
  var Form = document.search_form_footer;
  
  if(evt){
    if(Form.NAME_WORD.value == "" || Form.NAME_WORD.value == 'キーワード入力'){
      Form.NAME_WORD.value = 'キーワード入力';
      Form.NAME_WORD.select();
      if(evt.preventDefault){
        evt.preventDefault();
      }else{
        evt.returnValue = false;
      }
    }
  }
  
  if(TYP == 'ARTIST'){
    Form.action = "/servlet/ArtistFinder";
    Form.TEMPLATE.value = "art_srch_nm_rslt.html";
  }else if(TYP == 'PACKAGE'){
    Form.action = "/servlet/PackageFinder";
    Form.TEMPLATE.value = "package_search_result.html";
    Form.TITLE_WORD.value = Form.NAME_WORD.value;
    Form.NAME_WORD.name = "";
    Form.WORD_KIND.name = "";
    Form.GENERAL_WORD.name = "";
  }else if(TYP == 'TITLE'){
    Form.action = "/servlet/TrackFinder";
    Form.TEMPLATE.value = "track_search_result.html";
    Form.WORD_KIND.value = 'TITLE';
    Form.GENERAL_WORD.value = Form.NAME_WORD.value;
    Form.NAME_WORD.name = "";

  }else if(TYP == 'TITLE_AUDIO'){
    Form.action = "/servlet/TrackFinder";
    Form.TEMPLATE.value = "track_search_result.html";
    Form.WORD_KIND.value = 'TITLE';
    Form.GENERAL_WORD.value = Form.NAME_WORD.value;
    Form.AV_FLG.value = "0";
    Form.NAME_WORD.name = "";
    
  }else if(TYP == 'TITLE_VIDEO'){
    Form.action = "/servlet/TrackFinder";
    Form.TEMPLATE.value = "track_search_result.html";
    Form.WORD_KIND.value = 'TITLE';
    Form.GENERAL_WORD.value = Form.NAME_WORD.value;
    Form.AV_FLG.value = "1";
    Form.NAME_WORD.name = "";
    
  }else if(TYP == 'KEYWORD'){
    Form.action = "/servlet/TrackFinder";
    Form.TEMPLATE.value = "track_search_result.html";
    Form.WORD_KIND.value = 'KEYWORD';
    Form.GENERAL_WORD.value = Form.NAME_WORD.value;
    Form.NAME_WORD.name = "";
  }else{
    Form.action = "/servlet/TrackFinder";
    Form.TEMPLATE.value = "track_search_result.html";
    Form.WORD_KIND.value = 'KEYWORD';
    Form.GENERAL_WORD.value = Form.NAME_WORD.value;
    Form.NAME_WORD.name = "";
  }
  
  return true;
}


///------ ResetSearchBox -------///
function ResetSearchBox(p){
  var q;
  if(p == "search_form_header"){
    q = document.search_form_header;
  }else if(p == "search_form_footer"){
    q = document.search_form_footer;
  }
  if(q.NAME_WORD.value == 'キーワード入力'){
    q.NAME_WORD.value = "";
  }
}

///------ Focus SearchBox -------///
function FocusSearchBox(){
  //document.search_form_header.NAME_WORD.focus();
}

///---------- ProductID  -----------///
function pid(){
  
  if(document.URL.indexOf('PID=') > -1){
    var line_bgcolor='#f0b820';
    document.URL.match(/^.+\?.*PID\=([^\&]+)&*.*$/);
    var pid = RegExp.$1;
    pid = pid.replace(/\</g, "&lt;");
    pid = pid.replace(/\"/g, "&quot;");
    if(document.all){
      try{
        document.all(pid).style.backgroundColor = line_bgcolor;
        location.href='#_'+pid;
      }catch(e) {
        ;
      }
    }else{
      try{
        document.getElementById(pid).style.backgroundColor = line_bgcolor;
        location.href='#_'+pid;
      }catch(e2){
        ;
      }
    }
  }
  
}

///---------- ReleaseDateFormat -----------///
function releasedateformat(releasedate){
    
    tmp_releasedate = releasedate.replace(/\./g,"");
    
    today  = new Date();
    y = today.getFullYear();
    m = today.getMonth() + 1;
    d = today.getDate();
    if(m < 10){ m = "0" + m;}
    if(d < 10){ d = "0" + d;}
    tmp_today = y+m+d;
    
    if(tmp_releasedate < tmp_today){
      document.write("--");
    }else{
      document.write(releasedate+"リリース");
    }
}
///---------- ToppageInfoBar -----------///

function TopInfo(){
  
  var info_list  = new Array();
  info_list[0] = '<a href="/help/">[お知らせ] CONNECT Player, SonicStageをご利用のお客様へ</a>';
  info_list[1] = '<a href="/maintenance/">[お知らせ] サービス停止のお知らせ</a>';
  
  var cnt =  Math.floor(Math.random() * info_list.length); 
  var fade_scale = "30";
  var fade_timeout = "5000";
  
  var topinfo = document.getElementById("topinfomsg");
  topinfo_in();
  
  // MSG OUT
  function topinfo_out(){
    
    var fadeout_opacity = 100;
    var fadeout_timer;
    
    topinfo.style.filter = 'alpha(opacity=100 ,style=0)';
    topinfo.innerHTML = info_list[cnt]; 
    
    var func_topinfo_out = function(){
      fadeout_opacity = fadeout_opacity - fade_scale;
      if(fadeout_opacity <= 0){
        clearInterval(fadeout_timer);
        topinfo_in();
      }
      topinfo.style.filter = 'alpha(opacity=' + fadeout_opacity + ')';
      var non_ie_opacity = fadeout_opacity / 100;
      topinfo.style.mozOpacity = non_ie_opacity; //firefox
      topinfo.style.opacity = non_ie_opacity; //safari
      //topinfo.innerHTML = info_list[cnt];
      
    };
    fadeout_timer = setInterval(func_topinfo_out, 100);
    
  }
  
  // ---- MSG IN
  function topinfo_in(){
    
    if(cnt == info_list.length - 1){ cnt = "0"; }else{ cnt++;}
    
    var fadein_opacity = 0;
    var fadein_timer;
    
    topinfo.style.filter = 'alpha(opacity=0 ,style=0)';
    topinfo.innerHTML = info_list[cnt];
    
    var func_topinfo_in = function(){
      fadein_opacity = fadein_opacity + fade_scale;
      if(fadein_opacity >= 100){
        clearInterval(fadein_timer);
        var watch = setTimeout(topinfo_out, fade_timeout);
      }
      topinfo.style.filter = 'alpha(opacity=' + fadein_opacity + ')';
      var non_ie_opacity = fadein_opacity / 100;
      topinfo.style.mozOpacity = non_ie_opacity; //firefox
      topinfo.style.opacity = non_ie_opacity; //safari
      //topinfo.innerHTML = info_list[cnt];
      
    };
    fadein_timer = setInterval(func_topinfo_in, 100);
  }
  
}

///---------- Identity -----------///
function id(){
  
  /*  true: wmp
   *  false: browser
   */ 
  
  try{
    var g_oManager = external.DownloadManager;
    if(g_oManager==null){
      return false;
    }else{
      return true;
    }
  }catch(e){
    return false;
  }
  
}

///---------- Identity2 -----------///
function id2_org(){
  
  /*  true: OKブラウザ
   *  false: NGブラウザ
   */ 
  try{
    var g_oManager = external.DownloadManager;
    return true;
  }catch(e){
    return false;
  }
  return false;
}
///---------- Identity2 -----------///
function id2(){
  
  /*  true: OKブラウザ
   *  false: NGブラウザ
   */ 
  var u = navigator.userAgent;
  try{
    var g_oManager = window.external.DownloadManager;
    if(u.indexOf("MSIE 6", 0) > 0 || u.indexOf("MSIE 7", 0) > 0){
      return true;
    }else{
      return false;
    }
  }catch(e){
    return false;
  }
  return false;
}


///---------- photoSize -----------///
function photoSize(){
  
  try{
    photo = document.getElementById('product_photo');
    fix = 130;
    w = photo.width;
    h = photo.height;
    
    if(w == h && w > fix && h > fix){
      photo.width = fix;
      photo.height = fix;
    }else if(w > h && w > fix ){
      photo.width = fix;
      photo.height = Math.floor((fix/w) * h);
    }else if(w < h && h > fix ){
      photo.width = Math.floor((fix/h) * w);
      photo.height = fix;
    }
  }catch(e){
    ;
  }
}
///---------- mi_org  -----------///
var timer1;
function mi_org(){
  
  if(document.URL.indexOf('m=') > -1){
    var line_bgcolor='#f0b820';
    document.URL.match(/^[^\?]+\?.*m\=([^\&]+)&*.*$/);
    var pid = RegExp.$1;
    pid = pid.replace(/\</g, "&lt;");
    pid = pid.replace(/\"/g, "&quot;");
    var apid = "audition_"+pid;
    if(document.all){
      try{
        document.all(pid).style.backgroundColor = line_bgcolor;
        location.href='#_'+pid;
      }catch(e){}
      if(id()){
        try{
          if(document.all("audition_"+pid).href){
            location.href = document.all("audition_"+pid).href;
          }
        }catch(e){}
      }
    }else{
      try{
        document.getElementById(pid).style.backgroundColor = line_bgcolor;
        location.href='#_'+pid;
      }catch(e2){}
      if(id()){
        try{
          if(document.getElementById("audition_"+pid).href){
            location.href = document.getElementById("audition_"+pid).href;
          }
        }catch(e){}
      }
    }
  }
  
}
///--------------- mi  ---------------///
/*   mixi-type1連携対応版 2007/09/23  */
function mi(){
  var line_bgcolor='#f0b820';
  var pid;
  var flg = 0;
  
  //var debug="";
  
  if(document.URL.indexOf('m=') > -1){
    document.URL.match(/^[^\?]+\?.*m\=([^\&]+)&*.*$/);
    pid = RegExp.$1;
    pid = pid.replace(/\</g, "&lt;");
    pid = pid.replace(/\"/g, "&quot;");
    flg = 1;
    //debug += "-2: "+pid+"<br>";
  }else{
    pid = getCookieForMixi('mixiType1PID');
    if(pid){
      flg = 1;
    }
    //debug += "-1: "+pid+"<br>";
  }
  //debug += "1: "+pid+"<br>";
  
  if(flg){
    if(document.all){
      try{
        //document.all(pid).style.backgroundColor = line_bgcolor;
        location.href='#_'+pid;
        //debug += "2: "+'#_'+pid+"<br>";
      }catch(e){}
      if(id()){
        try{
          if(document.all("audition_"+pid).href){
            
            watch = setTimeout("to_audition('"+pid+"')", 50000);
            
            //location.href = document.all("audition_"+pid).href;
            //debug += "3: "+document.all("audition_"+pid).href+"<br>";
          }
        }catch(e){}
      }
    }else{
      try{
        //document.getElementById(pid).style.backgroundColor = line_bgcolor;
        location.href='#_'+pid;
        //debug += "4: "+'#_'+pid+"<br>";
      }catch(e2){}
      if(id()){
        try{
          if(document.getElementById("audition_"+pid).href){
            
            watch = setTimeout("to_audition('"+pid+"')", 50000);
            
            //location.href = document.getElementById("audition_"+pid).href;
            //debug += "5: "+document.getElementById("audition_"+pid).href+"<br>";
          }
        }catch(e){}
      }
    }
    setCookieForMixi("del");
  }
  
  //document.getElementById("mixi_stat").innerHTML = debug;
}
function to_audition(i){
  clearTimeout(watch);
  try{
    window.location.href = document.all("audition_"+i).href;
  }catch(e){
    window.location.href = document.getElementById("audition_"+i).href;
  }
}
///------------ topTopicsIcon ----------------///
function topTopicsIcon(){
  
  max = document.getElementById('topTopicsCnt').innerHTML;
  
  date = new Date();
  y = date.getFullYear();
  m = date.getMonth() + 1;
  d = date.getDate();
  if (m < 10) { m = "0" + m; }
  if (d < 10) { d = "0" + d; }
  today = y +""+ m +""+ d;
  
  
  for(n=0; n<max; n++){
    var searchstr = "\\.";
    var str1 = new RegExp(searchstr, "g");
    var str2 = "";
    var tmpdate = document.getElementById(n).firstChild.nodeValue;
    var displaydate = tmpdate.replace(str1,str2);
    if(parseInt(today) - parseInt(displaydate) < 3){
      document.getElementById(n).style.display = "";
      document.getElementById(n).innerHTML = '<img src="/image/ico_new.gif" alt="NEW" width="26" height="7">';
    }
  }
}


///------ onLoadEvent -------///
function onLoadEvent(){
  //document.search_form_header.NAME_WORD.focus();
  pid();
}
///------ onLoadTop -------///
function onLoadTop(){
  //floatingBanner();
  //topTopicsIcon();
}
///------ onLoadPkg -------///
function onLoadPkg(){
  photoSize();
  pid();
  mi();
}
///------ onLoadArt -------///
function onLoadArt(){
  photoSize();
  //floatingBanner();
}

///------ onLoadOther -------///
function onLoadOther(){
  //floatingBanner();
}


///----------- Get Version ------------///
///----------- mod for wmp12 20091009 ------------///
function getVersion() {
  try{
    version = window.external.version;
    majorVersion = version.substring(0,2);

    if(majorVersion == "10"){
      //WMP10の場合
      return "WMP10";
      
    }else if(majorVersion == "11"){
      //WMP11の場合
      return "WMP11";
      
    }else if(majorVersion == "12"){
      //WMP12の場合
      return "WMP12";
      
    }else{
      //その他の場合はIE扱い
      return "IE";
      
    }
  }catch(e){
    //その他の場合はIE扱い
    return "IE";
  }

}

///----------- Get ShopCd ------------///
///----------- mod for wmp12 20091009 ------------///

function getShopCd() {
  try{
    str = getVersion();

    if(str == "WMP10"){
      //WMP10の場合
      return "02";
      
    }else if(str == "WMP11"){
      //WMP11の場合
      return "03";
      
    }else if(str == "WMP12"){
      //WMP12の場合
      return "05";
      
    }else if(str == "IE"){
      //その他の場合はIE扱い
      return "01"; 
      
    }else{
      //その他の場合はIE扱い
      return "01"; 
    }
  }catch(e){
    //その他の場合はIE扱い
    return "01"; 
  }

}

///----------- Get ParamStr for Signin,Signout,AccountInfo ------------///

function getParamStrSignin(str1){

  shop_cd = str1;              //ショップコード
  portal_id = "LG0201";        //ポータルID
  url = document.URL;          //戻り値URL

  //URLの後ろに付与するパラメータ
  param = 'shop_cd='+shop_cd+'&portal_id='+portal_id+'&done='+encodeURIComponent(url);
  return param;
}

///----------- Get ParamStr for Purchase ------------///

function getParamStrPurchase(str1,str2,str3){

  shop_cd = str1;              //ショップコード
  portal_id = "LG0201";        //ポータルID
  url = document.URL;          //戻り値URL
  label_cd = str2;             //レーベルコード
  item_cd = str3;              //配信品番

  //URLの後ろに付与するパラメータ
  param = 'shop_cd='+shop_cd+'&label_cd='+label_cd+'&item_cd='+item_cd+'&portal_id='+portal_id+'&done='+encodeURIComponent(url);
  return param;
}

///----------- Get URL Param ------------///

function getUrlParam(prefix){
  //
  // http://xxx.yyy.zzz/aaa?name1=val1&nam2=val2&...
  //  getUrlParam("&") -> &name1=val1&nam2=val2&...
  //  getUrlParam()    ->  name1=val1&nam2=val2&...
  //
  str="";
  url=document.URL;
  if(url.indexOf('?') > -1){
    str=url.substr(url.indexOf('?')+1);
  }
  if(str != ""){
    str = ((prefix == null) ? "" : prefix) + str;
  }
  return str;
}


///----------- OnLoginChange Event --------------///
/*
 * ログイン状態変化イベントが発生した場合の処理
 */
try{
  external.OnLoginChange = loginchange;
}catch(e){
}
function loginchange() {
  try{
    //ページ読み込み時とログイン状態が異なる場合のみリロード
    if(type1LoginStatusOnLoad != window.external.userLoggedIn){
      location.reload();
    }
  }catch(e){
  }
}
///----------------------------------------------///

///----------- OnSendMessageComplete Event ------------///
try{
  external.OnSendMessageComplete = smc;
}catch(e){
}
function smc(msg, param, result) {
  if (msg == 'navigate')
    location.href = result;
}
///----------------------------------------------------///

// ------------ setCookieForMixi ------------------//
/*     mixi-Type1連携用クッキーに登録関数         */
/* 書式 : setCookieForMixi(cmd)                   */
/* 戻り値 : なし(void)                            */
/* 2007.09.23 / sakura                            */
function setCookieForMixi(cmd){
  
  myCookie = "mixiType1PID";
  myValue  = "";
  myMin    = 1; //分 
  
  //myMin
  // cmd:reg => myMin=1 , cmd:del => myMin=-1
  if(cmd == "reg"){
    myMin = 1;
  }else if(cmd == "del"){
    myMin = -1;
  }
  
  //myValue
  if(document.URL.indexOf('m=') > -1){
    document.URL.match(/^[^\?]+\?.*m\=([^\&]+)&*.*$/);
    myValue = RegExp.$1;
    myValue = myValue.replace(/\</g, "&lt;");
    myValue = myValue.replace(/\"/g, "&quot;");
  }
  //myValue = document.URL;
  
  myExp = new Date();
  myExp.setTime(myExp.getTime()+(myMin*24*60*60*1000));
  myItem = myCookie + "=" + escape(myValue) + ";";
  myExpires = "expires="+myExp.toGMTString();
  myPath = "path=/;";
  myDomain = "domain=.morawin.jp;";
  document.cookie =  myItem + myPath + myDomain + myExpires;
}
// ------------ getCookieForMixi ------------------//
/*      mixi-Type1連携用クッキー取り込み関数      */
/* 書式 : getCookieForMixi(クッキー名)            */
/* 戻り値 : 値(string)  null:該当なし             */
/* 2007.09.23 / sakura                            */
function getCookieForMixi(myCookie){
   myCookie = myCookie + "=";
   myValue = null;
   myStr = document.cookie + ";" ;
   myOfst = myStr.indexOf(myCookie);
   if (myOfst != -1){
      myStart = myOfst + myCookie.length;
      myEnd   = myStr.indexOf(";" , myStart);
      myValue = unescape(myStr.substring(myStart,myEnd));
   }
   return myValue;
}

///----------- SendMessage(loginchange) ------------///
///----------- mod for wmp12 20091009 ------------///
/*
 * ログイン状態変化をプラグインに通知する
 */
try{
  if(getVersion() == "WMP11" || getVersion() == "WMP12"){
    window.external.sendMessage('loginchange', '');
  }
}catch(e){
}
///----------------------------------------------------///

// -->

