//Gets the browser specific XmlHttpRequest Object
function getXmlHttpRequestObject() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest(); //Not IE
	} else if(window.ActiveXObject) {
		//return new ActiveXObject("Microsoft.XMLHTTP"); //IE
		return new ActiveXObject("Microsoft.XMLHTTP"); //IE
	} else {
		//Display your error message here.
		//and inform the user they might want to upgrade
		//their browser.
		alert("Your browser doesn't support the XmlHttpRequest object. Better upgrade to Firefox.");
	}
}

function GetScriptEngineInfo(){

   var s;

   s = ""; // Build string with necessary info.

   s += ScriptEngine() + " Version ";

   s += ScriptEngineMajorVersion() + ".";

   s += ScriptEngineMinorVersion() + ".";

   s += ScriptEngineBuildVersion();

   return(s);

}

var lastNav = null;
var allRequestHeaders = null;

function Switch(num) {
switch(num) {
case 1:
Switchit('ideelink','ideetext','texts/idee.txt');
break;
case 2:
Switchit('erstellunglink','erstellungtext','texts/erstellung.txt');
break;
case 3:
Switchit('gestaltunglink','gestaltungtext','texts/gestaltung.txt');
break;
case 4:
Switchit('fotoslink','fotostext','texts/fotos.txt');
break;
case 5:
Switchit('uebersetzunglink','uebersetzungtext','texts/uebersetzung.txt');
break;
default:
}
}

function Switchit(head,ele,html)
{
	lastNav = document.getElementById(head);
	if (document.getElementById(head).innerHTML == "Weniger ...") {
		document.getElementById(head).innerHTML = "Mehr ...";
		HideStatement(head,ele);
	}
	else if (document.getElementById(head).innerHTML == "Mehr ..."){
   	 document.getElementById(head).innerHTML = "Weniger ...";
   	 ShowStatement(head,ele,html);
	}
}

function ShowStatement(head,ele,html) {
		if(lastNav != null) {
			lastNav.style.textDecoration = "none";
	 		lastNav.style.color = "#890000";
	 	}
		//Get our browser specific XmlHttpRequest object.
		var receiveReq = getXmlHttpRequestObject();
		receiveReq.onreadystatechange=function() {
			//Check to see if the XmlHttpRequests state is finished.
	        		document.getElementById(ele).innerHTML = "bitte warten...";
			if (receiveReq.readyState == 0 || receiveReq.readyState == 4) {
				//Set the contents of our span element to the result of the asyncronous call.
	                         //<img src="photo" border="0" alt="photo">';
	       	 	    document.getElementById(head).style.textDecoration = "none";
		 	    //document.getElementById(head).style.color = "black";
	                     try{
		 		document.getElementById(ele).innerHTML = receiveReq.responseText;
	                     }catch(e) {
	                     	document.getElementById(ele).innerHTML = 'Sorry, please try these alternative links... <a href="?bio=modules/biography/projects.html">projects</a><br>';
	                         document.getElementById(ele).innerHTML += '(Microsoft Internet Explorer does not support the web standards very well, I recommend to use the <a href="http://www.mozilla-europe.org/en/products/firefox/">Mozilla Firefox</a> web browser)';
	                     	}
	                }
		}
	receiveReq.open("GET", html, true);
         receiveReq.setRequestHeader("Content-Type", "text/plain");
         receiveReq.setRequestHeader("Content-Type", "charset=iso-8859-1");
         receiveReq.setRequestHeader("Content-Transfer-Encoding","8bit");
	     receiveReq.send(null);
         //initLightbox();
}

function LoadContent(element) {
	var receiveReq = getXmlHttpRequestObject();
	receiveReq.onreadystatechange=function() {
		//Check to see if the XmlHttpRequests state is finished.
        document.getElementById(element).innerHTML = "bitte warten...";
		if (receiveReq.readyState == 0 || receiveReq.readyState == 4) {
			//Set the contents of our span element to the result of the asyncronous call.
                         //<img src="photo" border="0" alt="photo">';
	 		document.getElementById(element).innerHTML = receiveReq.responseText;
                 }
	}
	receiveReq.open("Get", html, true);
	receiveReq.send(null);
}

function HideStatement(head,result) {
    document.getElementById(head).style.textDecoration = "none";
 	document.getElementById(head).style.color = "#890000";
	document.getElementById(result).innerHTML = "";
}