
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;

}







// begin +++++++++++++++++++++++++++++++++++++



function show_price(p_psecode,type){//

	var promotion = 1;   //

	var proportion = 1.00;  //

	var rise = 1.10;     //

	var rise_price = price[p_psecode][0] * proportion * rise;

	var now_price  = price[p_psecode][0] * proportion;

	var save_price = rise_price - now_price;

	rise_price = round_decimals( rise_price ,2);

	now_price  = round_decimals( now_price  ,2);

	save_price = round_decimals( save_price ,2);



	if (promotion != 0){

		if (type != 0){

			//document.write("Reg .price: <strike>US $" + rise_price + "</strike><br>");

			document.write("&pound;" + now_price + "");

			//document.write("You save: <span class=\"style3\">$" + save_price + "</span><br>");

		}else{

			document.write("&pound;" + now_price + "");

		}

	}

	else{

		//

		document.write("&pound;" + now_price + "");

	}

}



// end ++++++++++++++++++++++++++++++++++++

// add by stone.wang ++++++++++++++++++++++++

 // BATTERY AND CHARGER

// +++++++++++++++++++++++++++++++++++++++++++

function show_price2(p_psecode,p_psecode2,type){//

	var promotion = 1;   //

	var proportion = 0.97;  //

	var rise = 1.10;     //

	var rise_price = price[p_psecode][0] * proportion * rise;

	var now_price  = (eval(price[p_psecode][0])+eval(price[p_psecode2][0])) * proportion;

	var save_price = rise_price - now_price;

	rise_price = round_decimals( rise_price ,2);

	now_price  = round_decimals( now_price  ,2);

	save_price = round_decimals( save_price ,2);

	

	if (promotion != 0){

		if (type != 0){

			//document.write("Reg .price: <strike>UK &#65505;" + rise_price + "</strike><br>");

			document.write("&pound;" + now_price + "");

			//document.write("You save: <span class=\"style3\">$" + save_price + "</span><br>");

		}else{

			document.write("&pound;" + now_price + "");

		}

	}

	else{

		//

		document.write("&pound;" + now_price + "");

	}

}


