﻿function PopupCenter(pageURL, title, w, h)
{ var left = (screen.width / 2) - (w / 2); var top = (screen.height / 2) - (h / 2); var targetWin = window.open(pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left); }

function OpenModelWindow(URL, Width, Height) {
    var WinSettings = "center:yes;resizable:yes;dialogHeight:" + Height + "px;dialogWidth:" + Width + "px"
    var MyArgs = window.showModalDialog(URL, null, WinSettings);
}

function addToFavorite() {
    var title, url; title = document.title; url = location.href; if (window.sidebar) { window.sidebar.addPanel(title, url, ""); } else if (window.external) { window.external.AddFavorite(url, title); }
    else if (window.opera && window.print) { return true; }
  }

  function Rtrim(VALUE) {
    var w_space = String.fromCharCode(32);
    var v_length = VALUE.length;
    var strTemp = "";

    if (v_length < 0) {
      return "";
    }
    var iTemp = v_length - 1;
    while (iTemp > -1) {
      if (VALUE.charAt(iTemp) == w_space) {
      }
      else {
        strTemp = VALUE.substring(0, iTemp + 1);
        break;
      }
      iTemp = iTemp - 1;
    }
    return strTemp;
  }

  function Ltrim(VALUE) {
    var w_space = String.fromCharCode(32);
    var v_length = VALUE.length;
    var strTemp = "";
    var iTemp = 0;

    if (v_length < 1) {
      return "";
    }

    while (iTemp < v_length) {
      if (VALUE.charAt(iTemp) == w_space) {
      }
      else {
        strTemp = VALUE.substring(iTemp, v_length);
        break;
      }
      iTemp = iTemp + 1;
    }
    return strTemp;
  }

  function Trim(TRIM_VALUE) {

    if (TRIM_VALUE.length < 1) {
      return "";
    }
    TRIM_VALUE = Rtrim(TRIM_VALUE);
    TRIM_VALUE = Ltrim(TRIM_VALUE);

    if (TRIM_VALUE == "") {
      return "";
    }
    else {
      return TRIM_VALUE;
    }

  }

  function f_clientWidth() {
    return f_filterResults(
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
  }
  function f_clientHeight() {
    return f_filterResults(
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
  }
  function f_scrollLeft() {
    return f_filterResults(
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
  }
  function f_scrollTop() {
    return f_filterResults(
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
  }
  function f_filterResults(n_win, n_docel, n_body) {
    var n_result = n_win ? n_win : 0;
    if (n_docel && (!n_result || (n_result > n_docel)))
      n_result = n_docel;
    return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
  }


  
