window.status = "Deutscher Anwaltssuchdienst"

var whitespace = " \t\n\r";

var bShowSubMenue = 0;
var bMoveSubMenue = 1;

var ebene
var posX, posY
posX = 0;
posY = 0;

var ns6;
var ns;
var ie;
if (document.layers) {ns = 1; ie = 0; ns6 = 0;}
else if (typeof window.sidebar == "object") { ns = 0; ie = 0; ns6 = 1}
else {ns = 0; ie = 1; ns6 = 0;}

function isNum(s){
	var i;
	for(i = 0; i < s.length; i++){
		var c = s.charAt(i);
		if (!isWhitespace(c))
			if ((c >= "0") && (c <= "9"))
				c=c;
			else
				return false;
	}
	return true;
}
function isWhitespace(s)
{   var i;
    if (isEmpty(s)) return true;
    for (i = 0; i < s.length; i++) {
        var c = s.charAt(i);
        if (whitespace.indexOf(c) == -1) return false;
    }
    return true;
}
function isEmpty(s)
{   return ((s == null) || (s.length == 0));
}

function newwindow(URL,NAME,BREITE,HOEHE,TOP,LEFT,SCROLL,TOOLBAR)
//Diese Funktion öffnet ein separates Fenster.
{
if (TOOLBAR != "yes" && TOOLBAR != "no"){
	TOOLBAR = "no"
	}
if (SCROLL != "yes" && SCROLL != "no"){
	SCROLL = "yes"
	}
if (isNaN(TOP+0) == true){
	TOP = (screen.height/2)-(HOEHE/2)
	}
if (isNaN(LEFT+0) == true){
	LEFT = (screen.width/2)-(BREITE/2)
	}
window.open(URL,NAME,"menubar=no,toolbar=" + TOOLBAR + ",location=no,status=no,resizable=no,scrollbars=" + SCROLL + ",width=" + BREITE + ",height=" + HOEHE + ",left=" + LEFT + ",top=" + TOP);
}

function bildertausch(element,datei,richtung,infoElement){
var feststellBild = ""
if (ie) {
   if (element != ""){
	   document.all[element].src = datei;
	   }
   if (infoElement != "" && richtung == "over"){
      document.all[infoElement].style.visibility = "visible";
      }
   if (infoElement != "" && richtung == "out"){
      document.all[infoElement].style.visibility = "hidden";
      }
   }
if (ns) {
   document[element].src = datei;
   if (element != ""){
	   document[element].src = datei;
	  }
   if (infoElement != "" && richtung == "over"){
      document[infoElement].visibility = "show"
      }
   if (infoElement != "" && richtung == "out"){
      document[infoElement].visibility = "hide"
      }
   }
if (ns6){
   if (element != ""){
		document[element].src=datei;
		}
   if (infoElement != "" && richtung == "over"){
		document.getElementById(infoElement).setAttribute("style","visibility: visible;");
		}
   if (infoElement != "" && richtung == "out"){
		document.getElementById(infoElement).setAttribute("style","visibility: hidden;");
		}
	}   
}

function funcJob(){
   var plz = document.frmJobsuche.sArbOrt.value;
   var zahlen = "0123456789"
   var i = 1;
   wert = 0;
   for (i >= 1;i <= plz.length;i++){
      stelle = plz.substring(i-1,i)
      if (zahlen.indexOf(stelle,0) < 0){
         alert('Bitte geben Sie eine korrekte Postleitzahl ein!')
         document.frmJobsuche.sArbOrt.focus();
         return false;
         }
      else{
         return true;
         }
      }
    return true;
   }

function clearChkBx()
{	for (i = 0; i < 10; i++) {
	document.frmJobsuche["chkPLZ"+i].checked = false;
	}
}
function mouseDownHandler(e){
	if (ie){
		posX = window.event.x;
		posY = window.event.y + document.body.scrollTop;
		}
	if (ns6){
		posX = e.pageX;
		posY = e.pageY;
		}
	}

function checkAt(sEMail){
//Überprüft sEMail auf das Vorhandensein eines @-Zeichens
var sEMailValue = sEMail.value;
	if (sEMailValue.indexOf("@") == -1){
			alert("Sie haben keine gültige E-Mail-Adresse angegeben.");
			sEMail.focus();
			return false;
			}
	}
function checkSendUmfrage(){
	if (document.frm.lMeinung.value == ""){
		alert("Sie haben keine Meinung ausgewählt!");
		return false;
		}
	}
function resizeIt(GRAFIK){
//Passt ein Fenster der Größe der Grafik an, die in diesem Fenster angezeigt wird.
	var ready
	ready = 0;
	if (document[GRAFIK].complete == true) {
		if (screen.height/2-(document[GRAFIK].height+150)/2 < 0) 	{
			window.moveTo((screen.width/2-(document[GRAFIK].width+50)/2),0);
			}
		else {
			window.moveTo((screen.width/2-(document[GRAFIK].width+50)/2),(screen.height/2-(document[GRAFIK].height+150)/2));
			}
		if (document[GRAFIK].height+150 > screen.height) {
			window.resizeTo(document[GRAFIK].width+50,screen.height);
			}
		else {
			window.resizeTo(document[GRAFIK].width+50,document[GRAFIK].height+150);
			}
		ready = 1;
		}
	if (ready == 0) setTimeout("'resizeIt(" + GRAFIK + ")'",500);
	}

function activeButton(){
	var FORM
	FORM = document.frmASD
	with(FORM){
		if (lStaat.value != 700 || plz.value != "" || sBundesland.value != "99" || sOrt.value != "kein" || (sName.value != "keine Angabe" && sName.value != "")) {
			submit.style.backgroundColor = "#FF0000";
			submit.style.color = "#FFFFFF";
			}
		else{
			submit.style.backgroundColor = "#D3E4F8";
			submit.style.color = "#4F92E3";
			}
		if(lStaat.value != "700"){
			submit.style.backgroundColor = "#FF0000";
			submit.style.color = "#FFFFFF";
			}
		if(sName.value != "keine Angabe" && sName.value != ""){
			sTitel.disabled = false;
			}
		else{
			sTitel.disabled = true;
			}
		}
	}
function setValue_Nachname(TYP){
	var FORM
	FORM = document.frmASD.sName;
	with (FORM){
		if (TYP == "IN"){
			if (value == "keine Angabe") value = "";
			}
		if (TYP == "OUT"){
			if (value == "") value = "keine Angabe";
			}
		}
	}
	
function checkIS_TS(){
	var FORM
	FORM = document.frmASD
	with(FORM){
		if (chkIS.checked == false && chkTS.checked == false && sRechtsgebiet1.value != 0){
			alert("Wählen Sie bitte aus, ob die angegebenen Rechtsgebiete als Tätigkeits- und / oder Interessenschwerpunkte betrieben werden sollen!");
			chkIS.focus();
			return false;	
			}
		}
	}

function SubMenue(TYP){
	var Breite = document.all.divSubMenue.style.width;
	Breite = Breite.replace("px","");
	
	var SubMenue = document.all.divSubMenue.style;
	with(SubMenue){
		if (TYP == "_IN"){
			visibility = "visible";
			if (bMoveSubMenue == 1){
				left = posX - (Breite/3);
				top = posY + 10;
				}
			bMoveSubMenue = 0;
			}
		if (TYP == "_OUT"){
			// setTimeout ("SubMenue2()", 500);
			SubMenue2();
			// geändert zu Testzwecken 15.08.06 TM
			}
		}
	}
function SubMenue2(){
	if (bShowSubMenue != 1) {
		document.all.divSubMenue.style.left = -200;
		bShowSubMenue = 0;
		bMoveSubMenue = 1;
		}
	}

function SubMenue3(TYP){
	if (TYP == "OUT"){
		bShowSubMenue = 0;
		bMoveSubMenue = 1;
		document.all.divSubMenue.style.visibility = 'hidden';
		}
	if (TYP == "IN"){
		bShowSubMenue = 1;
		bMoveSubMenue = 0;
		document.all.divSubMenue.style.visibility = "visible";
		}
	}

//Fotogalerie - Anfang
function FotoWechsel(){
	var i;

	NUMMER = Math.round((lMax - 1) * Math.random()) + 1;
	
	do {
		bDoppelt = 0;
		ELEMENT = Math.round((arrFotos.length - 1) * Math.random());
		Check:
		for (i = 1; i <= lMax; i++){
			if (document.all["foto" + i].src.indexOf(arrFotos[ELEMENT]) != -1){
				bDoppelt = 1;
				break Check;
				}
			}
		}
		while (bDoppelt == 1);
	document.all["foto" + NUMMER].src = "/grafiken/transpar.gif"
	document.all["foto" + NUMMER].src = "http://213.61.121.108/anwaltanm/fotos/" + arrFotos[ELEMENT];
	document.all["foto" + NUMMER].width = Breite;
	document.all["foto" + NUMMER].height = Hoehe;
	//document.all["foto" + NUMMER].title = arrFotoNamen[ELEMENT];
	document.frmFotogalerie["FotoName" + NUMMER].value = arrFotoNamen[ELEMENT];
	if (arrFotoKdNr[ELEMENT] != ""){	
		document.frmFotogalerie["FotoKdNr" + NUMMER].value = "/anwalt/anwliste.asp?sIntern=kdnr:" + arrFotoKdNr[ELEMENT];
		}
		else
		{
		document.frmFotogalerie["FotoKdNr" + NUMMER].value = "";
		}
	window.setTimeout("FotoWechsel()", ms);
	}
function resizeFoto(NR){
	var BILD = document["bild" + NR];
	var hoehe = BILD.height;
	var breite = BILD.width;
	
	var max_hoehe = 150;
	var max_breite = 120;
	
	var faktor_breite = max_hoehe/hoehe;
	var faktor_hoehe = max_breite/breite;

	if (hoehe > breite){
		if (hoehe > max_hoehe) {
			BILD.height = max_hoehe;
			BILD.width = breite*faktor_breite;
			}
		}
	else{
		if (breite > max_breite) {
			BILD.width = max_breite;
			BILD.height = hoehe*faktor_hoehe;
			}
		}
	}
//Fotogalerie - Ende

function addFavorit(){
	if (window.external){
		window.external.AddFavorite(location.href, document.title);
		}
	}
function showDiv(NAME){
	if (document.getElementById("div" + NAME).style.top == "-1000px" || document.getElementById("div" + NAME).style.top == "-500px"){
		document.getElementById("div" + NAME).style.position = "relative";
		document.getElementById("div" + NAME).style.top = 1;
		}
	else{
		document.getElementById("div" + NAME).style.position = "absolute";
		document.getElementById("div" + NAME).style.top = -1000;
		}
	}
function exit_popup(){ 
	window.open('http://www.anwaltssuchdienst.de/popup.htm','','toolbar=1,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,fullscreen=0,width=10,height=10,top=10000,left=10000');
	}

function counter(CURRENT, TARGET){

	REFERRER = self.location.href;
	do{
		REFERRER = REFERRER.replace("&", "%26");
		REFERRER = REFERRER.replace("#", "%23");
		}
	while(REFERRER.indexOf("&") > 0)
	do{
		CURRENT = CURRENT.replace("&", "%26");
		CURRENT = CURRENT.replace("#", "%23");
		}
	while(CURRENT.indexOf("&") > 0)
	
	if(TARGET == ""){
		self.location.href = "/admin/counter.asp?current=" + CURRENT + "&referrer=" + REFERRER + "&action=forward";
		}
	else{
		window.open("/admin/counter.asp?current=" + CURRENT + "&referrer=" + REFERRER + "&action=forward", TARGET);
		}
	}

function checkEMail(){
	var sEMail = document.getElementById("sEMail");
	var iLaenge = sEMail.value.length;

	if (sEMail.value.indexOf("@") == -1){
		alert("Sie haben keine gültige E-Mail-Adresse angegeben.\n\n(Kein @-Zeichen.)");
		sEMail.focus();
		return false;
		}
	if (sEMail.value.lastIndexOf(".") < sEMail.value.indexOf("@") + 2 || sEMail.value.lastIndexOf(".") > sEMail.value.length - 3){
	//  Stellt sicher, dass Punkt nach @-Zeichen.                        Stellt sicher, dass nach Punkt noch mindestens zwei Zeichen.
		alert("Sie haben keine gültige E-Mail-Adresse angegeben.\n\n(Keine gültige TLD.)");
		sEMail.focus();
		return false;
		}
}

function getHoeheBreite(TYP){
	// Ermittelt Höhe (TYP = "h") und Breite (TYP = "b")
	var x,y;
	if (self.innerHeight) // all except Explorer
	{
		x = self.innerWidth;
		y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}
	return (TYP.toLowerCase() == "h")?y:x;
}


var TIMER;

function showPopup() 
{
	var target = document.getElementById("popup");
	var tposl = parseInt(target.style.left);
	var tpost = parseInt(target.style.top);
	
	var iHoehe = Number(target.style.height.replace(/px/g, ""));
	var iBreite = Number(target.style.width.replace(/px/g, ""));
	var iOben = (getHoeheBreite("h")/2)-(iHoehe/2);
	var iLinks = (getHoeheBreite("b")/2)-(iBreite/2);
	
	target.style.top = iOben + "px";

	if(tposl <= iLinks)
	{
		target.style.left = tposl + 20 + "px";
	}
	TIMER = setTimeout(showPopup, 50);
}

document.onclick = mouseDownHandler;