function changeCounterValue(sElement, iStep, iMinimum, iMaximum) {
  var obj = document.getElementById(sElement);
  var val = (parseInt(obj.value) ? parseInt(obj.value) : 0);
  val = parseInt(val + iStep);
  if (val < iMinimum) val = iMinimum
  if (val > iMaximum) val = iMaximum
  obj.value = val;
}

function getWindowWidth() {
  var windowWidth = 0;
  if (typeof(window.innerWidth) == "number") {
    windowWidth=window.innerWidth;
  } else {
    if (document.documentElement && document.documentElement.clientWidth) {
      windowWidth = document.documentElement.clientWidth;
    } else {
      if (document.body && document.body.clientWidth) {
        windowWidth=document.body.clientWidth;
      }
    }
  }
  return windowWidth;
}

function getWindowHeight() {
  var windowHeight = 0;
  if (typeof(window.innerHeight) == "number") {
    windowHeight=window.innerHeight;
  } else {
    if (document.documentElement && document.documentElement.clientHeight) {
      windowHeight = document.documentElement.clientHeight;
    } else {
      if (document.body && document.body.clientHeight) {
        windowHeight=document.body.clientHeight;
      }
    }
  }
  return windowHeight;
}

function getScrollWidth() {
  var scrollWidth = 0;
  if (parseInt(document.body.scrollWidth)) scrollWidth = document.body.scrollWidth;
  if (scrollWidth < getWindowWidth()) scrollWidth = getWindowWidth();
  return scrollWidth;
}

function getScrollHeight() {
  var scrollHeight = 0;
  if (parseInt(document.body.scrollHeight)) scrollHeight = document.body.scrollHeight;
  if (scrollHeight < getWindowHeight()) scrollHeight = getWindowHeight();
  return scrollHeight;
}

function loadPage(sUrl) {
  window.location.href = sUrl;
  return false;
}

function trim(sString) {
  return sString.replace (/^\s+/, '').replace (/\s+$/, '');
}

function showTab(iActive, iTabs) {
  var sHead  = "";
  var sBody  = "";
  var sClass = "";
  for (i = 0; i < iTabs; i++) {
    sHead = "head" + i;
    sBody = "body" + i;
    if (i == iActive) {
      sClass = "active";
    } else {
      sClass = "normal";
    }
    document.getElementById(sHead).className = sClass;
    document.getElementById(sBody).className = sClass;
  }
}

function getFilteredHtmlAttribute(oElement, sAttribute) {
  var sResult = new String(oElement.getAttribute(sAttribute));
  if (sResult == "null" || sResult == "undefined") sResult = "";
  return sResult;
}

function transformLinkHrefs() {
  
  return 0;
  
  var aLink = document.getElementsByTagName("A");
  
  for (var i = 0; i < aLink.length; i++) {
    var oLink = aLink[i];
    var sHref = getFilteredHtmlAttribute(oLink, "href");
    var sRel = getFilteredHtmlAttribute(oLink, "rel");
    var sTarget = getFilteredHtmlAttribute(oLink, "target");
    var sOnClick = getFilteredHtmlAttribute(oLink, "onclick");
    
    if (sOnClick != "" && sOnClick.substring(0, 9) == "function ") sOnClick = "";
    
    if (sRel != "" && sRel.substring(0, 9).toLowerCase() == "shadowbox") {
      sHref = "";
      sOnClick = "";
    }
    
    var sOnMouseDown = getFilteredHtmlAttribute(oLink, "onmousedown");
    var sOnMouseUp = getFilteredHtmlAttribute(oLink, "onmouseup");
    var bOnlyHref = (sHref != "" && sTarget == "" && sOnClick == "" && sOnMouseDown == "" && sOnMouseUp == "");
    var bOnlyOnClick = ((sHref == "" || sHref == "javascript:void(0);") && sTarget == "" && sOnClick != "" && sOnMouseDown == "" && sOnMouseUp == "");
    if (bOnlyHref || bOnlyOnClick) {
      
      if (bOnlyHref) {
        
        var sNewOnMouseDown = (bOnlyHref ? sHref : sOnClick);
        
        if (sHref.substring(0, 11) == "javascript:") {
          sNewOnMouseDown = sHref.substring(11, sHref.length);
        } else {
          sNewOnMouseDown = "loadPage('" + sNewOnMouseDown + "');";
        }
        oLink.href = "javascript:void(0);";
        oLink.onmousedown = new Function(sNewOnMouseDown + "return false;");
        
      } else {
        
        oLink.onmousedown = oLink.onclick;
        
      }
      
    }
  }
  
}

