function topMenuOver(el) {
	return;
	if (el.className.indexOf("_over") == -1) {
		el.className = el.className + "_over";
	}
}

function shortInfo() {
	var obj1 = null;
	var obj2 = null;
	var obj3 = null;
	if (document.all) {
		obj1 = document.all["short_shadowbox_container"];
		obj2 = document.all["short_shadowbox_overlay"];
		obj3 = document.all["ShortInfoLayer"];
	}
	else {
		obj1 = document.getElementById("short_shadowbox_container");
		obj2 = document.getElementById("short_shadowbox_overlay");
		obj3 = document.getElementById("ShortInfoLayer");
	}
	obj1.style.visibility="visible";
	obj2.style.visibility="visible";
	obj3.style.visibility="visible";

	//obj1.style.opacity = 0.8;
}

function topMenuOut(el) {
	return;
	if (el.className.indexOf("_over") != -1) {
		el.className = el.className.substring(0, el.className.length - 5);
	}
}

function wmCount(u) {
	wm_page_name = ""+u;
		
  wm_page_name = wm_page_name.toLowerCase();

	if (wm_page_name.indexOf(".youtube.") == -1) {
		var ssPos = wm_page_name.indexOf("://");
		if (ssPos != -1) {
			wm_page_name = wm_page_name.substring(ssPos+3);
		}
		wm_page_name = wm_page_name.substring(wm_page_name.indexOf("/"));      
	}
	
  wm_custnum="478f87f44a5295df";
	wm_group_name="typo3";
	//wiredminds.count(wm_page_name);
	setTimeout("doWMCount()", 500);
	//doWMCount();
//	wiredminds.count();
	
}

function wmCountDirect(u) {
        wm_page_name = ""+u;

  wm_page_name = wm_page_name.toLowerCase();

        if (wm_page_name.indexOf(".youtube.") == -1) {
                var ssPos = wm_page_name.indexOf("://");
                if (ssPos != -1) {
                        wm_page_name = wm_page_name.substring(ssPos+3);
                }
                wm_page_name = wm_page_name.substring(wm_page_name.indexOf("/"));
        }

  wm_custnum="478f87f44a5295df";
        wm_group_name="typo3";
      wiredminds.count();

}


function doWMCount() {
	var url = "http://wm.wiredminds.de/track/ctin.php?wm_custnum="+
		wm_custnum+"&nojs=1&wm_page_name="+escape(wm_page_name)+"&wm_group_name="+wm_group_name+"&noCache="+new Date().getTime();
//alert(url);		
	document.getElementById("wm_iframe").src=url;
	//alert(url);
	/*
	xmlhttpGet(url);
	*/
}

function xmlhttpGet(strURL) {
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}
	
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}

  xmlhttp.open("GET", strURL, true);
  //xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  xmlhttp.send(null);
}

function initLinks() {
  var myLinks = document.links;
  for(var i=0;i < myLinks.length;i++) {
    var thehref = myLinks[i].href.toString().toLowerCase();
		var isDL = myLinks[i].getAttribute("isdownload");
		if (isDL != null && isDL == "true") {
			if (window.addEventListener) { 
				myLinks[i].addEventListener('click', downloadAction, false);
			} 
			else if (window.attachEvent) { 
				myLinks[i].attachEvent('onclick',downloadAction);
			}			
    }
		
		if (thehref.indexOf("youtube.com") != -1 || (thehref).indexOf(".pdf") != -1 || (thehref).indexOf(".doc") != -1 ||
		 (thehref).indexOf(".exe") != -1  || (thehref).indexOf(".zip") != -1 || (thehref).indexOf(".jpg") != -1 ||
		 (thehref).indexOf(".png") != -1) {
			
			if (window.addEventListener) { 
				myLinks[i].addEventListener('click', wmAction, false);
			} 
			else if (window.attachEvent) { 
				myLinks[i].attachEvent('onclick',wmAction);
			}			
    }

  }
	/*
	if (document.getElementById("addany").innerHTML == "-") {
		document.getElementById("addany").innerHTML = "<a class=\"a2a_dd\" href=\"http://www.addtoany.com/share_save?linkname=agorum&amp;linkurl=http%3A%2F%2Fwww.agorum.com\"><img src=\"/fileadmin/templates/agorum/img/weitersagen.gif\" width=\"171\" height=\"16\" border=\"0\" alt=\"Share/Bookmark\"/></a><script type=\"text/javascript\">a2a_linkname=\"agorum\";a2a_linkurl=\"http://www.agorum.com\";a2a_onclick=1;</script><script type=\"text/javascript\" src=\"http://static.addtoany.com/menu/locale/de.js\" charset=\"utf-8\"></script><script type=\"text/javascript\" src=\"http://static.addtoany.com/menu/page.js\"></script>";
		a();
	}
	*/
}

var askedForInfo = false;
function downloadAction(e) {
	var targ;
	if (!e) var e = window.event;
	if (e.target) { 
		targ = e.target;
	}
	else if (e.srcElement) {
		targ = e.srcElement;
	}
	
	if (targ.nodeType == 3) {
		targ = targ.parentNode;
	}
	
	//alert("Klick: "+targ);
	//wmCount(""+targ);
	setTimeout(function() {
		if (!askedForInfo) {
			askedForInfo = true;
			document.getElementById("InfoLayer").style.visibility="visible";
		}
	}, 500);
	
}

function wmAction(e) {
	var targ;
	if (!e) var e = window.event;
	if (e.target) { 
		targ = e.target;
	}
	else if (e.srcElement) {
		targ = e.srcElement;
	}
	
	if (targ.nodeType == 3) {
		targ = targ.parentNode;
	}
	
	if ((""+targ).toLowerCase().indexOf("[object htmlimageelement]") != -1) {
		targ = targ.parentNode;
	}
	
	if ((""+targ).indexOf("youtube") != -1) {
		var rel = targ.getAttribute("rel");
		//alert(typeof targ.firstChild == '[Object text]'); // targ.firstChild);
		var val = "";
		var obj = targ.childNodes;
		for (var i=0;i<obj.length;i++) {
			if (typeof obj[i].data !='undefined') {
				val = obj[i].data;
				break;
			}
		}
		//alert(val);
		var name = val;
		if (rel != null && rel.indexOf("videoname=") != -1) {
			name = rel.substring(rel.indexOf("videoname=")+10);
			if (name.indexOf(";") != -1) {
				name = name.substring(0, name.indexOf(";"));
			}
			wmCount("youtube: "+name);
		}
		else {
			wmCount("youtube: "+name);
			//wmCount(""+targ+"&videoname="+name);
		}
	}
	else {
		wmCount(""+targ);
	}
}

function closeInfoLayer() {
	document.getElementById("InfoLayer").style.visibility="hidden";
	document.getElementById("InfoLayer").style.position="absolute";
	document.getElementById("InfoLayer").style.left="-1000px";
}

if (window.addEventListener) { 
	window.addEventListener('load',initLinks,false);
} 
else if (window.attachEvent) { 
	window.attachEvent('onload',initLinks);
}

var ntLast = new Date().getTime();
var newsBox = null;
var lastY = 0; //-133;
var first = true;
var running = true;
var logLay = null;

var newsHeight = 141;

function newsticker() {
	if (first) {
		if (newsBox == null) {
			newsBox = document.getElementById("newsticker_content");
		}
		if (newsBox != null) {
			newsBox.style.top = lastY+"px";
		}
		first = false;
		//register events
		newsBox.onmouseover  = newsTickerMO;	
		newsBox.onmouseout  = newsTickerMOut;	
		var newsBox2 = document.getElementById("newsticker_news");
                newsBox2.onmouseover  = newsTickerMO;
                newsBox2.onmouseout  = newsTickerMOut;
	}
	if (running && new Date().getTime()-ntLast > 5000) {
		ntLast = new Date().getTime()+100000;
		//scroll to next news
		if (newsBox == null) {
			newsBox = document.getElementById("newsticker_content");
		}
		if (logLay == null) {
			logLay = document.getElementById("breadcrumb");
		}
		if (newsBox != null) {
			lastY = parseInt(newsBox.style.top);
			//logLay.innerHTML = ""+lastY+", "+(parseInt(newsBox.offsetHeight)-(newsHeight+1));
			if (-lastY > (parseInt(newsBox.offsetHeight)-(newsHeight+1))) {
				//end of doc
				newsBox.style.top = "0px";
				lastY = 0;
				ntLast = new Date().getTime()-100000;
				newsticker();
			}
			else {
				setTimeout("scrollToNextNews()", 30);
			}	
		}
	}
	else {
		setTimeout("newsticker()", 1000);	
	}
}

function news_up() {
	lastY = lastY + newsHeight;
	//if (lastY > -newsHeight) lastY = -newsHeight;
	if (lastY > 0) lastY = 0;
	newsBox.style.top = lastY+"px";
}

function news_dn() {
	if (-(lastY -newsHeight)< parseInt(newsBox.offsetHeight)-(newsHeight+1)) {
        	lastY = lastY - newsHeight;
        	newsBox.style.top = lastY+"px";
	}
}

function newsTickerMO() {
	running = false;
	newsBox.style.top = lastY+"px";
}

function newsTickerMOut() {
	running = true;
	ntLast = new Date().getTime();
}


function scrollToNextNews() {
	if (running) {
		var newY = parseInt(newsBox.style.top) - 1;
		newsBox.style.top = newY+"px";	
		if (newY - lastY < -(newsHeight-1)) {
			ntLast = new Date().getTime();
			lastY = newY;
			newsticker();
		}
		else {
			setTimeout("scrollToNextNews()", 30);
		}
	}
	else {
		newsticker();
	}
}

var lastPanNum = 1;
var maxPanNum = 7;
var actPanNum = 0;
var panActive = true;

function switchSPPanel(panNum) {
	var lastPan = document.getElementById("sp_back_"+lastPanNum);
	lastPan.style.visibility = "hidden";

	var pan = document.getElementById("sp_back_"+panNum);
	pan.style.visibility = "visible";

	var lastMenu = document.getElementById("sp_menu_"+lastPanNum);
	lastMenu.style.background = "url(fileadmin/templates/agorum/img/sp_non_sel.jpg) no-repeat";
	
	var actMenu = document.getElementById("sp_menu_"+panNum);
	actMenu.style.background = "url(fileadmin/templates/agorum/img/sp_sel.jpg) no-repeat";
	
	lastPanNum = panNum;
}

function spPanMO(panNum) {
	panActive = false;
	switchSPPanel(panNum);
}

function spPanCL(panNum) {
	var aHref = document.getElementById("link_p"+panNum);
	location.href=aHref.href;
}

function stopPanel() {
	panActive = false;
}

function switchAuto() {
	if (panActive) {
		actPanNum ++;
		if (actPanNum > maxPanNum) actPanNum = 1;
		switchSPPanel(actPanNum);
		setTimeout("switchAuto()", 300000);
	}
}
