// ウインドウオープン用スクリプト
// ver.1.01

      function window1(win1) {
      win=window.open(win1,"new","toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=440,height=440");
      }

      function window2(win2) {
      win=window.open(win2,"new","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=565,height=500");
      }

      function window3(win3) {
      win=window.open(win3,"new","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=350,height=280");
      }

      function window4(win4) {
      win=window.open(win4,"new","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=520,height=400");
      }

      function window5(win5) {
      win=window.open(win5,"new","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=340,height=600");
      }

      function winOpen(url, win, width, height) {
      openWindow = window.open(url,win,'menubar,scrollbars,resizable,width=' + width + ',height=' + height);
                        openWindow.focus();
      }

//ウインドウクローズ用スクリプト
        function closewindow() {
                close()
        }


//プリントアウト用

function PrintPage(){
        if(document.getElementById || document.layers){
                window.print();
        }
}


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 Text(id, flag){
        if(document.all){
                object = document.all(id).style;
        }else if(document.getElementById){
                object = document.getElementById(id).style;
        }else{
                return;
        }
        if(flag == 1){
                object.background = "#F9DCC3";
        }else if(flag == 2){
                object.background = "#fff";
        }
}

//メールアドレスの簡易チェック
function valid_mail(mailAddress) {
    if(!mailAddress.match(/.+@.+\..+/))
        return false;
    return true;
}

//電話番号の簡易チェック
function valid_tel(tel) {
    if(tel==""){
        return false;
    }
    if(tel.length < 10 || tel.length > 13)
        return false;
    if ((tel.match(/^[0-9]+\-[0-9]+\-[0-9]+$/) == null)) {
        return false;
    }
    return true;
}

function valid_day(y, m ,d) {
    var leap = false;
    if (y%4 == 0){
        if (y%400 == 0 || y%100 != 0){
            leap = true;
        }
    }
    dd = new Array(0,31,28,31,30,31,30,31,31,30,31,30,31);
    if (leap){
        if (m == 2){
            dd[2] = 29;
        }
    }
    if (d<1 || d>dd[m]){
        return false;
    }else{
        return true;
    }
}

function valid_month(m){
    
    if(m<1 || m>12) return false;
    return true;   
}

function checkMaxInput(elem,maxLen) {

    if (elem.value.length > maxLen){ 
        
        // if too long.... trim it!
        elem.value = elem.value.substring(0, maxLen);
    }
}

