//##### ======================================= #####
//#####             UKglasses.net            #####
//#####           EMPOLDER: 2007-04-25          #####
//##### ======================================= #####

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 * 115)/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>"+"high street price : "+"</b>"+"<span class=\"originalPrice\">&pound; " + ori_price + "</span>" +"</P>");
	document.write("<p>"+"<b>"+"our price : "+"</b>"+"<span class=\"priceText\">&pound; " + sale_price + "</span>" +"</P>");
	document.write("<p>"+"<b>"+"You Save : "+"</b>"+"<span class=\"savePrice\">&pound; " + save_price + "</span>" +"</P>");
	document.write("<p>"+"<a href=\"http://www.ukglasses.net/shipping.html\" class=\"search\"><img src=\"http://www.ukglasses.net/images/deliver.gif\" border=\"0\"> Shipping information."+"</a>" +"</P>");
	}
	else{
		document.write("<span class=\"light\">Out of stock</span>");
	}
}

function show_buy1(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("<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@ukglasses.net\">");
		document.write("<input type=\"hidden\" name=\"shipping\" value=\"4.95\">");
		document.write("<input name=\"Submit\" type=\"image\" value=\"Submit\" src=\"http://www.ukglasses.net/images/add_to_cart.gif\" hspace=\"5\">");
		document.write("<input type=\"hidden\" name=\"page_style\" value=\"PayPal\">");
		document.write("<input type=\"hidden\" name=\"currency_code\" value=\"GBP\">");
		document.write("<input type=\"hidden\" name=\"lc\" value=\"GB\">");
		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,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\">&pound; " + ori_price + "</span>" +"</P>");
	    document.write("<p>"+"<b>"+"Buy both now : "+"</b>"+"<span class=\"priceText\">&pound; " + sale_price + "</span>" +"</P>");
		document.write("<input name=\"Submit\" type=\"image\" value=\"Submit\" src=\"http://www.ukglasses.net/images/add_to_cart.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@ukglasses.net\">");
		document.write("<input type=\"hidden\" name=\"shipping\" value=\"0.0\">");
		document.write("<input type=\"hidden\" name=\"page_style\" value=\"PayPal\">");
		document.write("<input type=\"hidden\" name=\"currency_code\" value=\"GBP\">");
		document.write("<input type=\"hidden\" name=\"lc\" value=\"GB\">");
		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 ++++++++++++++++++++++++++

// 
