/**
 * A simple lock manager.
 */
function lockmgr()
{
  this.locks = new Array();

  this.lock = function(identifier)
  {
    if (!this.locks[identifier])
      this.locks[identifier] = true;
  }

  this.unlock = function(identifier)
  {
    if (this.locks[identifier])
      this.locks[identifier] = false;
  }

  this.islocked = function(identifier)
  {
    if (!this.locks[identifier])
      return false;
    return true;
  }
}

/**
 * An array containing objects identified by an unique id.
 *
 * @see getObject(Class, ID)
 */
var _objects = new Array();

/**
 * Get an object.
 *
 * If the object doesn't exists it will be created and stored in
 * an array.
 *
 * @param The class (as string)
 * @param The id, used as first parameter when creating a new instance
 *
 * @return An object
 *
 * @author Ringo Sasse
 */
function getObject(Class, ID)
{
  if (!ID) ID = 0;

  Index = Class;
  Index += "___" + ID;

  if (Class && _objects[Index])
    return _objects[Index];

  createStr =	"_objects['"+Index+"'] = new "+Class+"('"+ID+"');";
  eval(createStr);
  return _objects[Index];
}

/**
 * Set a global object, that can't be created within getObject().
 *
 * getObject() can use only one parameter for creating new objects, create
 * object yourself and put it into global object pool to access it later.
 *
 * @param The class (as string)
 * @param The id, used as first parameter when creating a new instance
 * @param An object
 *
 * @author Ringo Sasse
 */
function setObject(Class, ID, Object)
{
  if (!ID) ID = 0;

  Index = Class;
  Index += "___" + ID;

  _objects[Index] = Object;
}

/**
 * Let your script sleep.
 *
 * This function is for testing only, most browser will block this.
 *
 * @param Time to sleep in milliseconds
 *
 * @author Ringo Sasse
 */
function sleep(time)
{
  var _now = new Date();
  var _endtime = _now.getTime() + time;

  while (true)
  {
    _now = new Date();

    if (_now.getTime() > _endtime) return ;
  }
}

/**
 * The missed getElementsByClassName.
 *
 * Use it like getElementsByTagName ...
 *
 * @param A tagname
 * @param A classname
 *
 * @author Ringo Sasse
 *
 * TODO Make it working without setting a tagname
 */
document.getElementsByClassName = function (tagname, classname)
{
  var _elements = document.getElementsByTagName(tagname);
  var _found = new Array();

  for (i=0; i<_elements.length; i++)
  {
    if (_elements[i].className==classname) _found[_found.length] = _elements[i];
  }

  return _found;
}

/**
 * Browser check
 */
function browsercheck()
{
  this.ver = navigator.appVersion
  this.agent = navigator.userAgent
  this.dom = document.getElementById?1:0

  this.opera5 = this.agent.indexOf("Opera 5")>-1;

  this.ie5 = (this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;
  this.ie6 = (this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
  this.ie4 = (document.all && !this.dom && !this.opera5)?1:0;
  this.ie = this.ie4 || this.ie5 || this.ie6

  this.mac = this.agent.indexOf("Mac")>-1;

  this.ns6 = (this.dom && parseInt(this.ver) >= 5) ?1:0;
  this.ns4 = (document.layers && !this.dom)?1:0;

  this.checked = (this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
}

var bc = new browsercheck()


/* Set the opacity of an element */
function set_opacity(element, opacity)
{
  if (element.style)
  {
  	var _style = element.style;

    /* CSS 3 */
    _style.opacity = (opacity / 100);

    /* Mozilla */
    _style.MozOpacity = (opacity / 100);

    /* K-HTML (Konqueror/Safari) */
    _style.KhtmlOpacity = (opacity / 100);

    /* MS IE */
    //_style.filter = "alpha(opacity=" + opacity + ")";
    _style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity="+opacity+")";
  }
}

/* Set the opacity of an element */
function set_opacity_float(element, opacity, tagname)
{
  if (element.style && element.tagName==tagname)
  {
    var _style = element.style;

    /* CSS 3 */
    _style.opacity = opacity;

    /* Mozilla */
    _style.MozOpacity = opacity;

    /* K-HTML (Konqueror/Safari) */
    _style.KhtmlOpacity = opacity;

    /* MS IE */
    //_style.filter = "alpha(opacity=" + opacity + ")";
    _style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity="+(opacity*100)+")";
  }
}

document.linktable = new Array();

/* Disable links */
function disable_links(tdocument)
{
  if (navigator.userAgent.match(/MSIE/))
  {
    for (var i = 0; i < tdocument.links.length; ++i)
    {
      tdocument.linktable[i] = new Array();

      tdocument.linktable[i]["html"] = tdocument.links[i].outerHTML;

      tdocument.links[i].href = "javascript: void 0;";
      tdocument.links[i].onclick = "void 0;";
    }
  }
  else
  {
    for (var i = 0; i < tdocument.links.length; ++i)
    {
      tdocument.linktable[i] = new Array();

      tdocument.linktable[i]["href"] = tdocument.links[i].href;
      tdocument.linktable[i]["onclick"] = tdocument.links[i].onclick;

      tdocument.links[i].href = "javascript: void 0;";
      tdocument.links[i].onclick = "void 0;";
    }
  }
}

/* Enable links */
function enable_links(tdocument)
{
  if (! tdocument.linktable
      || tdocument.linktable.length == 0)
    return;

  if (navigator.userAgent.match(/MSIE/))
  {
    for (var i = 0; i < tdocument.links.length; ++i)
    {
      if (tdocument.linktable[i])
      	tdocument.links[i].outerHTML = tdocument.linktable[i]["html"];
    }
  }
  else
  {
    for (var i = 0; i < tdocument.links.length; ++i)
    {
      if (tdocument.linktable[i])
      {
      	tdocument.links[i].href = tdocument.linktable[i]["href"];
      	tdocument.links[i].onclick = tdocument.linktable[i]["onclick"];
      }
    }
  }
}

function hide_bytagname(tdocument, tagname)
{
  var _applets = tdocument.getElementsByTagName(tagname);

  if (_applets.length == 0) return;

  for (i=0; i<_applets.length; i++)
    _applets[i].style.visibility = "hidden";
}

function show_bytagname(tdocument, tagname)
{
  var _applets = tdocument.getElementsByTagName(tagname);

  if (_applets.length == 0) return;

  for (i=0; i<_applets.length; i++)
  {
    _applets[i].style.visibility = "visible";
  }
}

/* Set all children of the given element opaque */
function hide_content(parent)
{
  //disable_links(parent.document);
  //hide_bytagname(parent.document, "applet");
  if (navigator.userAgent.match(/MSIE/)) hide_bytagname(parent.document, "select");

  _child = parent.document.body.firstChild;

  while (_child)
  {
  	_next = _child.nextSibling;
    
    set_opacity_float(_child, 0.3, 'DIV');

    _child = _next;
  }
}

/* Set all children of the given element opaque using a overlaying iframe(for ie) and div (for transparency)*/
function hide_content_new(parent, zindex)
{
  //disable_links(parent.document);
  //hide_bytagname(parent.document, "applet");
  
  var _frame;
  var _div;

  var _pageSize = getPageSizeXY();
  
  if (document.getElementById('hide_content_iframe'))
  {
  	_frame = document.getElementById('hide_content_iframe');
  }
  else
  {
    _frame = document.createElement("IFRAME");
    _frame.id = 'hide_content_iframe';
    _frame.style.display='inline';
    _frame.style.opacity='0.0';
    _frame.style.filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';
    _frame.style.position='absolute';
    _frame.src = 'javascript: false;'; // <- do not remove this (prevents IE6 Warning)
    _frame.style.zIndex=zindex-2;
    resizeToPageSizeFast(_frame,_pageSize);
    document.body.appendChild(_frame);
  }
  
  if (document.getElementById('hide_content_div'))
  {
  	_div = document.getElementById('hide_content_div');
  }
  else
  {
    _div = document.createElement("DIV");
    _div.id = 'hide_content_div';
    _div.style.position='absolute';
    _div.style.zIndex=zindex-1;
    _div.style.display='block';
    _div.style.width='100%';
    _div.style.left='0px';
    _div.style.top='0px';
    _div.style.backgroundColor= '#FFFFFF';
    _div.innerHTML='&nbsp';
    _div.style.opacity='0.5';
    _div.style.filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=50)';
    resizeToPageSizeFast(_div,_pageSize);
    document.body.appendChild(_div);
  }
  
  //addLoadEvent(function() {resizeToPageSize(_frame)});
  addLoadEvent(function() {resizeToPageSize(_div)});
}

function show_content(parent)
{
  //enable_links(parent.document);
  //show_bytagname(parent.document, "applet");
  if (navigator.userAgent.match(/MSIE/)) show_bytagname(parent.document, "select");
  
  _child = parent.document.body.firstChild;

  while (_child)
  {
    _next = _child.nextSibling;

    set_opacity_float(_child, 1, 'DIV');

    _child = _next;
  }
}

/* shows the content */
function show_content_new(parent)
{
  enable_links(parent.document);
  show_bytagname(parent.document, "applet");
  
  var _frame = parent.document.getElementById('hide_content_iframe');
  if(_frame)
  {
	if (navigator.userAgent.match(/MSIE/))
	{
	  _frame.blur();
	}
  	_frame.style.display='none';
 	parent.document.body.removeChild(_frame);
  }
  
  var _div = parent.document.getElementById('hide_content_div');
  if(_div)
  {
	if (navigator.userAgent.match(/MSIE/))
	{
		_div.blur();
	}
    _div.style.display='none';
  	parent.document.body.removeChild(_div);
  }
  
  if (navigator.userAgent.match(/MSIE/))
  {
	  parent.focus();
  }
}

function create_iframe(id, url, width, height)
{
  Pointer = getObject("MousePointer");

  var _size = getPageSizeXY();
  if (parseInt(Pointer.getLeft())+parseInt(width)>parseInt(_size[2])
      && (parseInt(Pointer.getLeft()) - parseInt(width)) > 0)
  {
    _left = (parseInt(Pointer.getLeft()) - parseInt(width)) + "px";
  }
  else if (parseInt(Pointer.getLeft())+parseInt(width)>parseInt(_size[2]))
  {
    // Can't position iframe on left side, but it's to large ... resize.
    _left = Pointer.getLeft();
    width = (parseInt(_size[2]) - parseInt(Pointer.getLeft()) - 4) + "px";
  }
  else
  {
    _left = Pointer.getLeft();
  }

  
  if (parseInt(Pointer.getTop())>parseInt(height)
      && parseInt(Pointer.getTop())+parseInt(height)>parseInt(_size[3]))
  {
    _top = (parseInt(Pointer.getTop()) - parseInt(height)) + "px";
  }
  else
  {
    _top = Pointer.getTop();
  }

  if (parseInt(_top) + parseInt(height) > parseInt(_size[3]))
  {
    _top = (parseInt(_top) - (parseInt(_top) + parseInt(height) - parseInt(_size[3])) - 32);

    if (_top < 0)
      _top = 4;

    _top = _top + "px";
  }

  create_abspos_iframe(id, url, width, height, _left, _top);
}

function create_centered_iframe(id, url, width, height)
{
  _pageSize = getPageSizeXY();
  _left = Math.round((_pageSize[2] - parseInt(width)) >> 1);
  _top = Math.round((_pageSize[3] - parseInt(height)) >> 1);
  
  if (_top<0) _top=0;
  
  create_abspos_iframe(id, url, width, height, _left, _top);
}

function create_maximized_iframe(id, url)
{
  _size = getPageSizeXY();	
  create_abspos_iframe(id, url, _size[2] - 32, _size[3] - 32, 16, 16);
}

function create_abspos_iframe(id, url, width, height, left, ttop, donthide)
{
	// Fix for IE: if called in onload ie sometimes returns 0 for the scroll offsets, only waiting resolves this
	if (typeof window.pageYOffset == 'undefined' && !navigator.userAgent.match(/MSIE 7.0/)) 
	{
	   var obj = (window.document.compatMode && window.document.compatMode == "CSS1Compat") ?
				  	 window.document.documentElement : window.document.body || null;
	     
	   if (obj.scrollTop==0 && navigator.userAgent.match(/MSIE 6.0/))
	   {
		 if (donthide == null || ! donthide)
		   hide_content_new(window,50);
		 
		 window.setTimeout("create_abspos_iframe_internal('"+id+"','"+ url+"',"+ parseInt(width)+","+ parseInt(height)+","+parseInt(left)+","+ parseInt(ttop)+",true)",500);
		 
	     return;
	   } 
	}
	create_abspos_iframe_internal(id, url, parseInt(width), parseInt(height), parseInt(left), parseInt(ttop), donthide);
}

function create_abspos_iframe_internal(id, url, width, height, left, ttop, donthide)
{
  var _append = false;

  if (!document.body.appendChild)
  	return;

  if (donthide == null
      || ! donthide)
    hide_content_new(window,50);

  _size = getPageSizeXY();	
  
  /* dynamic positioning in viewport (for ie6 only, ff and ie7 uses position:fixed if dialog height/width is smaller than viewport) */
  if ((navigator.userAgent.match(/MSIE 6.0/) && !navigator.userAgent.match(/MSIE 7.0/)) || (_size[2]<width) || (_size[3]<height))
  {
	  if (typeof window.pageYOffset != 'undefined') {
		  ttop = parseInt(ttop) + window.pageYOffset;
	  } else
  {
		  var obj = (window.document.compatMode && window.document.compatMode == "CSS1Compat") ?
				  	 window.document.documentElement : window.document.body || null;
		  
		  ttop = parseInt(ttop) + obj.scrollTop;
	  }
  }
  
  /*
  altes verhalten: macht merkw�rdige reloads beim IE
  if (navigator.userAgent.match(/MSIE/))
  {
    // This is for m$
    if (!document.getElementById(id))
    {
      ttop = parseInt(ttop) + "px";
      left = parseInt(left) + "px";
      width = parseInt(width) + "px";
      height = parseInt(height) + "px";

      iframeHTML = '\<iframe src="' + url + '" id="' + id + '" frameborder="0" style="z-index: 99; border: 1px outset #FFFFFF; position: absolute; top: ' + ttop +'; left: ' + left + '; width:' + width + '; height:' + height + '; " scrolling="auto"><\/iframe>';
      document.body.innerHTML += iframeHTML;
    }
    else
    {
      document.getElementById(id).style.left = left;
      document.getElementById(id).style.top = ttop;
    }

    return;
  }
  else
  {*/
    // And this for the rest of the world
    if (document.getElementById(id))
    {
      _frame = document.getElementById(id);
    }
    else
    {
      _frame = document.createElement("IFRAME");
      _append = true;
    }

    _frame.id = id;

    _frame.src = url;

	_frame.style.zIndex = 50;
    
	/* dynamic positioning in viewport (for ie6, ff and ie7 uses position:fixed)*/
	if ((navigator.userAgent.match(/MSIE 6.0/) && !navigator.userAgent.match(/MSIE 7.0/)) || (_size[2]<width) || (_size[3]<height))
	{
		_frame.style.position = "absolute";
	} else
	{
		_frame.style.position = "fixed";
	}
	
    _frame.style.left = parseInt(left) + "px";
    _frame.style.top = parseInt(ttop) + "px";
    
    _frame.style.display = "block";

    _frame.height = height;
    _frame.width = width;
    
    if (navigator.userAgent.match(/MSIE/))
    {
      // special ie handling
      _frame.style.border = "1px outset #ffffff";
      _frame.scrolling = "auto";
      _frame.frameBorder = "0";
    }
    else
      _frame.style.border = "1px outset gray";

	if (_append==false)
	{
		_frame.parentNode.removeChild(_frame);
	}
    document.body.appendChild(_frame);

    // IE disables some controls (edits/textarea) after reopening the iframe, this seems to fix this.
	if (navigator.userAgent.match(/MSIE/))
    {
    	_frame.focus();
    }
  //}
}

function close_iframe(id)
{
  if (parent)
  {
	if (parent.document.getElementById(id))
    {
      _frame = parent.document.getElementById(id);
      _parent = parent;
      _win = _parent.window;
      _win.onScroll = "";
     
      // Stupid: IE dont like to show content before remove, and FF dont like it the IE way...
      //         This also solves a problem if the context menu is shown in a iframe and inputs
      //         are disabled after iframe close!
      if (navigator.userAgent.match(/MSIE/))
      {
        _frame.parentNode.removeChild(_frame);
        show_content_new(_win);
        
        parent.focus();
      } else
      {
    	  show_content_new(_win);
    	  _frame.parentNode.removeChild(_frame);
      }
    }
  }
}

function resize_textarea(formid, textid)
{
  var _addrest = 20;
  var _textarea = document.forms[formid].elements[textid];

  var _size = getPageSizeXY();
  
  if (_textarea.clientHeight)
  {
    var _ch = _textarea.clientHeight;
    var _cbody = document.body.clientHeight;

    var _rest = parseInt(_cbody) - parseInt(_ch);
    var _height = parseInt(_size[3]) - _rest - _addrest;

    _textarea.style.height = _height + "px";

    if(_height < 150)
      _textarea.style.height = "150px";
  }

  /* Applet IDs defined in EISStandardLayoutImpl#writeTextareaStyledEnd() */
  var _applet = document.getElementById(textid + "_applet");

  if (_applet && _applet.clientHeight)
  {
    var _ch = _applet.clientHeight;
    var _cbody = document.body.clientHeight;

    var _rest = parseInt(_cbody) - parseInt(_ch);

    _applet.style.height = (parseInt(_size[3]) - _rest - _addrest) + "px";
  }
}

function resize_textarea_new (formid, textid)
{
	var _textarea = document.forms[formid].elements[textid];

	var _centerTextarea = function()
	{
		if (_textarea.scrollIntoView)
		{
			_textarea.scrollIntoView(false);
		}
		else
		{
			_textarea.wrappedJSObject.scrollIntoView(false);
		}
	};

	var _textareaKeydown = function(e)
	{
		if (e.shiftKey && e.ctrlKey && e.keyCode == 13)
		{
			// shift-ctrl-enter
			_textarea.rows -= 1;
			_centerTextarea();
		}
		else if (e.shiftKey && e.ctrlKey && e.keyCode == 32)
		{
			// shift-ctrl-space
			_textarea.cols -= 1;
			_centerTextarea();
		}
		else if (e.ctrlKey && e.keyCode == 13)
		{
			// ctrl-enter
			if (_textarea.offsetHeight < window.innerHeight - 40)
			{
				_textarea.rows += 1;
			}
			_centerTextarea();
		}
		else if (e.ctrlKey && e.keyCode == 32)
		{
			// ctrl-space
			if (_textarea.offsetWidth < window.innerWidth - 40)
			{
				_textarea.cols += 1;
			}
			_centerTextarea();
		}
    };

	addEvent(_textarea, 'keydown', _textareaKeydown, false);

	function addEvent(elm, evType, fn, useCapture)
	{
		if (elm.addEventListener)
		{
			elm.addEventListener(evType, fn, useCapture);
			return true;
		}
		else if (elm.attachEvent)
		{
		   var _r = elm.attachEvent('on' + evType, fn);
		   return _r;
		}
		else
		{
			elm['on' + evType] = fn;
		}
	}
}

function resize_calendarbody()
{
  var _calendarbody = document.getElementById("calendarbody");
  var _calendarcontainer = document.getElementById("calendarcontainer");

  if (navigator.userAgent.match(/ecko/)
      && _calendarbody.clientHeight
      && _calendarcontainer.clientHeight)
  {
    // FIXME Special handling for mozilla disabled ... calculation of height was completely buggy ...
    // _calendarbody.style.height = _height + "px";
    _calendarbody.style.height = "auto";
    _calendarbody.style.overflow = "auto";
  }
  else
  {
    _calendarbody.style.height = "auto";
    _calendarbody.style.overflow = "auto";
  }
}


//deprecated: use getPageSizeXY()
function screen_width()
{
  return getPageSizeXY()[2];
}

//deprecated: use getPageSizeXY()
function screen_height()
{
  return getPageSizeXY()[3];
}


function displayAttributes(obj, ignoreattr)
{
  if (!ignoreattr) ignoreattr = "";

  _text = "";
  _html = "<html><body style=\"margin: 0px; padding: 0px; border: none;\"><table cellspacing=\"1\" cellpadding=\"3\" width=\"100%\">";

  _line = 0;

  _idx = 0;

  for (_key in obj)
  {
    _idx++;

    if (ignoreattr.indexOf(_key)<0)
    {
      if (_line % 2==0)
        _bgcolor = "#FFF7F7";
      else
        _bgcolor = "#FFFFFF";

      if (typeof obj[_key] != "function" && !_key.match(/^\_/) && !_key.match(/innerHTML/))
      {
        _text += _key + "= " + obj[_key] + " / ";
        if (_idx % 10 == 0) _text += "\n";

        _html += "<tr valign=\"top\"><td bgcolor=\"" + _bgcolor + "\" width=\"100\"><b>" + _key + ":</b></td><td bgcolor=\"" + _bgcolor + "\">" + obj[_key] + "</td></tr>";

        _line++;
      }
    }
  }

  _html += "</table></body></html>";

  if (true)
  {
    alert(_text);
  }
  else
  {
    _win = window.open("", "", "width=480,height=300");
    _win.document.open();

    _win.document.write(_html)

    _win.document.close();
  }
}


function selectAll()
{
  var _elements = document.getElementsByTagName("input");
  var _i=0;
  for (_i=0;_i<_elements.length;_i++)
  {
    if (_elements[_i].getAttribute("type")!=null && _elements[_i].getAttribute("type")=='checkbox' && _elements[_i].getAttribute("onclick")!=null  && _elements[_i].getAttribute("onclick")!="")
    {
      if (_elements[_i].getAttribute("id")==null || _elements[_i].getAttribute("id").indexOf("check")<0)
      {
        if (_elements[_i].getAttribute("name")==null || _elements[_i].getAttribute("name").indexOf("check")<0)
         _elements[_i].click();
      }
    }
  }
}

/**
 * Equal to document.getElementByID - but better for testing.
 */
function findElementByID(anID, aParentElement)
{
  if (! aParentElement)
    aParentElement = document.body;

  for (var _i = 0; _i < aParentElement.childNodes.length; _i++)
  {
    _child = aParentElement.childNodes[_i];

    if (_child.id
        && _child.id == anID)
      return _child;

    if (_child.innerHTML
        && _child.innerHTML.length > 0
        && _child.innerHTML.match(/anID/))
      return _child;

    var _childchild = findElementByID(anID, _child);

    if (_childchild)
      return _childchild;
  }

  return null;
}

/**
 * Try to find a number within given html element,
 * decrease the found and put it into element.
 */
function decreaseNumber(elementID)
{
  var _element = document.getElementById(elementID);

  if (_element)
  {
    var _str = _element.innerHTML;
    var _int = parseInt(_str, 10);

    if (_int && _int > 0)
    {
      var _dint = _int - 1;

      _element.innerHTML = "" + _dint;
    }
  }
}


/**
 * toggle the display-stayle of the array of element-ids.
 */
function toggleElements(elements)
{
  var elementIDs=elements.split(",");
  for (_i=0;_i<elementIDs.length;_i++)
  {
    var _element = document.getElementById(elementIDs[_i]);
    if (_element.style.display=='none')
      _element.style.display='block';
    else
      _element.style.display='none';
  }
}


/**
 * toggle the display-stayle of the array of element-ids.
 */
function toggleImage(image, off, on)
{
  if (image.src.indexOf(off)<0)
    image.src=off;
  else
    image.src=on;
}

/**
 * Adds a function to the onload event of the current window
 */
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

/**
 * Fetches the scrollable size.
 */
function getScrollSizeXY(){

	var xScroll,yScroll;

	if (self.pageYOffset) {
		xScroll = self.pageXOffset;
		yScroll = self.pageYOffset;
	} else if (document.documentElement && (document.documentElement.scrollTop || document.documentElement.scrollLeft)){	 
		// Explorer 6 Strict
	    xScroll = document.documentElement.scrollLeft;
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {
		// all other 
		xScroll = document.body.scrollLeft;
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array(xScroll,yScroll) 
	return arrayPageScroll;
}

/**
 * Fetches the page size.
 */
function getPageSizeXY(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	var pageHeight,pageWidth;
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(parseInt(pageWidth),parseInt(pageHeight),parseInt(windowWidth),parseInt(windowHeight)) 
	return arrayPageSize;
}

/**
 * Resizes the element to the whole page size (not only viewport!).
 */
function resizeToPageSize(element)
{
	var _overallSize = getPageSizeXY();
	
	element.style.left = "0px";
	element.style.top = "0px";
	element.style.height = (_overallSize[1]-1) + "px";
	element.style.width = (_overallSize[0]-1) + "px";
}

/**
 * Resizes the element to the whole page size (not only viewport!) using the given PageSize.
 */
function resizeToPageSizeFast(element,pagesize)
{
	element.style.left = "0px";
	element.style.top = "0px";
	element.style.height = (pagesize[1]-2) + "px";
	element.style.width = (pagesize[0]-2) + "px";
}

/**
 * Shows the onsubmit progress dialog.
 */
function showProgressDialog()
{
	var _div = document.getElementById('progressdialog');
	var _inner = document.getElementById('progressdialog_inner');
	var _iframe = document.getElementById('progressdialog_iframe');
	if (_div != null && _inner != null)
	{
	    resizeToPageSize(_div);

		if (_iframe!=null)
		{
			resizeToPageSize(_iframe);
			_iframe.style.display = "inline";
		}

		if (!_inner.style.width)
			_inner.style.width = "250px";
		if (!_inner.style.height)
			_inner.style.height = "75px";

		var _scroll = getScrollSizeXY();
		var _overallSize = getPageSizeXY();

		_inner.style.left = (_scroll[0]+(_overallSize[0]>>1)-(parseInt(_inner.style.width)>>1)) + "px";
		_inner.style.top  = (_scroll[1]+(_overallSize[3]>>1)-(parseInt(_inner.style.height)>>1)) + "px";

		_div.style.display = "block";
	}

	return true;
}

/**
 * Hides the onsubmit progress dialog.
 */
function hideProgressDialog()
{
	var _div = document.getElementById('progressdialog');
	var _iframe = document.getElementById('progressdialog_iframe');
	if (_div != null)
	{
		_div.style.display = "none";
		_iframe.style.display = "none";
	}

	return true;
}

/**
 *  Shows a text inside an inputfield of no input and focus exists.
 */
function clearText(field){
	/* set text and calc color*/
    if (field.defaultValue == field.value) {
    	field.value = '';
    	field.style.opacity='1.0';
    	field.style.filter='alpha(opacity=100)';
    }
    else if (field.value == '') {
    	field.value = field.defaultValue;
    	field.style.opacity='0.5';
    	field.style.filter='alpha(opacity=50)';
    }
}

function checkUncheckAll(theElement) 
{
  var theForm = theElement.form, z = 0;
  for(z=0; z<theForm.length;z++)
  {
    if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall')
    {
  	  theForm[z].checked = theElement.checked;
    }
  }  
}

function checkAll(theElement) 
{
  var theForm = theElement.form, z = 0;
  for(z=0; z<theForm.length;z++)
  {
    if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall')
    {
  	  theForm[z].checked = true;
    }
  }  
}

function uncheckAll(theElement) 
{
  var theForm = theElement.form, z = 0;
  for(z=0; z<theForm.length;z++)
  {
    if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall')
    {
  	  theForm[z].checked = false;
    }
  }
}  

function createInputAndAppend(theParent,theName,theValue,theType)
{
	var _e = document.createElement('input');
	_e.setAttribute('type',theType);
	_e.setAttribute('name',theName);
	_e.setAttribute('value',theValue);
	theParent.appendChild(_e);
}
