function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function jumptolink(what){
	var selectedopt=what.options[what.selectedIndex]
	if (document.getElementById && selectedopt.getAttribute("target")=="_self")
		window.open(selectedopt.value)
	else {
	  window.document.order.action=selectedopt.value;
		window.document.order.submit();
	}
}

function jumptolink2(what){
	var selectedopt=what.options[what.selectedIndex]
	if (document.getElementById && selectedopt.getAttribute("target")=="_self")
		window.open(selectedopt.value)
	else {
	  window.location=selectedopt.value;
	}
}
function Validator(num) {
	voll=true;
	if ((advise.name.value.length < num)) {
		advise.name.focus();
		voll=false;
	}
	var bez;
	bez = "<?php echo $bezeichnung; ?>";

	if(window.document.advise.name.value.toLowerCase()=="display" || window.document.advise.name.value.toLowerCase()=="kabel" ||
		window.document.advise.name.value.toLowerCase()=="gehäuse" || window.document.advise.name.value.toLowerCase()=="teile" ||
		window.document.advise.name.value.toLowerCase()=="intern" || window.document.advise.name.value.toLowerCase()=="interne" ||
		window.document.advise.name.value.toLowerCase()=="netzteile" || window.document.advise.name.value.toLowerCase()=="mainboard" ||
		window.document.advise.name.value.toLowerCase()=="board" || window.document.advise.name.value.toLowerCase()=="modem" ||
		window.document.advise.name.value.toLowerCase()=="scharniere" || window.document.advise.name.value.toLowerCase()=="lüfter" ||
		window.document.advise.name.value.toLowerCase()=="luefter" || window.document.advise.name.value.toLowerCase()=="tastatur" ||
		window.document.advise.name.value.toLowerCase()=="chips" || window.document.advise.name.value.toLowerCase()=="roehre" ||
		window.document.advise.name.value.toLowerCase()=="röhre" || window.document.advise.name.value.toLowerCase()=="combo-laufwerk" ||
		window.document.advise.name.value.toLowerCase()=="bioschip" || window.document.advise.name.value.toLowerCase()=="laufwerk" ||
		window.document.advise.name.value.toLowerCase()=="cd-laufwerk" || window.document.advise.name.value.toLowerCase()=="combo" ||
		window.document.advise.name.value.toLowerCase()=="diskettenlaufwerk" || window.document.advise.name.value.toLowerCase()=="displaykabel" ||
		window.document.advise.name.value.toLowerCase()=="inverter" || window.document.advise.name.value.toLowerCase()=="diske" ||
		window.document.advise.name.value.toLowerCase()=="dvd-laufwerk" || window.document.advise.name.value.toLowerCase()=="disket" ||
		window.document.advise.name.value.toLowerCase()=="diskette" || window.document.advise.name.value.toLowerCase()=="disketten")
		voll=false;

	if(!voll)
		alert("Bitte geben Sie mehr als "+num+" Zeichen ein und beachten Sie die Hinweise unter dem Suchfeld!");
	return voll;
}

function DigitTest(){
	voll=true;
	var anummer = window.document.advise2.name.value;
	exp = /^[0-9]{1,10}$/
    if (exp.test(anummer) != true) {
	  voll=false;
    }
  
	if(!voll)
		alert("Bitte geben Sie eine gültige Artikelnummer an!");
		
	return voll;	
}

// daten.php testet hier!!!
function alle_felder_pruefen() {
	voll=true;
	
	var name = document.order.name.value;
	if (name == ""){
	    alert("Bitte tragen Sie Ihren Namen ein.");
		voll=false;
		return voll;
	}
	
	var vorname = document.order.vorname.value;
	if (vorname == ""){
	    alert("Bitte tragen Sie Ihren Vornamen ein.");
		voll=false;
		return voll;
	}
	
	var strasse = document.order.strasse.value;
	if (strasse == ""){
	    alert("Bitte tragen Sie Straße ein.");
		voll=false;
		return voll;
	}
	
	var plz = document.order.plz.value;
	if (!plz.match (/^[0-9]{3,6}$/)){
	    alert("Bitte tragen Sie eine gültige PLZ ein.");
		voll=false;
		return voll;
	}

	var ort = document.order.ort.value;
	if (ort == ""){
	    alert("Bitte tragen Sie Ort ein.");
		voll=false;
		return voll;
	}

	var tel = document.order.tel.value;
	if (tel == ""){
	    alert("Bitte tragen Sie Ihre Tel.-Nummer ein.");
		voll=false;
		return voll;
	}
	
	var land = document.order.land.value;
	if (land == "keins"){
	    alert("Bitte wählen Sie Ihr Land!");
		voll=false;
		return voll;
	}
	
	var modell = document.order.modell.value;
	if (modell == ""){
	    alert("Bitte tragen Sie Notebook-Modell ein.");
		voll=false;
		return voll;
	}
	
//	if(window.document.order.methode.value=="bestellen.php?"){
//	    alert("Bitte Zahlungsmethode wählen!");
//		voll=false;
//		return voll;
//	}
	
//	if(window.document.order.agbs.checked==false){
//	    alert("Bitte lesen Sie die AGBs und stimmen Sie diesen zu!");
//		voll=false;
//		return voll;
//	}
	
	var mail = document.order.email.value;
	if (!mail.match (/[^\@]+\@[^\@]+/)){
	    alert("Bitte tragen Sie eine gültige Email ein.");
		voll=false;
		return voll;
	}

}

// zahlart.php testet hier!!!
function zahlart_pruefen() {
	voll=true;
	var art = document.zahlen.zahlart;
	if (art[0].checked!=true && art[1].checked!=true && art[2].checked!=true){
	    alert("Bitte wählen Sie eine Zahlungsmethode!");
		voll=false;
		return voll;
	}
}

// bestellung.php testet hier!!!
function check_agb() {
	voll=true;
	var art = document.abschliessen.agbs;
	if (art.checked!=true){
	    alert("Bitte lesen Sie die AGBs und stimmen Sie diesen zu!");
		voll=false;
		return voll;
	}
}

function fix(x) {
  var k = (Math.round(x * 100) / 100).toString();
  k += (k.indexOf('.') == -1)? '.00' : '00';
  return k.substring(0, k.indexOf('.') + 3);
}

function valid() {
	voll=true;
	var lang, teil, wort2;
	if (window.document.vergleich.bezeichnung.value.length==0) {
	  voll=false;
	}

	if (window.document.vergleich.bezeichnung.value.length > 1) {
	 	teil = window.document.vergleich.bezeichnung.value.split(" ");
	 	if (teil.length==1) {
	 	  voll=false;
	 	}
		if (teil.length==2) {
	 		wort2 = teil[1];
	 		lang = wort2.length;

			if (lang<2) {
				voll=false;
			}
		}
	}

	if(!voll)
		alert("Bitte geben Sie mindestens zwei Wörter ein!\nBeachten Sie: das 2.te Wörter muss mind. 2-stellig sein");
	return voll;
}

function alle_felder_pruefen2() {
	voll=true;
	anzahlFelder=8;
	for(n=2; n<anzahlFelder; n++) {
		if(window.document.neu.elements[n].value== ""){
			voll=false;
	   		alert("Bitte alle Pflichtfelder ausfüllen!");
	   		return voll;
		}
	}
	if(window.document.neu.tel.value== ""){
		voll=false;
	    alert("Bitte Pflichtfeld Telefon ausfüllen !");
	    return voll;
	}
	if(window.document.neu.email.value== ""){
		voll=false;
	    alert("Bitte Pflichtfeld eMail ausfüllen !");
	    return voll;
	}

	var tel = window.document.neu.tel.value;

  	// Remove spaces from the telephone number to help validation
  	while (tel.indexOf(" ")!= -1)  {
    	tel = tel.slice (0,tel.indexOf(" ")) + tel.slice (tel.indexOf(" ")+1)
  	}

	if (!tel.match (/^[0-9-()\/+.]*$/)){
	   voll=false;
	   alert("Bitte eine gültige Telefonnummer angeben!");
	   return voll;
	}

	var mail = window.document.neu.email.value;
	if (!mail.match (/[^\@]+\@[^\@]+/)){
	   voll=false;
	   alert("Bitte eine gültige eMail angeben!");
	   return voll;
	}


	// PLZ besteht aus 3 bis 6 ziffern
	var plz = window.document.neu.plz.value;
	if (!plz.match (/^[0-9]{3,6}$/)){
	   voll=false;
	   alert("Bitte eine gültige PLZ angeben!");
	   return voll;
	}

//	if(!voll)
//		alert("Bitte alle Pflichtfelder ausfüllen!");
//	return voll;
}

function testen() {
	voll=true;
	if(window.document.waren.hersteller.value== "")
		voll=false;
	if(window.document.waren.modell.value== "")
		voll=false;

	if(!voll)
		alert("Bitte Hersteller- und Modellfeld ausfüllen\n");
	return voll;
}

function admin1() {
	voll=true;
	if(window.document.admin.name.value=="")
		voll=false;

	if(window.document.admin.name.value!="") {
		if(window.document.admin.name.value.length<3)
			voll=false;
	}

	if(!voll)
		alert("Bitte Namenfeld ausfüllen\nMind. 3 Zeichen");
	return voll;
}
