function smartOver() {
NationFlagAreaInit();
smartRollover('wrapper');
}

function NationFlagAreaInit(){
	if( sgaNationFlag ){
		if( document.getElementById("NationFlagArea") != null){
			var	oNationFlagArea
			=	document.getElementById("NationFlagArea");
			oNationFlagArea.innerHTML
			=	NationFlagAreaMake( sgaNationFlag );
		}
	}
}

function NationFlagAreaMake(paData){
	var	sHTML		=	"";
	
	for( i=0; i < paData.length; i++ ){
		if( paData[i][0]	!=	"" ){
			sHTML		+=	NationFlagEdit(paData[i]);
		}
	}
	
	return	sHTML;
}

function NationFlagEdit(paData){
	var	sHTML			=	"";
	var	sPictDir		=	"http://www.samukawa.co.jp/common/images/";
	var	sPictFilePre	=	"icon_";
	var	sPictSmall		=	"_n.gif";
	var	sPictBig		=	"_o.gif";
	var	iHTMLWidth		=	36;
	var	iHTMLHeight		=	58;
	var	iHTMLBorder		=	0;
	
	sHTML
	=	"<a href=\""+"http://www.samukawa.co.jp/"					+
		paData[2]						+
		"\">"							+
		"<img src=\""					+
		sPictDir						+
		sPictFilePre					+
		paData[0];
	
	if( paData[3]	==	"0"	){
		sHTML	+=	sPictSmall			+
					"\"";
	}else{
		sHTML	+=	sPictBig			+
					"\"";
	}

	sHTML
	+=	" alt=\""						+
		paData[1]						+
		"\""							+
		" height=\""					+
		iHTMLHeight						+
		"\""							+
		" height=\""					+
		iHTMLWidth						+
		"\""							+
		" border=\""					+
		iHTMLBorder						+
		"\" /></a>";

	return sHTML;
}

function smartRollover(idName) {
	if(document.getElementsByTagName) {

	if(!document.getElementById(idName)){return;}

		var images = document.getElementById(idName).getElementsByTagName("img");
		for(var i=0; i < images.length; i++) {

			if(images[i].getAttribute("src").match(/_n\./))
			{
				fileName = new Array(images[i].getAttribute("src").replace("_n.", "_o."));
				preImages = new Array();
				for (j=0; j<fileName.length; j++)
				{
					preImages[j] = new Image();
					preImages[j].src = fileName[j];
				}

				images[i].onmouseover = function() {
				this.setAttribute("src", this.getAttribute("src").replace("_n.", "_o."));
				}
				images[i].onmouseout = function() {
				this.setAttribute("src", this.getAttribute("src").replace("_o.", "_n."));
				}
			}
		}
	}
}

if(window.addEventListener) {
window.addEventListener("load", smartOver, false);
}
else if(window.attachEvent) {
window.attachEvent("onload", smartOver);
}
else{
window.onload = smartOver;
}

function changeImage(d, type){

	// 画像ファイル形式判定
	if(d.src.indexOf(".jpg") > -1)
	{
		ext = ".jpg";
	}
	else if(d.src.indexOf(".gif") > -1)
	{
		ext = ".gif";
	}
	else if(d.src.indexOf(".png") > -1)
	{
		ext = ".png";
	}
	else
	{
		return;
	}

	d.src=d.src.substring(0,d.src.length-5)+type+ext;
}

function quickMenu(url)
  {
    if (url == "online/index.cgi") {
      window.open('online/index.cgi','_blank');
    }
    else if (url == "../online/index.cgi") {
      window.open('../online/index.cgi','_blank');
    }
    else if (url == "../../online/index.cgi") {
      window.open('../../online/index.cgi','_blank');
    }
	else if (url == "http://www.misonikomi.jp/index.html") {
      MM_openBrWindow('http://www.misonikomi.jp/index.html','','menubar=yes,scrollbars=yes,resizable=yes,width=800,height=600');
    }
    else{
      top.location=url;
    }
    return true;
  }
  
function movePage(d){
	path = href=d.options[d.selectedIndex].value;
	if(path) location.href=d.options[d.selectedIndex].value;
}

function setCSSClassById(elem, value) {
	if(document.getElementById) {
		var obj = document.getElementById(elem);
		if(obj) { obj.className = value; }
	}
}


function changeMode(flg){
	if(flg == 1)
	{
		setCSSClassById("temp_01","display_no");
		setCSSClassById("temp_02","display_show");
		setCSSClassById("temp_03","display_no");
		setCSSClassById("temp_04","display_no");
		setCSSClassById("temp_05","display_no");
	}
	else if(flg == 2)
	{
		setCSSClassById("temp_01","display_no");
		setCSSClassById("temp_02","display_no");
		setCSSClassById("temp_03","display_show");
		setCSSClassById("temp_04","display_no");
		setCSSClassById("temp_05","display_no");
	}
	else if(flg == 3)
	{
		setCSSClassById("temp_01","display_no");
		setCSSClassById("temp_02","display_no");
		setCSSClassById("temp_03","display_no");
		setCSSClassById("temp_04","display_show");
		setCSSClassById("temp_05","display_no");
	}
	else if(flg == 4)
	{
		setCSSClassById("temp_01","display_no");
		setCSSClassById("temp_02","display_no");
		setCSSClassById("temp_03","display_no");
		setCSSClassById("temp_04","display_no");
		setCSSClassById("temp_05","display_show");
	}
	else
	{
		setCSSClassById("temp_01","display_show");
		setCSSClassById("temp_02","display_no");
		setCSSClassById("temp_03","display_no");
		setCSSClassById("temp_04","display_no");
		setCSSClassById("temp_05","display_no");
	}
}



function mOv1(){
document.getElementById("img01").style.display = 'block';

}
function mOu1(){
document.getElementById("img01").style.display = 'none';
}

function mOv2(){
document.getElementById("img02").style.display = 'block';
}
function mOu2(){
document.getElementById("img02").style.display = 'none';
}

function mOv3(){
document.getElementById("img03").style.display = 'block';
}
function mOu3(){
document.getElementById("img03").style.display = 'none';
}

function mOv4(){
document.getElementById("img04").style.display = 'block';
}
function mOu4(){
document.getElementById("img04").style.display = 'none';
}

function mOv5(){
document.getElementById("img05").style.display = 'block';
}
function mOu5(){
document.getElementById("img05").style.display = 'none';
}

// utf-8
// switchCss.js
// Copyright (c) 2008 KAZUMiX
// http://d.hatena.ne.jp/KAZUMiX/
// Licensed under the MIT License:
// http://www.opensource.org/licenses/mit-license.php

// 2008/03/06 jQueryを不要にした

(function(){

    //クエリーにstylesheetがあれば切り替え関数呼び出し
    if(location.search.match(/\bstylesheet=([\w]+)/)){
        var titleValue = RegExp.$1;
        changeStyle(titleValue);
    }

    // CSS切り替え関数
    // 引数titleValueと一致したtitle属性を持つlink要素を有効にする
    // 一致しなかったものは無効にする
    // もともとtitle属性が無いものには何もしない
    function changeStyle(titleValue){
        //relとtitle属性の有るlinkを配列に格納
        //var links = $('link[@rel*=style][@title]');
        var head = document.getElementsByTagName('head')[0];
        var allLinks = head.getElementsByTagName('link');
        var links = [];
        for(var i=0; i<allLinks.length; i++){
            var link = allLinks[i];
            var linkRel = link.getAttribute('rel');
            var linkTitle = link.getAttribute('title');
            if(linkTitle && linkRel.match(/\bstylesheet\b/)){
                links.push(link);
            }
        }
        //すべてDOMから撤去する
        var matchedLink;
        for(var i=0;i<links.length;i++){
            links[i].disabled = true;
            links[i].parentNode.removeChild(links[i]);
            //引数と一致したものをmatchedLinkに保存する
            if(links[i].title == titleValue){
                matchedLink = links[i];
            }
        }
        if(!matchedLink)return;
        //有効にするlinkのrelをstylesheetにし、新規にDOMに追加
        var link = document.createElement('link');
        link.disabled = true;
        var attrs = matchedLink.attributes;
        for(var i=0;i<attrs.length;i++){
            var nodeValue = attrs[i].nodeValue;
            var nodeName = attrs[i].nodeName;
            if(nodeValue){
                if(nodeName=='rel'){
                    nodeValue='stylesheet';
                }
                link.setAttribute(nodeName,nodeValue);
            }
        }
        head.appendChild(link);
        link.disabled = false;
    }

})();

var DDSPEED = 3;
var DDTIMER = 10;

// main function to handle the mouse events //
function ddMenu(id,dir) {
  var head = document.getElementById(id + '-ddheader');
  var cont = document.getElementById(id + '-ddcontent');
  clearInterval(cont.timer);
  if(dir == 1) {
    clearTimeout(head.timer);
    if(cont.maxh && cont.maxh <= cont.offsetHeight) {
      return;
    } else if(!cont.maxh) {
      cont.style.display = 'block';
      cont.style.height = 'auto';
      cont.maxh = cont.offsetHeight;
      cont.style.height = '0px';
    }
    cont.timer = setInterval("ddSlide('" + id + "-ddcontent', 1)", DDTIMER);
  } else {
    head.timer = setTimeout('ddCollapse(\'' + id + '-ddcontent\')', 50);
  }
}

// collapse the menu //
function ddCollapse(id) {
  var cont = document.getElementById(id);
  cont.timer = setInterval("ddSlide('" + id + "', -1)", DDTIMER);
}

// cancel the collapse if a user rolls over the dropdown content //
function cancelHide(id) {
  var head = document.getElementById(id + '-ddheader');
  var cont = document.getElementById(id + '-ddcontent');
  clearTimeout(head.timer);
  clearInterval(cont.timer);
  if(cont.offsetHeight < cont.maxh) {
    cont.timer = setInterval("ddSlide('" + id + "-ddcontent', 1)", DDTIMER);
  }
}

// incrementally expand/contract the dropdown and change the opacity //
function ddSlide(id,dir) {
  var cont = document.getElementById(id);
  var currheight = cont.offsetHeight;
  var dist;
  if(dir == 1) {
    dist = (Math.round((cont.maxh - currheight) / DDSPEED));
  } else {
    dist = (Math.round(currheight / DDSPEED));
  }
  if(dist <= 1 && dir == 1) {
    dist = 1;
  }
  cont.style.height = currheight + (dist * dir) + 'px';
  cont.style.opacity = currheight / cont.maxh;
  cont.style.filter = 'alpha(opacity=' + (currheight * 100 / cont.maxh) + ')';
  if((currheight < 2 && dir != 1) || (currheight > (cont.maxh - 2) && dir == 1)) {
    clearInterval(cont.timer);
  }
}

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