//##### ======================================= #####
//#####             365battery.net            #####
//#####           EMPOLDER: 2008-07-22          #####
//##### ======================================= #####

function round_decimals(original_number,decimals){
 var result1 = original_number * Math.pow(10,decimals);
 var result2 = Math.round(result1);
 var result3 = result2 / Math.pow(10,decimals);
 return pad_with_zeros(result3,decimals);
}
function pad_with_zeros(rounded_value,decimal_places){
 var value_string = rounded_value.toString();
 var decimal_location = value_string.indexOf(".");
 if (decimal_location == -1){
  decimal_part_length = 0;
  value_string += decimal_places > 0 ? "." :"";
 }else{
  decimal_part_length = value_string.length - decimal_location - 1;
 }
 var pad_total = decimal_places - decimal_part_length;
 if(pad_total > 0){
  for (var counter = 1;counter <= pad_total;counter++){
   value_string += "0";
  }
 }
 return value_string;
}

function show_buy(T_code,imagepath){
	var proportion = 1.00; //
	var uk = 3.95;
	var eur = 5.95;
	var org;
	var save;
	var sale_price;	    //
	var ori_price  = Math.round(price[T_code][0] * proportion * 140)/100;
	var sale_price  = Math.round(price[T_code][0] * proportion * 100)/100;
	var save_price = ori_price - sale_price;
	var sale_price  = round_decimals( sale_price ,2);
	var ori_price  = round_decimals( ori_price ,2);
	var save_price  = round_decimals( save_price ,2);
	if (price[T_code] != "0" && price[T_code][1] == "1"){
	document.write("<b>"+"Preis : "+"</b>"+"<span class=\"priceText\">" + sale_price + " EUR </span>");
		document.write("<input type=\"hidden\" name=\"item_number\" value=\"" + T_code + "\">");
		document.write("<input type=\"hidden\" name=\"amount\" value=\"" + sale_price + "\">");
		document.write("<input type=\"hidden\" name=\"business\" value=\"order@365battery.net\">");
		document.write("<input name=\"Submit\" type=\"image\" value=\"Submit\" src=\"http://www.365battery.net/battery-images/add_to_cart.gif\">");
		document.write("<input type=\"hidden\" name=\"no_shipping\" value=\"0\">");
		document.write("<input type=\"hidden\" name=\"shipping2\" value=\"6.99\">");
		document.write("<input type=\"hidden\" name=\"page_style\" value=\"PayPal\">");
		document.write("<input type=\"hidden\" name=\"currency_code\" value=\"EUR\">");
		document.write("<input type=\"hidden\" name=\"lc\" value=\"DE\">");
		document.write("<input type=\"hidden\" name=\"bn\" value=\"PP-ShopCartBF\">");
		document.write("<input type=\"hidden\" name=\"add\" value=\"1\">");
		document.write("<input type=\"hidden\" name=\"cmd\" value=\"_cart\">");
	}
	else{
		document.write("<span class=\"light\">Out of stock</span>");
	}
}

function show_buy1(T_code,imagepath){
	var proportion = 1.00; //
	var uk = 3.95;
	var eur = 5.95;
	var org;
	var save;
	var sale_price;	    //
	var ori_price  = Math.round(price[T_code][0] * proportion * 200)/100;
	var sale_price  = Math.round(price[T_code][0] * proportion * 100)/100;
	var save_price = ori_price - sale_price;
	var sale_price  = round_decimals( sale_price ,2);
	var ori_price  = round_decimals( ori_price ,2);
	var save_price  = round_decimals( save_price ,2);
	if (price[T_code] != "0" && price[T_code][1] == "1"){
	document.write("<p>"+"<b>"+"Preis : "+"</b>"+"<span class=\"priceText\">" + sale_price + " EUR</span>"+"&nbsp; &nbsp; &nbsp; + 3.99 EUR (Lieferung)"+"</P>");
		document.write("<input type=\"hidden\" name=\"item_number\" value=\"" + T_code + "\">");
		document.write("<input type=\"hidden\" name=\"amount\" value=\"" + sale_price + "\">");
		document.write("<input type=\"hidden\" name=\"business\" value=\"order@365battery.net\">");
		document.write("<input name=\"Submit\" type=\"image\" value=\"Submit\" src=\"http://www.365battery.net/battery-images/add_to_cart.gif\">");
		document.write("<input type=\"hidden\" name=\"no_shipping\" value=\"0\">");
		document.write("<input type=\"hidden\" name=\"shipping\" value=\"3.99\">");
		document.write("<input type=\"hidden\" name=\"page_style\" value=\"PayPal\">");
		document.write("<input type=\"hidden\" name=\"currency_code\" value=\"EUR\">");
		document.write("<input type=\"hidden\" name=\"lc\" value=\"DE\">");
		document.write("<input type=\"hidden\" name=\"bn\" value=\"PP-ShopCartBF\">");
		document.write("<input type=\"hidden\" name=\"add\" value=\"1\">");
		document.write("<input type=\"hidden\" name=\"cmd\" value=\"_cart\">");
	}
	else{
		document.write("<span class=\"light\">Out of stock</span>");
	}
}

function show_buy2(T_code,imagepath){
	var proportion = 1.00; //
	var uk = 3.95;
	var eur = 5.95;
	var org;
	var save;
	var sale_price;	    //
	var ori_price  = Math.round(price[T_code][0] * proportion * 200)/100;
	var sale_price  = Math.round(price[T_code][0] * proportion * 100)/100;
	var save_price = ori_price - sale_price;
	var sale_price  = round_decimals( sale_price ,2);
	var ori_price  = round_decimals( ori_price ,2);
	var save_price  = round_decimals( save_price ,2);
	if (price[T_code] != "0" && price[T_code][1] == "1"){
	document.write("<p>"+"<b>"+"Preis : "+"</b>"+"<span class=\"priceText\">" + sale_price + " EUR</span>"+"&nbsp; &nbsp; &nbsp; + $3.99 EUR (Lieferung)"+"</P>");
		document.write("<input type=\"hidden\" name=\"item_number\" value=\"" + T_code + "\">");
		document.write("<input type=\"hidden\" name=\"amount\" value=\"" + sale_price + "\">");
		document.write("<input type=\"hidden\" name=\"business\" value=\"order@365battery.net\">");
		document.write("<input name=\"Submit\" type=\"image\" value=\"Submit\" src=\"http://www.365battery.net/battery-images/add_to_cart.gif\">");
		document.write("<input type=\"hidden\" name=\"no_shipping\" value=\"0\">");
		document.write("<input type=\"hidden\" name=\"shipping\" value=\"3.99\">");
		document.write("<input type=\"hidden\" name=\"page_style\" value=\"PayPal\">");
		document.write("<input type=\"hidden\" name=\"currency_code\" value=\"EUR\">");
		document.write("<input type=\"hidden\" name=\"lc\" value=\"DE\">");
		document.write("<input type=\"hidden\" name=\"bn\" value=\"PP-ShopCartBF\">");
		document.write("<input type=\"hidden\" name=\"add\" value=\"1\">");
		document.write("<input type=\"hidden\" name=\"cmd\" value=\"_cart\">");
	}
	else{
		document.write("<span class=\"light\">Out of stock</span>");
	}
}

function show_buy3(T_code,T_code2,imagepath){
	var proportion = 1.00; //
	var uk = 7.9;
	var eur = 11.9;
	var sav = 2.0;
	var ori_price;	    //
	var ori_price  = Math.round(price[T_code][0] * proportion * 100)/100;
	var ori_price2 = Math.round(price[T_code2][0] * proportion * 100)/100;
	var ori_price = eval(ori_price) + eval(ori_price2);
	var sale_price = ori_price - sav;
	var ori_price  = round_decimals( ori_price ,2);
	var sale_price  = round_decimals( sale_price ,2);
	if ((price[T_code] != "0" && price[T_code][1] == "1") && (price[T_code2] != "0" && price[T_code2][1] == "1")) {
		document.write(""+"<span class=\"originalPrice\">" + ori_price + " EUR</span>" +"<br>");
		document.write("<b>"+"Preis : "+"</b>"+"<span class=\"priceText\">" + sale_price + " EUR</span>"+"&nbsp; &nbsp; &nbsp; + 3.99 EUR (Lieferung)"+"<br>");
		document.write("<input type=\"hidden\" name=\"item_number\" value=\"" + T_code + "+" + T_code2 + "\">");
		document.write("<input type=\"hidden\" name=\"amount\" value=\"" + sale_price + "\">");
		document.write("<input type=\"hidden\" name=\"business\" value=\"order@365battery.net\">");
		document.write("<input type=\"hidden\" name=\"shipping\" value=\"3.99\">");
		document.write("<input name=\"Submit\" type=\"image\" value=\"Submit\" src=\"http://www.365battery.net/battery-images/add_to_cart.gif\"  vspace=\"5\">");
		document.write("<input type=\"hidden\" name=\"page_style\" value=\"PayPal\">");
		document.write("<input type=\"hidden\" name=\"currency_code\" value=\"EUR\">");
		document.write("<input type=\"hidden\" name=\"lc\" value=\"DE\">");
		document.write("<input type=\"hidden\" name=\"bn\" value=\"PP-ShopCartBF\">");
		document.write("<input type=\"hidden\" name=\"add\" value=\"1\">");
		document.write("<input type=\"hidden\" name=\"cmd\" value=\"_cart\">");
	}
	else{
		document.write("<span class=\"light\">Out of stock</span>");
	}
}
