//Center POPUP

//Preloader
function overlayLoading() {
	elem = document.getElementById("prepage");
	 elem.style.visibility="hidden";
	elem = document.getElementById("page");
	 elem.style.visibility="visible";
}

// --------------------------------------------------------------------------------------

// http Requests über js ----------------------------------------------------------------
	//var http_request = false;
	
	function makeRequest(url, parameters, targetID) {
		
		http_request = false;
		if (window.XMLHttpRequest) { // Mozilla, Safari,...
			http_request = new XMLHttpRequest();
			if (http_request.overrideMimeType) {
				// set type accordingly to anticipated content type
				//http_request.overrideMimeType('text/xml');
				http_request.overrideMimeType('text/html');
			}
		} else if (window.ActiveXObject) { // IE
			try {
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					http_request = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}
		if (!http_request) {
			alert('Cannot create XMLHTTP instance');
			return false;
		}
		http_request.onreadystatechange = function(){
			if (http_request.readyState == 4) {
				if (http_request.status == 200) {
					//alert(http_request.responseText);
					result = http_request.responseText;
					if(targetID){
						document.getElementById(targetID).style.display = 'block';
						document.getElementById(targetID).innerHTML = result;
					} else {
						return result;
					}
				} else {
					alert('There was a problem with the request.');
				}
			}
		}
		//http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
		http_request.open('GET', url + parameters, true);
		http_request.send(null);
		
	}

	function alertContents() {
		if (http_request.readyState == 4) {
			if (http_request.status == 200) {
				//alert(http_request.responseText);
				result = http_request.responseText;
				document.getElementById(targetID).innerHTML = result;            
			} else {
				alert('There was a problem with the request.');
			}
		}
	}
   
	function get(obj, targetID, post_file, action, form) {
		
		//alert(post_file);
		
		var getstr = "?";
		if(form == false){
			for (i=0; i<obj.length; i++){
				if(obj[i] != ""){
					getstr += obj[i] + "=" + obj[++i] + "&";
				}
			}
			
		}else{
			for (i=0; i<obj.childNodes.length; i++) {
				if (obj.childNodes[i].tagName == "INPUT") {
					if (obj.childNodes[i].type == "text") {
						getstr += obj.childNodes[i].name + "=" + convertText(obj.childNodes[i].value) + "&";
					}
					if (obj.childNodes[i].type == "checkbox") {
						if (obj.childNodes[i].checked) {
							getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
						} else {
							getstr += obj.childNodes[i].name + "=&";
						}
					}
					if (obj.childNodes[i].type == "radio") {
						if (obj.childNodes[i].checked) {
							getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
						}
					}
					if (obj.childNodes[i].type == "hidden") {
						getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
					}
				}
				
				if (obj.childNodes[i].tagName == "TEXTAREA") {
					getstr += obj.childNodes[i].name + "=" + convertText(obj.childNodes[i].value) + "&";
				}
				
				if (obj.childNodes[i].tagName == "SELECT") {
					var sel = obj.childNodes[i];
					for(j=0; sel.options[j]; j++){
						if(sel.options[j].selected == true){
							getstr += sel.name + "=" + sel.options[j].value + "&";
						}
					}
					
				}
			}
		}
		
		if(action != ""){
			getstr += 'action=' + action + '&';
		}
		
		if(post_file == ""){ post_file = "get.php"; }
		makeRequest(post_file, getstr, targetID);
		//makeRequest('get.php', getstr);
	}

	function resetRequestLayer(ID){
		document.getElementById(ID).innerHTML = "wird geladen ...";
		document.getElementById(ID).style.display = "none";
	}
// --------------------------------------------------------------------------------------


// Show Hide Layer
	function aLs(layerID){
		var isIE = false;
		var isOther = false;
		var isNS4 = false;
		var isNS6 = false;
		if(document.getElementById){
			if(!document.all){
				isNS6=true;
			}
			if(document.all){
				isIE=true;
			}
		}else{
			if(document.layers){
				isNS4=true;
			}else{
				isOther=true;
			}
		}
		var returnLayer;
			if(isIE){
				returnLayer = eval("document.all." + layerID + ".style");
			}
			if(isNS6){
				returnLayer = eval("document.getElementById('" + layerID + "').style");
			}
			if(isNS4){
				returnLayer = eval("document." + layerID);
			}
			if(isOther){
				returnLayer = "null";
				alert("-[Error]-\nDue to your browser you will probably not\nbe able to view all of the following page\nas it was designed to be viewed. We regret\nthis error sincerely.");
			}
		return returnLayer;
	}
	function HideShow(ID){
		/*if((aLs(ID).visibility == "visible") || (aLs(ID).visibility == "")){
			aLs(ID).visibility = "hidden";
			aLs(ID).position = "absolute";
			SetCookie(ID,'closed',null,'/');
		}else if(aLs(ID).visibility == "hidden"){
			aLs(ID).visibility = "visible";
			aLs(ID).position = "relative";
			SetCookie(ID,'opened',null,'/');
		}*/
		
		if((aLs(ID).display == "block") || (aLs(ID).display == "")){
			aLs(ID).display = "none";
			aLs(ID).visibility = "hidden";
			SetCookie(ID,'closed',null,'/');
			//getDocHeight('afterPostLayer');
		}else if(aLs(ID).display == "none"){
			aLs(ID).display = "block";
			aLs(ID).visibility = "visible";
			SetCookie(ID,'opened',null,'/');
			//getDocHeight('afterPostLayer');
		}
		
	}
	function HideShowAbsolute(ID){
		if((aLs(ID).visibility == "visible") || (aLs(ID).visibility == "")){
			aLs(ID).visibility = "hidden";
			aLs(ID).position = "absolute";
		}else if(aLs(ID).visibility == "hidden"){
			aLs(ID).visibility = "visible";
			aLs(ID).position = "absolute";
		}
	}



