function CssClassHelper(operation, el, c1, c2)
{
  switch (operation){
    case 'add':
      if(!CssClassHelper('check', el, c1)){el.className += el.className ? ' ' + c1 : c1;}
    break;
    case 'remove':
      var rep = el.className.match(' ' + c1) ? ' ' + c1 : c1;
      el.className = el.className.replace(rep, '');
    break;
    case 'check':
      return new RegExp('\\b' + c1 + '\\b').test(el.className)
    break;
  }
}

function getViewportHeight() {
  if (self.innerHeight) // all except Explorer
    return self.innerHeight;
    
  else if (document.documentElement && document.documentElement.clientHeight)// Explorer 6 Strict Mode
	  return document.documentElement.clientHeight;
	  
  else if (document.body) // other Explorers
	  return document.body.clientHeight;
}

function getViewportWidth() {
  if (self.innerHeight) // all except Explorer
	  return self.innerWidth;
	  
  else if (document.documentElement && document.documentElement.clientHeight) // Explorer 6 Strict Mode
    return document.documentElement.clientWidth;
    
  else if (document.body) // other Explorers
    return document.body.clientWidth;
}



function AdjustLayout()
{
  //ApplyCssOnVerticalScrollbars();
}

// Applies the class 'VerticalScrollbarVisible' to the div 'ThePage' when the vertical scrollbar is visible
function ApplyCssOnVerticalScrollbars()
{
  var thePage = document.getElementById('pagebase');
  if (thePage)
  {
    if (thePage.offsetHeight > getViewportHeight()-45)
      CssClassHelper('add', thePage, 'VerticalScrollbarVisible');
    else
      CssClassHelper('remove', thePage, 'VerticalScrollbarVisible');
  }
}

function clearContent(searchField, content)
{
  if (searchField.value == content)
    searchField.value = "";
}

function restoreContent(searchField, content) 
{
  if (searchField.value == "")
    searchField.value = content;
}
