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);

function openNW(theURL,winName,features) {
  window.open(theURL,winName,features);
}


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 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;
}

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;
 }
}

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) && !Opera && !iCab){
  pageScroll(0, getAnchorPosObj(getHash(elementname)).y - getContFontSize(), 5);
 } else {
  if (Opera) {
   location.href = "#" + elementname;
  } else {
   location.hash = elementname;
  }
 }
}

function submitForm(){
  document.Form1.submit();
}

var srchlist = new Array('キーワードを入力');

function srchhint(srchkind,paramstr){
if(paramstr == srchlist[srchkind]){
 if(srchkind == 0){document.F0.PARAM.value = '';}
 if(srchkind == 1){document.F1.PARAM.value = '';}
 if(srchkind == 2){document.F2.PARAM.value = '';}
 if(srchkind == 3){document.F3.PARAM.value = '';}
}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function PrintPage(){
	if(document.getElementById || document.layers){
		window.print();		//印刷をします
	}
}

function openSubWindow(strURL,target,style) {
  window.open(strURL,target,style);
  document.Form1.target = target;
  document.Form1.method = "post";
  document.Form1.action = strURL;
  document.Form1.submit();
}

function __ws__(id){ 
document.write(id.text);id.id=''; 
}

Flash = function(swf, width, height, version)
{
    this.swf = swf || "";
    this.width = width || "100%";
    this.height = height || "100%";
    this.requiredVersion = version || 6;
    this.id = "";
    this.params = new Object();
    this.variables = new Object();
};

Flash.resizeTo = function(id, w, h)
{
    var movie = document.getElementById(id);
    movie.width = w;
    movie.height = h;
};

Flash.prototype.getSWF = function()
{
    return this.swf;
};

Flash.prototype.setSWF = function(swf)
{
    this.swf = swf;
};

Flash.prototype.getWidth = function()
{
    return this.width;
};

Flash.prototype.setWidth = function(w)
{
    this.width = w;
};

Flash.prototype.getHeight = function()
{
    return this.height;
};

Flash.prototype.setHeight = function(h)
{
    this.height = h;
};

Flash.prototype.getRequiredVersion = function()
{
    return this.requiredVersion;
};

Flash.prototype.setRequiredVersion = function(v)
{
    this.requiredVersion = v;
};

Flash.prototype.getId = function()
{
    return this.id;
};

Flash.prototype.setId = function(id)
{
    this.id = id;
};

Flash.prototype.getParam = function(name)
{
    return this.params[name];
};

Flash.prototype.getParams = function()
{
    return this.params;
};

Flash.prototype.setParam = function(name, value)
{
    this.params[name] = value;
};

Flash.prototype.getVariable = function(name)
{
    return this.variables[name];
};

Flash.prototype.getVariables = function()
{
    return this.variables;
};

Flash.prototype.setVariable = function(name, value)
{
    this.variables[name] = value;
};

Flash.prototype.getVariableSets = function()
{
    var variableSets = new Array();
    for (var name in this.getVariables()) {
        variableSets.push(name + "=" + escape(this.getVariable(name)));
    }
    if (variableSets.length > 0) {
        return variableSets.join("&");
    }
    else {
        return null;
    }
};

Flash.prototype.getParamTags = function()
{
    var paramTags = "";
    for (var param in this.getParams()) {
        paramTags += '<param name="' + param + '" value="' + this.getParam(param) + '" />';
    }
    if (paramTags == "") {
        paramTags = null;
    }
    return paramTags;
};

Flash.prototype.getHTML = function()
{
    var flashHTML = "";
    if (window.ActiveXObject && navigator.userAgent.indexOf('Mac') == -1) { // PC IE
        flashHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + this.getWidth() + '" height="' + this.getHeight() + '" id="' + this.getId() + '">';
        flashHTML += '<param name="movie" value="' + this.getSWF() + '" />';
        if (this.getParamTags() != null) {
            flashHTML += this.getParamTags();
        }
        if (this.getVariableSets() != null) {
            flashHTML += '<param name="flashVars" value="' + this.getVariableSets() + '" />';
        }
        flashHTML += '</object>';
    }
    else { // Everyone else
        flashHTML += '<embed type="application/x-shockwave-flash" src="' + this.getSWF() + '" width="' + this.getWidth() + '" height="' + this.getHeight() + '" id="' + this.getId() + '"';
        for (var param in this.getParams()) {
            flashHTML += ' ' + param + '="' + this.getParam(param) + '"';
        }
        if (this.getVariableSets() != null) {
            flashHTML += ' flashVars="' + this.getVariableSets() + '"';
        }
        flashHTML += '></embed>';
    }
    return flashHTML;
};

Flash.prototype.render = function(elementId)
{
	if (elementId) {
	document.getElementById(elementId).innerHTML = this.getHTML();
	}
	else {
		document.write(this.getHTML());
	}
};
