
function activateTab(tab, id) {

	tabParent = tab.parentNode;
	tabs = tabParent.getElementsByTagName('div');
	for(i = 0; i < tabs.length; i++){
		if(tabs[i].parentNode == tab.parentNode) {
			tabs[i].className = 'mm-tab-header darkGrey gridwidth_1';

			/*
				IE fix (MANTIS 10910):
				Pr?fen, ob Browser = IE, dannach alle Tabs wieder auf 15.63em
				(Ausgangs-Breite von gridwidth_1) setzen
			*/
			if(navigator.appName.indexOf("Explorer") != -1){
				tabs[i].style.width = "15.63em";
			}

		}
	}
	tab.className = 'mm-tab-header lightGrey gridwidth_1';

	/*
		IE fix (MANTIS 10910):
		Pr?fen, ob Browser = IE, dannach aktuell aktiven Tab auf
		Breite gridwidth_1 + ?berstehender Teil des Containers setzen
	*/
	if(navigator.appName.indexOf("Explorer") != -1){
		tab.style.width = "15.8em";
	}

	tabNextSibling = tabParent.nextSibling;
	while(tabNextSibling.className == null || tabNextSibling.className.indexOf('mm-tab-content-container') == -1){
		tabNextSibling =  tabNextSibling.nextSibling;
	}
	contentTabs = tabNextSibling.getElementsByTagName('div');
	for(i = 0; i < contentTabs.length; i++){
		//nur elemente an der obersten Ebene ansprechen
		if(contentTabs[i].parentNode == tabNextSibling) {
			if(contentTabs[i].getAttribute('id') == id){
				contentTabs[i].style.display = 'block';
			} else {
				contentTabs[i].style.display = 'none';
			}
		}
	}
}

function changeImage(imagePath, linkPath, mmid, title, alt) {
	var currentImage = document.getElementById(String('mm-currentImage-' + mmid));
	currentImage.src = imagePath;
	currentImage.alt = alt;
	var currentTitle = document.getElementById(String('mm-picture-title-' + mmid));
	currentTitle.innerHTML = title;

	//umrahmendes Link setzen
	currentImage.parentNode.href = linkPath;

	//frame src ?berschreiben
	var lightBoxFrame = document.getElementById("iframe_" + currentImage.parentNode.rel);
	
	/*
	 * If lightBoxFrame is null here, initialize the frame and try again
	 */
	if(lightBoxFrame == null){
		initialize();
		lightBoxFrame = document.getElementById("iframe_" + currentImage.parentNode.rel);
	}
	
	lightBoxFrame.src = linkPath;
	
}



//
// SCROLLING
//
var scorllerInterval;

function scrolling(direction, containerId, innerDivId){

	stepwidth=2;
	// Because of different behavior in different browsers this offset is needed
	scrollOffset=99;

	quickcontainer = document.getElementById(containerId);
	quickclicktabelle = document.getElementById(innerDivId);

	tempPosition= quickclicktabelle.style.marginTop;
		//alert("gelesen: " + tempPosition);
	tempPosition= tempPosition.replace(/px/g,'');

	if(tempPosition=="") {
		 tempPosition="0";
	}
	topPosition = parseInt(tempPosition);

	// Container
	if (direction=="down"){
		//alert(quickclicktabelle.offsetTop + " "+ quickclicktabelle.offsetHeight + " "+quickcontainer.offsetHeight);

		if(quickclicktabelle.offsetTop + quickclicktabelle.offsetHeight + scrollOffset >= quickcontainer.offsetHeight){
				//alert("berechnet: " + topPosition - stepwidth + "px");
			quickclicktabelle.style.marginTop = topPosition - stepwidth + "px";
		}
	}
	if (direction=="up"){
		if (topPosition<0 && topPosition+stepwidth<0){
			quickclicktabelle.style.marginTop=topPosition+stepwidth+"px";
		}
		if (topPosition>=0 || topPosition+stepwidth>=0) quickclicktabelle.style.marginTop="";
	}
}


function startScrolling(direction, containerId, innerDivId) {
	var scroll = function() {
			scrolling(direction, containerId, innerDivId);
	};
	scorllerInterval = window.setInterval(scroll, 30);

}

function stopScrolling() {
	window.clearInterval(scorllerInterval);

}

//LIGHTBOX HANDLING
//When lightbox is ready, show picture and clear interval
function waitForLightBox(containerID){
	if(lightBoxReady){
		document.getElementById(containerID).style.visibility = "visible";
		window.clearInterval(wait);
	}
}

