var root = document.getElementsByTagName("html")[0];
var header = null;
var footer = null;
var content = null;
var allWorksTableCollabserHasRun = false;

jQuery(function(event) {

	
	root = document.getElementsByTagName("html")[0];
	hideNoscript();

	header = $("header");
	footer = $("footer");
	content = $("content");
	var contentHead = $("contentHead");
	var loading_img = $("loading_img");

	// collaps items
  	iterateChildren(content, "span", function(theSpan)
  	{
  		initializeCollapser(theSpan);
  	}, false);
  	
	var styleCookie = readCookie("theme1.style");
	var title = styleCookie ? styleCookie : getPreferredStyleSheet();
	setActiveStyleSheet(title);
  	
	initSubmenus();
	
	if(hasAccordion()) {
		initAccordion();
	}
	
	
	if(content)
		markExternalLinksAndReplaceTooltip();
	
	if(navigator.userAgent.indexOf("Safari")!=-1 || Prototype.Browser.IE) {
		//Quickfix
		handleResize();
		handleResize();
		handleResize();
		handleResize();
		handleResize();
		handleResize();
		handleResize();
	}
	
  Event.observe(window, "resize", handleResize);
	
	//Position the main content
	handleResize();
	
	/*Show mainContent when Loading finished*/
	if(content)
		content.style.visibility="visible";
	if(contentHead)
		contentHead.style.visibility="visible";
	//Reposition the main content (only slight changes) to reflect the changes made during becoming visible
	handleResize();
	
	/*hide loading_image when loading finished*/
  hideLoadingIndicator();
	
	/*Add direct navigation to already open page (accordion)*/
	if(hasAccordion()) {
		var location = window.location.href;
		
		iterateChildren(header, "div", function(subMenu) {
			if(Element.hasClassName(subMenu, "subnav")) {
				iterateChildren(subMenu, "a",
				function(subMenuItem) {
					var subMenuItemLink = subMenuItem.href;
					if(subMenuItemLink.indexOf("#")!=-1)
						subMenuItemLink=subMenuItemLink.substring(0, subMenuItemLink.indexOf("#"));
					if(location.indexOf(subMenuItemLink)!=-1) {
						subMenuItemLink=subMenuItem.href.substring(subMenuItem.href.indexOf("#")+1);
						Event.observe(subMenuItem, "click", new Function("activateTab(getTab("+subMenuItemLink+"));"));
					}
				}, true);
			}
		}, true);
	}
	
	/*show background*/
	exchangeBackground();
});

//on window unload, sets a cookie that contains the currently active css-style
Event.observe(window, "unload", function() {
	var title = getActiveStyleSheet();
	createCookie("theme1.style", title, 365);
});

function collapseAllWorksTable() {
	if (allWorksTableCollabserHasRun == false) {
		content = $("allWorksTable");
	
		// collaps items
	  	iterateChildren(content, "span", function(theSpan)
	  	{
	  		initializeCollapser(theSpan);
	  	}, false);
	}
	allWorksTableCollabserHasRun = true;
}

function submitForm(changed) {
	var form = document.getElementById('worksSelectionForm');
	var optionChanged = document.getElementById('optionChanged');
	optionChanged.setAttribute("value", changed);
	form.submit();
}


function hideLoadingIndicator() {
	$("loading_img").hide();
}

function showLoadingIndicator () {
	$("loading_img").show();
}

// do not display any noscript-containers
function hideNoscript() {
  noscripts = $$("noscript");
  noscripts.each(function(noscript) {
    noscript.hide();
  });
}

//is called if the window is resized. recalculates center for content and content heads, height & width for content and accordions
function handleResize() {
	root = document.getElementsByTagName("html")[0];
	header = $("header");
	footer = $("footer");
	if (!footer) {
		window.setTimeout(handleResize, 100);
		return;
	}
	content = $("content");
	var contentHead = $("contentHead");
	
	if(content) {
		var contentHeadAddition = contentHead ? contentHead.clientHeight : 0;
		var xAddition = content.clientHeight < content.scrollHeight ? -getScrollerWidth() : 0;
		centerFloatingDiv(content, xAddition, contentHeadAddition);
	}
	
	if(contentHead) {
		contentHead.style.left = content.style.left;
		contentHead.style.top = ""+(findPosY(content) - contentHead.clientHeight)-1+"px";
	}
	
	//Fix for IE-Type browsers
	var image = $("image");
	var cWidth = getClientWidth();
	var cHeight = getClientHeight();
	if(Prototype.Browser.IE && cWidth!=image.clientWidth)
		image.style.width=""+cWidth+"px";
	if(Prototype.Browser.IE && cHeight!=image.clientHeight)
		image.style.height=""+cHeight+"px";
	if(Prototype.Browser.IE && cWidth!=footer.clientWidth) {
		footer.style.width=""+(cWidth-50)+"px";
	}
	
	if(Prototype.Browser.IE && cWidth!=header.clientWidth) {
		header.style.width=""+(cWidth-50)+"px";
	}
}

//returns the anchor in an url. if no argument is present, the current location is assumed as url to be inspected
function getAnchorPath() {
	var anchorString = arguments[0] || window.location.hash;
	anchorString = anchorString.substring(anchorString.indexOf("#"));
	
	if(!anchorString.match(/^#\d+(_\d+)*$/))
		return new Array();
	
	locationsArray = $A(anchorString.substring(1).split("_"));
	resultArray = new Array();
	locationsArray.each(function(item)
	{
		resultArray[resultArray.length]= +item;
	});
	return resultArray;
}

function getAnchorTabIndex(arg) {
	var anchor = getAnchorPath(arg);
	if(anchor.length>0)
		return anchor[0];
	else
		return 0;
}

function getAnchorContentNavigationIndex(arg) {
	var anchor = getAnchorPath(arg);
	if(anchor.length>1)
		return anchor[1];
	else
		return 0;
}

//applies a certain code using eval on the submenu of a given top navigation point index. if menuId is null, all submenus will be affected
function applyOnSubmenu(menuId, code) {
	header = $("header");
	
	iterateChildren(header, "div", function(menu, submenuCounter){
		if(Element.hasClassName(menu, "subnav"))
		{
			//if menuId matches or is undefined (null)
			if(((menuId != null) && submenuCounter==menuId) || (menuId==null))
				eval("menu."+code);
		}
	}, true);
}

//initializes the submenus (dropdowns) by placing them at their correct locations
function initSubmenus() {
	header = $("header");
	var submenuCounter = 0;
	
	iterateChildren(header, "span",
	function(menu)
	{
		if(Element.hasClassName(menu, "navigation_item"))
		{
			applyOnSubmenu(submenuCounter, "style.left = '"+(findPosX(menu)-10)+"px'");
			submenuCounter++;
		}
	}, true);
}

//mouseover-handler for main navigation points to show/hide the submenus
function displaySubmenu(menuId, isShow) {
	var code="style.visibility="+(isShow ? "'visible'" : "'hidden'");
	applyOnSubmenu(menuId, code);
}

//centers a floating element horizontally and vertically
function centerFloatingDiv(layerName, offsetX, offsetY) {
	var content = $(layerName);
	
	cHeight = getClientHeight();
	cWidth = getClientWidth();
	
	content.style.left=(cWidth/2+offsetX)-((content.clientWidth+offsetX)/2)+"px";
	content.style.top=(cHeight/2+offsetY)-((content.clientHeight+offsetY)/2)+"px";
}

//sets the mode of any div (mostly #content) to scrolling depending on whether it matches certain criteria
function scrollFloatingDiv(layerName, possibleContentHeight, doHeightComparison, tolerance) {
	var content = $(layerName);
	
	var maxContentHeight = possibleContentHeight-100;
	
	/*
	//Don't do height larger than width
	if(maxContentHeight > (content.scrollWidth*0.7))
		maxContentHeight = (content.scrollWidth*0.7);
	*/
	
	//Fix max-height to 380
	if(maxContentHeight > 380)
		maxContentHeight = 380;
	
	if(!doHeightComparison)
		maxContentHeight=possibleContentHeight;
	
	var contentHeight = content.scrollHeight;
	
	if(contentHeight-tolerance > maxContentHeight)
	{
		content.style.overflow = "auto";
		content.style.height = maxContentHeight+"px";
	}
	else if(contentHeight != content.clientHeight)
	{
		content.style.overflow = "hidden";
		content.style.height = "auto";
	}
}

//returns the height of the browser window's content area
function getClientHeight() {
	var root = document.getElementsByTagName("html")[0];
	
	cHeight = root.clientHeight;
	if(cHeight == 0)
	cHeight = document.body.clientHeight;
	if(cHeight == 0)
		cHeight = document.body.scrollHeight;
	return cHeight;
}

//returns the width of the browser window's content area
function getClientWidth() {
	root = document.getElementsByTagName("html")[0];
	
	cWidth = document.body.clientWidth;
	if(cWidth == 0)
		cWidth = root.clientWidth;
	if(cWidth == 0)
		cWidth = document.body.scrollWidth;
	return cWidth;
}

/**
 *	creates ajax-requests for each individual object that is passed to the method. All requests 
 *  are processed over the url <code>CONTEXT_PATH</code>/ajax-response.do .
 *
 *  <p>Objects passed as argument must have an <code>action</code> (String) and an <code>id</code> (String) field and
 *  may have a <code>callback</code> field to be called on successfull requests.
 *
 * @param infinite number of objects for each of which a request to the server is created
 */
function getAjax() {
	var argumentCounter=0;
	for(argumentCounter=0; argumentCounter<arguments.length; argumentCounter++)
	{
		var theArgument=arguments[argumentCounter];
		var options={method:"post"};
		options.postBody="action="+theArgument.action+"&id="+theArgument.id;
		// if there is a callback provided
		if(theArgument.callback) {
			var _callback = theArgument.callback;
			options.onSuccess=function() {	
				// hides the loading indicator
				hideLoadingIndicator();
				// call callback immedeatly after the response has been received
				window.setTimeout( _callback , 10);	
			};
		}
		// makes the loading indicator visible
		showLoadingIndicator();
		// create an Ajax.Updater (from the prototype.js library)
		new Ajax.Updater(theArgument.element, CONTEXT_PATH+'/ajax-response.do', options);
	}
}

//"opens" a popup overlay by making the popup div visible and draggable
function openPopUp() {
	var popUpBorderName = "popUpBorder";
	var popUpContainer = "responseDescription";
	var popUpBorder = $(popUpBorderName);
	var responseDescriptionE = document.getElementById('responseDescription');
    var draggerTable = document.getElementById('draggerTable');
    var closeButton = $('closeXonPopUp');

	if (popUpBorder.style.display == 'block') {
	    popUpBorder.style.display="none";
	    var draggerTable = document.getElementById('draggerTable');
	    var tableWidth = '100px';
	    draggerTable.style.width = tableWidth;
	}
	
    popUpBorder.style.display="block";
    
    xMoveTo(popUpBorder, 301, 251);//element,ab.links,ab.oben
    if (Prototype.Browser.IE) {
	    xMoveTo(closeButton, xWidth(popUpBorder) - 29, 6);
    } else {
	    xMoveTo(closeButton, xWidth(popUpBorder) - 29, 7);
	}
    xMoveTo(popUpBorder, 300, 250);//element,ab.links,ab.oben
    //alert('PopUp width: ' + xWidth(popUpBorder));
  
    //correct table width and cell widths
    var tableWidth = (xWidth(popUpBorder) - 36) + 'px';
    draggerTable.style.width = tableWidth;
    xShow(popUpBorder);
}

//closes a div-popup by hiding it and then emptying it
function closePopUp() {
	//xDisableDrag(popUpBorder, false);

	var popUpBorder = $("popUpBorder");
	popUpBorder.style.display="none";

    var draggerTable = $('draggerTable');
    var tableWidth = '100px';
    draggerTable.style.width = tableWidth;

	var popUpContainer = $("popUpContainer");
	emptyElement(popUpContainer);
}

//scrolls the whatever visible Content to the top
function scrollTop() {
	var content = $("content");
	if(!content)
		return;
	if(hasAccordion())
	{
		var activeTab = arguments[0] || getOpenTab();
		content = getAccordionContent(activeTab);
	}
	content.scrollTop=0;
}

//adds adds popup and newWindow icons to all links that have the rel attribute set to popup or external, respectively
//if given an argument, only the descendants of the given element will be searched (useful after using ajax to get new content from the server)
function markExternalLinksAndReplaceTooltip() {
	var theDoc = arguments[0] || document;
	var allLinks = $A(theDoc.getElementsByTagName("a"));

	allLinks.each(function(theLink)
	{
		//Add rosa-Tooltip and remove title-attribute
		if(theLink.getAttribute("title") != null && theLink.getAttribute("title") != "")
		{
			var tt = new Tooltip();
			tt.setImage(null);
			tt.setText(theLink.getAttribute("title"));
			theLink.setAttribute("title", "");
			tt.attach(theLink);
		}
		
		//If link has no rel or rel is not one of the known ones, exit
		if(!(theLink.rel && (theLink.rel == "external" || theLink.rel == "back" || theLink.rel == "popup" || theLink.rel == "internal" || theLink.rel == "download"  || theLink.rel == "document" || theLink.rel == "noicon")))
			return;
		
		//default properties
		theLink.target="_blank";
		
		//specific properties
		switch (theLink.rel)
		{
			case "external":
				iconName = "icon_ext_link.gif";
			break;
			case "internal":
				iconName = "icon_arrow.gif";
				theLink.target="_top";
			break;
			case "back":
				iconName = "icon_back.gif";
				theLink.target="_top";
			break;
			case "popup":
				iconName = "icon_popup.gif";
			break;
			case "download":
				iconName = "icon_download.gif";
			break;
			case "document":
				iconName = "icon_file.gif";
			break;
			case "noicon":
				return;
			break;
		}
		
		addLinkImage(theLink, iconName);

	});
}

function addLinkImage(link, iconName) {
	var iconPath = CONTEXT_PATH+"/themes/rosa1/_img/icons/";
	var linkIcon = document.createElement("img");
	Element.addClassName(linkIcon, "linkAttributeIcon");
	linkIcon.src=iconPath+iconName;
	Event.observe(link, "mouseover", new Function("exchangeHoverImage(this);"));
	Event.observe(link, "mouseout", new Function("exchangeHoverImage(this);"));
	link.insertBefore(linkIcon, link.firstChild);
}

//mouseover-event-handler for link-accompanying images that switch between active and inactive states
function exchangeHoverImage(element) {
	var image=element.firstChild;
	var searcher = arguments[1] || "_a.gif";
	var replacer = arguments[2] || ".gif";
	
	exchangeImageSrc(image, searcher, replacer);
}

function exchangeImageSrc(image, searcher, replacer) {
	if(image.src.indexOf(searcher)!=-1) {
		image.src=image.src.replace(searcher, replacer);
	} else {
		image.src=image.src.replace(replacer, searcher);
	}
}

/** 
 * Gets a new background from the server by appending a unique 
 * timestamp which prevents the browser from caching, sets the background src
 */
function exchangeBackground() {
	if($("image").hasClassName('special')) {
		return;
	}
	var evaluateMetaData = function(transport) {
		var exifElement = transport.responseXML.documentElement;
		$("image").src = exifElement.getAttribute("path");
		
		var description = exifElement.getAttribute("description");
		var copyright = exifElement.getAttribute("copyright");
		
		var image_metadata = $("image_metadata");
		
		if(description || copyright) {
			if(!image_metadata) {
				image_metadata = document.createElement("div");
				image_metadata.setAttribute("id", "image_metadata");
				document.body.appendChild(image_metadata);
			}
			emptyElement(image_metadata);
			description = description ? description+" / " : "";
			copyright = copyright || "";
			image_metadata.appendChild(document.createTextNode("Image: "+description+copyright))
			image_metadata.show();
		} else if(image_metadata) {
			image_metadata.hide();
		}
	};
	
	var parameters={};
	if(hasAccordion())
	{
		var activeTab = arguments[0] || getOpenTab();
		var activeTabLink = getLinkForTab(activeTab);
		var tabText = activeTabLink.firstChild.nodeValue;
		parameters['accordion_tab']=tabText;
	}
	parameters['location']=window.location.pathname;
	
	new Ajax.Request(CONTEXT_PATH+"/image-copyright", {onSuccess:evaluateMetaData, parameters: parameters, method: "get"});
}

/*
provides ruby-style iteration over a tag's direct or any children
(depending on whether the fourth argument, directOnly is set to true or false, respectively)
deprecated. use Prototype's each() instead
*/
function iterateChildren(tag, childTagName, functionToExecute) {
	var directOnly = arguments[3] || false;
	if(typeof(functionToExecute)=="string")
		functionToExecute=new function(arg){exec(functionToExecute+"("+arg+")");};
	
	var children=tag.getElementsByTagName(childTagName);
	
	var kidCounter=0;
	var usedKidCounter=0;
	var theChild;
	for(kidCounter=0;kidCounter<children.length;kidCounter++)
	{
		theChild=children[kidCounter];
		//Only iterate if directOnly is false or theChild is a direct child of tag
		if((!directOnly)||(theChild.parentNode==tag))
		{
			var res = functionToExecute(theChild, usedKidCounter);
			usedKidCounter++;
			if(res===false)
				return theChild;
		}
	}
}

function emptyElement(el) {
	el = $(el);
	$A(el.childNodes).each(function(child)
	{
		el.removeChild(child);
	});
}

function showRestOfElement(hideItem) {
	var allItems = $A(hideItem.parentNode.childNodes);
	allItems.each(function(item)
	{
		if(item.nodeType != 1 )//Node.ELEMENT_NODE
			return;
		if(item !== hideItem)
		{
			item.style.display = item.style.display == "none" ? "" : "none";
		}
	});
	exchangeHoverImage(hideItem, "icon_show", "icon_hide");
	var replaceToShow = (hideItem.childNodes[1].nodeValue.indexOf("Show")===-1)
	var searcher = replaceToShow ? /Hide/ : /Show/;
	var replacer = replaceToShow ? "Show" : "Hide";
	hideItem.childNodes[1].nodeValue = hideItem.childNodes[1].nodeValue.replace(searcher, replacer);
}

// Tooltip
var Tooltip = Class.create({
  initialize: function() {
    this.element = 	document.createElement("div");
    Element.addClassName(this.element, "tooltip");
	  
  	this.title = document.createElement("div");
  	Element.addClassName(this.title, "tooltip-title");
	  
  	this.image = document.createElement("img");
    Element.addClassName(this.image, "tooltip-image");
	  
  	this.element.appendChild(this.image);
  	this.element.appendChild(this.title);
	  
  	if(!Prototype.Browser.IE) {
  		this.element.style.position = "fixed";
	  }
	  
  	document.body.appendChild(this.element);
  },
  
  show: function(htmlText , x, y, upSide) {
		this.element.style.visibility = "visible";
		if(x && y)
			this.setPosition( x, y , upSide);
		if(this.image && this.title.style.width == "" && this.image.clientWidth!=0)
			this.title.style.width = ""+this.image.clientWidth+"px";
	},
	
  hide: function() {
		this.element.style.top = "0px";
		this.element.style.left = "0px";
		this.element.style.visibility = "";
	},
	
  setPosition: function(x, y, upSide) {
	    if(upSide)
	        y -= this.element.offsetHeight;
	    this.element.style.left = "" + (x+5) + "px";
	    this.element.style.top = "" + (y-5) + "px";
	},
  
  setText: function(text) {
		emptyElement(this.title);
		this.title.appendChild(document.createTextNode(text));
	},
  
  setImage: function(imageLocation) {
		if(imageLocation == null)
		{
			this.element.removeChild(this.image);
			return;
		}
		
		setImage(this.image, imageLocation);
	},
  
  showDefault: function(event) {
		var pos = this.correspondingTooltip.getPreferredPosition(event, this.correspondingTooltip);
		this.correspondingTooltip.show('', pos[0], pos[1], true);
	},
  
  showDefaultDown: function(event) {
		var pos = this.correspondingTooltip.getPreferredPosition(event, this.correspondingTooltip);
		this.correspondingTooltip.show('', pos[0], pos[1], false);
	},
  
  setPositionDefault: function(event) {
		var pos = this.correspondingTooltip.getPreferredPosition(event, this.correspondingTooltip);
		this.correspondingTooltip.setPosition(pos[0], pos[1], true);
	},
  
  getPreferredPosition: function(event, tooltip) {
		if(!event) event = window.event;
		var addX = 5, addY = 5;
		var endX = event.clientX+addX;
		var endY = event.clientY+addY;
		return [endX, endY];
	},
  
  hideDefault: function() {
	    this.correspondingTooltip.hide();
	},
  
  attach: function(to) {
		to.correspondingTooltip = this;
		Event.observe(to, "mouseover", this.showDefault.bindAsEventListener(to));
		Event.observe(to, "mousemove", this.setPositionDefault.bindAsEventListener(to));
		Event.observe(to, "mouseout", this.hideDefault.bindAsEventListener(to));
	}
});

function initializeCollapser(collapser) {
  	if(!Element.hasClassName(collapser, "collapser"))
  		return false;
	addLinkImage(collapser, "icon_hide.gif");
	Event.observe(collapser, "click", new Function("showRestOfElement(this);"));
	showRestOfElement(collapser);
	return true;
}

//-------------------------------//
//copied functions, not by rosa  //
//-------------------------------//

/*returns the size of any scrollbar*/
function getScrollerWidth() {
    var scr = null;
    var inn = null;
    var wNoScroll = 0;
    var wScroll = 0;

    // Outer scrolling div
    scr = document.createElement('div');
    scr.style.position = 'absolute';
    scr.style.top = '-1000px';
    scr.style.left = '-1000px';
    scr.style.width = '100px';
    scr.style.height = '50px';
    // Start with no scrollbar
    scr.style.overflow = 'hidden';

    // Inner content div
    inn = document.createElement('div');
    inn.style.width = '100%';
    inn.style.height = '200px';

    // Put the inner div in the scrolling div
    scr.appendChild(inn);
    // Append the scrolling div to the doc
    document.body.appendChild(scr);

    // Width of the inner div sans scrollbar
    wNoScroll = inn.offsetWidth;
    // Add the scrollbar
    scr.style.overflow = 'auto';
    // Width of the inner div width scrollbar
    wScroll = inn.offsetWidth;

    // Remove the scrolling div from the doc
    document.body.removeChild(scr);

    // Pixel width of the scroller
    return (wNoScroll - wScroll);
}

//returns the user's preferred stylesheet that is stored in a cookie
function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

//returns the name of the active css style
function getActiveStyleSheet() {
	var i, a;
 	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
  		if(a.getAttribute("rel").indexOf("style") != -1
  			&& a.getAttribute("title")
  			&& !a.disabled)
  		return a.getAttribute("title");
  	}
  	return null;
}

//set the active css style via name
function setActiveStyleSheet(title) {
   	var i, a, main;
   	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
     	if(a.getAttribute("rel").indexOf("style") != -1
        	&& a.getAttribute("title"))
        {
       		a.disabled = true;
       		if(a.getAttribute("title") == title) a.disabled = false;
     	}
   }
}

//find an object's horizontal position on screen, 0 is left
function findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

//find an object's vertical position on screen, 0 is top
function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

//creates any cookie
function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}


//reads a cookie
function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

//sets the src of the image with id to src
function setImage(id, src) {
	var idRef = $(id);
	idRef.setAttribute("src", src);
}

function log ( txt ) {
    var log = document.getElementById( "log" );
    if (!log) {
        log = document.createElement( "div" );
        log.id = "log" ;
        log.style.backgroundColor = "black";
        log.style.bottom = "10px";
        log.style.border = "dotted white";
        log.style.padding = "10px";
        log.style.position = "absolute";
        log.style.right = "200px";
        log.style.zIndex = "25";
        log.innerHTML = "<a href='#' onclick='resizeLog()'>rsz</a><br />";
        document.body.appendChild( log ) ;
    }
	var br = document.createElement("br");
	log.appendChild(document.createTextNode(txt));
	log.appendChild(br);
}

function resizeLog() {
    var logDiv = document.getElementById( "log" );
	var tabs = getTabs();
}

Normal1 = document.createElement("img");
Normal1.src = CONTEXT_PATH+"/themes/rosa1/_img/icons/icon_asterisk_a.gif";     /* erste Standard-Grafik */

Highlight1 = document.createElement("img");
Highlight1.src = CONTEXT_PATH+"/themes/rosa1/_img/icons/icon_asterisk.gif"; /* erste Highlight-Grafik */

function Bildwechsel (Bildnr, Bildobjekt) {
  window.document.images[Bildnr].src = Bildobjekt.src;
  /*Kein document.images bitte, gruusig *shiver, es gibt schon eine Funktion für mouseovers, sie heisst exchangeHoverImage()
  	Ausserdem: Funktionsname immer klein es ist der eines Konstruktors, das Selbe gilt für Variablen und Parameter
  */
}