
	/*
		Allgemeine Javascript-Funktionen
	*/

	/**
	 * Popup zentriert am Bildschirm anzeigen
	 */
	function popupCenter(url, name, attributes, width, height) {
		var topx = (screen.height - height) / 2;
		var leftx = (screen.width - width) / 2;
		if (attributes.length > 0)
			if (attributes.substr(attributes.length-1,1) != ',')
				attributes += ','
		var w = window.open(url, name, attributes + 'width='+width+',height='+height+',screenx='+leftx+',screeny='+topx+',top='+topx+',left='+leftx+',status=yes,resizable=yes,scrollbars=yes');
		if (w) {
			w.focus();
		}
		return w;
	}

	/**
	 * Oeffnet Popup fuer Arzt weiterempfehlen
	 *
	 * @param	string	URL
	 * @param	string	Window-Name
	 */
	function popupEmpfehlen(sUrl, sName) {
		var w = popupCenter(sUrl, sName, '', 500, 400);
		if (w) {
			return false;
		}
		return true;
	}


	/*
		Funktionen verwendet in der Operator-Administration
	*/
	function openDependenciesWindowAndLocateToPassedUrl(uid,table,urli){
		window.open('../administration/dependencies.php?id=' + uid + '&table=' + table,'dependencies','width=750,height=400,top=000,resizable=yes,scrollbars=yes');
		window.location.href=urli;
	}

	function closeWindowAndReloadOpener(){
		window.opener.location.reload();
		window.close();
	}

	function closeWindowAndInsertCityDetailsInOpenerForm(uid,description){
		w=window.opener;
		self.close();
		w.document.object.city_id.value=uid;
		w.document.object.address.value=description;
		
	}

	function reloadOpener(){
		window.opener.location.reload();
	}
	function loadSameUrlInOpenerWithAnchor(sAnchor) {
		var sUrl = window.opener.location.href;
		// Bestehenden Anker entfernen
		if (sUrl.indexOf('#') > 0) {
			sUrl = sUrl.substring(0, sUrl.indexOf('#'));
		}
		// Der Trick ohne .reload() ist, dass sich die URL aendern muss, damit
		// der Browser einen Reload erzwingt. Das schaffe wir, in dem wir
		// einfach eine Zufallszahl, die nichts beeinflusst, an die URL
		// anhaengen
		var iRandom = Math.round( Math.random() * 10000 );
		sUrl += '&' + iRandom + '#' + sAnchor;
		window.opener.location.href = sUrl;
	}

	/**
	 * Oeffnet das Popup fuer die Formular-Infos.
	 * Wenn das Popup nicht geoeffnet werden kann, wird der Link normal ausgefuehrt
	 *
	 * @param	string	Url
	 * @param	string	Popup-Name
	 * @param	string	Optional: ID des select elements, von dem die Nummer fuer anspringen des ausgewaehlten Eintrages verwendet werden soll
	 */
	function popupFormularInfo(sUrl, sName, sSelectId) {
		if (typeof sSelectId != 'undefined') {
			var domSelect = document.getElementById(sSelectId);
			if (domSelect && domSelect.selectedIndex && domSelect.options[domSelect.selectedIndex]) {
				sUrl += '#' + domSelect.options[domSelect.selectedIndex].value;
			}
		}
		var w = popupCenter(sUrl, sName, '', 500, 450);
		if (!w) {
			return true;
		}
		return false;
	}
