// JavaScript Document

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}


//ブラウザウィンド

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}



// -*-javascript-*-
function writeFlashHTML( arg ) {
  for( i = 0 ; i < arguments.length ; i++ ) {
    var parm = arguments[i].split(' ').join('').split('=');
    var n = parm[0];
    var v = parm.slice(1).join('=');
    switch (n)
      {
      case '_swf'     : var _swf     = v; break;
      case '_quality' : var _quality = v; break;
      case '_loop'    : var _loop    = v; break;
      case '_bgcolor' : var _bgcolor = v; break;
      case '_wmode'   : var _wmode   = v; break;
      case '_play'    : var _play    = v; break;
      case '_menu'    : var _menu    = v; break;
      case '_scale'   : var _scale   = v; break;
      case '_salign'  : var _salign  = v; break;
      case '_height'  : var _height  = v; break;
      case '_width'   : var _width   = v; break;
      case '_hspace'  : var _hspace  = v; break;
      case '_vspace'  : var _vspace  = v; break;
      case '_align'   : var _align   = v; break;
      case '_class'   : var _class   = v; break;
      case '_id'      : var _id      = v; break;
      case '_name'    : var _name    = v; break;
      case '_style'   : var _style   = v; break;
      case '_declare' : var _declare = v; break;
      case '_FlashVars' : var _flashvars = v; break;
      }
  }
  var https = location.href.charAt(4) == 's';
  var html = '';
  html+='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"';
  if (https) {
    html+=' codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"';
  } else {
    html+=' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"';
  }
  if(!!_width)   html+=' width  = "' + _width   + '"';
  if(!!_height)  html+=' height = "' + _height  + '"';
  if(!!_hspace)  html+=' hspace = "' + _hspace  + '"';
  if(!!_vspace)  html+=' vspace = "' + _vspace  + '"';
  if(!!_align)   html+=' align  = "' + _align   + '"';
  if(!!_class)   html+=' class  = "' + _class   + '"';
  if(!!_id)      html+=' id     = "' + _id      + '"';
  if(!!_name)    html+=' name   = "' + _name    + '"';
  if(!!_style)   html+=' style  = "' + _style   + '"';
  if(!!_declare) html+='           ' + _declare;
  html+='>';
  if(!!_swf)     html+='<param name="movie"   value="' + _swf     + '">';
  if(!!_quality) html+='<param name="quality" value="' + _quality + '">';
  if(!!_loop)    html+='<param name="loop"    value="' + _loop    + '">';
  if(!!_bgcolor) html+='<param name="bgcolor" value="' + _bgcolor + '">';
  if(!!_play)    html+='<param name="play"    value="' + _play    + '">';
  if(!!_menu)    html+='<param name="menu"    value="' + _menu    + '">';
  if(!!_scale)   html+='<param name="scale"   value="' + _scale   + '">';
  if(!!_salign)  html+='<param name="salign"  value="' + _salign  + '">';
  if(!!_wmode)   html+='<param name="wmode"   value="' + _wmode   + '">';
  if(!!_flashvars) html+='<param name="FlashVars" value ="' + _flashvars + '">';

  html+='<embed ';
  if (https) {
    html+=' pluginspage="https://www.macromedia.com/go/getflashplayer"';
  } else {
    html+=' pluginspage="http://www.macromedia.com/go/getflashplayer"';
  }
  if(!!_width)   html+=' width  = "' + _width   + '"';
  if(!!_height)  html+=' height = "' + _height  + '"';
  if(!!_hspace)  html+=' hspace = "' + _hspace  + '"';
  if(!!_vspace)  html+=' vspace = "' + _vspace  + '"';
  if(!!_align)   html+=' align  = "' + _align   + '"';
  if(!!_class)   html+=' class  = "' + _class   + '"';
  if(!!_id)      html+=' id     = "' + _id      + '"';
  if(!!_name)    html+=' name   = "' + _name    + '"';
  if(!!_style)   html+=' style  = "' + _style   + '"';
  html+=' type   = "application/x-shockwave-flash"';
  if(!!_declare) html+=' ' + _declare;
  if(!!_swf)     html+=' src      = "' + _swf     + '"';
  if(!!_quality) html+=' quality  = "' + _quality + '"';
  if(!!_loop)    html+=' loop     = "' + _loop    + '"';
  if(!!_bgcolor) html+=' bgcolor  = "' + _bgcolor + '"';
  if(!!_play)    html+=' play     = "' + _play    + '"';
  if(!!_menu)    html+=' menu     = "' + _menu    + '"';
  if(!!_scale)   html+=' scale    = "' + _scale   + '"';
  if(!!_salign)  html+=' salign   = "' + _salign  + '"';
  if(!!_flashvars) html+=' FlashVars = "' + _flashvars  + '"';
  html+='></embed>';
  html+='</object>';
  document.write(html);
}


function set_form(){
  if (navigator.cookieEnabled) {
    var ua = navigator.userAgent.toUpperCase();
    var username = get_cookie('dbbs_username');
    var n = document.forms["form1"].length;
    for(var elName = 0; elName <n; elName++){
      if (mode == 'bbs') {
        if(document.forms["form1"][elName].name.match(/^name_/)){
          document.forms["form1"][elName].value = username;
          $(document.forms["form1"][elName].name+'_span').update(username);
        } else if (document.forms["form1"][elName].name.match(/^send_/)) {
          document.forms["form1"][elName].disabled = false;
        }
      } else if (mode == 'ml' || mode == 'hp') {
        if(document.forms["form1"][elName].name == 'name'){
          $('user_name').update(username);
          document.forms["form1"][elName].value = username;
        } else if (document.forms["form1"][elName].type == 'submit'){
          document.forms["form1"][elName].disabled = false;
        }
      }
    }
  }
}

function get_cookie(cookie_name){
  var ua = navigator.userAgent.toUpperCase();
  cookie_name += "=";
  var theCookie = document.cookie + ";";
  start = theCookie.indexOf(cookie_name);
  if (start != -1){
    end = theCookie.indexOf(";",start);
    return decodeURIComponent(theCookie.substring(start + cookie_name.length, end));
  }
  return false;
}
