﻿
/*====================================================================
 * Flash用 EMBEDとOBJECTタグを書き出す関数2          useFree
 *--------------------------------------------------------------------
 * http://allabout.co.jp/computer/javascript/closeup/CU20031226/
 */

function writeFlash( arg )
{
  
  /**
   * 引数から属性を抽出する
   */
   
  var parm = []
  
  //すべての引数を順番に
  for( i = 0 ; i < arguments.length ; i++ )
  {
    //属性名と属性値をあらわす文字列を配列parmへセットする(半角空白は除去)
    parm[i] = arguments[i].split(' ').join('').split('=')
    
    //有効な属性名があれば属性値で変数化( 無効な名前は無視 )
    switch (parm[i][0])
    {
      case '_swf'     : var _swf     = parm[i][1] ; break ; // フラッシュのURL
      case '_quality' : var _quality = parm[i][1] ; break ; // 画質
      case '_loop'    : var _loop    = parm[i][1] ; break ; // 繰り返し
      case '_bgcolor' : var _bgcolor = parm[i][1] ; break ; // 背景色
      case '_wmode'   : var _wmode   = parm[i][1] ; break ; // 背景透明(WinIEのみ)
      case '_play'    : var _play    = parm[i][1] ; break ; // 自動再生
      case '_menu'    : var _menu    = parm[i][1] ; break ; // 右クリックメニュー
      case '_scale'   : var _scale   = parm[i][1] ; break ; // 幅高さが%の時の縦横比等
      case '_salign'  : var _salign  = parm[i][1] ; break ; // 表示領域内表示位置
      case '_height'  : var _height  = parm[i][1] ; break ; // ムービーの高さ
      case '_width'   : var _width   = parm[i][1] ; break ; // ムービーの幅
      case '_hspace'  : var _hspace  = parm[i][1] ; break ; // まわりの余白(水平方向)
      case '_vspace'  : var _vspace  = parm[i][1] ; break ; // まわりの余白(垂直方向)
      case '_align'   : var _align   = parm[i][1] ; break ; // 表示位置
      case '_class'   : var _class   = parm[i][1] ; break ; // クラス
      case '_id'      : var _id      = parm[i][1] ; break ; // ID名
      case '_name'    : var _name    = parm[i][1] ; break ; // ムービー名
      case '_style'   : var _style   = parm[i][1] ; break ; // スタイル
      case '_declare' : var _declare = parm[i][1] ; break ; // 読み込まれるだけで実行しない
      default        :;
    }
  }
  

  // flash
  var htm = ""
  
  htm+="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'"
  htm+="        codebase='http://download.macromedia.com/pub/shockwave/"
                    htm+="cabs/flash/swflash.cab'"
  if(!!_width)   htm+="        width    = '" + _width   + "'"
  if(!!_height)  htm+="        height   = '" + _height  + "'"
  if(!!_hspace)  htm+="        hspace   = '" + _hspace  + "'"
  if(!!_vspace)  htm+="        vspace   = '" + _vspace  + "'"
  if(!!_align)   htm+="        align    = '" + _align   + "'"
  if(!!_class)   htm+="        class    = '" + _class   + "'"
  if(!!_id)      htm+="        id       = '" + _id      + "'"
  if(!!_name)    htm+="        name     = '" + _name    + "'"
  if(!!_style)   htm+="        style    = '" + _style   + "'"
  if(!!_declare) htm+="                    " + _declare  
  htm+=">"
  if(!!_swf)     htm+="<param  name     = 'movie'   value ='" + _swf     + "'>"
  if(!!_quality) htm+="<param  name     = 'quality' value ='" + _quality + "'>"
  if(!!_loop)    htm+="<param  name     = 'loop'    value ='" + _loop    + "'>"
  if(!!_bgcolor) htm+="<param  name     = 'bgcolor' value ='" + _bgcolor + "'>"
  if(!!_play)    htm+="<param  name     = 'play'    value ='" + _play    + "'>"
  if(!!_menu)    htm+="<param  name     = 'menu'    value ='" + _menu    + "'>"
  if(!!_scale)   htm+="<param  name     = 'scale'   value ='" + _scale   + "'>"
  if(!!_salign)  htm+="<param  name     = 'salign'  value ='" + _salign  + "'>"
  if(!!_wmode)   htm+="<param  name     = 'wmode'   value ='" + _wmode   + "'>"
  htm+=""
  htm+="<embed                          "
  htm+="        pluginspage='http://www.macromedia.com/go/getflashplayer'"
  if(!!_width)   htm+="        width    = '" + _width   + "'"
  if(!!_height)  htm+="        height   = '" + _height  + "'"
  if(!!_hspace)  htm+="        hspace   = '" + _hspace  + "'"
  if(!!_vspace)  htm+="        vspace   = '" + _vspace  + "'"
  if(!!_align)   htm+="        align    = '" + _align   + "'"
  if(!!_class)   htm+="        class    = '" + _class   + "'"
  if(!!_id)      htm+="        id       = '" + _id      + "'"
  if(!!_name)    htm+="        name     = '" + _name    + "'"
  if(!!_style)   htm+="        style    = '" + _style   + "'"
  htm+="        type     = 'application/x-shockwave-flash' "
  if(!!_declare) htm+="                    " + _declare  
  if(!!_swf)     htm+="        src      = '" + _swf     + "'"
  if(!!_quality) htm+="        quality  = '" + _quality + "'"
  if(!!_loop)    htm+="        loop     = '" + _loop    + "'"
  if(!!_bgcolor) htm+="        bgcolor  = '" + _bgcolor + "'"
  if(!!_play)    htm+="        play     = '" + _play    + "'"
  if(!!_menu)    htm+="        menu     = '" + _menu    + "'"
  if(!!_scale)   htm+="        scale    = '" + _scale   + "'"
  if(!!_salign)  htm+="        salign   = '" + _salign  + "'"
  htm+="></embed>"
  htm+="</object>"

  //書き出し処理
  document.write(htm)
  
}

// JavaScript Document


//ロールオーバー
function initRollOverImages() {
  var image_cache = new Object();
  $("img.swap").each(function(i) {
    var imgsrc = this.src;
    var dot = this.src.lastIndexOf('.');
    var imgsrc_r = this.src.substr(0, dot) + '_r' + this.src.substr(dot, 4);
    image_cache[this.src] = new Image();
    image_cache[this.src].src = imgsrc_r;
    $(this).hover(
      function() { this.src = imgsrc_r; },
      function() { this.src = imgsrc; });
  });
}

//ページ内移動
$(document).ready(initRollOverImages);

function backToTop() {
  var x1 = x2 = x3 = 0;
  var y1 = y2 = y3 = 0;
  if (document.documentElement) {
      x1 = document.documentElement.scrollLeft || 0;
      y1 = document.documentElement.scrollTop || 0;
  }
  if (document.body) {
      x2 = document.body.scrollLeft || 0;
      y2 = document.body.scrollTop || 0;
  }
  x3 = window.scrollX || 0;
  y3 = window.scrollY || 0;
  var x = Math.max(x1, Math.max(x2, x3));
  var y = Math.max(y1, Math.max(y2, y3));
  window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));
  if (x > 0 || y > 0) {
      window.setTimeout("backToTop()", 25);
  }
}


//フォントサイズ変更
function class_cookielib(){ 
this.getCookie = getCookie; 
this.setCookie = setCookie; 
this.removeCookie = removeCookie; 

var expireDate = new Date(); 
expireDate.setFullYear(expireDate.getFullYear()+1); 
expireStr = "expires=" + expireDate.toUTCString(); 

function getCookie(name){ 
var gc=name+"="; 
var Cookie=document.cookie; 
if (Cookie.length>0) { 
var start=Cookie.indexOf(gc); 
if (start!=-1) { 
start+=gc.length; 
terminus=Cookie.indexOf(";",start); 
if (terminus==-1) terminus=Cookie.length; 
return unescape(Cookie.substring(start,terminus)); 
} 
} 
return ''; 
} 
function setCookie() { 
var key = arguments[0]; 
var val = arguments[1]; 
var path = (typeof(arguments[2]) != 'undefined' ? arguments[2] : '/'); 
var exp = (typeof(arguments[3]) != 'undefined' ? arguments[3] : expireStr); 
var sc = key + "=" + escape(val) + "; path=" + path + "; " + exp; 
document.cookie = sc; 
} 
function removeCookie(key,path) { 
if(!path){ 
path = '/'; 
} 
var rc = key + "=; path=" + path + "; expires=Thu, 1 Jan 1970 00:00:00 UTC"; 
document.cookie = rc; 
} 
} 
var cookieObj = new class_cookielib(); 

function onresize_handler(){ 
if(document.layers){ 
window.location.reload(); 
} 
} 
window.onresize = onresize_handler; 

var txtsize_val = 1; 
var txtsize_css_size = new Array(); 
txtsize_css_size[0] = '70%';
txtsize_css_size[1] = '100%';
txtsize_css_size[2] = '110%';
function setTextSize(){ 
if(cookieObj.getCookie('txtsize') != ''){ 
txtsize_val = 1 * cookieObj.getCookie('txtsize'); 
} 
document.write('<style type="text/css">'); 
document.write('* body { font-size:' + txtsize_css_size[txtsize_val] + '; }'); 
document.write('</style>'); 
} 

function changeTextSize(num){ 
var fl_update = false; 
var tmp_val = txtsize_val + num; 
if(tmp_val >= 0 && tmp_val < txtsize_css_size.length){ 
txtsize_val = tmp_val; 
fl_update = true; 
} 
if(fl_update){ 
cookieObj.setCookie('txtsize',txtsize_val,'/',''); 
window.location.reload(); 
} 
} 

function defaultTextSize(){ 
var fl_update = false; 
var tmp_val = 1; 
if(tmp_val >= 0 && tmp_val < txtsize_css_size.length){ 
txtsize_val = tmp_val; 
fl_update = true; 
} 
if(fl_update){ 
cookieObj.setCookie('txtsize',txtsize_val,'/',''); 
window.location.reload(); 
} 
} 


//新規ウィンドウ固定
function winOpen(url,window_name){
window.open(url,"syuri");
}

//ウインドウを閉じる
function close_win(){
var nvua = navigator.userAgent;
if(nvua.indexOf('MSIE') >= 0){
if(nvua.indexOf('MSIE 5.0') == -1) {
top.opener = '';
}
}
else if(nvua.indexOf('Gecko') >= 0){
top.name = 'CLOSE_WINDOW';
wid = window.open('','CLOSE_WINDOW');
}
top.close();
}
