function stxt(txt) {
  if(txt != null && txt != "") window.status = txt;
    else window.status = "Bild vergrößern";
}

function cs() {
  window.status = "";
}


function open_bigpic(picurl, b, h, bildtitel) {
  open_bigpic(picurl, b, h, bildtitel, "")
}


function open_bigpic(picurl, b, h, bildtitel, artnr) {
	var eigenschaft, sbreite, shoehe, fenster, b, h, addwidth, addheight;
  addwidth = 0;
  addheight = 0;
  
	var ns6 = (!document.all && document.getElementById);
	var ie4 = (document.all);
	var ns4 = (document.layers);
	if(ns6||ns4) {
		sbreite = innerWidth;
		shoehe = innerHeight;
		} else if(ie4) {
			sbreite = document.body.clientWidth;
			shoehe = document.body.clientHeight;
	}

	x = (sbreite-b)/2;
	y = (shoehe-h)/2;
  
	eigenschaften = "left="+x+",top="+y+",screenX="+x+",screenY="+y+",width="+b+",height="+h+",location=no,menubar=no,toolbar=no,scrollbars=no,resizable=yes";

  if(ns6) {
    addwidth = 0;
    addheight = 18;
  }
  
  if(bildtitel != "") {
    addheight += 55;
  }
  
  if (window.XMLHttpRequest) {
    // IE 7, mozilla, safari, opera 9
     addheight += 55;
  }


	fenster = window.open("","mammutpics",eigenschaften);
	fenster.focus();
	fenster.document.open();
	
  with(fenster) {
    document.write('<html><head>');

    document.write('<title>Bildvergrößerung</title></head>');
		document.write('<script language="JavaScript">');
		document.write('function popupresize() {');
		document.write('var picbreite = document.bild.width + ' + addwidth + ';');
		document.write('var pichoehe = document.bild.height + ' + addheight + ';');
		document.write('window.resizeTo(picbreite+10, pichoehe+35);');
		document.write('window.focus();');
		document.write('}');
		document.write('</script>');
    document.write('<body BGCOLOR="#000000" onLoad="popupresize()"');
    document.write('marginwidth="0" marginheight="0" leftmargin="0" topmargin="0">');
    document.write('<center>');
    document.write('<A HREF="JavaScript:window.close();"><img src="'+ picurl + '" border="0" name="bild" alt="Fenster schliessen"></A>');
    document.write('</center><div style="margin:5px 5px 0 5px;"><span style="font-family:Verdana, Times New Roman; font-size:16px; color:#FCF5E5;">' + bildtitel + '</span>');
    if(artnr != null && artnr != "") document.write(' <span style="font-family:Verdana, Times New Roman; font-size:12px; color:#FCF5E5;">(Nr.: ' + artnr + ')</span>');
    document.write('</div>');
    document.write('</body></html>');
    
    fenster.document.close();
	}
}


function open_gbrowser(picid, b, h) {
	var eigenschaft, sbreite, shoehe, fenster, b, h, addwidth, addheight;
  
  addwidth = 0;
  addheight = 0;
  
	var ns6 = (!document.all && document.getElementById);
	var ie4 = (document.all);
	var ns4 = (document.layers);
	if(ns6||ns4) {
		sbreite = innerWidth;
		shoehe = innerHeight;
		} else if(ie4) {
			sbreite = document.body.clientWidth;
			shoehe = document.body.clientHeight;
	}

	x = (sbreite-b)/2;
	y = (shoehe-h)/2;

	eigenschaften = "left="+x+",top="+y+",screenX="+x+",screenY="+y+",width="+b+",height="+h+",location=no,menubar=no,toolbar=no,scrollbars=no,resizable=yes";

  if(ns6) {
    addwidth = 0;
    addheight = 18;
  }
  
  // Bildtitel
  addheight += 55;
  
  if (window.XMLHttpRequest) {
    // IE 7, mozilla, safari, opera 9
     addheight += 55;
  }

  var gallerbrowserurl = "/_includes/gallerybrowser.php?id=" + picid + "&addw=" + addwidth + "&addh=" + addheight;
	fenster = window.open(gallerbrowserurl, "mammutpics", eigenschaften);
	fenster.focus(); 
}



function check_bastketdel(id) {
  check = confirm("Möchten Sie das Produkt wirklich aus dem Warenkorb entfernen?");
  
  if(check) {
    self.location.href="warenkorb.php?del=" + id;
  } else {
    return false;
  }
}


function trimstring(mystring) {
	var newstring;
	
	newstring = mystring.replace(/^\s*/gi, "");
	newstring = mystring.replace(/\s+$/gi, "");
	
	return newstring;
}


function validate_orderform1() {
  form = document.orderform1;

  var tmp = "";
	var alerttext = "";
  var check_ok = true;
	var checkforms = new Array("vorname","Vorname",1,"nachname","Nachname",1,"strasse","Strasse",1,"plz","Plz",1,"ort","Ort",1,"email","E-Mail",1);

	for(var i=0; i<checkforms.length; i=i+3) {
		tmp = checkforms[i];

		if(trimstring(form[tmp].value) == "" && checkforms[i+2] == 1) {
			alerttext = alerttext + checkforms[i+1] + "\n";
			check_ok = false;
		}

		if(tmp == "email" && trimstring(form[tmp].value) != "" && (form[tmp].value.indexOf('@') == -1 || form[tmp].value.indexOf('.') == -1)) {
			alerttext = alerttext + "Das Format Ihrer E-Mail-Adresse ist falsch\n";
			check_ok = false;
		}
	}

  if(!check_ok) {
    alerttext = "Bitte vervollständigen Sie die folgenden Eingabefelder:\n\n" + alerttext;
    alert(alerttext);
    return false;
	} else {
    form.submit();
  }
}
