
function $(str) {
	document.getElementById(str);
}

function openNews(id) {
	sURL = '/../../shared/php/ext_news.php?mode=ausgabe&id='+id;
	winText = window.open(sURL, 'Startseitennews', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=400,height=700');
	winText.focus();
}
function openNewsEditor(pos) {
	sURL = '../cms/ext_newsEditor.php?pos='+pos;
	winText = window.open(sURL, 'StartseitennewsEditor', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=616,height=750');
	winText.focus();
}

function openLogoEditor() {
	sURL = '../cms/ext_logoEditor.php';
	winText = window.open(sURL, 'LogoEditor', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=1150,height=800');
	winText.focus();
}
/*
 * KeywordsEditor
 * @param lang, fuer welche Sprachversion sollen die Keywords angelegt werden
 * ruft das entsprechende Popup auf um die Keywords zu aendern oder neue anzulegen 
 */
function openKeywordsEditor(lang) {
	sURL = '../cms/ext_keywordEditor.php?lang='+lang;
	winText = window.open(sURL, 'LogoEditor', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=520,height=700');
	winText.focus();
}

function deleteLogo(firmenname,id) {
	box=window.confirm("Das Logo von "+firmenname+" mit ID"+id+" wirklich löschen?");
	if(box==true) {
		document.forms['myForm4'].submit();
	} else {
		alert("Löschen abgebrochen");
	}
}

function openKontaktEditor() {
	sURL = '../cms/ext_kontaktEditor.php';
	winText = window.open(sURL, 'KontaktEditor', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=1150,height=800');
	winText.focus();
}

function deleteKontakt(kontaktname,id) {
	box=window.confirm("Diesen Kontakt ("+kontaktname+" ID"+id+") wirklich löschen?");
	if(box==true) {
		//document.forms['myForm4'].submit();
        if (id) {
            location.href="ext_kontaktEditor.php?loeschen=1&id="+id;            
        }

	} else {
		alert("Löschen abgebrochen");
	}
}


function openNewsletterEditor() {
	sURL = '../cms/ext_newsletterEditor.php';
	winText = window.open(sURL, 'NewsletterEditor', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=616,height=750');
	winText.focus();
}

function deleteNewsletter(titel,id) {
	box=window.confirm("Den Newsletter \""+titel+"\" (ID"+id+") wirklich löschen?");
	if(box==true) {
		document.forms['myForm4'].submit();
	} else {
		alert("Löschen abgebrochen");
	}
}

function openTextEditor(iPagePK) {
	sURL = '../cms/textEditor.php?page='+iPagePK;
	winText = window.open(sURL, 'winText', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=516,height=450');
	winText.focus();
}

function openFileEditor(iPagePK) {
	sURL = '../cms/fileEditor.php?page='+iPagePK;
	winFile = window.open(sURL, 'winFile', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=450,height=450');
	winFile.focus();
}

function openImageEditor(iPagePK) {
	sURL = '../cms/imageEditor.php?page='+iPagePK;
	winImage = window.open(sURL, 'winText', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=486,height=440');
	winImage.focus();
}

function editPageDetails(iPagePK) {
	sURL = '../cms/detailEditor.php?page='+iPagePK;
	winDetail = window.open(sURL, 'winDetail', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=370,height=430');
	winDetail.focus();
}

function zoomImage(sImg) {
	sURL = '../zoom.htm?'+sImg;
	winImage = window.open(sURL, 'winImage', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=486,height=400');
	winImage.focus();
	return false;
}

function createNewPage() {
		
	sNewPageName = document.getElementById('txtNewPage').value;
	if(sNewPageName=='') {
		alert("Bitte geben Sie einen Namen für die neue Seite ein.");
	}else{
		document.myFormPageAction.formaction.value = 'newpage';
		document.myFormPageAction.pagetitle.value = sNewPageName;
		document.myFormPageAction.submit();
	}
	
}

function deletePage(iPagePK, iParentPK) {
	if(confirm("Diese Seite wirklich löschen?")) {
		document.myFormPageAction.formaction.value = 'delpage';
		document.myFormPageAction.deletepk.value = iPagePK;
		document.myFormPageAction.parentpk.value = iParentPK;
		document.myFormPageAction.submit();
	}
}

function movePage(iPagePK, sMoveDirection) {
	document.myFormPageAction.formaction.value = 'movepage';
	document.myFormPageAction.movepk.value = iPagePK;
	document.myFormPageAction.movedirection.value = sMoveDirection;
	document.myFormPageAction.submit();
}

var sLastBtnClass = null;

function buttonOver(oBtn) {
	sLastBtnClass = oBtn.className;
	oBtn.className = sLastBtnClass + 'Active';
}

function buttonOut(oBtn) {
	oBtn.className = sLastBtnClass;
}

var sLastFieldClass = null;

function fieldFocus(oField) {
	sLastFieldClass = oField.className;
	oField.className = sLastFieldClass + 'Active';
}

function fieldBlur(oField) {
	oField.className = sLastFieldClass;
}

function showNewPageInput(iParentPK, iNewSorter) {
	document.myFormPageAction.parentpk.value = iParentPK;
	document.myFormPageAction.newpagesorter.value = iNewSorter;
	document.getElementById('divNewPage').style.display = '';
	document.getElementById('txtNewPage').focus();
	document.getElementById('divDisableSheet').style.display = '';
}

function hideNewPageInput() {
	document.getElementById('divNewPage').style.display = 'none';
	document.getElementById('divDisableSheet').style.display = 'none';
}

function hoverMenu(oBtn, active) {
	if (active == 1 ) {
		oBtn.className = 'hover';
	} else {
		oBtn.className = '';
	}

}


/**************************************************************/
// Anfrage Popup öffnen
	
	function openAnfragePopup (iPagePK) {
		sURL = '../de/anfrage.php?page='+iPagePK;
		winImage = window.open(sURL, 'winText', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=446,height=610');
		winImage.focus();
	}
	


/**************************************************************/
// Set Content Height wenn Content zu klein

	function setContentHeight(iAbstand){
					
		if (iAbstand==null){iAbstand = 530;}
		
		var oContent = document.getElementById('idContentElement');
					
		// Höhe auf Auto setzen
		oContent.style.height = "auto";
		
		
		var iBrowserHeight = GetBrowserInnerHeight() - iAbstand;		
		var iContentHeight = oContent.offsetHeight;
		
		// Wenn Content < wie verfügbare Browser höhe dan höhe von Content Setzen
		if ( iContentHeight <= iBrowserHeight ) {			
			// Höhe des Contents Anpassen			
			var iContentHeight = iBrowserHeight+"px";		
			oContent.style.height = iContentHeight;		
		}
	}



/**************************************************************/
// Browser Width & Height


	function GetBrowserInnerHeight() {		
	   if (window.innerHeight) {
			return window.innerHeight;								   
	   } else if (document.body && document.body.offsetHeight) {
			return document.body.offsetHeight;
	   } else {
			return 0;
	   }
	}

	function GetBrowserInnerWidth()
	{
	   if (window.innerWidth) {
			return window.innerWidth;
	   } else if (document.body && document.body.offsetWidth) {
			return document.body.offsetWidth;
	   } else {
			return 0;
	   }
	}


/**************************************************************/
// Resize und OnLoad Event Händler

// Onload und Onresize Eventhandler erg?nzen
	function addOnLoadEventHandler(oEventHandler) {
		if(typeof window.onload != 'undefined' && window.onload != null) {
			var oOnLoad = window.onload;
			window.onload = function(){oOnLoad(); oEventHandler()};
		} else {
			window.onload = function(){oEventHandler()};
		}
	}
	
	function addOnResizeEventHandler(oEventHandler) {
		if(typeof window.onresize != 'undefined' && window.onresize != null) {
			var oOnResize = window.onresize;
			window.onresize = function(){oOnResize(); oEventHandler()};
		} else {
			window.onresize = function(){oEventHandler()};
		}
	}
