var steuer = 0;
var produkteinzelpreis = null;

var tempdiscount ="";
var temp_coupon = "";
var temp_affiliate = "&affiliate=googleadwords";


if(parent.discountID=='uta15'){
	temp_coupon="&COUPON1=uta15";
}
if(parent.discountID=='db2007db'){
	temp_coupon="&COUPON1=db2007db";
}
if(parent.discountID=='tachopoint'){
	temp_affiliate="&affiliate=tachopoint";
}
if(parent.discountID=='slv15'){
	temp_coupon="&COUPON1=slv15";
}
if(parent.discountID=='Teleroute10'){
	temp_coupon="&COUPON1=Teleroute10";
}
if(parent.discountID=='BVG2006'){
	temp_coupon="&COUPON1=BVG2006";
}
if(parent.discountID=='TID2007'){
	temp_coupon="&COUPON1=TID2007";
}
if(parent.discountID=='bwvl2006'){
	temp_coupon="&COUPON1=bwvl2006";
}

if(parent.affilateID=='teleroute'){
	temp_affiliate="&affiliate=teleroute";
}
if(parent.affilateID=='kops'){
	temp_affiliate="&affiliate=kops";
}

tempdiscount = tempdiscount + temp_coupon + temp_affiliate;

function openmail(addy){

	if (addy == "dialoge")
	{
		location.href = 'mailto:' + 'dialog' + '@' + 'digital-spirit.de';
	}
	if (addy == "digital")
	{
		location.href = 'mailto:' + 'digital.tachograph' + '@' + 'digital-spirit.de';
	}
	if (addy == "jens")
	{
		location.href = 'mailto:' + 'J.Graszynski' + '@' + 'digital-spirit.de';
	}
}



function langselect()
{
//	var selectedLang = document.formular1.productid.options[document.formular1.productid.selectedIndex].value;
//	selectedLang = selectedLang.split("/")[1];
//	alert(selectedLang);
	location.href=document.formular1.productid.options[document.formular1.productid.selectedIndex].value;
}

function order(product_id)
{
	if(parent.discountID=='uta15')
	{
		var locahref = 'https://sshop.element5.com/esales/cart.html?PRODUCT['+product_id+']=1&cookies=1';
		document.location.href=locahref;
	}
	else
	{
		if(product_id == "300164354")
		{
			product_id = "300149484";
		}

		var locahref = "https://sshop.element5.com/esales/cart.html?PRODUCT["+product_id+"]=1"+tempdiscount+"&cookies=1";

		//locahref = locahref.replace(/&affiliate=/,"&affiliates=");
		top.document.location.href=locahref;
	}


}

function weiterleitung1(){
	var productID = document.flottenform.productid.options[document.flottenform.productid.selectedIndex].value;
	if(productID == 0001) {
		document.location.href="http://www.eltacografodigital.com/";
	 }
	else{

		if(parent.discountID=='uta15'){	document.location.href="https://sshop.element5.com/esales/cart.html?PRODUCT["+productID+"]=1&cookies=1";}
		else{		top.document.location.href="https://sshop.element5.com/esales/cart.html?PRODUCT["+productID+"]=1"+tempdiscount+"&cookies=1";
		}
	}
}
function weiterleitung2(){
	var productID = document.flottenform.productid.options[document.flottenform.productid.selectedIndex].value;
	if(productID == 0001) {
		document.location.href="http://www.eltacografodigital.com/";
	  }
	else{
		document.location.href="coupon_frame.htm?productID="+productID+"";
	}
}

function weiterleitung3(){
	var productID = document.behoerdenform.productid.options[document.behoerdenform.productid.selectedIndex].value;
	if(productID == 0001) {
		document.location.href="http://www.eltacografodigital.com/";
	 }
	else{
		if(parent.discountID=='uta15'){
			document.location.href="https://sshop.element5.com/esales/cart.html?PRODUCT["+productID+"]=1&cookies=1";
		}
		else
		{
			top.document.location.href="https://sshop.element5.com/esales/cart.html?PRODUCT["+productID+"]=1"+tempdiscount+"&cookies=1";
		}

	}
}

function weiterleitung4(){
	var productID = document.behoerdenform.productid.options[document.behoerdenform.productid.selectedIndex].value;
	if(productID == 0001) {
		document.location.href="http://www.eltacografodigital.com/";
	  }
	else{
		document.location.href="coupon_frame.htm?productID="+productID+"";
	}
}

function weiterleitung5(){
	var productID = document.formsimulator.productid.options[document.formsimulator.productid.selectedIndex].value;
	if(productID == 0001) {
		document.location.href="http://www.eltacografodigital.com/";
	 }
	else{
		if(parent.discountID=='uta15'){
			document.location.href="https://sshop.element5.com/esales/cart.html?PRODUCT["+productID+"]=1&cookies=1";
		}
		else
		{
			top.document.location.href="https://sshop.element5.com/esales/cart.html?PRODUCT["+productID+"]=1"+tempdiscount+"&cookies=1";
		}
		
	}
}

function weiterleitung6(){
	var productID = document.formsimulator.productid.options[document.formsimulator.productid.selectedIndex].value;
	if(productID == 0001) {
		document.location.href="http://www.eltacografodigital.com/";
	  }
	else{
		document.location.href="coupon_frame.htm?productID="+productID+"";
	}
}

function weiterleitung7(){
	document.location.href="prod6.htm";
}
function weiterleitung8()
{
		location.href="https://sshop.element5.com/esales/cart.html?PRODUCT[300149484]=1&affiliate=googleadwords&cookies=1";
	
}
function weiterleitung8a()
{
		document.location.href="coupon_frame.htm?productID=300164354";
	
}
function updateprice()
{

	var tempcode = document.getElementById("gutschein").value;
	
	var anzahl1 = parseInt(window.document.getElementById("count1").value);
	if(isNaN(anzahl1) || anzahl1 == 0 ){
		alert(alert_1);
		return
	}
	if (anzahl1 >10)
	{
		var kontaktinfo = alert_2;
		kontaktinfo += "digital spirit GmbH\n";
		kontaktinfo += "Jens Graszynski\n";
		kontaktinfo += "fon +49 (0)30 84 19 14-78 \n";
		kontaktinfo += "fax +49 (0)30 84 19 14-99 \n\n";
		kontaktinfo += "www.digital-spirit.de\n";
		kontaktinfo += "J.Gras" + " zynski" + "@digital-spirit.de";
		alert(kontaktinfo);
		return;
	}

	var produkt1 ;

		if(parent.discountID == "BVG2006")
		{
			produkt1 	= 646.00;
		}
		else{
			produkt1 	= 311.21;
		}
		if(parent.discountID == "uta15" )
		{
			produkt1 	= 680.00;
		}
	if(produkteinzelpreis != null)
	{
		produkt1 = produkteinzelpreis;
	}
	if(tempcode.length == 7 || tempcode.length == 6 )
	{
		produkt1 = 646.00;
		document.getElementById("einzel1").innerHTML = "646,00 €";
		document.getElementById("einzel1_hidden").value = "646,00 €";
		document.getElementById("gesamt1").innerHTML = "646,00 €";
	}


	var gesamt1 = anzahl1 * produkt1 ;
	gesamt1 = (Math.round(gesamt1*100))/100;
	var versand = calculate_shipping(anzahl1,produkt1);
	
	var selected_country = document.bestellung.country.options[document.bestellung.country.selectedIndex].value;
	if(selected_country  == "de"){
		steuer = calculate_tax(19,gesamt1,versand);
	}
	else{
		steuer = 0;
	}

	var gesamt_all = gesamt1 + steuer + versand;
	gesamt_all = (Math.round(gesamt_all*100))/100;

	window.document.getElementById("gesamt_preis").value =  + gesamt1 + " €"
	window.document.getElementById("gesamt_versand").value =  + versand + " €"
	window.document.getElementById("mwst").value =  + steuer + " €"
	window.document.getElementById("gesamt_preis_all").value =  + gesamt_all + " €"

	window.document.getElementById("gesamt1").innerHTML =   gesamt1.toString().replace(".",",") + " €"
	window.document.getElementById("versand1").innerHTML =   versand.toString().replace(".",",") + " €"
	window.document.getElementById("mwst1").innerHTML =   steuer.toString().replace(".",",") + " €"
	window.document.getElementById("gesamt_all1").innerHTML =  "<b>"+ gesamt_all.toString().replace(".",",")  + " €</b>"
}


function updateprice2(produktpreis)
{

	var tempcode = document.getElementById("gutschein").value;
	
	var anzahl1 = parseInt(window.document.getElementById("count1").value);
	if(isNaN(anzahl1) || anzahl1 == 0 ){
		alert(alert_1);
		return
	}
	if (anzahl1 >10)
	{
		var kontaktinfo = alert_2;
		kontaktinfo += "digital spirit GmbH\n";
		kontaktinfo += "Jens Graszynski\n";
		kontaktinfo += "fon +49 (0)30 84 19 14-78 \n";
		kontaktinfo += "fax +49 (0)30 84 19 14-99 \n\n";
		kontaktinfo += "www.digital-spirit.de\n";
		kontaktinfo += "J.Gras" + " zynski" + "@digital-spirit.de";
		alert(kontaktinfo);
		return;
	}
	var produkt1 ;
		if(parent.discountID == "BVG2006")
		{
			produkt1 	= 646.00;
		}
		else{
			produkt1 	= 311.21;
		}
		if(parent.discountID == "uta15" )
		{
			produkt1 	= 680.00;
		}
	if(tempcode.length == 7 || tempcode.length == 6 )
	{
		produkt1 = 646.00;
		document.getElementById("einzel1").innerHTML = "646,00 €";
		document.getElementById("einzel1_hidden").value = "646,00 €";
		document.getElementById("gesamt1").innerHTML = "646,00 €";
	}


	var gesamt1 = anzahl1 * produkt1 ;
	gesamt1 = (Math.round(gesamt1*100))/100;
	var versand = calculate_shipping(anzahl1,produkt1);
	
	var selected_country = document.bestellung.country.options[document.bestellung.country.selectedIndex].value;
	if(selected_country  == "de"){
		steuer = calculate_tax(19,gesamt1,versand);
	}
	else{
		steuer = 0;
	}

	var gesamt_all = gesamt1 + steuer + versand;
	gesamt_all = (Math.round(gesamt_all*100))/100;

	window.document.getElementById("gesamt_preis").value =  + gesamt1 + " €"
	window.document.getElementById("gesamt_versand").value =  + versand + " €"
	window.document.getElementById("mwst").value =  + steuer + " €"
	window.document.getElementById("gesamt_preis_all").value =  + gesamt_all + " €"

	window.document.getElementById("gesamt1").innerHTML =   gesamt1.toString().replace(".",",") + " €"
	window.document.getElementById("versand1").innerHTML =   versand.toString().replace(".",",") + " €"
	window.document.getElementById("mwst1").innerHTML =   steuer.toString().replace(".",",") + " €"
	window.document.getElementById("gesamt_all1").innerHTML =  "<b>"+ gesamt_all.toString().replace(".",",")  + " €</b>"
}


//(gesamt_all.toString()).replace(/./, ",") + " €"

function calculate_shipping(anzahl_produkte, produktpreis)
{
	var versand = 9;
	if(anzahl_produkte >2)
	{
		versand = 15;
	}
	if(anzahl_produkte >5)
	{
		versand = 30;
	}
	return versand;
}


function calculate_tax(mwst_satz,produktgesamt_preis, versandgesamt_preis )
{
	var tax = (produktgesamt_preis + versandgesamt_preis)/100*mwst_satz
	tax = (Math.round(tax*100))/100;
	return tax;
}


function checkFields()
{

	var alert_text = "Please fill in all mandatory fields";
	
	
	if((window.location.pathname).indexOf("/de/") >= 0 ||(window.location.pathname).indexOf("\\de\\") >= 0)
	{
		alert_text = "Sie haben noch nicht alle Pflichtfelder ausgefüllt.";
	}




         var forkfbnogo=document.all?document.all.fbnogo:document.getElementById?document.getElementById('fbnogo'):'';
if (forkfbnogo!=''){
   with( document.kontakt ){
      if( nachname.value == '' ){
         alert(alert_text);
         return false;
      }else  if( vorname.value == '' ){
         alert(alert_text);
         return false;
      }else  if( unternehmen.value == '' ){
         alert(alert_text);
         return false;
      }else  if( telefon.value == '' ){
         alert(alert_text);
         return false;
      }else  if( strasse_nr.value == '' ){
         alert(alert_text);
         return false;
      }else  if( plz_ort.value == '' ){
         alert(alert_text);
         return false;
      }else  if( land.value == '' ){
         alert(alert_text);
         return false;
      }else  if( nutzergruppe.selectedIndex == 0 ){
         alert(alert_text);
         return false;
      }else  if( dsmail.value == '' ){
         alert(alert_text);
         return false;
      }else return true;
      }
}else return true;
}

function checkFields2(){
		var forkfbnogo=document.all?document.all.fbnogo:document.getElementById?document.getElementById('fbnogo'):'';
		var message = alert_3;
		if (forkfbnogo!=''){
		   with( document.bestellung ){

			  if(parent.discountID == "uta15"){
				  if( gutschein.value == '' || gutschein.value == ' ' || gutschein.value == '  ' ){
					 alert(message);
					 return false;
				  }
			  }
			  if (document.bestellung.country.options[document.bestellung.country.selectedIndex].value == "0")
			  {
		         alert(choose_country);
				 return false;
			  }else if( nachname.value == '' ){
		         alert(message);
		         return false;
		      }else  if( vorname.value == '' ){
		         alert(message);
		         return false;
		      }else  if( unternehmen.value == '' ){
		         alert(message);
		         return false;
		      }else  if( strasse_nr.value == '' ){
		         alert(message);
		         return false;
		      }else  if( plz_ort.value == '' ){
		         alert(message);
		         return false;
		      }else  if( tel.value == '' ){
		         alert(message);
		         return false;
		      }else  if( dsmail.value == '' ){
		         alert(message);
			  }else if (agb.checked != true)
			  {
				window.document.getElementById("agb").style.borderWidth = "2px";
				window.document.getElementById("agb").style.borderStyle = "solid";
				window.document.getElementById("agb").style.borderColor = "ff0000";
		         alert(message);
		         return false;
		      }else return true;
		}
	}else return true;
}


function checklang()
{
	var choosen_lang = "";
	var url_string = document.formular1.productid.options[document.formular1.productid.selectedIndex].value
	if(url_string.indexOf("/de/") >= 0)
		choosen_lang = "de";
	if(url_string.indexOf("/en/") >= 0)
		choosen_lang = "en";
	if(url_string.indexOf("/fr/") >= 0)
		choosen_lang = "fr";
	if(url_string.indexOf("/it/") >= 0)
		choosen_lang = "it";
	if(url_string.indexOf("/es/") >= 0)
		choosen_lang = "es";
	if(url_string.indexOf("/nl/") >= 0)
		choosen_lang = "nl";

	var pre_select_index;
	switch(choosen_lang){
	case "de":
		pre_select_index = 1;
		break;
	case "en":
		pre_select_index = 2;
		break;
	case "nl":
		pre_select_index = 3;
		break;
	case "fr":
		pre_select_index = 4;
		break;
	case "it":
		pre_select_index = 5;
		break;
	case "es":
		pre_select_index = 6;
		break;
	}
	document.bestellung.country.selectedIndex = pre_select_index;

}

function removeProductsfromUTA()
{
	if(parent.discountID=='uta15' ){

		 var Knoten1 = document.getElementById("product_behoerden");
		 var Knoten2 = document.getElementById("product_behoerden2");
		Knoten1.parentNode.removeChild(Knoten1);
		Knoten2.parentNode.removeChild(Knoten2);

		 var Knoten3 = document.getElementById("product_simulator");
		 var Knoten4 = document.getElementById("product_simulator2");
		Knoten3.parentNode.removeChild(Knoten3);
		Knoten4.parentNode.removeChild(Knoten4);
	}

}


function writePrice(product)
{


var preise_fahrer1 = new Array();
//NORMAL
preise_fahrer1[0] = "14,88";
preise_fahrer1[0] = "12,50";
//UTA15 SLV15
preise_fahrer1[1] = "12,50";
//BVG2006
preise_fahrer1[2] = "11,25";
//DB
preise_fahrer1[3] = "11,88";


var preise_fahrer2 = new Array();
//NORMAL
preise_fahrer2[0] = "14,88";
preise_fahrer2[0] = "12,50";
//UTA15 SLV15
preise_fahrer2[1] = "12,50";
//BVG2006
preise_fahrer2[2] = "11,25";


var preise_flotten = new Array();
//NORMAL
preise_flotten[0] = "92,33";
preise_flotten[0] = "77,58";
//UTA15 SLV15
preise_flotten[1] = "77,58";
//BVG2006
preise_flotten[2] = "69,83";
//DB
preise_flotten[3] = "73,68";

var preise_behoerden = new Array();
//NORMAL
preise_behoerden[0] = "14,88";
preise_behoerden[0] = "12,50";
//UTA15 SLV15
preise_behoerden[1] = "12,50";
//BVG2006
preise_behoerden[2] = "11,25";


var preise_simulator = new Array();
//NORMAL
preise_simulator[0] = "132,34";
preise_simulator[0] = "111,21";
//UTA15 SLV15
preise_simulator[1] = "111,21";
//BVG2006
preise_simulator[2] = "100,09";
//DB
preise_simulator[3] = "105,65";


var preise_erstehilfepaket = new Array();
//NORMAL
preise_erstehilfepaket[0] = "370,34";
preise_erstehilfepaket[0] = "311,21";
// SLV15
preise_erstehilfepaket[1] = "295,65";
//BVG2006
preise_erstehilfepaket[2] = "295,65";

//UTA15
preise_erstehilfepaket[3] = "680,00";



var preise_erstehilfepaketpremium = new Array();
//NORMAL
preise_erstehilfepaketpremium[0] = "680,00";
// SLV15
preise_erstehilfepaketpremium[1] = "680,00";
//BVG2006
preise_erstehilfepaketpremium[2] = "680,00";

//UTA15
preise_erstehilfepaketpremium[3] = "680,00";

var preise_tisoffice = new Array();
//NORMAL
preise_tisoffice[0] = "1100,00";
// SLV15
preise_tisoffice[1] = "1100,00";
//BVG2006
preise_tisoffice[2] = "1100,00";

//UTA15
preise_tisoffice[3] = "1100,00";




var preise_lrz = new Array();
//NORMAL
preise_lrz[0] = "29,75";
preise_lrz[0] = "25,00";
//UTA15 SLV15
preise_lrz[1] = "25,00";
//BVG2006
preise_lrz[2] = "26,77";
//DB
preise_lrz[3] = " 23,75";

/////////////////////////////////////////////////////
	if(product == "lrz")
	{
		switch(parent.discountID)
		{
			case "db2007db":
				document.write(preise_lrz[3]);
				break;
			case "uta15":
			case "slv15":
				document.write(preise_lrz[1]);
				break;
			case "BVG2006":
				document.write(preise_lrz[2]);
				break;
			default:
				document.write(preise_lrz[0]);
		}
		return;
	}
	if(product == "fahrer1")
	{
		switch(parent.discountID)
		{
			case "db2007db":
				document.write(preise_fahrer1[3]);
				break;
			case "uta15":
			case "slv15":
				document.write(preise_fahrer1[1]);
				break;
			case "BVG2006":
				document.write(preise_fahrer1[2]);
				break;
			default:
				document.write(preise_fahrer1[0]);
		}
		return;
	}
	if(product == "fahrer2")
	{
		switch(parent.discountID)
		{
			case "uta15":
			case "slv15":
				document.write(preise_fahrer2[1]);
				break;
			case "BVG2006":
				document.write(preise_fahrer2[2]);
				break;
			default:
				document.write(preise_fahrer2[0]);
		}
		return;
	}
	if(product == "flotten")
	{
		switch(parent.discountID)
		{
			case "db2007db":
				document.write(preise_flotten[3]);
				break;
			case "uta15":
			case "slv15":
				document.write(preise_flotten[1]);
				break;
			case "BVG2006":
				document.write(preise_flotten[2]);
				break;
			default:
				document.write(preise_flotten[0]);
		}
		return;
	}

	if(product == "behoerden")
	{
		switch(parent.discountID)
		{
			case "uta15":
			case "slv15":
				document.write(preise_behoerden[1]);
				break;
			case "BVG2006":
				document.write(preise_behoerden[2]);
				break;
			default:
				document.write(preise_behoerden[0]);
		}
		return;
	}
	if(product == "simulator")
	{
		switch(parent.discountID)
		{
			case "db2007db":
				document.write(preise_simulator[3]);
				break;
			case "uta15":
			case "slv15":
				document.write(preise_simulator[1]);
				break;
			case "BVG2006":
				document.write(preise_simulator[2]);
				break;
			default:
				document.write(preise_simulator[0]);
		}
		return;
	}
	if(product == "erstehilfepaket")
	{
		switch(parent.discountID)
		{
			case "uta15":
				document.write(preise_erstehilfepaket[3]);
				break;
			case "slv15":
				document.write(preise_erstehilfepaket[1]);
				break;
			case "BVG2006":
				document.write(preise_erstehilfepaket[2]);
				break;
			default:
				document.write(preise_erstehilfepaket[0]);
		}
		return;
	}
	if(product == "erstehilfepaketpremium")
	{
		switch(parent.discountID)
		{
			case "uta15":
				document.write(preise_erstehilfepaketpremium[3]);
				break;
			case "slv15":
				document.write(preise_erstehilfepaketpremium[1]);
				break;
			case "BVG2006":
				document.write(preise_erstehilfepaketpremium[2]);
				break;
			default:
				document.write(preise_erstehilfepaketpremium[0]);
		}
		return;
	}

	if(product == "tisoffice")
	{
		switch(parent.discountID)
		{
			case "uta15":
				document.write(preise_tisoffice[3]);
				break;
			case "slv15":
				document.write(preise_tisoffice[1]);
				break;
			case "BVG2006":
				document.write(preise_tisoffice[2]);
				break;
			default:
				document.write(preise_tisoffice[0]);
		}
		return;
	}






}