function FB_changeLang(which) {
urlParam = location.href;
from = urlParam.lastIndexOf('/') + 1;
to = urlParam.length;
urlParam = urlParam.substring(from, to);
urlParam = '../' + which + '/' + urlParam;

MM_goToURL('parent', urlParam);
}

function shippingInfo(checkbox) {
if (checkbox.checked == true) {
MM_showHideLayers('Layer3','','show');
MM_changeProp('Layer3','','style.position','static','DIV');
} else {
MM_changeProp('Layer3','','style.position','absolute','DIV');
MM_showHideLayers('Layer3','','hide');
}
}

function textCounter() {
df_greetings_v = document.orderForm.greetings;
maxlimit=250;
if (df_greetings_v.value.length > maxlimit) {
df_greetings_v.value = df_greetings_v.value.substring(0, maxlimit);
} else {
document.getElementById('numchars').firstChild.nodeValue = maxlimit - df_greetings_v.value.length;
}
}

function FB_checkForm(which) {
totalQuantity = 0;

errors1 = '';
errors2 = '';

if (which == 'con') {
df_vorname_v = document.contactForm.Vorname.value;
df_name_v = document.contactForm.Name.value;
df_email_v = document.contactForm.Email.value;
df_message_v = document.contactForm.Msg.value;

if (df_vorname_v == "" || df_name_v == "" || df_email_v == "" || df_message_v == "") {
errors1 += 'Bitte füllen Sie alle benötigten Felder (*) aus!\n';
}
}

if (which == 'com') {
df_firma_v = document.orderForm.Firma.value;
df_strasse_v = document.orderForm.Strasse.value;
df_plzort_v = document.orderForm.PLZOrt.value;
df_telefon_v = document.orderForm.Telefon.value;
df_email_v = document.orderForm.Email.value;

if (df_firma_v == "" || df_strasse_v == "" || df_plzort_v == "" || df_telefon_v == "" || df_email_v == "") {
errors1 += 'Bitte füllen Sie alle benötigten Felder (*) aus!\n';
}
}

if (which == 'pub') {
df_vorname_v = document.orderForm.Vorname.value;
df_name_v = document.orderForm.Name.value;
df_strasse_v = document.orderForm.Strasse.value;
df_plzort_v = document.orderForm.PLZOrt.value;
df_email_v = document.orderForm.Email.value;

df_greetings_v = document.orderForm.greetings.value;
df_lvorname_v = document.orderForm.lVorname.value;
df_lname_v = document.orderForm.lName.value;
df_lstrasse_v = document.orderForm.lStrasse.value;
df_lplzort_v = document.orderForm.lPLZOrt.value;
df_lemail_v = document.orderForm.lEmail.value;

for (i = 1; i <= 12; i++) {
posQuantity = eval('document.orderForm.Ed_' + i + '.value');
totalQuantity += (posQuantity * 100 / 100);
}

if (totalQuantity < 1) {
errors1 += 'Sie müssen mindestens 1 Karte bestellen!\n';
}

if (df_vorname_v == "" || df_name_v == "" || df_strasse_v == "" || df_plzort_v == "" || df_email_v == "") {
if (document.orderForm.shippingAdr.checked == true) {
errors1 += 'Bitte geben Sie alle benötigten Rechnungsinformationen (*) an!\n';
} else {
errors1 += 'Bitte füllen Sie alle benötigten Felder (*) aus!\n';
}
}
}

if (df_email_v != "") {
eem1 = df_email_v.indexOf('@');
eem2 = df_email_v.lastIndexOf('.');
eem3 = df_email_v.length-1;
checkVar1 = 0

if (eem1 < 1)
checkVar1 = checkVar1 + 1;
if (eem3 - eem2 < 2)
checkVar1 = checkVar1 + 1;
if (eem2-eem1 < 2)
checkVar1 = checkVar1 + 1;
if (checkVar1 != 0)
errors1 += 'Bitte geben Sie eine gültige E-Mail Adresse ein!\n'
}

if (which == 'pub') {
if (document.orderForm.shippingAdr.checked == true) {

if (totalQuantity > 1) {
errors2 += 'Sie können nur eine Karte pro Grussbotschaft versenden!\nBitte ändern Sie die Bestellmenge.\n';
}

if (df_greetings_v == "") {
errors2 += 'Geben Sie eine Grussbotschaft ein!\n';
}

if (df_lvorname_v == "" || df_lname_v == "" || df_lstrasse_v == "" || df_lplzort_v == "" ) {
errors2 += 'Bitte geben Sie alle benötigten Lieferinformationen (*) an!\n';
}
}
}

if (errors1) alert(errors1); document.errorstatus = false;
if ((!errors1) && (errors2)) alert(errors2); document.errorstatus = false;
if ((!errors1) && (!errors2)) document.errorstatus = true;

}

function FB_checkQuantity() {
totalQuantity = 0;
breakDiscount = 25;

errors1 = '';

for (i = 1; i <= 12; i++) {
posQuantity = eval('document.orderForm.Ed_' + i + '.value');
totalQuantity += (posQuantity * 100 / 100);
}
if (totalQuantity < breakDiscount) {
errors1 += 'Die Mindestbestellmenge beträgt 25 Stück\n';
if (errors1) alert(errors1); document.errorstatus = false;
} else {
FB_checkForm('com');
}
}

function calculate(which) {
totalQuantity = 0;
totalPrice = 0;
totalSub = 0;
totalExcl = 0;
totalIncl = 0;
totalAccessories = 0;
totalTax = 0;
priceRegular = 14.9;
priceDealer = 9.7;
pricePostage = 15.00;
breakDiscount = 25;
breakPostage = 500;
rateTax = 7.5;

if (which == 'com') {
priceRegular = (priceRegular / (100 + rateTax) * 100).toFixed(2);

for (i = 1; i <= 12; i++) {
posQuantity = eval('document.orderForm.Ed_' + i + '.value');
posPrice = posQuantity * priceRegular;
totalQuantity += (posQuantity * 100 / 100);
totalSub += posPrice;
eval('document.getElementById(\'pEd_' + i + '\').firstChild.nodeValue = posPrice.toFixed(2)');
}

totalPrice = totalSub;

if (totalQuantity >= breakDiscount) {
discount = totalPrice - (totalQuantity * priceDealer);
discountRate = discount / totalPrice * 100;
totalPrice -= discount
document.getElementById('discountrate').firstChild.nodeValue = discountRate.toFixed(0);
document.getElementById('prozent').firstChild.nodeValue = '%';
document.getElementById('minus').firstChild.nodeValue = '-';
document.getElementById('discountprice').firstChild.nodeValue = discount.toFixed(2);
} else {
discount = 0;
discountRate = 0;
document.getElementById('discountrate').firstChild.nodeValue = '';
document.getElementById('prozent').firstChild.nodeValue = '';
document.getElementById('minus').firstChild.nodeValue = '';
document.getElementById('discountprice').firstChild.nodeValue = discount.toFixed(2);
}

if (document.orderForm.aTs2.checked == true) { totalAccessories += 60; }
if (document.orderForm.aTs4.checked == true) { totalAccessories += 80; }
if (document.orderForm.aDvd.checked == true) { totalAccessories += 280; }
if (totalQuantity >= 240) {
totalAccessories = 0;
} else if (totalQuantity >= 160 && totalAccessories >= 360) {
totalAccessories -= 360;
} else if (totalQuantity >= 160 && totalAccessories >= 340) {
totalAccessories -= 340;
} else if (totalQuantity >= 160 && totalAccessories >= 280) {
totalAccessories -= 280;
} else if (totalQuantity >= 80 && document.orderForm.aTs4.checked == true) {
totalAccessories -= 80;
} else if (totalQuantity >= 80 && document.orderForm.aTs2.checked == true) {
totalAccessories -= 60;
}

totalPrice += totalAccessories;

totalPrice = (totalPrice < breakPostage) ? (totalPrice += pricePostage) : totalPrice;

totalExcl = totalPrice;

totalTax = totalPrice * rateTax / 100;

totalPrice += totalTax;

totalIncl = totalPrice;

document.getElementById('totalsub').firstChild.nodeValue = totalSub.toFixed(2);

document.getElementById('totalaccessories').firstChild.nodeValue = totalAccessories.toFixed(2);

document.getElementById('pricepostage').firstChild.nodeValue = (totalPrice < breakPostage) ? pricePostage.toFixed(2) : '0.00';

document.getElementById('totalexcl').firstChild.nodeValue = totalExcl.toFixed(2);

document.getElementById('totaltax').firstChild.nodeValue = totalTax.toFixed(2);

document.getElementById('totalincl').firstChild.nodeValue = totalIncl.toFixed(2);
}

if (which == 'pub') {
pricePostage = 5.00;

for (i = 1; i <= 12; i++) {
posQuantity = eval('document.orderForm.Ed_' + i + '.value');
posPrice = posQuantity * priceRegular;
totalQuantity += (posQuantity * 100 / 100);
totalSub += posPrice;
}

totalPrice = totalSub;

totalPrice += pricePostage;

totalIncl = totalPrice;

document.getElementById('totalquantity').firstChild.nodeValue = totalQuantity;

document.getElementById('totalsub').firstChild.nodeValue = totalSub.toFixed(2);

document.getElementById('pricepostage').firstChild.nodeValue = pricePostage.toFixed(2);

document.getElementById('totalincl').firstChild.nodeValue = totalIncl.toFixed(2);
}
}

// beginn var over url

// ? parse
urlParam = location.href;
from = urlParam.indexOf('?') + 1;
to = urlParam.length;
urlParam = urlParam.substring(from, to);
urlParam = urlParam.replace(/%20/g, " ");

if (from != 0) {
	// & parse
	urlParamArray = urlParam.split("&");
	// = parse
	for (i = 0; i < urlParamArray.length; i++) {
		paramArray = urlParamArray[i].split("=");
		if (isNaN(paramArray[1])) {
			urlParamArray[i] = paramArray[0] + '=' + '"' + paramArray[1] + '"';
		}
		eval(urlParamArray[i]);
	}
}
// end var over url

// Begin Macromedia Dreamweaver Functions
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_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_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.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_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

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_showHideLayers() { //v6.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_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}
// End Macromedia Dreamweaver Functions