﻿
if (!Number.prototype.toFixed) {
    Number.prototype.toFixed = function(n) {
        with (Math) return round(Number(this) * pow(10, n)) / pow(10, n)
    }
}

Request = {
    QueryString: function(item) {
        var svalue = location.search.match(new RegExp('[\?\&]' + item + '=([^\&]*)(\&?)', 'i'));
        return svalue ? svalue[1] : svalue;
    }
}

function changeDisplay(id, v) {
    var d = v == 0 ? "none" : ""; //0-hidden, 1-show
    if (id) {
        if (id.toString().indexOf(',') > 0) {
            var ids = id.toString().split(',');
            for (var i = 0; i < ids.length; i++) {
                if (ids[i] != "") {
                    v == 0 ? $("#" + ids[i]).hide() : $("#" + ids[i]).show();
                }
            }
        }
        else {
            v == 0 ? $("#" + id).hide() : $("#" + id).show();
        }
    }
}

function logout() {
    $.get("/ajax/ajaxoption.aspx?action=logout",
      function(data) {
          if (data == "logout") {
              window.location = window.document.URL;
              alert(data);
          }
      });
  }

  function changeSiteID(url) {
      $.get("/ajax/ajaxoption.aspx?action=changeSiteID",
      function(data) {
              window.location = url;
      });
  }
  
  function validEmailAddr(email) {
      var pattern = /^[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}/;
      return pattern.test(email);
  }


  function dyniframesize(iframename) {
      var pTar = null;
      if (document.getElementById) {
          pTar = document.getElementById(iframename);
      }
      else {
          eval('pTar = ' + iframename + ';');
      }
      if (pTar && !window.opera) {
          pTar.style.display = "block"

          if (pTar.contentDocument && pTar.contentDocument.body.scrollHeight) {
              pTar.height = pTar.contentDocument.body.scrollHeight + 8;
          }
          else if (pTar.Document && pTar.Document.body.scrollHeight) {
              pTar.height = pTar.Document.body.scrollHeight + 8;
          }
      }
  }
