var myRegexMail = /^([a-zA-Z0-9_\-])+(\.([a-zA-Z0-9_\-])+)*@((\[(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5]))\]))|((([a-zA-Z0-9])+(([\-])+([a-zA-Z0-9])+)*\.)+([a-zA-Z])+(([\-])+([a-zA-Z0-9])+)*))$/;
//var myRegexURL = /^(ht|f)tp(s?)\:\/\/[a-zA-Z0-9\-\._]+(\.[a-zA-Z0-9\-\._]+){2,}(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&%\$#_]*)?$/;
var myRegexURL = /^(((ht|f)tp(s?):\/\/)|(www\.[^ \[\]\(\)\n\r\t]+)|(([012]?[0-9]{1,2}\.){3}[012]?[0-9]{1,2})\/)([^ \[\]\(\),;"'<>\n\r\t]+)([^\. \[\]\(\),;"'<>\n\r\t])|(([012]?[0-9]{1,2}\.){3}[012]?[0-9]{1,2})$/;
//var myRegexMail = /^[\w_äÄöÖüÜß-]+(?:\.[\w_äÄöÖüÜß-]+)*@(?:[\w_äÄöÖüÜß-]+\.)+[a-zA-Z]{2,7}$/;

var nn=document.layers?true:false;
var n6=document.getElementById?true:false;
var ie=document.all?true:false;
if ((ie) && (n6)) n6 = false;

var sichtbar = "visible";
var unsichtbar = "hidden";

var fJS = false;

function ieFake(fake) {
	if ((document.all) && (fake)) fake.blur();
}

var tmpTxt;
function statAnzeige(txt) {
	tmpTxt = txt;
	setTimeout("window.status = tmpTxt;",0);
	return true;
}

var wi = null;
function info(datei,x,y,scbar) {
	tmpScroll = "yes";
	if (scbar == 0) tmpScroll = "no";
	if (!x) var tmpX = 520;
	else var tmpX = x+20;
	if (!y) var tmpY = 350;
	else var tmpY = y+30;
	if (wi != null) if (!wi.closed) wi.close();
	wi = window.open(datei,'Infofenster','left=' + ((screen.availWidth/2)-tmpX/2) + ',top=' + ((screen.availHeight/2)-tmpY/2) + ',marginwidth=0 marginheight=0,leftmargin=0,topmargin=0,scrollbars=' + tmpScroll + ',status=no,width=' + tmpX + ',height=' + tmpY + ',resizable=yes');
	if (wi.opener==null) wi.opener=self;
	//if (vn >= "4") wi.moveTo((screen.availWidth/2)-tmpX/2,(screen.availHeight/2)-tmpY/2);
	return;
}

var ew = null;
function zoomFenster(datei,x,y,alt,scbar,id,wo) {
	var tmpX = x+25;
	var tmpY = y+143;
	if (id > 0) tmpY = tmpY+20;
	var tmpSc = "no";
	if (tmpX < 420) tmpX = 420;
	if (tmpY > 580) {
		tmpY = 580;
		tmpSc = "yes";
		tmpX += 16;
	}
	if (scbar == 1) {
		tmpSc = "yes";
		tmpX += 16;
	}
	if (ew != null) if (!ew.closed) ew.close();
	ew = window.open('zoom.asp?id=' + id + '&hoch=' + y + '&breit=' + x + '&bild=' + datei + '&titel=' + alt + '&woher=' + wo,'Bildvergroesserung','left=' + ((screen.availWidth/2)-tmpX/2) + ',top=' + ((screen.availHeight/2)-tmpY/2) + ',marginwidth=0 marginheight=0,leftmargin=0,topmargin=0,scrollbars=' + tmpSc + ',status=no,width=' + tmpX + ',height=' + tmpY + ',resizable=yes');
	if (ew.opener==null) ew.opener=self;
	//if (vn >= "4") ew.moveTo((screen.availWidth/2)-tmpX/2,(screen.availHeight/2)-tmpY/2);
	return;
}

function feldGr(feld,inhalt,max) {
	who = feld;
	if (inhalt >= max) {
		alert('Achtung, maximale Feldgröße erreicht!');
		who.value = who.value.substr(0,max-1);
	}
}

function drucken() {
	if (window.print) self.print();
	if(document.all && navigator.appVersion.substring(22,23)==4) {
		self.focus();
	    var OLECMDID_PRINT = 6;
	    var OLECMDEXECOPT_DONTPROMPTUSER = 2;
	    var OLECMDEXECOPT_PROMPTUSER = 1;
	    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH="0" HEIGHT="0" CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
	    document.body.insertAdjacentHTML('beforeEnd',WebBrowser);
	    WebBrowser1.ExecWB(OLECMDID_PRINT,OLECMDEXECOPT_DONTPROMPTUSER);
	    WebBrowser1.outerHTML = '';
	}
}

function checkSuche(field,inhalt,ausgabe) {
	var iCheck = true;
	for(i=0;i<field.value.length;i++) {
		if (field.value.substr(i,1) != ' ') {
			iCheck = false;
			i = field.value.length;
		}
	}
	if ((field.value == inhalt) || (field.value == '') || (iCheck)) {
		alert(ausgabe);
		return false;
	}
	return;
}

function inhaltCheck(field,txt,url,inhalt) {
	iCheck = true;

	for(i=0;i<field.value.length;i++) {
		if (field.value.substr(i,1) != ' ') {
			iCheck = false;
			i = field.value.length;
		}
	}
	if (field.value == inhalt) iCheck = true;
	if (iCheck) {
		alert(txt);
		//return false;
	}
	else document.location.href = url;
}

function loginCheck(inout,seite) {
	iCheck = true;

	for(i=0;i<document.login_kalkulation.user.value.length;i++) {
		if (document.login_kalkulation.user.value.substr(i,1) != ' ') {
			iCheck = false;
			i = document.login_kalkulation.user.value.length;
		}
	}
	for(i=0;i<document.login_kalkulation.passwort.value.length;i++) {
		if (document.login_kalkulation.passwort.value.substr(i,1) != ' ') {
			iCheck = false;
			i = document.login_kalkulation.passwort.value.length;
		}
	}
	if ((document.login_kalkulation.user.value == '') || (document.login_kalkulation.passwort.value == '') || (iCheck)) {
		alert("Bitte geben Sie Ihren Benutzernamen und das zugehörige Passwort an!");
		return false;
	}
	else {
		if (seite) return inout+".asp?herkunft="+seite;
		else return inout+".asp";
	}
}

function loginCheck_mm(inout,seite) {
	iCheck = true;

	for(i=0;i<document.login_mm.user.value.length;i++) {
		if (document.login_mm.user.value.substr(i,1) != ' ') {
			iCheck = false;
			i = document.login_mm.user.value.length;
		}
	}
	for(i=0;i<document.login_mm.passwort.value.length;i++) {
		if (document.login_mm.passwort.value.substr(i,1) != ' ') {
			iCheck = false;
			i = document.login_mm.passwort.value.length;
		}
	}
	if ((document.login_mm.user.value == '') || (document.login_mm.passwort.value == '') || (iCheck)) {
		alert("Bitte geben Sie Ihren Benutzernamen und das zugehörige Passwort an!");
		return false;
	}
	else {
		if (seite) return inout+".asp?herkunft="+seite;
		else return inout+".asp";
	}
}

function checkPLZ(wieviel){
	count = 0;
	text1 = "";
	 
	if (document.maske.PLZ.value.length < wieviel) {
		text1 += "Bitte geben Sie min. "+wieviel+" Stellen der PLZ ein.\n";
		count += 1;
	}
	if (count == 0) return true;
	else {
		alert(text1);
		return false;
	}
}

function checkPLZOrt() {
	var count = 0;
	var text1 = "";
	if (document.anbietersuche.anbieter.options[document.anbietersuche.anbieter.selectedIndex].value == "") {
		text1 += "Bitte wählen Sie noch einen Anbieter aus.\n";
		count += 1;
	}
	if (document.anbietersuche.plz.value.length < 1 || document.anbietersuche.plz.value == "PLZ o. Ort") {
//		text1 += "Bitte geben Sie die PLZ 5-stellig ein.\n";
		text1 += "Bitte geben Sie eine PLZ oder einen Ort ein.\n";
		count += 1;
	}
	if (count == 0) return true;
	else {
		alert(text1);
		return false;
	}
}

var tmpAuf = "";
function aufzu(inhalt,pfeilfarbe,wieviele, auflassen) {
	var tmp1 = "pfeil_"+inhalt;
	var tmp2 = "blau";
	if (pfeilfarbe) tmp2 = pfeilfarbe;
	if ((tmpAuf != inhalt) && (tmpAuf != "") && (tmpAuf != auflassen) && (wieviele == 1)) {
		document.getElementById(tmpAuf).style.display = 'none';
		if (document.getElementById("text_"+tmpAuf)) document.getElementById("text_"+tmpAuf).innerHTML = 'aufklappen';
		if (document.getElementById(tmpAuf+"_titel")) document.getElementById(tmpAuf+"_titel").style.backgroundColor = '';
		if (document.images[tmp1]) {
			document.images[tmp1].src = "gif/pfeil_"+tmp2+"_runter.gif";
			document.images[tmp1].alt = "aufklappen";
		}
		tmpAuf = "";
	}
	if (document.getElementById(inhalt).style.display == "none") {
		document.getElementById(inhalt).style.display = 'block';
		if (document.getElementById("text_"+inhalt)) document.getElementById("text_"+inhalt).innerHTML = 'zuklappen';
		if (document.getElementById(inhalt+"_titel")) document.getElementById(inhalt+"_titel").style.backgroundColor = '#F2F6FB';
		if (document.images[tmp1]) {
			document.images[tmp1].src = "gif/pfeil_"+tmp2+"_rauf.gif";
			document.images[tmp1].alt = "zuklappen";
		}
		tmpAuf = inhalt;
	} else {
		document.getElementById(inhalt).style.display = 'none';
		if (document.getElementById("text_"+inhalt)) document.getElementById("text_"+inhalt).innerHTML = 'aufklappen';
		if (document.getElementById(inhalt+"_titel")) document.getElementById(inhalt+"_titel").style.backgroundColor = '';
		if (document.images[tmp1]) {
			document.images[tmp1].src = "gif/pfeil_"+tmp2+"_runter.gif";
			document.images[tmp1].alt = "aufklappen";
		}
	}
	return true;
}

var offen = "";
function aufzuCheck() {
	if(document.cookie) {
		var tmp1 = document.cookie.indexOf(",");
  		var tmp2 = document.cookie.indexOf(";");
		//alert(tmp1+" / "+tmp2);
 		if (tmp2 < tmp1) tmp2 = document.cookie.length;
		if (tmp1 > 1) offen = document.cookie.substring(tmp1,tmp2);
		//alert(tmp1+" / "+tmp2);
	}
	//alert(document.cookie + " / " + offen);
	//alert(offen.substr(1,offen.length));
	var offeneDiv = offen.substr(1,offen.length).split(",");
	offen = ""
	document.cookie = "offen=";
	for(i=0; i < offeneDiv.length; i++) {
		//alert(offeneDiv[i]);
		if (offeneDiv[i] != "") {
			if (!document.getElementById(offeneDiv[i])) offen += "," + offeneDiv[i];
			auf_zuklappen(offeneDiv[i]);
		}
	}
}

function auf_zuklappen(feld) {
	var bildname = "pfeil_"+feld;
	//alert(feld);
	if (document.getElementById(feld)) {
		if (document.getElementById(feld).style.display == "none") {
			document.getElementById(feld).style.display= "block";
			document.images[bildname].src = "gif/pfeil_rot_rauf.gif";
			document.images[bildname].alt = "zuklappen";
			offen += "," + feld;
		} else {
			document.getElementById(feld).style.display = "none";
			document.images[bildname].src = "gif/pfeil_rot_runter.gif";
			document.images[bildname].alt = "aufklappen";
			var tmp = "," + feld
			offen = offen.replace(tmp,"");
		}
	}
	document.cookie = "offen=" + offen;
	//alert(offen);
	realheight = 0;
	//ausrichten_unten();
}

function ankerAufklappen ()
{
	var tmp = window.location.hash;
	if ( tmp )
	{
		tmp = tmp.replace( "#pos_", "" );
		var tmpID = tmp;
		
		for ( i = 0; i < 11; i++ ) 
		{
			if ( i > 0 )
			{
				tmpID = tmp + i;
			}
			if ( document.getElementById(tmpID) )
			{
				tmpDIV = eval ( "document.all." + tmpID );
				if ( tmpDIV.tagName == "DIV" )
				{
					aufzu ( tmpID, "weiss" );
				}
			}
		}
	}
}

function urlCheck(url) {
	if (myRegexURL.test(url)) {
		uc = window.open(url);
		if (uc.opener==null) uc.opener=self;
	} else {
		alert("Ungültiges URL-Format! (z.B. http://www.domain.de)");
	}
}

function seitenaufruf(url) {
	document.location.href = url;
}