
function setOpacityId ( id, opacity ) {
	var obj = document.getElementById(id);
	setOpacity ( obj, opacity );
}


function setOpacity(obj, opacity) {

  if ( obj ) {

  	opacity = (opacity == 100)?99.999:opacity;
  
  	// IE/Win
  	obj.style.filter = "Alpha(opacity="+opacity+")";
  
  	// Safari<1.2, Konqueror
  	obj.style.KHTMLOpacity = opacity/100;
  
  	// Older Mozilla and Firefox
  	obj.style.MozOpacity = opacity/100;
  
  	// Safari 1.2, newer Firefox and Mozilla, CSS3
  	obj.style.opacity = opacity/100;
  }
}

function fadeIn(objId,opacity,stop_opacity,step,interval, end_fkt) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity <= stop_opacity) {
      setOpacity(obj, opacity);
      opacity += step;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+","+stop_opacity+","+step+","+interval+","+end_fkt+")", interval);
    }
    else  {
      if ( end_fkt ) end_fkt ();
    }
  }
}

function fadeOut(objId,opacity,stop_opacity,step, interval, end_fkt ) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity >= stop_opacity) {
      setOpacity(obj, opacity);
      opacity -= step;
      window.setTimeout("fadeOut('"+objId+"',"+opacity+","+stop_opacity+","+step+","+interval+","+end_fkt+")", interval);
    }
    else {
      if ( end_fkt ) end_fkt ();
    }
  }
}

function resize_and_move_Element ( objId, left, top, width, stop_left, stop_top, stop_width, step_left, step_top, step_width, interval, aspect_ratio ) {
	var obj = document.getElementById( objId );

	if ( obj ) {
	
		if ( left  == -1 )  left  = eliminatePX(obj.style.left);
		if ( top   == -1 )  top   = eliminatePX(obj.style.top);
		if ( width == -1 )  width = eliminatePX(obj.style.width);
		if ( width < 0 ) return;

		ratio_width  = obj.width;
		if ( !ratio_width && obj.clientWidth )   ratio_width  = obj.clientWidth;
		if ( !ratio_width && obj.offestWidth )   ratio_width  = obj.offsetWidth;

		if ( step_left < 0 && left > stop_left ) left  = (left + step_left);
		if ( step_left > 0 && left < stop_left ) left  = (left + step_left);

		if ( step_top < 0 && top > stop_top ) top  = (top + step_top);
		if ( step_top > 0 && top < stop_top ) top  = (top + step_top);

		width = (width + step_width);

		if ( aspect_ratio ) {
			ratio_height = obj.height;
			if ( !ratio_height && obj.clientHeight ) ratio_height = obj.clientHeight;
			if ( !ratio_height && obj.offsetHeight ) ratio_height = obj.offestHeight;
			ratio = ratio_height / ratio_width;
			var height = ratio * width;
		}

		if ( step_width < 0 && width < stop_width ) width = stop_width;
		if ( step_width > 0 && width > stop_width ) width = stop_width;

		obj.style.width  = width  + "px";
		if ( height ) obj.style.height = Math.ceil(height) + "px";
		obj.style.left	 = left + "px";
		obj.style.top	 = top + "px";

		if ( step_width < 0 ) {
			if ( width > stop_width ) {
				window.setTimeout("resize_and_move_Element('"+objId+"',"+left+","+top+","+width+","+stop_left+","+stop_top+","+stop_width+","+step_left+","+step_top+","+step_width+","+interval+")", interval);
			}
		}
		else {
			if ( width < stop_width ) {
				window.setTimeout("resize_and_move_Element('"+objId+"',"+left+","+top+","+width+","+stop_left+","+stop_top+","+stop_width+","+step_left+","+step_top+","+step_width+","+interval+")", interval);
			}
		}
	}
}

function move ( objId, left, top, stop_left, stop_top, step_left, step_top, interval, end_fkt ) {
	var obj = document.getElementById( objId );

	if ( obj ) {
		if ( left  == -1 )  left  = eliminatePX(obj.style.left);
		if ( top   == -1 )  top   = eliminatePX(obj.style.top);

		if ( step_left < 0 && left > stop_left ) left  = (left + step_left);
		if ( step_left > 0 && left < stop_left ) left  = (left + step_left);

		if ( step_top < 0 && top > stop_top ) top  = (top + step_top);
		if ( step_top > 0 && top < stop_top ) top  = (top + step_top);

		if ( step_left > 0 && left > stop_left ) left = stop_left;
		if ( step_left < 0 && left < stop_left ) left = stop_left;
		if ( step_top  > 0 && top  > stop_top  ) top  = stop_top;
		if ( step_top  < 0 && top  < stop_top  ) top  = stop_top;

		obj.style.left	 = left + "px";
		obj.style.top	 = top + "px";

		if ( stop_left != left || stop_top != top ) {
			var end_fkt_str = "";
			if ( typeof end_fkt == "string" && end_fkt != "" ) end_fkt_str = ",\""+end_fkt+"\"";
			var fkt = "move ('"+objId+"',"+left+","+top+","+stop_left+","+stop_top+","+step_left+","+step_top+","+interval+end_fkt_str+")";
			window.setTimeout(fkt, interval);
		}
		else {
			if ( typeof end_fkt == "string" && end_fkt != "" ) eval ( end_fkt );
		}
	}
}

function eliminatePX ( str ) {
	return ( Math.ceil(str.substr(0, str.length-2)) );
}

function hide ( objId ) {
	var obj = document.getElementById ( objId );
	if ( obj ) obj.style.visibility = "hidden";
}

function show ( objId, left, top ) {
	var obj = document.getElementById ( objId );
	if ( obj ) {
		obj.style.visibility = "visible";
		if ( left ) obj.style.left	= left;
		if ( top )  obj.style.top	= top;
	}
}

function showDisplay ( objId ) {
	var obj = document.getElementById ( objId );
	if ( obj ) obj.style.display = "inline";
}

function hideDisplay ( objId ) {
	var obj = document.getElementById ( objId );
	if ( obj ) obj.style.display = "none";
}

function resetElement ( objId, left, top, width, height ) {
	var obj = document.getElementById ( objId );

	if ( obj ) obj.style.left   = left + "px";
	if ( obj ) obj.style.top    = top + "px";
	if ( obj ) obj.style.width  = width + "px";
	if ( obj ) obj.style.height = height + "px";

	if ( obj ) obj.width  = width;
	if ( obj ) obj.height = height;

}


