function el(id) { return document.getElementById(id); }
var maxLeft = new Array("0");
function setTabs(parent) {
	var tabs=el(parent).getElementsByTagName('li');
	var maxWd=parseFloat(el(parent).clientWidth);
	for(i=0;i<tabs.length;i++) {
		if(i==0) {
			tabs[i].style.marginLeft=0;
			tabs[i].firstChild.style.cursor = "auto";
			tabs[i].firstChild.onclick = new Function("x=1;");
		} else {
			tabs[i].style.marginLeft=maxWd-(13*(tabs.length-i))+"px";
			tabs[i].firstChild.style.cursor = "pointer";
			tabs[i].firstChild.onclick=new Function("autoRun=0;displayTab('"+parent+"',"+i+",0);return false;");
			maxLeft[i] = maxWd-(13*(tabs.length-i));
		}
	}
}
function displayTab(parent,number,run) {
	if(typeof timer!="undefined") window.clearTimeout(timer);
	if(typeof timer2!="undefined") window.clearTimeout(timer2);
	if(run!="") autoRun = run;
	timer=window.setTimeout('slideTab("'+parent+'",'+number+')',1);
}
function slideTab(parent,number) {
	var tabs=el(parent).getElementsByTagName('li');
	var maxWd=parseFloat(el(parent).clientWidth);
	if(parseFloat(tabs[number].style.marginLeft)==number*13&&number+1<tabs.length) {
		if(parseFloat(tabs[number+1].style.marginLeft)<maxLeft[number+1]) {
			for(i=number+1;i<tabs.length;i++) {
				if(parseFloat(tabs[i].style.marginLeft)<maxLeft[i]) {
					if(parseFloat(tabs[i].style.marginLeft)+13>=maxLeft[i]) tabs[i].style.marginLeft=maxLeft[i]+"px";
					else tabs[i].style.marginLeft=parseFloat(tabs[i].style.marginLeft)+13+"px";
				}
			}
			if(typeof timer!="undefined") window.clearTimeout(timer);
			timer=window.setTimeout('slideTab("'+parent+'",'+number+')',1);
		}
		else {
			var newNum=number+1;
			if(newNum==tabs.length) newNum=0;
			if(autoRun) timer2=window.setTimeout('displayTab("'+parent+'",'+newNum+',1)',10000);
			else timer2 = window.setTimeout('displayTab("'+parent+'",'+newNum+',1)',25000);
		}
		for(i=0;i<tabs.length;i++) {
			if(i==number) {
				tabs[i].firstChild.onclick = new Function("x=1;");
				tabs[i].firstChild.style.cursor = "auto";
			} else {
				tabs[i].firstChild.style.cursor = "pointer";
				tabs[i].firstChild.onclick=new Function("autoRun=0;displayTab('"+parent+"',"+i+",0);return false;");
			}
		}
	} else if(parseFloat(tabs[number].style.marginLeft)>number*13) {
			for(i=1;i<=number;i++) {
				if(parseFloat(tabs[i].style.marginLeft)>i*13) {
					if(parseFloat(tabs[i].style.marginLeft)-13<=i*13) tabs[i].style.marginLeft=i*13+"px";
					else tabs[i].style.marginLeft=parseFloat(tabs[i].style.marginLeft)-13+"px";
				}
			}
			if(typeof timer!="undefined") window.clearTimeout(timer);
			timer=window.setTimeout('slideTab("'+parent+'",'+number+')',1);
	} else {
		for(i=0;i<tabs.length;i++) {
			if(i==number) {
				tabs[i].firstChild.onclick = new Function("x=1;");
				tabs[i].firstChild.style.cursor = "auto";
			} else {
				tabs[i].firstChild.style.cursor = "pointer";
				tabs[i].firstChild.onclick=new Function("autoRun=0;displayTab('"+parent+"',"+i+",0);return false;");
			}
		}
		var newNum=number+1;
		if(newNum==tabs.length) newNum=0;
		if(autoRun) timer2=window.setTimeout('displayTab("'+parent+'",'+newNum+',1)',10000);
		else timer2=window.setTimeout('displayTab("'+parent+'",'+newNum+',1)',25000);
	}
}
var autoRun=1;
timer2=window.setTimeout('displayTab("slider",1,1)',10000);
setTabs('slider');
