// +++++++++++++++++++++++++++++++++++++++++++++++++
// ++++++++++ Start Dreamweaver Crap +++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++

function MM_setTextOfLayer(objName,x,newText) { //v4.01
  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (document.layers) {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

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 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_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_validateFormFix() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateFormFix.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' muss eine E-Mail-Adresse enthalten.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' muss eine Zahl sein.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' muss eine Zahl zwischen '+min+' und '+max+' sein.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' muss eingegeben werden.\n'; }
  } 
  if (!document.anmeldung.AGB.checked) errors += '- Sie haben die Allgemeinen Geschäftsbedingungen nicht akzeptiert!\n';
  if (errors) alert('Folgende Fehler :\n'+errors);
  if(errors == '') {
    var zielURL = document.anmeldung.forwardURL.value + '?';
	for(var counter = 0; counter < document.anmeldung.elements.length; counter++) {
		if(document.anmeldung.elements[counter].type == 'radio' && document.anmeldung.elements[counter].checked == true) {
			zielURL = zielURL + document.anmeldung.elements[counter].name + '=' + document.anmeldung.elements[counter].value + '&';
		}
		if(document.anmeldung.elements[counter].type == 'text') {
			zielURL = zielURL + document.anmeldung.elements[counter].name + '=' + document.anmeldung.elements[counter].value + '&';
		}
		if(document.anmeldung.elements[counter].type == 'checkbox' && document.anmeldung.elements[counter].checked == true) {
			zielURL = zielURL + document.anmeldung.elements[counter].name + '=' + document.anmeldung.elements[counter].value + '&';
		}
	}
	zielURL = encodeURI(zielURL);
	document.anmeldung.forwardURL.value = zielURL;
  }
  document.MM_returnValue = (errors == '');
}

function MM_validateFormVormerk() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateFormVormerk.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' muss eine E-Mail-Adresse enthalten.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' muss eine Zahl sein.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' muss eine Zahl zwischen '+min+' und '+max+' sein.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' muss eingegeben werden.\n'; }
  } 
  if (!document.anmeldung.AGB.checked) errors += '- Sie haben die Allgemeinen Geschäftsbedingungen nicht akzeptiert!\n';
  if (errors) alert('Folgende Fehler :\n'+errors);
  if(errors == '') {
    var zielURL = document.anmeldung.forwardURL.value + '?';
	for(var counter = 0; counter < document.anmeldung.elements.length; counter++) {
		if(document.anmeldung.elements[counter].type == 'radio' && document.anmeldung.elements[counter].checked == true) {
			zielURL = zielURL + document.anmeldung.elements[counter].name + '=' + document.anmeldung.elements[counter].value + '&';
		}
		if(document.anmeldung.elements[counter].type == 'text') {
			zielURL = zielURL + document.anmeldung.elements[counter].name + '=' + document.anmeldung.elements[counter].value + '&';
		}
		if(document.anmeldung.elements[counter].type == 'checkbox' && document.anmeldung.elements[counter].checked == true) {
			zielURL = zielURL + document.anmeldung.elements[counter].name + '=' + document.anmeldung.elements[counter].value + '&';
		}
	}
	zielURL = encodeURI(zielURL);
	document.anmeldung.forwardURL.value = zielURL;
  }
  document.MM_returnValue = (errors == '');
}

function MM_validateFormInteresse() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateFormInteresse.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' muss eine E-Mail-Adresse enthalten.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' muss eine Zahl sein.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' muss eine Zahl zwischen '+min+' und '+max+' sein.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' muss eingegeben werden.\n'; }
  } 
  if (errors) alert('Folgende Fehler :\n'+errors);
  if(errors == '') {
    var zielURL = document.anmeldung.forwardURL.value + '?';
	for(var counter = 0; counter < document.anmeldung.elements.length; counter++) {
		if(document.anmeldung.elements[counter].type == 'text') {
			zielURL = zielURL + document.anmeldung.elements[counter].name + '=' + document.anmeldung.elements[counter].value + '&';
		}
	}
	zielURL = encodeURI(zielURL);
	document.anmeldung.forwardURL.value = zielURL;
  }
  document.MM_returnValue = (errors == '');
}
// +++++++++++++++++++++++++++++++++++++++++++++++++
// ++++++++++++ End Dreamweaver Crap +++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++
// ++++++++++ Start self written Crap ++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++

function copyAddressData() {
	document.anmeldung.Rechnungsadressat.value = document.anmeldung.Vorname.value + ' ' + document.anmeldung.Nachname.value;
	document.anmeldung.Rechnungsadresse.value = document.anmeldung.Adresse.value;
	document.anmeldung.RechnungsPLZ.value = document.anmeldung.PLZ.value;
	document.anmeldung.Rechnungsort.value = document.anmeldung.Ort.value;
}

function swapCellStyle(cell,styleDef) {
	cell.className = styleDef;
}

function showNavigationPullDowns(menuObject,leftMargin,topMargin) {
	var newLeftMargin = leftMargin;
	var newTopMargin = topMargin;
	var winW = 939;
	var winH = 590;
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			winW = window.innerWidth-4;
			winH = window.innerHeight;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			winW = document.body.offsetWidth-20;
			winH = document.body.offsetHeight-3;
		}
	}
	if (winW > 939) {
		newLeftMargin = (((winW - 939) / 2) + leftMargin);
	}
	if (winH > 590) {
		newTopMargin = (((winH - 590) / 2) + topMargin);
	}
	window.FW_showMenu(menuObject,newLeftMargin,(newTopMargin + 63));
}

function correctLayerPlace(layerName,leftPos,topPos) {
	var newLeftPos = leftPos;
	var newTopPos = topPos;
	var winW = 939;
	var winH = 590;
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			winW = window.innerWidth-4;
			winH = window.innerHeight;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			winW = document.body.offsetWidth-20;
			winH = document.body.offsetHeight-3;
		}
	}
	if (winW > 939) {
		newLeftPos = (((winW - 939) / 2) + leftPos);
	}
	if (winH > 590) {
		newTopPos = (((winH - 590) / 2) + topPos);
	}
    if (document.getElementById) {
		document.getElementById(layerName).style.left = newLeftPos + 'px';
		document.getElementById(layerName).style.top = newTopPos + 63 + 'px';
    } else if (document.all) {
		document.all(layerName).style.left = newLeftPos;
		document.all(layerName).style.top = newTopPos + 63;
    } else if (document.layers) {
		document.layers[layerName].moveTo(newLeftPos,newTopPos + 63);
    }
}

function setPath(theURI,theTarget) {
	if (!theTarget) {
		window.location.href = theURI;
	} else {
		window.open(theURI,'new');
	}
}

function showPreview(layerName) {
	layerName = 'preview_' + layerName;
	moveLayerToMouse(layerName);
	MM_showHideLayers(layerName,'','show');
}

function hidePreview(layerName) {
	layerName = 'preview_' + layerName;
	MM_showHideLayers(layerName,'','hide');
}

xMousePos = 0; // horizontal position of the mouse on the screen
yMousePos = 0; // vertical position of the mouse on the screen

if (document.layers) {
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = captureMousePosition;
} else if (document.all) {
    document.onmousemove = captureMousePosition;
} else if (document.getElementById) {
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = captureMousePosition;
}

function captureMousePosition(e) {
    if (document.layers) { // Netscape 4.x
        xMousePos = e.pageX;
        yMousePos = e.pageY;
    } else if (document.all) { // Mircosoft IE
        xMousePos = window.event.x+document.body.scrollLeft;
        yMousePos = window.event.y+document.body.scrollTop;
    } else if (document.getElementById) { // Mozilla
        xMousePos = e.clientX + window.pageXOffset;
        yMousePos = e.clientY + window.pageYOffset;
    }
}

function moveLayerToMouse(layerName) {
    if (document.getElementById) {
		document.getElementById(layerName).style.top = yMousePos - 10 + 'px';
		document.getElementById(layerName).style.left = xMousePos + 20 + 'px';
    } else if (document.all) {
		document.all(layerName).style.top = yMousePos -10;
		document.all(layerName).style.left = xMousePos + 20;
    } else if (document.layers) {
		document.layers[layerName].moveTo(xMousePos + 20,yMousePos - 10);
    }
}

