function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);


//Flash For IE//
function mkFlash(){
var noFla = '';
noFla += '<a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&promoid=BIOW" target="_blank"><img src="/flash/noflash.jpg" width="950" height="375" border="0" alt=""></a>';
var flaArea= "";
flaArea += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+flaWidth+'" height="'+flaHeight+'">'; 
flaArea += '<param name="movie" value="'+flaFile+'">';
flaArea += '<param name="quality" value="high">';
flaArea += '<param name="wmode" value="opaque">';
flaArea += '<embed src="'+flaFile+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+flaWidth+'" height="'+flaHeight+'">';
flaArea += '</embed>';
flaArea += '</object>';
var FlaVerCk=false;
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0);
if (plugin && parseInt(plugin.description.substring(plugin.description.indexOf(".")-2)) >= 8) {
FlaVerCk=true;
}
else if(navigator.userAgent && (navigator.userAgent.indexOf("MSIE") >= 0) && (navigator.userAgent.indexOf("Win") >= 0)){
if(navigator.userAgent.indexOf("Opera") <= 0){
var flaVer=new ActiveXObject("ShockwaveFlash.ShockwaveFlash").FlashVersion();
flaVer=Math.floor(flaVer / 0x10000);
(flaVer >= 8) ? FlaVerCk=true : FlaVerCk=false;
}

	}else{FlaVerCk=false;}

	if(FlaVerCk){
	document.write(flaArea);
	} else {
	document.write(noFla);
	}

}

//Flash For IE//
function mkFlashMap(){
var noFla = '最新の<a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&promoid=BIOW" target="_blank">Flash Player</a>をインストールしてください。';
noFla += '';
var flaArea= "";
flaArea += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+flaWidth+'" height="'+flaHeight+'">'; 
flaArea += '<param name="movie" value="'+flaFile+'">';
flaArea += '<param name="quality" value="high">';
flaArea += '<param name="wmode" value="opaque">';
flaArea += '<embed src="'+flaFile+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+flaWidth+'" height="'+flaHeight+'">';
flaArea += '</embed>';
flaArea += '</object>';
var FlaVerCk=false;
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0);
if (plugin && parseInt(plugin.description.substring(plugin.description.indexOf(".")-2)) >= 6) {
FlaVerCk=true;
}
else if(navigator.userAgent && (navigator.userAgent.indexOf("MSIE") >= 0) && (navigator.userAgent.indexOf("Win") >= 0)){
if(navigator.userAgent.indexOf("Opera") <= 0){
var flaVer=new ActiveXObject("ShockwaveFlash.ShockwaveFlash").FlashVersion();
flaVer=Math.floor(flaVer / 0x10000);
(flaVer >= 6) ? FlaVerCk=true : FlaVerCk=false;
}

	}else{FlaVerCk=false;}

	if(FlaVerCk){
	document.write(flaArea);
	} else {
	document.write(noFla);
	}

}