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) {
  document.location.href = sUrl;
}

function clearForm(formIdent) 
{ 
  var form, elements, i, elm; 
  form = document.getElementById(formIdent) != null  
    ? document.getElementById(formIdent) 
    : document.forms[formIdent]; 

	if (document.getElementsByTagName)
	{
		elements = form.getElementsByTagName('input');
		for( i=0, elm; elm=elements.item(i++); )
		{
			clearElement(elm);
		}
		elements = form.getElementsByTagName('textarea');
		for( i=0, elm; elm=elements.item(i++); )
		{
			clearElement(elm);
		}
	}

	else
	{
		elements = form.elements;
		for( i=0, elm; elm=elements[i++]; )
		{
			clearElement(elm);
		}
	}
}

function clearElement(el) {
  if (el.disabled == true) return;
  if (el.getAttribute('type') == "text") {
    el.value = '';
  } else if (el.getAttribute('type') == "checkbox") {	
    el.checked = false;
  }
}
