
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 getOpacity(obj) {
	var opacity = 100;
	
	if ( obj ) {

		// IE/Win  = "Alpha(opacity="+opacity+")"
		if ( typeof obj.style.filter != "undefined") {
			if ( (typeof obj.filters != "undefined") && (obj.filters.alpha != null)) {
				opacity = obj.filters.alpha.opacity;
				return ( opacity );
			}
		}

		// Safari<1.2, Konqueror  = opacity/100
		if ( typeof obj.style.KHTMLOpacity != "undefined") {
			if ( obj.style.KHTMLOpacity != "" ) {
				opacity = parseInt(obj.style.KHTMLOpacity * 100);
				if ( opacity >= 99 ) opacity == 100;
				return ( opacity );
			}
		}

		// Older Mozilla and Firefox = opacity/100
		if ( typeof obj.style.MozOpacity != "undefined" ) {
			if ( obj.style.MozOpacity != "" ) {
				opacity = parseInt(obj.style.MozOpacity * 100);
				if ( opacity >= 99 ) opacity == 100;
				return ( opacity );
			}
		}

		// Safari 1.2, newer Firefox and Mozilla, CSS3 = opacity/100
		if ( typeof obj.style.opacity != "undefined" ) {
			if ( obj.style.opacity != "" ) {
				opacity = parseInt(obj.style.opacity * 100);
				if ( opacity >= 99 ) opacity == 100;
				return ( opacity );
			}
		}
	
	}
	return ( opacity );
}

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;
			var fkt = "fadeIn('"+objId+"',"+opacity+","+stop_opacity+","+step+","+interval+",'"+end_fkt+"')";
			window.setTimeout(fkt, interval);
			return;
		}
		else  {
			if ( typeof end_fkt != "undefined" ) eval (end_fkt);
		}
	}
	return;
}

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;
			var fkt = "fadeOut('"+objId+"',"+opacity+","+stop_opacity+","+step+","+interval+",'"+end_fkt+"')";
			window.setTimeout(fkt, interval);
			return;
		}
		else {
			if ( typeof end_fkt != "undefined" ) eval (end_fkt);
		}
	}
	return;
}

function resize_and_move_Element ( objId, left, top, width, height, stop_left, stop_top, stop_width, stop_height, step_left, step_top, step_width, step_height, interval, aspect_ratio, usetopasbottom ) {
	var obj = document.getElementById( objId );

	var usebottom		= false;
	if ( typeof usetopasbottom != "undefined" && usetopasbottom ) {
		usebottom = true;
	}

	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;

		left  = (left + step_left);
		if ( !((step_left < 0 && left > stop_left) || ( step_left > 0 && left < stop_left )) ) {
			left = stop_left;
		}
			

		top  = (top + step_top);
		if ( !((step_top < 0 && top > stop_top) || ( step_top > 0 && top < stop_top )) ) {
			top  = stop_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;
		}
		else {
			if ( height == -1 ) height = eliminatePX(obj.style.height);
			if ( height < 0 ) return;
			height = (height + step_height);
			if ( step_height < 0 && height < stop_height ) height = stop_height;
			if ( step_height > 0 && height > stop_height ) height = stop_height;
		}

		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";
		obj.style.left	 = left + "px";
		if ( usebottom ) {
			obj.style.bottom = top + "px";
		}
		else {
			obj.style.top	 = top + "px";
		}
		obj.style.height = Math.ceil(height) + "px";

		if ( !((left == stop_left) && (top == stop_top) && (width == stop_width) && (height == stop_height)) ) {
			window.setTimeout("resize_and_move_Element('"+objId+"',"+left+","+top+","+width+","+height+","+stop_left+","+stop_top+","+stop_width+","+stop_height+","+step_left+","+step_top+","+step_width+","+step_height+","+interval+","+aspect_ratio+","+usebottom+")", 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;

}

function toggleHooverImage ( objName, togglefix, postfix ) {

	var obj		= document.getElementsByName ( objName );
	var post	= togglefix + postfix;
	var new_src	= "";
	
	if ( obj[0] ) {
		if ( obj[0].src ) {
			var len_string	= obj[0].src.length;
			var len_post	= post.length;
			var start	= len_string - len_post;

			new_src		= obj[0].src;
			
			var post_string	= "";
			if ( start >= 0 ) post_string = obj[0].src.substring(start);
			if ( post_string == post ) {
				new_src = obj[0].src.substring ( 0, start) + postfix;
			}
			else {
				start = obj[0].src.lastIndexOf(".");
				if ( start > 0 ) {
					new_src = obj[0].src.substring ( 0, start) + post;
				}
			}
			
			var img = new Image();
			img.src = new_src;
			if ( img.height > 0 ) {
				obj[0].src = new_src;
			}
			
		}
	}

}
