﻿
	function newImage(arg) {
		if (document.images) {
			rslt = new Image();
			rslt.src = arg;
		return rslt;
	}
}

	function changeImages() {
		if (document.images && (preloadFlag == true)) {
			for (var i=0; i<changeImages.arguments.length; i+=2) {
				document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;

var an_102 = 'an102';
var an_103 = 'an103';
var an_102c = 'an102c';
var an_103c = 'an103c';
var pn_101 = 'pn101';
var pn_101c = 'pn101c';
var pn_102 = 'pn102';
var pn_102c = 'pn102c';
var mn_101 = 'mn101';
var mn_101c = 'mn101c';
	function preloadImages() {
		//document.form1.pcheckbox3.disabled=true;
	//document.form1.pcategory3.disabled=true;
	//document.form1.pcheckbox6.disabled=true;
	//document.form1.pcategory6.disabled=true;
			//document.form1.pcheckbox3.disabled=true;
	//document.form1.pcategory3.disabled=true;
	//document.form1.pcheckbox6.disabled=true;
	//document.form1.pcategory6.disabled=true;
	//document.form1.pcheckbox2.disabled=true;
	//document.form1.pcategory2.disabled=true;
	//document.form1.pcheckbox5.disabled=true;
	//document.form1.pcategory5.disabled=true;
document.getElementById(an_102).innerHTML='AN102 <span class=\"style17\">ㄚ樣椰子油</span><strong><br />方案二、3.0公升(新包裝)x6瓶<br /><span class=\"style10\">超值特價 3400元</span></strong>';
document.getElementById(an_103).innerHTML='AN103 <span class=\"style17\"> ㄚ樣椰子油</span><strong><br />方案三、3.0公升(新包裝)x6瓶<br /><span class=\"style10\">特價 3400元</span></strong>';

document.getElementById(an_102c).innerHTML='新包裝3.0公升，品質更高，敬請選購!!';
document.getElementById(an_103c).innerHTML='新包裝3.0公升，品質更高，敬請選購!!';

document.getElementById(pn_101).innerHTML='PN101 <span class=\"style8\">ㄚ樣椰油禮盒</span><strong><br>專案一、0.9 公升2瓶<br /><span class=\"style10\">感恩回饋價 600元</span></strong>';
document.getElementById(pn_101c).innerHTML='';

document.getElementById(pn_102).innerHTML='PN102<span class=\"style8\"> ㄚ樣椰油禮盒</span><strong><br>專案二、(0.9公升2瓶)5組<br></strong><span class=\"style17\"><em>再加送(0.9 公升2瓶)x1組</em></span><strong><br /><span class=\"style10\">買到賺到 特價 3150元</span></strong>';
document.getElementById(pn_102c).innerHTML='買五送一瘋狂實施中，<br>買到絕對賺到~感恩回饋';

document.getElementById(mn_101).innerHTML='MN101 <span class=\"style8\">金標椰油禮盒</span><strong><br /><strong>特惠專案、0.96 公升x2瓶<br /><span class=\"style10\">回饋特價 2630元</span>';
document.getElementById(mn_101c).innerHTML='再送ㄚ樣椰子油 0.9公升裝1瓶';
		if (document.images) {
		home_over = newImage("images/home-over.png"/*tpa=http://www.ihealthoil.com/images/home-over.png*/);
		order_over = newImage("images/order-over.png"/*tpa=http://www.ihealthoil.com/images/order-over.png*/);
		howto_over = newImage("images/howto-over.png"/*tpa=http://www.ihealthoil.com/images/howto-over.png*/);
		cookbook_over = newImage("images/cookbook-over.png"/*tpa=http://www.ihealthoil.com/images/cookbook-over.png*/);
		faq_over = newImage("images/faq-over.png"/*tpa=http://www.ihealthoil.com/images/faq-over.png*/);
		contact_over = newImage("images/contact-over.png"/*tpa=http://www.ihealthoil.com/images/contact-over.png*/);
		prod = newImage("images/record_manual.jpg"/*tpa=http://www.ihealthoil.com/images/record_manual.jpg*/);
		success = newImage("images/insert_photo_01.jpg"/*tpa=http://www.ihealthoil.com/images/insert_photo_01.jpg*/);
		preloadFlag = true;
	}
}
function pitemchk1(){
	document.form1.checkbox1.checked=false;
	


	  if(document.form1.pcheckbox1.checked){
	  document.form1.pcategory1.disabled=false;
	  }else{
	  document.form1.pcategory1.disabled=true;
	  }
	  }
	  	  function pitemchk2(){
	  if(document.form1.pcheckbox2.checked){
	  document.form1.pcategory2.disabled=false;
	  }else{
	  document.form1.pcategory2.disabled=true;
	  }
	  }
	  	  function pitemchk3(){
	  if(document.form1.pcheckbox3.checked){
	  document.form1.pcategory3.disabled=false;
	  }else{
	  document.form1.pcategory3.disabled=true;
	  }
	  }
	   	  function pitemchk4(){
	  if(document.form1.pcheckbox4.checked){
	  document.form1.pcategory4.disabled=false;
	  }else{
	  document.form1.pcategory4.disabled=true;
	  }
	  }
	  	  function pitemchk5(){
	  if(document.form1.pcheckbox5.checked){
	  document.form1.pcategory5.disabled=false;
	  }else{
	  document.form1.pcategory5.disabled=true;
	  }
	  }
	  	 function pitemchk6(){
	  if(document.form1.pcheckbox6.checked){
	  document.form1.pcategory6.disabled=false;
	  }else{
	  document.form1.pcategory6.disabled=true;
	  }
	  }
	  	function pitemchk7(){
	  if(document.form1.pcheckbox7.checked){
	  document.form1.pcategory7.disabled=false;
	  }else{
	  document.form1.pcategory7.disabled=true;
	  }
	  }
	  	function pitemchk8(){
	  if(document.form1.pcheckbox8.checked){
	  document.form1.pcategory8.disabled=false;
	  }else{
	  document.form1.pcategory8.disabled=true;
	  }
	  }
	  	  function itemchk1(){
	  if(document.form1.checkbox1.checked){
	  document.form1.category1.disabled=false;
	  }else{
	  document.form1.category1.disabled=true;
	  }
	  }
	  function itemchk2(){
	  if(document.form1.checkbox2.checked){
	  document.form1.category2.disabled=false;
	  }else{
	  document.form1.category2.disabled=true;
	  }
	  }
	  function itemchk3(){
	  if(document.form1.checkbox3.checked){
	  document.form1.category3.disabled=false;
	  }else{
	  document.form1.category3.disabled=true;
	  }
	  }function itemchk4(){
	  if(document.form1.checkbox4.checked){
	  document.form1.category4.disabled=false;
	  }else{
	  document.form1.category4.disabled=true;
	  }
	  }function itemchk5(){
	  if(document.form1.checkbox5.checked){
	  document.form1.category5.disabled=false;
	  }else{
	  document.form1.category5.disabled=true;
	  }
	  }function itemchk6(){
	  if(document.form1.checkbox6.checked){
	  document.form1.category6.disabled=false;
	  }else{
	  document.form1.category6.disabled=true;
	  }
	  }

function caculate(){
var amount = 0;
var pamount =0;
var p_an101 =1650;
var p_an102 =3400;
var p_an103 =3400;
var p_an201 =298;
var p_an202 =620;
var p_an203 =620;
var p_an2022 =600;
var p_gn101 =2600;
var p_gn102 =5800;
var p_gn103 =4800;
var p_gn201 =1380;
var p_gn202 =4800;
var p_pn101 =600;
var p_pn102 =3150;
var p_mn101 =2630;
var scount = 0;
var discount =0;
	if (document.form1.pcheckbox1.checked){
  pamount += (document.form1.pcategory1.options[document.form1.pcategory1.selectedIndex].value)*1;
  amount += (document.form1.pcategory1.options[document.form1.pcategory1.selectedIndex].value)*p_an101;
  }	if (document.form1.pcheckbox2.checked){
  pamount += (document.form1.pcategory2.options[document.form1.pcategory2.selectedIndex].value)*1;
  amount += (document.form1.pcategory2.options[document.form1.pcategory2.selectedIndex].value)*p_an102;
  }	if (document.form1.pcheckbox3.checked){
  pamount += (document.form1.pcategory3.options[document.form1.pcategory3.selectedIndex].value)*1;
  amount += (document.form1.pcategory3.options[document.form1.pcategory3.selectedIndex].value)*p_an103;
  }	if (document.form1.pcheckbox4.checked){
  pamount += (document.form1.pcategory4.options[document.form1.pcategory4.selectedIndex].value)*1;
  amount += (document.form1.pcategory4.options[document.form1.pcategory4.selectedIndex].value)*p_an201;
  } if (document.form1.pcheckbox5.checked){
  pamount += (document.form1.pcategory5.options[document.form1.pcategory5.selectedIndex].value)*1;
  if(((document.form1.pcategory5.options[document.form1.pcategory5.selectedIndex].value)*1)==1){
  amount += (document.form1.pcategory5.options[document.form1.pcategory5.selectedIndex].value)*p_an202;
  }else{
	 amount += (document.form1.pcategory5.options[document.form1.pcategory5.selectedIndex].value)*p_an2022;
	 }
  } if (document.form1.pcheckbox6.checked){
  pamount += (document.form1.pcategory6.options[document.form1.pcategory6.selectedIndex].value)*1;
  if(((document.form1.pcategory6.options[document.form1.pcategory6.selectedIndex].value)*1)==1){
  amount += (document.form1.pcategory6.options[document.form1.pcategory6.selectedIndex].value)*p_an203;
  }else{
	 amount += (document.form1.pcategory6.options[document.form1.pcategory6.selectedIndex].value)*p_an2022;
	 }
  } if (document.form1.pcheckbox7.checked){
  pamount += (document.form1.pcategory7.options[document.form1.pcategory7.selectedIndex].value)*1;
  amount += (document.form1.pcategory7.options[document.form1.pcategory7.selectedIndex].value)*p_pn101;
  } if (document.form1.pcheckbox8.checked){
  pamount += (document.form1.pcategory8.options[document.form1.pcategory8.selectedIndex].value)*1;
  amount += (document.form1.pcategory8.options[document.form1.pcategory8.selectedIndex].value)*p_pn102;
  } if (document.form1.checkbox1.checked){
  pamount += (document.form1.category1.options[document.form1.category1.selectedIndex].value)*1;
  amount += (document.form1.category1.options[document.form1.category1.selectedIndex].value)*p_gn101;
  } if (document.form1.checkbox2.checked){
  pamount += (document.form1.category2.options[document.form1.category2.selectedIndex].value)*1;
  amount += (document.form1.category2.options[document.form1.category2.selectedIndex].value)*p_gn102;
  }if (document.form1.checkbox3.checked){
  pamount += (document.form1.category3.options[document.form1.category3.selectedIndex].value)*1;
  amount += (document.form1.category3.options[document.form1.category3.selectedIndex].value)*p_gn103;
  }	if (document.form1.checkbox4.checked){
  pamount += (document.form1.category4.options[document.form1.category4.selectedIndex].value)*1;
  amount += (document.form1.category4.options[document.form1.category4.selectedIndex].value)*p_gn201;
  }	if (document.form1.checkbox5.checked){
  pamount += (document.form1.category5.options[document.form1.category5.selectedIndex].value)*1;
  amount += (document.form1.category5.options[document.form1.category5.selectedIndex].value)*p_gn202;
  } if (document.form1.checkbox6.checked){
  pamount += (document.form1.category6.options[document.form1.category6.selectedIndex].value)*1;
  amount += (document.form1.category6.options[document.form1.category6.selectedIndex].value)*p_mn101;
  } if((amount!=0) && (amount < 2400)){
  document.form1.paynum.value = amount+100;
  document.form1.pay.value = amount+100;
  document.form1.pay.value += "(含運費100元)";
    document.form1.ori_paynum.value=amount;
  } else if(amount >= 2400){
  document.form1.paynum.value = amount;
  document.form1.pay.value = amount;
    document.form1.pay.value += "(免運費)";
    document.form1.ori_paynum.value=amount;
  } else if(amount == 0){
  document.form1.paynum.value = 0;
  document.form1.pay.value = 0;
    document.form1.ori_paynum.value=amount;
  }
  document.form1.address.value=document.form1.city.options[document.form1.city.selectedIndex].text +document.form1.town.options[document.form1.town.selectedIndex].text + document.form1.addr.value;
}
function check(form){
if (form.name.value.length == 0) { alert("請輸入收貨人姓名"); return false }
if (form.email.value.length == 0) { alert("一定要輸入email"); return false }
if (form.email.value.indexOf("@") == -1) { alert("請輸入正確的電子郵件"); return false }
if (form.email.value.indexOf(".") == -1) { alert("請輸入正確的電子郵件"); return false }
if (form.phone.value.length == 0) { alert("一定要輸入連絡電話"); return false }
if (form.phone.value.length < 8) { alert("請輸入正確的連絡電話"); return false }
if (form.addr.value.length == 0) { alert("一定要輸入收貨地址"); return false }
if (form.addr.value.length < 4) { alert("請輸入正確的收貨地址"); return false }
caculate();
if(form.paynum.value <= 100){alert("請選擇產品和數量"); return false}
if (form.confirmok.checked == 0) { alert("請勾選送出確認鈕"); return false }

return true
}