//var myRegexMail = /^[\w-]+(?:\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$/;
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 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;
var vn = navigator.appVersion.substring(0,1);
var lay_open = -1;
var l_anzahl = 4;
var anzahl = 7;
var bClicked = 0;

menuNor = new Array(anzahl);
menuFoc = new Array(anzahl);
menuMMNor = new Array(anzahl-1);
menuMMFoc = new Array(anzahl-1);

hoehe = new Array(l_anzahl);
breite = new Array(l_anzahl);
lay_id = new Array(l_anzahl);
lay = new Array(l_anzahl);
lay[0] = "service";
lay[1] = "downloads";
lay[2] = "aktuelles";
lay[3] = "unternehmen";
zustand = new Array(l_anzahl);

function init() {
	if (vn >= 4) {
		for (i=1; i<=anzahl; i++) {
			menuNor[i] = new Image();
			menuNor[i].src = "gif/b_0" + i + "n.gif";
			menuFoc[i] = new Image();
			menuFoc[i].src = "gif/b_0" + i + "f.gif";
			
			menuMMNor[i] = new Image();
			menuMMNor[i].src = "gif/mmb_0" + i + "n.gif";
			menuMMFoc[i] = new Image();
			menuMMFoc[i].src = "gif/mmb_0" + i + "f.gif";
		}
		for (i=0; i<l_anzahl; i++) {
			if (n6) {
				lay_id[i] = document.getElementById(lay[i]).style;
				lay_id[i].width = parseInt(lay_id[i].width)-2;
				hoehe[i] = document.getElementById(lay[i]).offsetHeight;
				breite[i] = document.getElementById(lay[i]).offsetWidth;
			}
			if (ie) {
				lay_id[i] = document.all(lay[i]).style;
				hoehe[i] = document.all(lay[i]).offsetHeight;
				breite[i] = document.all(lay[i]).offsetWidth;
			}
			if (nn) {
				lay_id[i] = document[lay[i]];
				//alert(lay_id[i] + "/" + lay[i]);
				hoehe[i] = lay_id[i].document.height;
				breite[i] = lay_id[i].document.width;
			}
		}
		if ((ie) || (n6)) {
			document.onmousemove=mouseMove;
		}
		if (nn) {
			sichtbar = "show";
			unsichtbar = "hide";
			window.captureEvents(Event.MOUSEMOVE);
			window.onMouseMove=mouseMove;
		}
		fJS = true;
	}
}

function mouseMove(Ereignis) {
	if (nn) {
		xwert = Ereignis.pageX;
		ywert = Ereignis.pageY;
		var outPos = 80;
	}
	if (ie) {
		xwert = window.event.clientX;
		ywert = window.event.clientY;
		var outPos = 80 - document.body.scrollTop;
	}
	if (n6) {
		//alert("OK");
		xwert = Ereignis.pageX;
		ywert = Ereignis.pageY;
		var outPos = 80;
	}
	//window.status = document.body.scrollTop + "/" + xwert + "/" + ywert;
	if ((lay_open >= 0) && (ywert < outPos)) Reset();
	if ((lay_open >= 0) && (xwert < parseInt(lay_id[lay_open].left)-0)) Reset();
	if ((lay_open >= 0) && (ywert > outPos+hoehe[lay_open]+30)) Reset();
	if ((lay_open >= 0) && (xwert > parseInt(lay_id[lay_open].left)+breite[lay_open]+0)) Reset();
}

function m_go(id) {
	if ((fJS) && (id != lay_open)) {
		for(i=0;i<l_anzahl;i++) {
			if (zustand[i] > 0) {
				//alert(zustand[i] + "/" + i);
				lay_id[i].visibility = unsichtbar;
			}
		}
		lay_open = id;
		zustand[id] = 1;
		//alert(lay[0]);
		//if (ie) document.all(lay[id]).filters.revealTrans.Apply();
		lay_id[id].visibility = sichtbar;
		//if (ie) document.all(lay[id]).filters.revealTrans.Play();
	}
}

function Reset() {
	if((fJS) && (lay_open >= 0)) {
		for(i=0;i<l_anzahl;i++) {
			if (zustand[i] != 0) {
				lay_id[i].visibility = unsichtbar;
				zustand[i] = 0;
			}
		}
		lay_open = -1;
		//for(i=1;i<=anzahl;i++) {
		//	Blur(i);
		//}
	}
}

function ieFake(fake) {
	if ((document.all) && (fake)) fake.blur();
}

function tdClick(src){
	ieFake(src);
	src.children.tags('A')[0].click();
}

function tdOver(src,clr){
	src.style.backgroundColor=clr;
	src.children.tags('A')[0].style.color='#000000';
}

function tdOut(src,clr){
	src.style.backgroundColor=clr;
	src.children.tags('A')[0].style.color='#00309C';
}

function Focus(idx) {
	// Btn fokussiert darstellen.
	if ((fJS) && (idx != bClicked)) {
		var s = "b"+idx;
		document.images[s].src = menuFoc[idx].src;
	}
}
function Blur(idx) {
	// Btn normal darstellen.
	if ((fJS) && (idx != bClicked)) {
		var s = "b"+idx;
		document.images[s].src = menuNor[idx].src;
	}
}

function mmFocus(idx) {
	// Btn fokussiert darstellen.
	if ((fJS) && (idx != bClicked)) {
		var s = "b"+idx;
		document.images[s].src = menuMMFoc[idx].src;
	}
}
function mmBlur(idx) {
	// Btn normal darstellen.
	if ((fJS) && (idx != bClicked)) {
		var s = "b"+idx;
		document.images[s].src = menuMMNor[idx].src;
	}
}

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=no');
	if (wi.opener==null) wi.opener=self;
	//if (vn >= "4") wi.moveTo((screen.availWidth/2)-tmpX/2,(screen.availHeight/2)-tmpY/2);
	return;
}
var wi1 = null;
function info1(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 (wi1 != null) if (!wi1.closed) wi1.close();
	wi1 = window.open(datei,'Infofenster1','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=no');
	if (wi1.opener==null) wi.opener=self;
	//if (vn >= "4") wi1.moveTo((screen.availWidth/2)-tmpX/2,(screen.availHeight/2)-tmpY/2);
	return;
}
var wi2 = null;
function info2(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 (wi2 != null) if (!wi2.closed) wi1.close();
	wi2 = window.open(datei,'Infofenster2','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=no');
	if (wi2.opener==null) wi.opener=self;
	//if (vn >= "4") wi2.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+20;
	var tmpY = y+170;
	if (id > 0) tmpY = tmpY+20;
	var tmpSc = "no";
	if (tmpX < 520) tmpX = 520;
	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=no');
	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 checkSystemSuche() {
	if ((document.systemsuche.stichwort.value == "Stichwort eingeben") || (document.systemsuche.stichwort.value == "")) {
		alert("Bitte geben Sie ein Stichwort ein,\nnachdem gesucht werden soll.");
		return false;
	}
	return;
}

function checkStichwortSuche() {
	var iCheck = true;
	for(i=0;i<document.stichwortsuche.stichwort.value.length;i++) {
		if (document.stichwortsuche.stichwort.value.substr(i,1) != ' ') {
			iCheck = false;
			i = document.stichwortsuche.stichwort.value.length;
		}
	}
	if ((document.stichwortsuche.stichwort.value == '') || (iCheck)) {
		alert("Bitte geben Sie mind. ein Stichwort ein,\nnachdem gesucht werden soll.");
		return false;
	}
	return;
}

function checkMail() {
	var checkMail = document.nletter.newsmail.value.indexOf("@");
	var checkMail1 = document.nletter.newsmail.value.lastIndexOf(".");
	var checkMail2 = document.nletter.newsmail.value.lastIndexOf(" ");
	var checkMailLaenge = document.nletter.newsmail.value.length;
	if ((checkMail2 != -1) || (checkMail1 == -1) || (checkMail < 1) || (checkMail == checkMailLaenge-1) || (checkMail == checkMail1-1) || (checkMail1 > checkMailLaenge-3) || (checkMailLaenge < 6) || (document.nletter.newsmail.value == "eMail eingeben") || (document.nletter.newsmail.value == "")) {
		alert("Bitte geben Sie eine gültige eMail-Adresse ein.");
		return false;
	}
	if (document.nletter.zielgruppe.options[document.nletter.zielgruppe.selectedIndex].value == "") {
		alert("Bitte wählen Sie eine Zielgruppe aus.");
		return false;
	}
	return;
}

var nl = null;
function newsl() {
	var mail = document.nletter.newsmail.value;
	var zielgruppe = document.nletter.zielgruppe.options[document.nletter.zielgruppe.selectedIndex].value;
	if (nl != null) if (!nl.closed) nl.close();
	nl = window.open('newsletter.asp?email=' + mail + '&zielgruppe=' + zielgruppe,'Newsletter','left=' + ((screen.availWidth/2)-260) + ',top=' + ((screen.availHeight/2)-200) + ',marginwidth=0 marginheight=0,leftmargin=0,topmargin=0,scrollbars=yes,status=no,width=520,height=400,resizable=no');
	if (nl.opener==null) nl.opener=self;
	//if (vn >= "4") nl.moveTo((screen.availWidth/2)-160,(screen.availHeight/2)-110);
	return;
}

function aufzu(inhalt,pfeil) {
	var tmp1 = "p"+pfeil;
	if (document.getElementById(inhalt).style.display == "none") {
		document.getElementById(inhalt).style.display = 'block';
		document.getElementById("text_"+pfeil).innerHTML = 'zuklappen';
		document.images[tmp1].src = "gif/pfeil_rauf.gif";
		document.images[tmp1].alt = "zuklappen";
	} else {
		document.getElementById(inhalt).style.display = 'none';
		document.getElementById("text_"+pfeil).innerHTML = 'aufklappen';
		document.images[tmp1].src = "gif/pfeil_runter.gif";
		document.images[tmp1].alt = "aufklappen";
	}
}

function ausrichten_unten() {
	setTimeout("ausrichten_unten_1();",100);
}

var realheight = 0;
function ausrichten_unten_1() {
	//alert(document.body.offsetHeight+"/"+document.body.scrollHeight);
	if (ie){
		leiste_unten.style.visibility = sichtbar;
		//if window height is less than document height
		if (realheight==0) realheight=document.body.scrollHeight;
		if (document.body.offsetHeight < realheight)
			leiste_unten.style.pixelTop = realheight - 14;
		else
		// if window height is greater than document height
			leiste_unten.style.pixelTop = document.body.offsetHeight - 29;
	}
	if (n6) {
		document.getElementById('leiste_unten').style.visibility = sichtbar;
		if (window.innerHeight < document.height)
			document.getElementById('leiste_unten').style.top = document.height;
		else
			document.getElementById('leiste_unten').style.top = window.innerHeight - 25;
	}
	if (nn){
		document["leiste_unten"].visibility = sichtbar;
		if (realheight==0) realheight=document.height;
		if (window.innerHeight > realheight){
			document["leiste_unten"].top = window.innerHeight - 25;
			document.height = window.innerHeight;		
		} else {
			document.height = realheight + 25;
			document["leiste_unten"].top = realheight;
		}
	}
}

function checkPLZ(){
	var count = 0;
	var text1 = "";
	if (document.haendlersuche.hs_plz.value.length <= 4) {
		text1 += "Bitte geben Sie die PLZ 5-stellig ein.\n";
		count += 1;
	}
	if ((!document.haendlersuche.hs_trockenbau.checked) && (!document.haendlersuche.hs_putze.checked) && (!document.haendlersuche.hs_daemmstoffe.checked)) {
		if (count >= 1) text1 += "\n";
			text1 += "Bitte klicken Sie mind. eines der folgenden Produktbereiche an:\n- Trockenbau\n- Putze\n- Dämmstoffe\n";
			count += 1;
		}
		if (count == 0) return true;
	else {
		alert(text1);
		return false;
	}
}

function checkPLZ1(){
	var count = 0;
	var text1 = "";
	if (document.marktsuche.bs_plz.value.length <= 4) {
		text1 += "Bitte geben Sie die PLZ 5-stellig ein.\n";
		count += 1;
	}
	if (count == 0) return true;
	else {
		alert(text1);
		return false;
	}
}

function checkPLZ2(){
	count = 0;
	text1 = "";
	 
	if (document.maske.PLZ.value.length < 2) {
		text1 += "Bitte geben Sie min. 2 Stellen der PLZ ein.\n";
		count += 1;
	}
	if (count == 0) return true;
	else {
		alert(text1);
		return false;
	}
}

function inhaltCheck(field,txt,url) {
	iCheck = true;

	for(i=0;i<field.value.length;i++) {
		if (field.value.substr(i,1) != ' ') {
			iCheck = false;
			i = field.value.length;
		}
	}
	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 seitenaufruf(url) {
	document.location.href = url;
}

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 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)");
	}
}

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-25298380-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

