var activeLink = ""; 

function successHandler(o){ 
	// root zeigt auf den ersten Knoten
	var root = o.responseXML.documentElement;
	var text = "";
	var title = "";
	var description = "";
	var image = "";
	var imagetag = "";
	var items = root.getElementsByTagName('item');
	
	// loop through all items
	for (var i=0; i<items.length; i++){
		title = root.getElementsByTagName('title')[i].firstChild.nodeValue;
		if (root.getElementsByTagName('description')[i].firstChild) {
			description = root.getElementsByTagName('description')[i].firstChild.nodeValue;
		}
		else {
			description = "";
		}
		if (root.getElementsByTagName('image')[i].firstChild) {
			image = root.getElementsByTagName('image')[i].firstChild.nodeValue;
			imagetag = "<img  src=\"" + image + "\"/>";
		}
		else {
			imagetag = "";
		}
		text = text + "<div class=\"item\"><h2>" + title +  "</h2>" + "<p>" + imagetag + description + "</p></div>";
	}
	// Format and display results in the response container. 
	document.getElementById('ajax_output').innerHTML = text; 
}
function successHandlerHtml(o){ 
	// root zeigt auf den ersten Knoten
		
	var ie = false;
	var root = o.responseXML.documentElement;
		
	var array_all = root.getElementsByTagName('item');
	// cdata section ausgeben
	if (!array_all[0].childNodes[1]) {
		// knoten nicht bekannt -> ie
		ie = true;
	}
	if (ie == true) {
		document.getElementById('ajax_inner').innerHTML = array_all[0].childNodes[0].nodeValue;
	}
	else {
		document.getElementById('ajax_inner').innerHTML = array_all[0].childNodes[1].nodeValue;
	}
}
 

	// This is a simple failure handler
function failureHandler(o){ 
	document.getElementById('ajax_inner').innerHTML = o.status + " " + o.statusText; 
}

function getModule(link_id,sUrl){ 
	// 
	if (activeLink != "") {
		document.getElementById(activeLink).className = "inactive_Link";
	}
	document.getElementById(link_id).className = "active_Link";
	activeLink = link_id;
	
	// Initiate the HTTP GET request.
	var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, { success:successHandler, failure:failureHandler });
	
} 
function getModuleHtml(sUrl){ 
	// 
	if (activeLink != "") {
		//document.getElementById(activeLink).className = "inactive_Link";
	}
	//document.getElementById(link_id).className = "active_Link";
	//activeLink = link_id;
	// now replace "index.php" -> "ajax_create"
	
	document.getElementById('ajax_output').style.display ="block";
	
	sUrl = "ajax_create" + sUrl.substr(5);
	// Initiate the HTTP GET request.
	document.getElementById('ajax_inner').innerHTML = "Loading Content...";
	
	
	// init
	this.warxScr = 0;
	if (window.pageXOffset) {
    	this.warxScr = window.pageXOffset;
  	} else if (document.body && document.body.scrollLeft) {
    	this.warxScr = document.body.scrollLeft;
	}
	this.timerScr = 0;
	this.durationScr = 30;
	this.sollxScr = 700;
	this.animTimerScroll = setInterval("scrollforward()",10);
	//scrollforward();
	
	var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, { success:successHandlerHtml, failure:failureHandler });
	
	
}

function hideajax() {
	// document.getElementById('ajax_output').style.display ="none";
	document.getElementById('ajax_output').style.visibility ="hidden";
	
	
	// init
	
	if (window.pageXOffset) {
    	this.warxScr = window.pageXOffset;
  	} 
	
	else if (document.documentElement && document.documentElement.scrollLeft) {
    	this.warxScr = document.documentElement.scrollLeft;
	}
	
	this.timerScr = 0;
	this.durationScr = 30;
	this.sollxScr = 0;
	
	this.animTimerScroll = setInterval("scrollback()",10);
	//alert (window.pageXOffset);
}

function scrollforward() {
	if (this.timerScr < this.durationScr) {
		TposScr = (this.timerScr) / (this.durationScr);
		TposScr = ((-Math.cos(TposScr*Math.PI)/2) + 0.5);
		counterScr = TposScr * (this.sollxScr-this.warxScr) + this.warxScr;
		window.scrollTo(counterScr, 0);
		this.timerScr = this.timerScr +1;
	}
	else {
		window.scrollTo(this.sollxScr, 0);
		clearInterval(this.animTimerScroll);
		//document.getElementById('ajax_output').style.display ="none";
		//document.getElementById('ajax_output').style.visibility ="visible";
		
	}
}

function scrollback() {
	if (this.timerScr < this.durationScr) {
		TposScr = (this.timerScr) / (this.durationScr);
		TposScr = ((-Math.cos(TposScr*Math.PI)/2) + 0.5);
		counterScr = TposScr * (this.sollxScr-this.warxScr) + this.warxScr;
		window.scrollTo(counterScr, 0);
		this.timerScr = this.timerScr +1;
	}
	else {
		clearInterval(this.animTimerScroll);
		document.getElementById('ajax_output').style.display ="none";
		document.getElementById('ajax_output').style.visibility ="visible";
		
	}
}


var layer_1 = "";
var layer_1basis = "";
var layer_2= "";
var layer_2basis= "";
var vater_1= "";
var vater_2= "";
var vater_3= "";
var vater_1basis= "";
var vater_2basis= "";
var vater_class="";

this.sollx = 0;
this.warx = 0;
this.anim = false;

this.duration = 40;

this.timerScr = 0;
this.durationScr = 300;
this.sollxScr = 0;




// fuer safari
var detect = navigator.userAgent.toLowerCase();
this.saftest=(detect.indexOf('safari')!=-1);

if (this.saftest == true) {
	this.duration = 60;
}


function startrestore() {
	this.animTimerRes = setInterval("restore()",3000);
}

function stoprestore() {
	clearInterval(this.animTimerRes);	
}

function restore() {
	clearInterval(this.animTimerRes);
	if (layer_1 != layer_1basis) {
		shownavul(layer_1basis, vater_1basis);
	}
	
	
	
}


function movenavi() {
	temp1 =document.getElementById('navcontainer1').style.left;
	suche = temp1.indexOf("p");
	temp = temp1.substring(0,suche);
	temp = parseInt(temp);
	this.warx = temp;
	temp = temp +220;
	this.sollx = temp;
	this.timer = 0;
/*	this.duration = 30;
*/	if (this.anim == false) {
		this.animTimer = setInterval("doSlide()",10);
		this.anim = true;
	}
}
function doSlide() {
	details=document.getElementById('navcontainer1');
	if (this.timer < this.duration) {
		temp3 = this.timer/this.duration-1;
		this.counter = 220.1 *(temp3*temp3*temp3 +1) + this.warx;
		
		
		/* moofx - klappt auch nicht
		Tpos = (this.timer) / (this.duration);
		Tpos = ((-Math.cos(Tpos*Math.PI)/2) + 0.5);
		this.counter = Tpos * (this.sollx-this.warx) + this.warx;*/
				
		details.style.left = this.counter + "px";
		this.timer = this.timer + 1;
	
	} else {	// if time's up
		
		details.style.left = this.sollx + "px";
		this.anim = false;
		
		clearInterval(this.animTimer);


	}	
}
function doSlideRight() {
	details=document.getElementById('navcontainer1');
	if (this.timer < this.duration) {
		temp3 = this.timer/this.duration-1;
		this.counter = -220 *(temp3*temp3*temp3 +1) + this.warx;
		details.style.left = this.counter + "px";
		this.timer = this.timer + 1;
		
	
	} else {	// if time's up
		details.style.left = this.sollx + "px";
		this.anim = false;
		clearInterval(this.animTimer);
	}
}

// einmal bei der initialisierung
function loop() {
	
	var uls = document.getElementsByTagName('ul');

	var temp = 0;
	var temp1 = 1;
		// loop through all anchor tags
		for (var i=0; i<uls.length; i++){
			var ul = uls[i];
			
			
			// use the string.match() method to catch 'lightbox' references in the rel attribute
			if ((ul.className == "active") && (temp > 0) ){
				if (temp1 == 1) {
					layer_1 = ul.id;
					layer_1basis = ul.id;
				}
				if (temp1 == 2) {
					layer_2 = ul.id;
					layer_2basis = ul.id;
				}
				
				temp1 ++;
			}
			temp ++;
	
		}
		
	var lis = document.getElementsByTagName('li');
	var temp1 = 1;
	for (var i=0; i<lis.length; i++){
			var li = lis[i];
			if ((li.className == "sub_no_active_li") || (li.className == "sub_ul_active_li") || (li.className == "sub_no_active_li") || (li.className == "firstsub_no_active_li")) {
								
				if (temp1 == 1) {
					vater_1 = li.id;
					vater_1basis = li.id;
				}
				if (temp1 == 2) {
					vater_2 = li.id;
					vater_2basis = li.id;
				}
				if (temp1 == 3) {
					vater_3 = li.id;
					vater_3basis = li.id;
				}
				// ersten link merken
				if (li.className == "firstsub_no_active_li") {
					vater_class = "li.className";	
				}
				temp1 ++;
			}
	}
			   
}


function shownavul(idelement, vater) {
	if (layer_1 != "") {
		document.getElementById(layer_1).style.visibility = "hidden";
	}
	if (layer_2 != "") {
		document.getElementById(layer_2).style.visibility = "hidden";
	}
	if (vater_1 != "") {
		if (vater_class == "li.className") {
			document.getElementById(vater_1).className = "firstsub_no";	
		}
		else {
			document.getElementById(vater_1).className = "sub_ul";
		}
	}
	if (vater_2 != "") {
		document.getElementById(vater_2).className = "sub_ul";
	}	
	
	
	
	
	layer_1 = idelement;
	layer_2 = "";
	vater_1 = vater;
	
	
	if (idelement) {
		document.getElementById(idelement).style.visibility = "visible";
		//document.getElementById(vater).firstChild.className = "sub_ul_active_li";
	}
	
	
	document.getElementById(vater).className = "sub_ul_active_li";
	
	
	if (vater == vater_1basis) {
		
				
		if (document.getElementById(vater_2basis)) {
			document.getElementById(vater_2basis).className = "sub_ul_active_li";
			if (layer_2basis) {
				document.getElementById(layer_2basis).style.visibility = "visible";
				layer_2 = layer_2basis;
			}
		}
		

		
	}

}

function shownavul2(idelement, vater) {

	if (layer_2 != "") {
		document.getElementById(layer_2).style.visibility = "hidden";
	}
	if (vater_2 != "") {
		document.getElementById(vater_2).className = "sub_ul";
	}
	layer_2 = idelement;
	vater_2 = vater;
	document.getElementById(idelement).style.visibility = "visible";
	document.getElementById(vater).className = "sub_ul_active_li";
	if (vater == vater_1basis) {
		document.getElementById(vater_2basis).className = "sub_ul";
		
	}
	
	
	temp1 =document.getElementById('navcontainer1').style.left;
	suche = temp1.indexOf("p");
	temp = temp1.substring(0,suche);
	temp = parseInt(temp);
	this.warx = temp;
	this.timer = 0;
/*	this.duration = 30;
*/	temp = temp -220;
	this.sollx = temp;
	
	if (this.anim == false) {
		this.animTimer = setInterval("doSlideRight()",10);
		this.anim = true;
	}
	
	
}








function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function clearText(thefield){
if (thefield.defaultValue==thefield.value) thefield.value = "";
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function int_only(value) {
	value = parseInt(value);
	if(value<0) value = value * -1;
	return (value) ? value+"" : "";
}




function BookMark_Page(alerttext) {
	var title = document.title;
	var url = this.location;
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title);
	} else {
		if(!alerttext) alerttext = "To bookmark this page use [Ctrl+D]";
		alert(alerttext);	
	}
}

var ie4 = document.all ? 1 : 0;
var ns4 = document.layers ? 1 : 0;
var ns6 = window.netscape ? 1 : 0;
function addText(id,text) {
	
	menuobj = (ie4) ? document.all[id] : (ns6 ? document.getElementById(id) : (ns4 ? document.layers[id] : ''));
	
	if(ie4 || ns6) {
		menuobj.innerHTML=text;
	} else {
		menuobj.document.open();
		menuobj.document.write(text);
		menuobj.document.close();
	}
	
}

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

var clickZoomImage;
function clickZoom(url,imgname,windowstatus) {
	clickZoomImage=window.open(url,imgname,windowstatus + ',scrollbars=no');
	if (window.focus) {
		clickZoomImage.focus();
	}
}
function checkClickZoom() {
	if (clickZoomImage) {
		clickZoomImage.close();
	}
}

var layerDisplayStatus = new Array;
// switch layer visibility
function toggleLayerDisplay(whichLayer, status) {
	// store current layer status
	layerDisplayStatus[whichLayer] = status;
	// status: 'none', 'block'	
	if (document.getElementById) {
		// this is the way the standards work
		document.getElementById(whichLayer).style.display = status;
	}
	else if (document.all) {
		// this is the way old msie versions work
		document.all[whichLayer].style.display = status;
	}
	else if (document.layers) {
		// this is the way nn4 works
		document.layers[whichLayer].display = status;
	}
}

function toggleClassName(whichLayer, newClassName) {
	if (document.getElementById) {
		// this is the way the standards work
		document.getElementById(whichLayer).className = newClassName;
	}
	else if (document.all) {
		// this is the way old msie versions work
		document.all[whichLayer].className = newClassName;
	}
	else if (document.layers) {
		// this is the way nn4 works
		document.layers[whichLayer].className = newClassName;
	}
}

function mailtoLink(part1, part2) {	
	if(part1 && part2) {
		window.location.href="mailto:"+part1+"@"+part2;
		return true;
	}
	return false;		
}

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

function getObjectById(fld) {
	if (document.getElementById && document.getElementById(fld) != null) {
		return document.getElementById(fld);
	} else if (document.layers && document.layers[fld] != null) {
		return document.layers[fld];
	} else if (document.all) {
		return document.all(fld);
	} else {
		return false;
	}
}

