//##### ======================================= #####
//#####          DEVELOPER: W.Q.F Peter         #####
//#####           EMPOLDER: 2004-10-25          #####
//##### ======================================= #####
//

// 
// begin ++++++++++++++++++++++++++++++++++
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;
}
//end  +++++++++++++++++++++++

//
// begin ++++++++++++++++++++++
function show_buynow(p_psecode,imagepath){
	var proportion = 1.00; //
	var now_price;	    //
	var now_price  = Math.round(price[p_psecode][0] * proportion * 100)/100;
	var now_price  = round_decimals( now_price ,2);
	if ((price[p_psecode]!="0")&&(price[p_psecode][1]=="1")){
		document.write("<span class=\"price\">"+ "Now Price: " + "US $" + now_price + " &nbsp;&nbsp;</span>");
		//document.write("<br>");
		document.write("<input name=\"Submit\" type=\"image\" value=\"Submit\" src=\"/images/add_to_cart.gif\">");
		document.write("<input type=\"hidden\" name=\"psecode\" value=\"" + p_psecode + "\">");
		document.write("<input type=\"hidden\" name=\"pseprice\" value=\"" + now_price + "\">");
		document.write("<input type=\"hidden\" name=\"sitename\" value=\"www.electricscooter.us.com\">");
		
	}
	else{
		document.write("<span class=\"price\">"+"Sorry, out of stock now!" + "</span>");
		//document.write("<span class=\"style3\">Out of stock</span>");
	}
}
