//	Smart Mini Tabs by Rob L Glazebrook.
//	Last edited: Feb. 10, 2006
//	This script is based on slayeroffice's focus slide navigation:		
//	http://slayeroffice.com/code/focus_slide/



//var d=document;			// These four variables
var activeLI2 = 0;		// should not be
var currentLI2 = 0;		// edited unless you
var zInterval2 = null;	// really know your stuff

var SLIDE_STEP2 = 3;		// # of pixels to slide each step (higher is faster)
var RESIZE_STEP2 = 1;	// # of pixels to resize each step (higher is faster)

function initSlider2() {
	if(!document.getElementById || window.opera)return;

	mObj2 = d.getElementById("navheader2");
	liObj2 = mObj2.getElementsByTagName("li");
	aObj2 = mObj2.getElementsByTagName("a");

	for(i=0;i<liObj2.length;i++) { // create mouseovers/mouseouts for the li's and the ul
		liObj2[i].xid1 = i;
		liObj2[i].onmouseover = function() { initSlide2(this.xid1); }
	}
	mObj2.onmouseout = function() { initSlide2(currentLI2); }

	// create the slider object
	slideObj2 = mObj2.appendChild(d.createElement("div"));
	slideObj2.id = "slider2";

	// position the slider over the current li
	initActive2(); 
	x2 = liObj2[activeLI2].offsetLeft;
	y = liObj2[activeLI2].offsetTop;//-3; (end) auskommentiert
	slideObj2.style.top = y + "px";
	slideObj2.style.left = x2 + "px";
	slideObj2.style.width = liObj2[activeLI2].offsetWidth + "px";
}

function initActive2() { // discover the current tab by comparing anchor hrefs to the window href
	for(i=0;i<aObj2.length;i++) {
		if(d.location.href.indexOf(aObj2[i].href)>=0) {
			activeLI2 = currentLI2 = i;
		}
	}
	liObj2[currentLI2].className=liObj2[currentLI2].className +" current";	//set a class so the li can be styled
}

function initSlide2(objIndex2) {
	if(objIndex2 == activeLI2)return;
	clearInterval(zInterval2);
	activeLI2 = objIndex2;
	destX2 = liObj2[activeLI2].offsetTop;		// the desination location
	destW2 = liObj2[activeLI2].offsetWidth;	// the destination size
	intervalMethod2 = function() { doSlide2(destX2); }
	zInterval2 = setInterval(intervalMethod2,10);
}

function doSlide2(dX2) { // move the slider div
	x2 = slideObj2.offsetTop;
	if(x2+SLIDE_STEP2<dX2) {
		// if the x-value is less than its destination, move it to the right
		x2+=SLIDE_STEP2;
		slideObj2.style.top = x2 + "px";
		doResize2(destW2);
	} else if (x2-SLIDE_STEP2>dX2) {
		// if the x-value is more than its destination, move to the left
		x2-=SLIDE_STEP2;
		slideObj2.style.top = x2 + "px";
		doResize2(destW2);
	} else  {
		// if the div is within SLIDE_STEP2 pixels, move it to the proper location
		slideObj2.style.top = dX2 + "px";
		slideObj2.style.width = destW2 +"px";
		clearInterval(zInterval2);
		zInterval2 = null;
	}
}

function doResize2(dW2) { // resize the slider div -- similar in execution to doSlide2
	w = slideObj2.offsetWidth;
	if (slideObj2.offsetWidth!=dW2) {
		if (w+RESIZE_STEP2<dW2) {
			w+=RESIZE_STEP2;
			slideObj2.style.width = w + "px";
		} else if (w-RESIZE_STEP2>dW2) {
			w-=RESIZE_STEP2;
			slideObj2.style.width = w + "px";
		} else {
			slideObj2.style.width = dW2 + "px";
		}
	}
}
