// JavaScript Document

//
// New Text 
//
function NewText (nen,tsuki,hi) {
	koushinbi = new Date (nen,tsuki-1,hi);
	genzai    = new Date ();
	kikan     = (genzai - koushinbi)/(1000*60*60*24);
	if (kikan <= 14) {
		document.write ('<FONT color="orange">&nbsp;&nbsp;??&nbsp;NEW&nbsp;??</FONT>')
	}
}

//
// forSetCss
//

var Mac = navigator.appVersion.indexOf('Mac',0) != -1;
var Win = navigator.appVersion.indexOf('Win',0) != -1;
var IE  = navigator.appName.indexOf("Microsoft Internet Explorer",0) != -1;
var NN  = navigator.appName.indexOf("Netscape",0) != -1;
var Moz = navigator.userAgent.indexOf("Gecko") != -1;
var Opera = window.opera;
var Opera6 = navigator.userAgent.indexOf("Opera 6") != -1;
var Opera7 = navigator.userAgent.indexOf("Opera 7") != -1;
var Vmajor = parseInt(navigator.appVersion); // ex. 3
var Vminor = parseFloat(navigator.appVersion); // ex. 3.01
var WinIE55 = ((Win && navigator.appVersion.indexOf('MSIE 5.5',0) != -1));
var MacIE5 = ((Mac && navigator.appVersion.indexOf('MSIE 5.',0) != -1));
var MacIE4 = ((Mac && navigator.appVersion.indexOf('MSIE 4.',0) != -1));
var MacIE3 = ((Mac && navigator.appVersion.indexOf('MSIE 3.',0) != -1));
var iCab = (navigator.userAgent.indexOf("iCab",0) != -1);

//
// forSwapImage 
//
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_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_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];}
}

//
// openBrWindow
//

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

//
// reLoad NN4 Bugs
//

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

//
// getScroll
//

function getScrollLeft() {
 if ((navigator.appName.indexOf("Microsoft Internet Explorer", 0) != -1)) {
  return document.body.scrollLeft;
 } else if (window.pageXOffset) {
  return window.pageXOffset;
 } else {
  return 0;
 }
}

function getScrollTop() {
 if ((navigator.appName.indexOf("Microsoft Internet Explorer", 0) != -1)) {
  return document.body.scrollTop;
 } else if (window.pageYOffset) {
  return window.pageYOffset;
 } else {
  return 0;
 }
}

//
// getInnerSize
//

function getInnerSize() {
 var obj = new Object();

 if (document.all || (document.getElementById && IE)) {
  obj.width = document.body.clientWidth;
  obj.height = document.body.clientHeight;

 } else if (document.layers || document.getElementById) {
  obj.width = window.innerWidth;
  obj.height = window.innerHeight;
 }

 return obj;
}


//
// scroll to Top
//


var pageScrollTimer;
function pageScroll(toX,toY,frms,cuX,cuY) {
 if (pageScrollTimer) clearTimeout(pageScrollTimer);
 if (!toX || toX < 0) toX = 0;
 if (!toY || toY < 0) toY = 0;
 if (!cuX) cuX = 0 + getScrollLeft();
 if (!cuY) cuY = 0 + getScrollTop();
 if (!frms) frms = 6;

 if (toY > cuY && toY > (getAnchorPosObj('end').y) - getInnerSize().height) toY = (getAnchorPosObj('end').y - getInnerSize().height) + 1;
 cuX += (toX - getScrollLeft()) / frms; if (cuX < 0) cuX = 0;
 cuY += (toY - getScrollTop()) / frms;  if (cuY < 0) cuY = 0;
 var posX = Math.floor(cuX);
 var posY = Math.floor(cuY);
 window.scrollTo(posX, posY);

 if (posX != toX || posY != toY) {
  pageScrollTimer = setTimeout("pageScroll("+toX+","+toY+","+frms+","+cuX+","+cuY+")",16);
 }
}

function jumpToPageTop() {
 if (!Opera && !iCab) {
  pageScroll(0,0,5);
 } else {
  if (Opera) {
   location.href = "#top";
  } else {
   location.hash = "top";
  }
 }
}

//
//
//

function setObj(id) {
 if (document.all) {
  return document.all(id);
 } else if (document.getElementById) {
  return document.getElementById(id);
 } else if (document.layers) {
  return document.layers[id];
 }
 return false;
}

function getAnchorPosObj(elementname) {
 var obj = setObj(elementname);
 var objnew = new Object();
 var objtmp;

 if (document.getElementById) {
  objtmp = obj;
  objnew.x = objtmp.offsetLeft;
  objnew.y = objtmp.offsetTop;
  while ((objtmp = objtmp.offsetParent) != null) {
   objnew.x += objtmp.offsetLeft;
   objnew.y += objtmp.offsetTop;
  }
 } else if (document.all) {
  objtmp = obj;
  objnew.x = objtmp.offsetLeft;
  objnew.y = objtmp.offsetTop;
  while ((objtmp = objtmp.offsetParent) != null) {
   objnew.x += objtmp.offsetLeft;
   objnew.y += objtmp.offsetTop;
  }
 } else if (document.layers) {
  objnew.x = document.anchors[elementname].x;
  objnew.y = document.anchors[elementname].y;
 } else {
  objnew.x = 0;
  objnew.y = 0;
 }
 return objnew;
}

function getHash(strPath) {
	return strPath.substring(strPath.lastIndexOf("#") + 1);
}

function getContFontSize() {
 var intSize = 0;

 if (Moz || Opera) {
  intSize = 16;
 }

 return intSize;
}

function jumpToAnchor(elementname) {
 if ((!getAnchorPosObj(getHash(elementname)).x - getContFontSize() <= 0 || getAnchorPosObj(getHash(elementname)).y - getContFontSize() <= 0) ){
  pageScroll(0, getAnchorPosObj(getHash(elementname)).y - getContFontSize(), 5);
 } else {
  if (Opera) {
   location.href = "#" + elementname;
  } else {
   location.hash = elementname;
  }
 }
}

//
// Flash plugin detection
//

var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false;

var requiredVersion = 6;
var useRedirect;
var checkedPlugin = false;

if(isWin){
	useRedirect = false;
}else{
	useRedirect = true;
}

var flashPage = "index.html"
var noFlashPage = "noflash.html"
var upgradePage = "noflash.html"

var flash2Installed = false;    // boolean. true if flash 2 is installed
var flash3Installed = false;    // boolean. true if flash 3 is installed
var flash4Installed = false;    // boolean. true if flash 4 is installed
var flash5Installed = false;    // boolean. true if flash 5 is installed
var flash6Installed = false;    // boolean. true if flash 6 is installed
var flash7Installed = false;    // boolean. true if flash 7 is installed

var maxVersion = 7;             // highest version we can actually detect
var actualVersion = 0;          // version the user really has
var hasRightVersion = false;    // boolean. true if it's safe to embed the flash movie in the page
var jsVersion = 1.0;            // the version of javascript supported

jsVersion = 1.1;

if(isIE && isWin){
  document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
  document.write('on error resume next \n');
  document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
  document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
  document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
  document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');
  document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');
  document.write('flash7Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');
  document.write('</SCR' + 'IPT\> \n'); // break up end tag so it doesn't end our script
}

function detectFlash() {  
  if (navigator.plugins) {
    if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
      var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
      var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
      var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));

      flash2Installed = flashVersion == 2;
      flash3Installed = flashVersion == 3;
      flash4Installed = flashVersion == 4;
      flash5Installed = flashVersion == 5;
      flash6Installed = flashVersion == 6;
      flash7Installed = flashVersion == 7;
    }
  }
  
  for (var i = 2; i <= maxVersion; i++) {  
    if (eval("flash" + i + "Installed") == true) actualVersion = i;
  }
 
  if(navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 3;

  if (actualVersion >= requiredVersion) {
	checkedPlugin = true;
    hasRightVersion = true;
  } else {  
    if (useRedirect) {
      if(jsVersion > 1.0) {
        if(actualVersion >=2){
			location.href=upgradePage;
		}else{
			location.href=noFlashPage;
		}
      } else {
        window.location = (actualVersion >= 2) ? upgradePage : noFlashPage;
      }
    }
  }
}

//detectFlash();


//
// fullwindow
//

function fullwin(pageurl, wname){
	var isWin=(navigator.appVersion.indexOf("Win")!=-1)? true : false;
	var isIE=(navigator.appVersion.indexOf("MSIE")!=-1)? true : false;
	var win_cfg = 'fullscreen=yes,toolbar=no,location=no,directories=no,status=no,menubar=0,scrollbars=0,resizable=no';
	if(isWin&&isIE){
		newWin = window.open(pageurl,wname,win_cfg );
	}else{
		newWin = window.open(pageurl,wname,win_cfg);
		newWin.moveTo(0,0);
		newWin.resizeTo(screen.availWidth,screen.availHeight);
	}
}


//
// resizeTo
//

function windowResizeTo(size_w,size_h) { // no window option

	if ( ((brw.win) && (brw.ie)) || ((brw.win) && (brw.ns4)) ) {
		size_w += 13;
		size_h += 35;
		window.resizeTo(size_w,size_h);
	}

	if ((brw.win) && (brw.ns6)) {
		size_w += 11;
		size_h += 35;
		window.resizeTo(size_w,size_h);
	}
	
	if ( ((brw.mac) && (brw.ie)) || ((brw.mac) && (brw.ns6)) ) {
		window.resizeTo(size_w,size_h);
	}

	if ((brw.mac) && (brw.ns4)) {
		size_w -= 15;
		window.resizeTo(size_w,size_h);
	}

}

//
// moveToCenter
//

function moveToCenter (size_w,size_h) { // 
	x = (screen.width  - size_w) / 2;
	y = (screen.height - size_h) / 2;
	window.moveTo(x,y);
}

function writeKou() {
	if(brw.win) {
		document.write('&#23878;');
	} else {
		document.write('????');
	}

}

//
// font-size
//

function fontPatch() {
	if ( document.defaultView.getComputedStyle(document.body,'"').getPropertyValue("font-size") !== "16px") {
		document.body.style.fontSize='16px';
	}
}
if ( document.defaultView && document.styleSheets ) addEvent(window, 'load', fontPatch, false);



/*====================================================================
 * Flash用 EMBEDとOBJECTタグを書き出す関数          2006.04.20
 *--------------------------------------------------------------------
 */

// Flash書き出し
//  書式 
//     writeFlashCode('_属性名1=値','_属性名2=値','属性名n=値',...)
//  例 writeFlashCode('_swf=test.swf','_width=100','_height=100')

function writeFlashCode( 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 ; // 読み込まれるだけで実行しない
	  //
	  // FlashVars を追加
	  //
	  case '_flashvars' : _flashvars =  parm[i][1] ; break ; 
      default        :;
    }
  }
  

  // タグ用文字列生成
  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(!!_flashvars)   htm+=" <param  name     = 'flashvars'   value ='" + _flashvars     + "' />"
  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(!!_flashvars)     htm+="        flashvars      = '" + _flashvars     + "'"
  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)
  
}
