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_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_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 openAccordion(_elem){
	var _acc_elem = document.getElementsByClassName("accordion_elem");
	for(var t= 0 ; t<_acc_elem.length; t++){
		_e = _acc_elem[t];
		if(_e.getAttribute("id")!=_elem) $(_acc_elem[t]).style.display = "none";//new Effect.BlindUp(_acc_elem[t], {duration:.5});
	}
	$(_elem).style.display = "block";
	//new Effect.BlindDown(_elem, {duration:.5});
}

function checkTypeSelect(ret){
	_val = $('ptv_id').value;
	if(_val==0){
		alert("Bitte wählen Sie eine gültige Einheit");
		if(ret) return false;
	}else{
		if(ret){
			return true;
		}else{
			$('form_select_type').submit();
		}
	}
}


 function closeAjaxPopup(){
	var body_elem = parent.$("body_elem");
	//alert(body_elem);
	body_elem.style.overflow="auto"; 	// SET OVERFLOW	
	$("deactivate").style.display="none";
	$("popup").style.display = "none";
}


function openAjaxPopup(url, w, h){
	var nh = deactivateAll();
	var abf = $("popup");
	abf.height = h;
	var _content = $('popup_content');
	abf.style.display = "block";
	_content.innerHTML = "";
	abf.className = "load";
	abf.style.width = w+"px";
	abf.style.height = h+"px";
	abf.style.marginTop = -(h/2)+"px";
	
	// CENTER BOX
	var pagesize = getPageSize();
	var arrayPageScroll = getPageScrollTop();
	abf.style.top = (arrayPageScroll[1] + ((pagesize[1])/2))-(0)+"px";
	
	var popupReq = new Ajax.Request(url, {method:'post', parameters:'', 
			onComplete:function(elem){
						abf.className = "";
						_content.innerHTML =  elem.responseText;
						abf.style.height = "auto";//h+"px";						
					}
			});
}

function saveAjaxPopup(url, form){
	
	var params = Form.serialize(form);
	$('popup').className = "load";
	$('popup').style.height = $('popup').height+"px";
	$('popup_content').innerHTML = "";
	var popupReq = new Ajax.Request(url, {method:'post', parameters:params, 
			onComplete:function(elem){
						_resp = elem.responseText
						if(_resp == 1){
							document.location.reload();
						}else{
							$('popup_content').innerHTML = _resp;
							$('popup').style.height = "auto";
							$('popup').className = "";
							//alert(_resp); 
						}
						//alert(_resp);
					}
			});
}

function getPageScrollTop(){
	var yScrolltop;
	if (self.pageYOffset) {
		yScrolltop = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScrolltop = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScrolltop = document.body.scrollTop;
	}
	arrayPageScroll = new Array('',yScrolltop) 
	return arrayPageScroll;
}

function getPageSize(){
	var de = document.documentElement;
	var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
	
	arrayPageSize = new Array(w,h) 
	return arrayPageSize;
}

function deactivateAll(){
	var deact_all = $("deactivate");
	if (window.innerHeight && window.scrollMaxY) {	
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		yScroll = document.body.offsetHeight;
  	}
	deact_all.style.height = yScroll +"px";
	deact_all.style.display = "block";
	
}




 function checkDlDisclaimer(_url){
 	 	var _chk = $('dl_disclaimer').checked;
 	 	if(_chk) return true;
 	 	
 	 	$('disclaimer').className = "smalltext red"; 
 	 	
 	 	return false;
 	 }
 function loadGuestlist(_id){
 	//$("faq_wait").style.display = "block";
	var url = "/content/static/pelzig_unterhaelt_sich_gaeste_"+_id+".html";
	var quickEditReq = new Ajax.Request(url, {method:'post', parameters:"", 
			onComplete:function(elem){
				var jsString = elem.responseText;
				$('guest_list').innerHTML = jsString;
			}
	});

 }
function sendFaq(){
	$("faq_wait").style.display = "block";
	var url = "/modules/send_faq.php";
	var param = Form.serialize("faq_form");
	var quickEditReq = new Ajax.Request(url, {method:'post', parameters:param, 
			onComplete:function(elem){
				$("faq_wait").style.display = "none";
				var jsString = elem.responseText;
				
				//jsString = jsString.replace("#", "'");
				var can_parse = jsString.match(/^\[.*\]$/);
				if(can_parse){
					var resp_array = eval(jsString);
					
					if(resp_array[0]!="fail"){
						_class = "";
						$("faq_form").innerHTML = resp_array[1];
						new Effect.Highlight("faq_form")
					}else{
						_class = "fail";
					}
						$('faq_name_msg').className ="";
						$('faq_mail_msg').className ="";
						$('faq_question_msg').className ="";
						for(a=1; a<resp_array.length; a++){
							var el = $(resp_array[a]+"_msg");
							if(el) el.className = _class;
						}
				}else{	
					alert("Ubekannter Fehler");	
				}
				
			}
	});
}	


 function openWindow(url, w, h) 
 { 

 	 if (window.screen) {
        var hori = 20;//screen.availWidth;
        var verti = 20;//screen.availHeight;
        dorthin = window.open(url,'popup','width='+ w  +',height='+ h +',left='+hori +',top='+verti+", menubar=no,locationbar=no,statusbar=no,resizable=no,toolbar=no,dependent=yes,scrollbars=yes")
dorthin.focus();

 	 }
 	 

 	
 	/*
    var padding; 
    (navigator.appName == "Microsoft Internet Explorer") ? (padding = 10) : (padding = 0); 

    var screenw = screen.width; 
    var screenh = screen.height; 
    var winw = (w + 15 + padding); 
    var winh = (h + 15 + padding); 
    var posx = (screenw / 2) - (winw / 2); 
    var posy = (screenh / 2) - (winh / 2); 
	if(h==0) winh = (screenh + 15 + padding); 
    var mywin = window.open(url,"mywin","top="+posy+",left="+posx+",width="+winw+",height="+winh+",menubar=no,locationbar=no,statusbar=no,resizable=no,toolbar=no,dependent=yes,scrollbars=yes");
    mywin.focus(); 
    
    */
 } 
 

