var timerID = null;
var dspName = "";

function late_hide(name){
    MM_showHideLayers( name ,'','hide');
}

function HideSomeMinutes(timeCount,LayerName){
    if (timerID) {
        clearTimeout(timerID);
        MM_showHideLayers(dspName,'','hide');
    }
    timerID = setTimeout("late_hide('"+LayerName+"')",timeCount * 1000);
    dspName = LayerName;
}

function ClearTimer(){
    if (timerID) {
         clearTimeout(timerID);
         timerID = null;
        MM_showHideLayers( dspName ,'','hide');
        dspName = null;
     }
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

//背景色変更
function chbgcolor(tg, clr){
	tg.style.backgroundColor = clr;
}

//詳細画像セット
function photodset( targetId ){
	if (document.getElementById){
  		for(var i=1; i<6; i++){
	  		var target = document.getElementById( 'photod'+i );
			if(targetId == 'photod'+i){
				target.style.display = "";
  			} else {
  				target.style.display = "none";
  			}
		}
	}
}

//画像縮小リサイズ処理
function resizeImage(AT_width, AT_height, AT_name){
	//ページ内画像数取得
	var imgLen = document.images.length;
	
	//全画像に対して実行
	for(var i=0; i<imgLen; i++){
		//画像のオブジェクト取得
		var imgObj = document.images[i];
		//クラス名が指定された物のみ実行
		if(imgObj.className == AT_name){
			//画像表示
			imgObj.style.display = "block";
			var w = imgObj.width;
			var h = imgObj.height;
			var ww = w;
			var hh = h
			
			if(AT_width == 998) {
				//縦幅優先
				ww = AT_height * w / h;
				hh = AT_height;
				if(ww>100){
					//横100px以上なら横幅優先
					hh = 100 * h / w;
					ww = 100;
				}
			} else if(AT_width == 999){
				//縦幅優先
				ww = AT_height * w / h;
				hh = AT_height;
			} else {
				//画像幅サイズが指定サイズ以上の場合
				if(w > AT_width || h > AT_height){
					//横幅の方が大きい場合
					if(w > h){
						hh = AT_width * h / w;
						ww = AT_width;
					} else {
						//縦幅の方が大きい場合
						ww = AT_height * w / h;
						hh = AT_height;
					}
				}
			}
			imgObj.width = ww;
			ww = "" + ww;
			imgObj.style.width = ww + "px";
			imgObj.height = hh;
			hh = "" + hh;
			imgObj.style.height = hh + "px";
			if(imgObj.style.visibility == "hidden"){
				imgObj.style.visibility = "visible";
			}
		}
	}
}

function slowdownScroll() {
   if(navigator.appName == "Microsoft Internet Explorer" && document.compatMode == "CSS1Compat") {
      sctop = document.body.parentNode.scrollTop;
   }
   else if(window.pageYOffset){
      sctop = window.pageYOffset;
   } else {
      sctop = document.body.scrollTop;
   }

   if(sctop){
      scup = Math.ceil(sctop*.2);
      scrollBy(0,-scup);
      if (sctop-scup) setTimeout("slowdownScroll()",20);
   }
}

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];}
}

function openimage(filename,width,height){
	var html = new Array();
	html[0] = "<html><head><title>PHOTO</title>\n";
	html[1] = "<style type=\"text/css\"><!--\n";
	html[2] = "body{margin:0}\n";
	html[3] = "--></style></head>\n";
	html[4] = "<body marginwidth=\"0\" marginheight=\"0\">\n"
	html[5] = "<div><a href='javascript:window.close()' title='ウィンドウを閉じる'><img src=\"";
	html[6] = filename;
	html[7] = "\" border=\"0\"></a></div></body></html>\n"
	
	var windowsize;
	windowsize = "width="+width+",height="+height;
	
	newWindow = window.open('','',windowsize+",scrollbars=no");
	newWindow.document.open();
	newWindow.document.write(html.join(""));
	newWindow.document.close();
	
	return false;
}

function id_show(name){
	if (document.getElementById){
		target = document.getElementById( name );
		target.style.display = "";
	}
}

function id_hide(name){
	if (document.getElementById){
		target = document.getElementById( name );
		target.style.display = "none";
	}
}

function toggle( targetId ){
  if (document.getElementById){
  		target = document.getElementById( targetId );
  			if (target.style.display == "none"){
  				target.style.display = "";
  			} else {
  				target.style.display = "none";
  			}
  	}
}