//##### ======================================= #####
//#####             USbattery.net            #####
//#####           EMPOLDER: 2006-11-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){
	var proportion = 1.00; //
	var ori;
	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("<p>"+"<b>"+"Original price : "+"</b>"+"<span class=\"originalPrice\">$ " + ori_price + "</span>" +"</P>");
	document.write("<p>"+"<b>"+"Special price : "+"</b>"+"<span class=\"priceText\">$ " + sale_price + "</span>" +"</P>");
	document.write("<p>"+"<b>"+"You Save : "+"</b>"+"<span class=\"savePrice\">$ " + save_price + "</span>" +"</P>");
	 if (price[T_code] != "0" && price[T_code][1] == "1" && price[T_code][2] == "2"){
	       document.write("<div class=\"samsung\">"+"* "+"Brand New, Six Months Warranty!"+"</div>");
		   document.write("<div class=\"samsung\">"+"* "+"High quality LG / SAMSUNG battery cells!"+"</div>");
	    }
	      else{
		  document.write("<div class=\"light\">"+"* "+"Brand New, 1 year Warranty!"+"</div>"); 
		  document.write("<div class=\"light\">"+"* "+"High quality SANYO / SAMSUNG / PANASONIC battery cells!"+"</div>"); 
	    }
	document.write("<div>"+"<a href=\"http://usbattery.net/shipping.html\" target=\"_blank\">"+"<img alt=\"Shipping information\" src=\"http://usbattery.net/image/deliver.gif\" border=\"0\">"+"Shipping information."+"</a>"+"</div>");
	document.write("<br>");
		document.write("<input name=\"Submit\" type=\"image\" value=\"Submit\" src=\"http://www.usbattery.net/image/buy.gif\" hspace=\"5\">");
		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=\"payment@usbattery.net\">");
		document.write("<input type=\"hidden\" name=\"shipping\" value=\"6.95\">");
		document.write("<input type=\"hidden\" name=\"no_shipping\" value=\"0\">");
		document.write("<input type=\"hidden\" name=\"page_style\" value=\"PayPal\">");
		document.write("<input type=\"hidden\" name=\"currency_code\" value=\"USD\">");
		document.write("<input type=\"hidden\" name=\"lc\" value=\"US\">");
		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_buy5(T_code){
	var proportion = 1.00; //
	var ori;
	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("<p>"+"<b>"+"Original price : "+"</b>"+"<span class=\"originalPrice\">$ " + ori_price + "</span>" +"</P>");
	document.write("<p>"+"<b>"+"Special price : "+"</b>"+"<span class=\"priceText\">$ " + sale_price + "</span>" +"</P>");
	document.write("<p>"+"<b>"+"You Save : "+"</b>"+"<span class=\"savePrice\">$ " + save_price + "</span>" +"</P>");
	 if (price[T_code] != "0" && price[T_code][1] == "1" && price[T_code][2] == "2"){
	       document.write("<div class=\"samsung\">"+"* "+"Brand New, Six Months Warranty!"+"</div>");
		   document.write("<div class=\"samsung\">"+"* "+"High quality LG / SAMSUNG battery cells!"+"</div>");
	    }
	      else{
		  document.write("<div class=\"light\">"+"* "+"Brand New, 1 year Warranty!"+"</div>"); 
		  document.write("<div class=\"light\">"+"* "+"High quality SANYO / SAMSUNG / PANASONIC battery cells!"+"</div>"); 
	    }
	document.write("<div>"+"<a href=\"http://usbattery.net/shipping.html\" target=\"_blank\">"+"<img alt=\"Shipping information\" src=\"http://usbattery.net/image/deliver.gif\" border=\"0\">"+"Shipping information."+"</a>"+"</div>");
	document.write("<br>");
		document.write("<input name=\"Submit\" type=\"image\" value=\"Submit\" src=\"http://www.usbattery.net/image/buy.gif\" hspace=\"5\">");
		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=\"payment@usbattery.net\">");
		document.write("<input type=\"hidden\" name=\"shipping\" value=\"6.95\">");
		document.write("<input type=\"hidden\" name=\"shipping2\" value=\"3.49\">");
		document.write("<input type=\"hidden\" name=\"no_shipping\" value=\"0\">");
		document.write("<input type=\"hidden\" name=\"page_style\" value=\"PayPal\">");
		document.write("<input type=\"hidden\" name=\"currency_code\" value=\"USD\">");
		document.write("<input type=\"hidden\" name=\"lc\" value=\"US\">");
		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_buy7(T_code){
	var proportion = 1.00; //
	var ori;
	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("<p>"+"<b>"+"Original price : "+"</b>"+"<span class=\"originalPrice\">$ " + ori_price + "</span>" +"</P>");
	document.write("<p>"+"<b>"+"Special price : "+"</b>"+"<span class=\"priceText\">$ " + sale_price + "</span>" +"</P>");
	document.write("<p>"+"<b>"+"You Save : "+"</b>"+"<span class=\"savePrice\">$ " + save_price + "</span>" +"</P>");
	 if (price[T_code] != "0" && price[T_code][1] == "1" && price[T_code][2] == "2"){
	       document.write("<div class=\"samsung\">"+"* "+"Brand New, Six Months Warranty!"+"</div>");
		   document.write("<div class=\"samsung\">"+"* "+"High quality LG / SAMSUNG battery cells!"+"</div>");
	    }
	      else{
		  document.write("<div class=\"light\">"+"* "+"Brand New, 1 year Warranty!"+"</div>"); 
	    }
	document.write("<div>"+"<a href=\"http://usbattery.net/shipping.html\" target=\"_blank\">"+"<img alt=\"Shipping information\" src=\"http://usbattery.net/image/deliver.gif\" border=\"0\">"+"Shipping information."+"</a>"+"</div>");
	document.write("<br>");
		document.write("<input name=\"Submit\" type=\"image\" value=\"Submit\" src=\"http://www.usbattery.net/image/buy.gif\" hspace=\"5\">");
		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=\"payment@usbattery.net\">");
		document.write("<input type=\"hidden\" name=\"shipping\" value=\"6.95\">");
		document.write("<input type=\"hidden\" name=\"shipping2\" value=\"3.49\">");
		document.write("<input type=\"hidden\" name=\"no_shipping\" value=\"0\">");
		document.write("<input type=\"hidden\" name=\"page_style\" value=\"PayPal\">");
		document.write("<input type=\"hidden\" name=\"currency_code\" value=\"USD\">");
		document.write("<input type=\"hidden\" name=\"lc\" value=\"US\">");
		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_buy6(T_code){
	var proportion = 1.00; //
	var ori;
	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("<p>"+"<b>"+"Original price : "+"</b>"+"<span class=\"originalPrice\">$ " + ori_price + "</span>" +"</P>");
	document.write("<p>"+"<b>"+"Special price : "+"</b>"+"<span class=\"priceText\">$ " + sale_price + "</span>" +"</P>");
	document.write("<p>"+"<b>"+"You Save : "+"</b>"+"<span class=\"savePrice\">$ " + save_price + "</span>" +"</P>");
	 if (price[T_code] != "0" && price[T_code][1] == "1" && price[T_code][2] == "2"){
	       document.write("<div class=\"samsung\">"+"* "+"Brand New, Six Months Warranty!"+"</div>");
		   document.write("<div class=\"samsung\">"+"* "+"High quality LG / SAMSUNG battery cells!"+"</div>");
	    }
	      else{
		  document.write("<div class=\"light\">"+"* "+"Brand New, 1 year Warranty!"+"</div>"); 
		  document.write("<div class=\"light\">"+"* "+"High quality SANYO / SAMSUNG / PANASONIC battery cells!"+"</div>"); 
	    }
	document.write("<div>"+"<a href=\"http://usbattery.net/shipping.html\" target=\"_blank\">"+"<img alt=\"Shipping information\" src=\"http://usbattery.net/image/deliver.gif\" border=\"0\">"+"Shipping information."+"</a>"+"</div>");
	document.write("<br>");
		document.write("<input name=\"Submit\" type=\"image\" value=\"Submit\" src=\"http://www.usbattery.net/image/buy.gif\" hspace=\"5\">");
		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=\"payment@usbattery.net\">");
		document.write("<input type=\"hidden\" name=\"shipping\" value=\"6.95\">");
		document.write("<input type=\"hidden\" name=\"shipping2\" value=\"6.95\">");
		document.write("<input type=\"hidden\" name=\"no_shipping\" value=\"0\">");
		document.write("<input type=\"hidden\" name=\"page_style\" value=\"PayPal\">");
		document.write("<input type=\"hidden\" name=\"currency_code\" value=\"USD\">");
		document.write("<input type=\"hidden\" name=\"lc\" value=\"US\">");
		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 sale_price = 1.0	    //
	var sale_price  = Math.round(price[T_code][0] * sale_price * 100)/100;
	var sale_price  = round_decimals( sale_price ,2);
	if (price[T_code] != "0" && price[T_code][1] == "1"){
	document.write("<span class=\"priceText\">USD $" + sale_price + "</span>");
	}
	else{
		document.write("<span class=\"light\">Out of stock</span>");
	}
}

function show_buy2(T_code,T_code2){
	var proportion = 1.00; //
	var sav = 2.5;
	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("<p>"+"Total List Price : "+"<span class=\"originalPrice\">$" + ori_price + "</span>" +"</P>");
	    document.write("<p>"+"<b>"+"Buy both now : "+"</b>"+"<span class=\"priceText\">$" + sale_price + "</span>" +"</P>");
		document.write("<input name=\"Submit\" type=\"image\" value=\"Submit\" src=\"http://usbattery.net/image/buy.gif\" vspace=\"5\">");
		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=\"payment@usbattery.net\">");
		document.write("<input type=\"hidden\" name=\"shipping\" value=\"13.9\">");
		document.write("<input type=\"hidden\" name=\"page_style\" value=\"PayPal\">");
		document.write("<input type=\"hidden\" name=\"currency_code\" value=\"USD\">");
		document.write("<input type=\"hidden\" name=\"lc\" value=\"US\">");
		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>");
	}
}
// end ++++++++++++++++++++++++++

// 