﻿/*                                                           */
/*           kanbunken    Javascript関数定義 [共通]          */
/*                                                           */
/*   Copyright 2009 環境文化創造研究所 All rights reserved.  */
/*                                                           */



// ----- 送信・変更時の確認 -----
var change_flag = 0;
var send_flag = 0;

function check_submit() {
  if ( send_flag == 1 ) {
    alert('ただいま送信中です。\n「OK」ボタンをクリックしてお待ちください。');
    return false;
  }

  send_flag = 1;

  return true;
}

// ----- オブジェクトの取得 -----
function get_object(id) {
  if (document.getElementById) {
    return document.getElementById(id);
  }
  else if (document.all) {
    return document.all(id);
  }
  return null;
}

// ----- クッキーの読み込み -----
function getCookie(key){
  tmp = document.cookie+";";
  tmp1 = tmp.indexOf(key, 0);
  if( tmp1 != -1 ){
    tmp = tmp.substring( tmp1, tmp.length );
    start = tmp.indexOf("=", 0 ) + 1;
    end = tmp.indexOf( ";", start );
    return( unescape( tmp.substring( start, end )));
  }
  return("");
}


// ----- 別ウィンドウの表示 -----
function openwin(url,width,height,target) {
  if (url != '') {
//    var tg = ( target == '' ) ? '_blank' : target;
    var x = parseInt( window.screen.width/2-width/2 );
    var y = parseInt( window.screen.height/2-height/2 );
    window.open(url,target,"toolbar=no,location=yes,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width="+width+",height="+height+",left="+x+",top="+y+",screenX="+x+",screenY="+y);
  }
}

// ----- エリアの表示・非表示(display) -----
function view_display(id){
  var obj = get_object(id);
  if(obj) {
    if(obj.style) {
      obj.style.display='block';
    }
  }
}

function hidden_display(id){
  var obj = get_object(id);
  if(obj) {
    if(obj.style) {
      obj.style.display='none';
    }
  }
}

// ----- 指定エリアの表示・非表示(display) -----
function change_display(id) {
  obj = get_object(id);
  if ( obj ) {
    if ( obj.style.display == 'none' || obj.style.display == '' ) {
      obj.style.display = 'block';
    }
    else {
      obj.style.display = 'none';
    }
  }
}

// ----- エリアの表示・非表示(visibility) -----
function view_visibility(id){
  var obj = get_object(id);
  if(obj) {
    if(obj.style) {
      obj.style.visibility='visible';
    }
  }
}

function hidden_visibility(id){
  var obj = get_object(id);
  if(obj) {
    if(obj.style) {
      obj.style.visibility='hidden';
    }
  }
}

// ----- 指定エリアの表示・非表示(visibility) -----
function change_visibility(id) {
  obj = get_object(id);
  if ( obj ) {
    if ( obj.style.visibility == 'hidden' || obj.style.visibility == '' ) {
      obj.style.visibility = 'visible';
    }
    else {
      obj.style.visibility = 'hidden';
    }
  }
}

// ----- ボタン画像のロールオーバー -----
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 access () {
  document.write("<img src='/cgi/ac.cgi?vs=" + window.screen.width + "x" + window.screen.height + "' width='1' height='1' border='0'>");
}

// ---------- End of File ----------
