var bStyle;
var bColor; 

var clientPC = navigator.userAgent.toLowerCase();
var clientVer = parseInt(navigator.appVersion);

var isIE = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));
var isNav = ((clientPC.indexOf('mozilla') != -1) && (clientPC.indexOf('spoofer') == -1)
            && (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera') == -1)
            && (clientPC.indexOf('webtv') == -1) && (clientPC.indexOf('hotjava') == -1));

var isWin = ((clientPC.indexOf("win") != -1) || (clientPC.indexOf("16bit") != -1));
var isMac = (clientPC.indexOf("mac") != -1);

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 getToday() {
  var now = new Date();
  var date = (now.getDate() < 10) ? "0" + now.getDate() : now.getDate();
  var mon = (now.getMonth() < 10) ? "0" + (now.getMonth() + 1) : (now.getMonth() + 1);
  var year = (!isIE) ? (now.getYear() + 1900) : now.getYear();
  document.write(date + "/" + mon + "/" + year);
}

function isDate(yea, mon, da) {
  var dScrap = new Date(yea + '/' + mon + '/' + da);
  if (dScrap == "NaN") {
    return false;
  } else {
    if ((parseInt(yea) < 1899) || (parseInt(yea) > 2099)) {
      return false;
    }
    if ((parseInt(mon) < 1) || (parseInt(mon) > 12)) {
      return false;
    }
    if (parseInt(da) < 1) {
      return false;
    }
    if (((parseInt(mon) == 1) || (parseInt(mon) == 3) || (parseInt(mon) == 5) || (parseInt(mon) == 7) ||
         (parseInt(mon) == 8) || (parseInt(mon) == 10) || (parseInt(mon) == 12)) && (parseInt(da) > 31)) {
      return false;
    }
    if (((parseInt(mon) == 2) || (parseInt(mon) == 4) || (parseInt(mon) == 6) || (parseInt(mon) == 9) || (parseInt(mon) == 11)) && (parseInt(da) > 30)) {
      return false;
    }
    if (parseInt(mon) == 2) {
      if (((parseInt(yea) % 4) == 0) && (parseInt(da) > 29)) {
        return false;
      } else if((parseInt(yea) % 4 != 0) && (parseInt(da) > 28)) {
        return false;
      }
    }
  }
  return true;
}

function checkMail(email) {
  var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  if (filter.test(email))
    return true;
  else
    return false;
}

function ChangeBorder(field) {
  bStyle = field.style.borderStyle;
  bColor = field.style.borderColor;
  with (field.style) {
    borderStyle = 'solid';
    borderColor = '#6699FF';
  }
}

function ResetBorder(field) {
  with (field.style) {
    borderStyle = bStyle;
    borderColor = bColor;
  }
}

function openWin(url, width, height) {
  window.open(url,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=' + width + ',height=' + height + ',left=50,top=50');
}

function openWinWithScroll(url, width, height) {
  window.open(url,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=' + width + ',height=' + height + ',left=50,top=50');
}

function showInput(val, key, file) {
  if (val == key)
    file.disabled = false;
  else
    file.disabled = true;
}

function dispP(obj, e, eid) {
  document.getElementById("d" + eid).style.visibility = "visible";
}

function dispN(obj, e, eid) {
  document.getElementById("d" + eid).style.visibility = "hidden";
}

function checkBoxSelect(field, status) {
  for (var i = 0; i < field.length; i++) {
	if (status == "select") {
	  field[i].checked = true;
	} else {
	  field[i].checked = false;
	}
  }
}