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";
if (nn) {
	sichtbar = "show";
	unsichtbar = "hide";
}
var vn = navigator.appVersion.substring(0,1);
			
function ieFake(fake) {
	if ((document.all) && (fake)) fake.blur();
}

function tdClick(src,id){
	ieFake(src);
	if (id) {
		if ((n6) || (ie)) {
			document.getElementById("b"+id).click();
		}
		if (nn) {
			document["b"+id].click();
		}
	} else {
		src.children.tags('A')[0].click();
	}
}

function tdOver(src,clr,clr1,id){
	src.style.backgroundColor=clr;
	if (id) {
		if ((n6) || (ie)) {
			document.getElementById("b"+id).style.color=clr1;
		}
		if (nn) {
			document["b"+id].style.color=clr1;
		}
	} else {
		src.children.tags('a')[0].style.color=clr1;
	}
	src.style.cursor='hand';
}

function tdOut(src,clr,clr1,id){
	src.style.backgroundColor=clr;
	if (id) {
		if ((n6) || (ie)) {
			document.getElementById("b"+id).style.color=clr1;
		}
		if (nn) {
			document["b"+id].style.color=clr1;
		}
	} else {
		src.children.tags('a')[0].style.color=clr1;
	}
}

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 ew = null;
function zoomFenster(datei,x,y,rahmen,alt,scbar,id,wo) {
	var tmpX = 600;
	var tmpY = 715;
	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;
	}
	tmpFensterBreite = tmpX;
	tmpFensterHoehe = tmpY+48;
	if (ew != null) if (!ew.closed) ew.close();
	ew = window.open('zoom.asp?id=' + id + '&hoch=' + y + '&breit=' + x + '&rahmen=' + rahmen + '&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=yes,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 bildwechsel(bild,breite,hoehe,alt) {
	var tmpTxt = alt;
	if (nn) {
		with (document.bildgrosstxt.document) {
			open();
			write(tmpTxt);
			close();
		}
	}
	if (ie) {
		bildgrosstxt.innerHTML = tmpTxt;
		document.getElementById("bild").style.width = breite;
		document.getElementById("bild").style.height = hoehe;
		document.getElementById("bildgross").style.width = breite;
		document.getElementById("bildgross").style.height = hoehe;
		document.getElementById("bildgross").style.backgroundImage = "url('" + bild + "')";
	}
	if (n6) {
		document.getElementById("bildgrosstxt").innerHTML = tmpTxt;
		document.getElementById("bild").style.width = breite;
		document.getElementById("bild").style.height = hoehe;
		document.getElementById("bildgross").style.width = breite;
		document.getElementById("bildgross").style.height = hoehe;
		document.getElementById("bildgross").style.backgroundImage = "url('" + bild + "')";
	}
}

var position = 0;
var aktiv = null;
function bildliste(pos) {
	if (n6) {
		txtLang = document.getElementById("listeinnen").offsetWidth;
		lay_bilder = document.getElementById("listeinnen").style;
	}
	if (ie) {
		txtLang = document.all("listeinnen").offsetWidth;
		lay_bilder = document.all['listeinnen'].style;
	}
	if (nn) {
		txtLang = document.bildliste.document.listeinnen.width;
		lay_bilder = document['bildliste'].document['listeinnen'];
	}
	//alert(txtLang);
	if ((position <= 0) && (position >= (txtLang-540)*-1)) {
		position += pos;
		//alert(position);
		if (position < (txtLang-540)*-1) position = (txtLang-540)*-1;
		if (position > 0) position = 0;
		if ((ie) || (n6)) lay_bilder.left = position + "px";
		if (nn) lay_bilder.left = position;
	}
	if (pos == 1) aktiv = setTimeout('bildliste(1)', 1);
	if (pos == -1) aktiv = setTimeout('bildliste(-1)', 1);
}

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 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 == '') || (document.stichwortsuche.stichwort.value == 'Stichwort/Art.-Nr. eingeben') || (iCheck)) {
		alert("Bitte geben Sie ein Stichwort oder eine Artikelnr. ein,\nnach dem bzw. der gesucht werden soll.");
		return false;
	}
	return;
}

function inhaltCheck(field,txt,url,leer) {
	iCheck = true;

	for(i=0;i<field.value.length;i++) {
		if (field.value.substr(i,1) != ' ') {
			iCheck = false;
			i = field.value.length;
		}
	}
	if ((iCheck) || (leer == field.value)) {
		alert(txt);
		//return false;
	}
	else document.location.href = url;
}

function warenkorb(art,anzahl) {
	for (i=0;i<1000;i++) {
		if (document.getElementsByTagName("select")[i]) {
			if (document.getElementsByTagName("select")[i].options[document.getElementsByTagName("select")[i].selectedIndex].value == "") {
				alert(document.getElementsByTagName("select")[i].id + ' - bitte wählen Sie eine Variante aus!');
				return false;
			}
		} else {
			i = 1000;
		}
	}
	if (anzahl != "") {
		if (art < 0) document.location.href="warenkorb.asp?delall=1";
		else {
			//document.location.href="warenkorb.asp?art=" + art + "&id=" + id + "&anzahl=" + anzahl;
			return "warenkorb.asp";
		}
	} else {
		alert("Bitte geben Sie die gewünschte Bestellmenge an!");
		return false;
	}
}

function loginCheck(inout,wer,seite) {
	iCheck = true;
	var tmp1 = eval("document." + wer + "login.benutzername");
	var tmp2 = eval("document." + wer + "login.passwort");
	//alert(tmp1);
	for(i=0;i<tmp1.value.length;i++) {
		if (tmp1.value.substr(i,1) != ' ') {
			iCheck = false;
			i = tmp1.value.length;
		}
	}
	for(i=0;i<tmp2.value.length;i++) {
		if (tmp2.value.substr(i,1) != ' ') {
			iCheck = false;
			i = tmp2.value.length;
		}
	}
	if ((tmp1.value == '') || (tmp1.value == 'Benutzername') || (tmp1.value == 'Kundennummer') || (tmp2.value == '') || (tmp2.value == 'Passwort') || (iCheck)) {
		if (wer == "kunden") alert("Bitte geben Sie Ihren Benutzernamen und das zugehörige Passwort an!");
		if (wer == "haendler") alert("Bitte geben Sie Ihre Kundennummer und das zugehörige Passwort an!");
		return false;
	}
	else {
		if (seite) return inout+".asp?herkunft="+seite;
		else return inout+".asp";
	}
}
