ï»¿function calcPrice()
{
  var item_totals;
  var N1_qty = parseInt(document.getElementById("order_sheet").N1_qty.value);
  if(isNaN(N1_qty) === true)
  {
    N1_qty = 0;
  }
  var N2_qty = parseInt(document.getElementById("order_sheet").N2_qty.value);
  if(isNaN(N2_qty) === true)
  {
    N2_qty = 0;
  }
  var N3_qty = parseInt(document.getElementById("order_sheet").N3_qty.value);
  if(isNaN(N3_qty) === true)
  {
    N3_qty = 0;
  }
  var N4_qty = parseInt(document.getElementById("order_sheet2").N4_qty.value);
  if(isNaN(N4_qty) === true)
  {
    N4_qty = 0;
  }
  var N5_qty = parseInt(document.getElementById("order_sheet2").N5_qty.value);
  if(isNaN(N5_qty) === true)
  {
    N5_qty = 0;
  }
  
  var N6_qty = parseInt(document.getElementById("order_sheet2").N6_qty.value);
  if(isNaN(N6_qty) === true)
  {
    N6_qty = 0;
  }
  var N7_qty = parseInt(document.getElementById("order_sheet3").N7_qty.value);
  if(isNaN(N7_qty) === true)
  {
    N7_qty = 0;
  }
  var N8_qty = parseInt(document.getElementById("order_sheet3").N8_qty.value);
  if(isNaN(N8_qty) === true)
  {
    N8_qty = 0;
  }
 

  var qty_total = N1_qty + N2_qty + N3_qty + N4_qty + N5_qty + N6_qty + N7_qty + N8_qty;

  //If you change any of the prices or quantities, this starts the section you need to make changes to
  if((qty_total == 0) || (qty_total == "") || (isNaN(qty_total) === true))
  {
    price_per_num = 0;
    }
  if((qty_total == 1))
  {
    price_per_num = 6.00;
  }
  if((qty_total == 2))
  {
    price_per_num = 5.00;
  }
 if((qty_total == 3))
  {
    price_per_num = 13/3;
  }
if((qty_total == 4))
  {
    price_per_num = 4;
  }
if((qty_total == 5))
  {
    price_per_num = 3.7;
  }
if((qty_total == 6))
  {
    price_per_num = 3.5;
  }
if((qty_total == 7))
  {
    price_per_num = 24/7;
  }
if((qty_total == 8))
  {
    price_per_num = 3.25;
  }
  //do not edit below this line!
  
  getTotal();
  alert("Panier mis Ã  jour !");
  
  var total_price = price_per_num * qty_total;
    
  document.getElementById("order_sheet").total_qty.value = qty_total;
  document.getElementById("order_sheet").price_per_num.value = price_per_num.toFixed(2);
  document.getElementById("order_sheet").total_price.value = total_price.toFixed(2);
  if(total_price > 0)
  {
	document.getElementById("prixtotal").innerHTML = "Total : " + total_price.toFixed(2) + "&euro;";
  }
  if(total_price == 0)
  {
  document.getElementById("prixtotal").innerHTML = "";
  }

  
  var N1_price = N1_qty * price_per_num;
  var N2_price = N2_qty * price_per_num;
  var N3_price = N3_qty * price_per_num;
  var N4_price = N4_qty * price_per_num;
  var N5_price = N5_qty * price_per_num;
  var N6_price = N6_qty * price_per_num;
  var N7_price = N7_qty * price_per_num;
  var N8_price = N8_qty * price_per_num;
  
  // document.getElementById("order_sheet").N1_price.value = N1_price.toFixed(2);
  // document.getElementById("order_sheet").N2_price.value = N2_price.toFixed(2);
  // document.getElementById("order_sheet").N3_price.value = N3_price.toFixed(2);
  // document.getElementById("order_sheet2").N4_price.value = N4_price.toFixed(2);
  // document.getElementById("order_sheet2").N5_price.value = N5_price.toFixed(2);

}
function buildlist()
{
  document.paypal.amount.value = document.getElementById("order_sheet").price_per_num.value;
  document.paypal.quantity.value = document.getElementById("order_sheet").total_qty.value;
  if(document.getElementById("order_sheet").N1_qty.value > 0)
  {
    if(document.paypal.item_name.value !== "Anciens Numeros: ")
    {
      document.paypal.item_name.value += ", ";
    }
    document.paypal.item_name.value += document.getElementById("order_sheet").N1_qty.value + " N1";
  }
  if(document.getElementById("order_sheet").N2_qty.value > 0)
  {
    if(document.paypal.item_name.value !== "Anciens Numeros: ")
    {
      document.paypal.item_name.value += ", ";
    }
    document.paypal.item_name.value += document.getElementById("order_sheet").N2_qty.value + "  N2";
  }
  if(document.getElementById("order_sheet").N3_qty.value > 0)
  {
    if(document.paypal.item_name.value !== "Anciens Numeros: ")
    {
      document.paypal.item_name.value += ", ";
    }
    document.paypal.item_name.value += document.getElementById("order_sheet").N3_qty.value + "  N3";
  }
  if(document.getElementById("order_sheet2").N4_qty.value > 0)
  {
    if(document.paypal.item_name.value !== "Anciens Numeros: ")
    {
      document.paypal.item_name.value += ", ";
    }
    document.paypal.item_name.value += document.getElementById("order_sheet2").N4_qty.value + "  N4";
  }
  if(document.getElementById("order_sheet2").N5_qty.value > 0)
  {
    if(document.paypal.item_name.value !== "Anciens Numeros: ")
    {
      document.paypal.item_name.value += ", ";
    }
    document.paypal.item_name.value += document.getElementById("order_sheet2").N5_qty.value + "  N5";
  }
  if(document.getElementById("order_sheet2").N6_qty.value > 0)
  {
    if(document.paypal.item_name.value !== "Anciens Numeros: ")
    {
      document.paypal.item_name.value += ", ";
    }
    document.paypal.item_name.value += document.getElementById("order_sheet2").N6_qty.value + "  N6";
  }
  if(document.getElementById("order_sheet3").N7_qty.value > 0)
  {
    if(document.paypal.item_name.value !== "Anciens Numeros: ")
    {
      document.paypal.item_name.value += ", ";
    }
    document.paypal.item_name.value += document.getElementById("order_sheet3").N7_qty.value + "  N7";
  }
  if(document.getElementById("order_sheet3").N8_qty.value > 0)
  {
    if(document.paypal.item_name.value !== "Anciens Numeros: ")
    {
      document.paypal.item_name.value += ", ";
    }
    document.paypal.item_name.value += document.getElementById("order_sheet3").N8_qty.value + "  N8";
  }
}

function getTotal()
{
	var N1_qty = parseInt(document.getElementById("order_sheet").N1_qty.value);
	if(isNaN(N1_qty) === true)
	{
	N1_qty = 0;
	}
	var N2_qty = parseInt(document.getElementById("order_sheet").N2_qty.value);
	if(isNaN(N2_qty) === true)
	{
	N2_qty = 0;
	}
	var N3_qty = parseInt(document.getElementById("order_sheet").N3_qty.value);
	if(isNaN(N3_qty) === true)
	{
	N3_qty = 0;
	}
	var N4_qty = parseInt(document.getElementById("order_sheet2").N4_qty.value);
	if(isNaN(N4_qty) === true)
	{
	N4_qty = 0;
	}
	var N5_qty = parseInt(document.getElementById("order_sheet2").N5_qty.value);
	if(isNaN(N5_qty) === true)
	{
	N5_qty = 0;
	}
	var N6_qty = parseInt(document.getElementById("order_sheet2").N6_qty.value);
	if(isNaN(N6_qty) === true)
	{
	N6_qty = 0;
	}
	var N7_qty = parseInt(document.getElementById("order_sheet3").N7_qty.value);
	if(isNaN(N7_qty) === true)
	{
	N7_qty = 0;
	}
	var N8_qty = parseInt(document.getElementById("order_sheet3").N8_qty.value);
	if(isNaN(N8_qty) === true)
	{
	N8_qty = 0;
	}
	var qty_tot=N1_qty + N2_qty + N3_qty + N4_qty + N5_qty + N6_qty + N7_qty + N8_qty;
	if(qty_tot > 0)
	{
		document.getElementById("panier").innerHTML="<h3>Panier</h3>";
		document.getElementById("boutonpaypal").innerHTML="<form id=\"paypal\" name=\"paypal\" target=\"paypal\" action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\">"	+ "<input type=\"hidden\" name=\"cmd\" value=\"_xclick\"/>"	+ "<input type=\"hidden\" name=\"business\" value=\"contact@motaralp.fr\"/> " + "<input type=\"hidden\" name=\"item_name\" value=\"Ancien Numeros\"/>" + "<input type=\"hidden\" name=\"currency_code\" value=\"EUR\">"	+ "<input type=\"hidden\" name=\"quantity\"/>" + "<input type=\"hidden\" name=\"amount\"/>"	+ "<img alt=\"\" border=\"0\" src=\"https://www.paypal.com/fr_FR/i/scr/pixel.gif\" width=\"1\" height=\"1\"/>" + "<input onclick=\"buildlist()\" tabIndex=\"14\" type=\"image\" alt=\"PayPal - la solution de paiement en ligne la plus simple et la plus sécurisée !\" src=\"https://www.paypal.com/fr_FR/FR/i/btn/btn_buynowCC_LG.gif\" name=\"submit\"/>" + "</form>";
	}
	if(qty_tot == 0)
	{
		document.getElementById("panier").innerHTML="";
		document.getElementById("boutonpaypal").innerHTML="";
	}
	return qty_tot;
}

function addN1()
{
	var qty_total = getTotal();
	if(qty_total < 8)
	{
		var N1_qty = parseInt(document.getElementById("order_sheet").N1_qty.value);
		N1_qty = N1_qty + 1;
		document.getElementById("order_sheet").N1_qty.value = N1_qty;
		document.getElementById("order_sheet").N1 = N1_qty;
		if (document.getElementById("N1")){
			document.getElementById("N1").innerHTML=N1_qty + " Numero(s) 1" + "<button onclick=removeN1() type=button style=\"background-color:transparent; border:0px;\"><img src=\"/Images/Divers/delcart.png\" alt=\"Enlever du panier\"/></button> ";
		}
		calcPrice();
	}
}

function addN2()
{
	var qty_total = getTotal();
	if(qty_total < 8)
	{
		var N2_qty = parseInt(document.getElementById("order_sheet").N2_qty.value);
		N2_qty = N2_qty + 1;
		document.getElementById("order_sheet").N2_qty.value = N2_qty;
		document.getElementById("order_sheet").N2 = N2_qty;
		if (document.getElementById("N2")){
			document.getElementById("N2").innerHTML=N2_qty + " Numero(s) 2" + "<button onclick=removeN2() type=button style=\"background-color:transparent; border:0px;\"><img src=\"/Images/Divers/delcart.png\" alt=\"Enlever du panier\"/></button> ";
		}
		calcPrice();
	}
}

function addN3()
{
	var qty_total = getTotal();
	if(qty_total < 8)
	{
		var N3_qty = parseInt(document.getElementById("order_sheet").N3_qty.value);
		N3_qty = N3_qty + 1;
		document.getElementById("order_sheet").N3_qty.value = N3_qty;
		document.getElementById("order_sheet").N3 = N3_qty;
		if (document.getElementById("N3")){
			document.getElementById("N3").innerHTML=N3_qty + " Numero(s) 3" + "<button onclick=removeN3() type=button style=\"background-color:transparent; border:0px;\"><img src=\"/Images/Divers/delcart.png\" alt=\"Enlever du panier\"/></button> ";
		}
		calcPrice();
	}
}
function addN4()
{
	var qty_total = getTotal();
	if(qty_total < 8)
	{
		var N4_qty = parseInt(document.getElementById("order_sheet2").N4_qty.value);
		N4_qty = N4_qty + 1;
		document.getElementById("order_sheet2").N4_qty.value = N4_qty;
		document.getElementById("order_sheet2").N4 = N4_qty;
		if (document.getElementById("N4")){
			document.getElementById("N4").innerHTML=N4_qty + " Numero(s) 4" + "<button onclick=removeN4() type=button style=\"background-color:transparent; border:0px;\"><img src=\"/Images/Divers/delcart.png\" alt=\"Enlever du panier\"/></button> ";
		}
		calcPrice();
	}
}

function addN5()
{
	var qty_total = getTotal();
	if(qty_total < 8)
	{
		var N5_qty = parseInt(document.getElementById("order_sheet2").N5_qty.value);
		N5_qty = N5_qty + 1;
		document.getElementById("order_sheet2").N5_qty.value = N5_qty;
		document.getElementById("order_sheet2").N5 = N5_qty;
		if (document.getElementById("N5")){
			document.getElementById("N5").innerHTML=N5_qty + " Numero(s) 5" + "<button onclick=removeN5() type=button style=\"background-color:transparent; border:0px;\"><img src=\"/Images/Divers/delcart.png\" alt=\"Enlever du panier\"/></button> ";
		}
		calcPrice();
	}
}

function addN6()
{
	var qty_total = getTotal();
	if(qty_total < 8)
	{
		var N6_qty = parseInt(document.getElementById("order_sheet2").N6_qty.value);
		N6_qty = N6_qty + 1;
		document.getElementById("order_sheet2").N6_qty.value = N6_qty;
		document.getElementById("order_sheet2").N6 = N6_qty;
		if (document.getElementById("N6")){
			document.getElementById("N6").innerHTML=N6_qty + " Numero(s) 6" + "<button onclick=removeN6() type=button style=\"background-color:transparent; border:0px;\"><img src=\"/Images/Divers/delcart.png\" alt=\"Enlever du panier\"/></button> ";
		}
		calcPrice();
	}
}

function addN7()
{
	var qty_total = getTotal();
	if(qty_total < 8)
	{
		var N7_qty = parseInt(document.getElementById("order_sheet3").N7_qty.value);
		N7_qty = N7_qty + 1;
		document.getElementById("order_sheet3").N7_qty.value = N7_qty;
		document.getElementById("order_sheet3").N7 = N7_qty;
		if (document.getElementById("N7")){
			document.getElementById("N7").innerHTML=N7_qty + " Numero(s) 7" + "<button onclick=removeN7() type=button style=\"background-color:transparent; border:0px;\"><img src=\"/Images/Divers/delcart.png\" alt=\"Enlever du panier\"/></button> ";
		}
		calcPrice();
	}
}

function addN8()
{
	var qty_total = getTotal();
	if(qty_total < 8)
	{
		var N8_qty = parseInt(document.getElementById("order_sheet3").N8_qty.value);
		N8_qty = N8_qty + 1;
		document.getElementById("order_sheet3").N8_qty.value = N8_qty;
		document.getElementById("order_sheet3").N8 = N8_qty;
		if (document.getElementById("N8")){
			document.getElementById("N8").innerHTML=N8_qty + " Numero(s) 8" + "<button onclick=removeN8() type=button style=\"background-color:transparent; border:0px;\"><img src=\"/Images/Divers/delcart.png\" alt=\"Enlever du panier\"/></button> ";
		}
		calcPrice();
	}
}

function removeN1()
{
	var N1_qty = parseInt(document.getElementById("order_sheet").N1_qty.value);
	if(N1_qty !== 0)
	{	
		N1_qty = N1_qty - 1;
		if (document.getElementById("N1"))
		{
			document.getElementById("N1").innerHTML=N1_qty + " Numero(s) 1" + "<button onclick=removeN1() type=button style=\"background-color:transparent; border:0px;\"><img src=\"/Images/Divers/delcart.png\" alt=\"Enlever du panier\"/></button> ";
		}
	}
	if(N1_qty == 0)
	{
		document.getElementById("N1").innerHTML="";
	}	
	document.getElementById("order_sheet").N1_qty.value = N1_qty;
	calcPrice();
}

function removeN2()
{
	var N2_qty = parseInt(document.getElementById("order_sheet").N2_qty.value)
	if(N2_qty !== 0)
	{	
		N2_qty = N2_qty - 1;
		if (document.getElementById("N2"))
		{
			document.getElementById("N2").innerHTML=N2_qty + " Numero(s) 2" + "<button onclick=removeN2() type=button style=\"background-color:transparent; border:0px;\"><img src=\"/Images/Divers/delcart.png\" alt=\"Enlever du panier\"/></button> ";
		}
	}	
	if(N2_qty == 0)
	{
		document.getElementById("N2").innerHTML="";
	}
	document.getElementById("order_sheet").N2_qty.value = N2_qty;
	calcPrice();
}

function removeN3()
{
	var N3_qty = parseInt(document.getElementById("order_sheet").N3_qty.value);
	if(N3_qty !== 0)
	{	
		N3_qty = N3_qty - 1;
		if (document.getElementById("N3"))
		{
			document.getElementById("N3").innerHTML=N3_qty + " Numero(s) 3" + "<button onclick=removeN3() type=button style=\"background-color:transparent; border:0px;\"><img src=\"/Images/Divers/delcart.png\" alt=\"Enlever du panier\"/></button> ";
		}
	}
	if(N3_qty == 0)
	{
		document.getElementById("N3").innerHTML="";
	}
	document.getElementById("order_sheet").N3_qty.value = N3_qty;
	calcPrice();
}
function removeN4()
{
	var N4_qty = parseInt(document.getElementById("order_sheet2").N4_qty.value);
	if(N4_qty !== 0)
	{	
		N4_qty = N4_qty - 1;
		if (document.getElementById("N4"))
		{
			document.getElementById("N4").innerHTML=N4_qty + " Numero(s) 4" + "<button onclick=removeN4() type=button style=\"background-color:transparent; border:0px;\"><img src=\"/Images/Divers/delcart.png\" alt=\"Enlever du panier\"/></button> ";
		}
	}
	if(N4_qty == 0)
	{
		document.getElementById("N4").innerHTML="";
	}
	document.getElementById("order_sheet2").N4_qty.value = N4_qty;
	calcPrice();
}
function removeN5()
{
	var N5_qty = parseInt(document.getElementById("order_sheet2").N5_qty.value);
	if(N5_qty !== 0)
	{	
		N5_qty = N5_qty - 1;
		if (document.getElementById("N5"))
		{
			document.getElementById("N5").innerHTML=N5_qty + " Numero(s) 5" + "<button onclick=removeN5() type=button style=\"background-color:transparent; border:0px;\"><img src=\"/Images/Divers/delcart.png\" alt=\"Enlever du panier\"/></button> ";
		}
	}
	if(N5_qty == 0)
	{
		document.getElementById("N5").innerHTML="";
	}
	document.getElementById("order_sheet2").N5_qty.value = N5_qty;
	calcPrice();
}
function removeN6()
{
	var N6_qty = parseInt(document.getElementById("order_sheet2").N6_qty.value);
	if(N6_qty !== 0)
	{	
		N6_qty = N6_qty - 1;
		if (document.getElementById("N6"))
		{
			document.getElementById("N6").innerHTML=N6_qty + " Numero(s) 6" + "<button onclick=removeN6() type=button style=\"background-color:transparent; border:0px;\"><img src=\"/Images/Divers/delcart.png\" alt=\"Enlever du panier\"/></button> ";
		}
	}
	if(N6_qty == 0)
	{
		document.getElementById("N6").innerHTML="";
	}
	document.getElementById("order_sheet2").N6_qty.value = N6_qty;
	calcPrice();
}
function removeN7()
{
	var N7_qty = parseInt(document.getElementById("order_sheet3").N7_qty.value);
	if(N7_qty !== 0)
	{	
		N7_qty = N7_qty - 1;
		if (document.getElementById("N7"))
		{
			document.getElementById("N7").innerHTML=N7_qty + " Numero(s) 7" + "<button onclick=removeN7() type=button style=\"background-color:transparent; border:0px;\"><img src=\"/Images/Divers/delcart.png\" alt=\"Enlever du panier\"/></button> ";
		}
	}
	if(N7_qty == 0)
	{
		document.getElementById("N7").innerHTML="";
	}
	document.getElementById("order_sheet3").N7_qty.value = N7_qty;
	calcPrice();
}

function removeN8()
{
	var N8_qty = parseInt(document.getElementById("order_sheet3").N8_qty.value);
	if(N8_qty !== 0)
	{	
		N8_qty = N8_qty - 1;
		if (document.getElementById("N8"))
		{
			document.getElementById("N8").innerHTML=N8_qty + " Numero(s) 8" + "<button onclick=removeN7() type=button style=\"background-color:transparent; border:0px;\"><img src=\"/Images/Divers/delcart.png\" alt=\"Enlever du panier\"/></button> ";
		}
	}
	if(N8_qty == 0)
	{
		document.getElementById("N8").innerHTML="";
	}
	document.getElementById("order_sheet3").N8_qty.value = N8_qty;
	calcPrice();
}