//判断是否出现"buy now"按钮

// 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("<br><input name=\"Submit\" type=\"image\" value=\"Submit\"  src=\"http://www.atbattery.org/images/buybattery.jpg\"  align=\"absbottom\">");

		document.write("<input type=\"hidden\" name=\"item_code\" value=\"" + p_psecode + "\">");

		document.write("<input type=\"hidden\" name=\"price\" value=\"" + now_price + "\">");

		document.write("<input type=\"hidden\" name=\"site_name\" value=\"www.atbattery.org\">");
		
		document.write("<br><strong>Availability:</strong> In Stock");
	}

	else{

		document.write("<br><strong>Coming Soon!</strong>");

		//document.write("<span class=\"style3\">Coming Soon</span>");

	}

}

// end ++++++++++++++++++++++++++



// 根据type参数选择显示的价格类型

function show_price(p_psecode,type){//显示价格，如果要搞促销，可以做这样的修改，也就是修改一下promotion这个常量的值为1以及修改一下proportion的比例即可。

	var promotion = 1;   //促销时为"1"，日常销售为"0"

	var proportion = 1.00;  //价格的比率，相对于标准价

	var rise = 1.15;     //用于显示促销前后价格的变化，是嘘头.

	var rise_price = price[p_psecode][0] * rise ;

	var now_price  = price[p_psecode][0] * proportion;

//mobile phone *2 end
	if(price[p_psecode][2] =="M"){
		rise_price = now_price * 2 ;
	}
//mobile phone *2 end
	
	var save_price = rise_price - now_price;

	var rise_price = round_decimals( rise_price ,2);

	var now_price  = round_decimals( now_price  ,2);

	var save_price = round_decimals( save_price ,2);

	
	if(now_price ==0){
		
		document.write("No price!");
	
	}else{	
	
		if (promotion != 0){

			if (type != 0){

				document.write("<span class='price'><strike>$" + rise_price + "</strike></span><br>");
	
				document.write("Now Price: <span class='price'>$"  + now_price + "</span><br>");
	
				document.write("You save: $" + save_price + "");
				
			}else{
	
				document.write("<span class='price'>$" + now_price + "</span>");
	
			}

		}else{

		//document.write("<span class=\"style3\">US $" + now_price + "</span>");

		document.write("<strong>Price:</strong> <span class='price'>US $" + now_price + "</span><br>");

		}
	}

}


////////////////////////////////
function show_both_price(psecode1,psecode2){
	var psecode1_price  = eval (price[psecode1][0]);
	var psecode2_price  = eval (price[psecode2][0]);
	var total_price_old = round_decimals((psecode1_price + psecode2_price)*1,2);	
	var total_price = round_decimals((psecode1_price + psecode2_price)*0.97,2);
	var save_price = round_decimals((total_price_old - total_price)*1,2);
	document.write("<span class='price'> [ <strike> $" + total_price_old + " </strike> ]</span>");	
	document.write("<br><br><strong>Now price:</strong> <span class='price'>US $" + total_price + "</span>&nbsp;&nbsp;");
	document.write("<br><br><strong>You save:</strong> US $" + save_price);
}

function show_both_buynow(psecode1,psecode2){
	var psecode1_price  = eval (price[psecode1][0]);
	var psecode2_price  = eval (price[psecode2][0]);
	var total_price = round_decimals((psecode1_price + psecode2_price)*0.95,2);
	var total_psecode = psecode1 + "," + psecode2;
	
	if((price[psecode1][1]==1) && (price[psecode2][1]==1)){
		
		document.write("<input name=\"Submit\" type=\"image\" value=\"Submit\" src=\"/images/buybattery.jpg\">");

		document.write("<input type=\"hidden\" name=\"item_code\" value=\"" + total_psecode + "\">");

		document.write("<input type=\"hidden\" name=\"price\" value=\"" + total_price + "\">");

		document.write("<input type=\"hidden\" name=\"site_name\" value=\"www.atbattery.org\">");
		
	}else{

		document.write("<br><strong>Coming Soon!</strong>");

	}

}

//show right products price
function show_right_price(p_psecode,type){
	now_price = price[p_psecode][0];
	document.write("$" + now_price + "");

}

// end ++++++++++++++++++++++++++++++++++++

//start last page information
     function featureClick(id){
      var obj = document.getElementById("battery_"+id);
      var return_obj = document.getElementById("battery_1");
      var shipping_obj = document.getElementById("battery_2");
      var Payment_obj = document.getElementById("battery_3");
      
      return_obj.style.display = "none";
      shipping_obj.style.display = "none";
      Payment_obj.style.display = "none";
      obj.style.display = "";
     }

//end information

// 函数round_decimals()功能: 将价格数字保留N位小数,不够的补"0";

// 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  +++++++++++++++++++++++

// brand 页面跳转
<!--
function submitform(form)
 {
  form.submit();
 }
//-->
// jump big image
function launchwindow(url){
	window.open(url,"CompatibleModels","width=500,height=500,left=180,top=180,scrollbars=no,resizable=no,menubar=0");  
}
//-->
function jumplist(it) {
           var dest = it.options[it.selectedIndex].value;
           if (dest == "nowhere") {
              it.selectedIndex = 0;
           } else {
              location.href = dest;
           }
}