if(typeof html_GetElement !== 'function'){
function html_GetElement(pNd){
    try{
      var node;
      switch(typeof (pNd)){
        case 'string':node = document.getElementById(pNd); break;
        case 'object':node = pNd; break;
        default:node = false; break;
      }
      return node;
    }catch(e){return false;}
  }
}

if(typeof html_HideElement !== 'function'){
  function html_HideElement(pNd){
      var node = html_GetElement(pNd);
      if (node) {node.style.display = "none"};
    return node;
  }
}

if(typeof html_ShowElement !== 'function'){
  function html_ShowElement(pNd){
      var node = html_GetElement(pNd);
      if (node) {node.style.display = ""};
    return node;
    }
}

//determine size of document
var xWidth,yHeight;
function getDocSize(){
	var test1 = document.body.scrollHeight;
	var test2 = document.body.offsetHeight
	if (test1 > test2) // all but Explorer Mac
	{
		xWidth = document.body.scrollWidth;
		yHeight = document.body.scrollHeight;
	}
	else // Explorer Mac;
		//would also work in Explorer 6 Strict, Mozilla and Safari
	{
		xWidth = document.body.offsetWidth;
		yHeight = document.body.offsetHeight;
	}
}

//determine scrolling
var xPos,yPos;
function getScrolling(){
	if (self.pageYOffset) // all except Explorer
	{
		xPos = self.pageXOffset;
		yPos = self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
		// Explorer 6 Strict
	{
		xPos = document.documentElement.scrollLeft;
		yPos = document.documentElement.scrollTop;
	}
	else if (document.body) // all other Explorers
	{
		xPos = document.body.scrollLeft;
		yPos = document.body.scrollTop;
	}
}

//determine size of viewport
var xDim,yDim;
function getViewportSize(){
	if (self.innerHeight) // all except Explorer
	{
		xDim = self.innerWidth;
		yDim = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		xDim = document.documentElement.clientWidth;
		yDim = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		xDim = document.body.clientWidth;
		yDim = document.body.clientHeight;
	}
}

// some nice fading with opacity
function opac_fade(myid,source,target,duration){
	if (duration == null) duration = 500;
	//default: fade in
	if (source == null) source = 0;
	if (target == null) target = 500;
	
	//calculate steps
	var delta = target - source;
	var speed = Math.round(duration / Math.abs(delta));
	var timer = 0;
	
	//set initial opacity-level
	setOpacity(myid,source);

	if (source < target){ //fade in
		//alert('fadein');
		for (i = source; i <= target;i++){
			setTimeout("setOpacity('" + myid + "'," + i + ")",(timer * speed));
			timer++;
		}
	}

	else if(source > target){//fade out
		//alert('fadeout');
		for(i = source;i >= target;i--){
			setTimeout("setOpacity('" + myid + "'," + i + ")",(timer * speed));
			timer++;
		}
	setTimeout("html_HideElement('" + myid + "')",duration);
	}
}

function fogScreen(level){
if(level == null) level = 70;
mydiv = document.appendChild('div');
mydiv.id="fog_div";
mydiv.style="background-color:#FFF;opacity:" + (level / 100) + ";-moz-opacity:" + eval(level / 100) + ";filter:alpha(opacity=" + level + ");position:absolute;top:0px;left:0px;";
getDocSize();
alert(xWidth);
mydiv.width = xWidth;
mydiv.height = yHeight;
}

//set opacity of element to value in percent
function setOpacity(myid,value){
  //CSS 3.0
  html_GetElement(myid).style.opacity = (value / 100);
  //Firefox/Mozilla
  html_GetElement(myid).style.MozOpacity = (value / 100);
  //Internet Exploder
  html_GetElement(myid).style.filter = "alpha(opacity=" + value + ")";
}

//center element with css on screen
function centerElement(myid){
  getViewportSize();
  getScrolling();
  myItem = html_GetElement(myid);
  //myItem.style.position = "relative";
  if(myItem){
    itemWidth = myItem.offsetWidth;
    itemHeight = myItem.offsetHeight;
    if(itemWidth == NaN) itemWidth = 0;
    if(itemHeight == NaN) itemHeight = 0;
  
    //alert(myItem.id + '= y: ' + eval(yPos + Math.round(yDim / 2) - Math.round(itemHeight / 2)) + ', x: ' + eval(xPos + Math.round(xDim / 2) - Math.round(itemWidth / 2)));
    myItem.style.top = eval(yPos + Math.round(yDim / 2) - Math.round(itemHeight / 2)) + "px";
    myItem.style.left = eval(xPos + Math.round(xDim / 2) - Math.round(itemWidth / 2)) + "px";
    //alert(myItem.id + '= y: ' + myItem.style.top + ', x: ' + myItem.style.left);
  }
}