var adultobj=["alcohol", "beer","spirit","beverage","tobacco","cigarette","cigar", "whiskey", "wine", "vodka", "water"];var prohibit=["aerosol", "ammunition", "animal", "arms", "battery", "batteries", "bird", "bodily fluid", "bomb", "bonds", "bottled liquid", "bouquet", "bullion", "canned liquid", "car bonnes", "car bumpers", "car engine", "car exhaust", "car panel", "cash", "cheques", "chocolate", "christmas cracker", "corrosive", "counterfit item", "dangerous good", "deceased animal", "diesel", "drug", "engine", "explosive", "fireworks", "fish", "fishing rod", "flammable", "flower", "fluid", "food", "gasses", "gun", "hazardous", "illegal substance", "juice", "knive", "large car component", "liquid", "live animals", "livestock", "lottery ticket", "medical sample", "motorcycle engine", "motorcycle panel", "munition", "oil", "oxidising", "paint", "passport", "perishable good", "petrol", "pharmaceutical products", "pils", "plant", "poorly packaged good", "precious stones", "pyrotechnics", "radioactive", "replica item", "replica weapon", "settee", "shrub", "sofa", "stolen good", "sword", "tablet", "pill", "tissue sample", "toilet", "toxic", "tree", "un-boxed furniture", "un-packaged good", "unboxed bicycle", "weapon"];var nocompensation=["glass components", "antiques", "artworks", "crt screens", "monitors", "ceramics", "china", "damaged goods", "fur", "glass", "golf clubs", "lcd screens", "marble", "led screens", "musical instruments", "plasma screens", "porcelain", "pots", "screens", "sheet metals", "sheet plastics", "tft screens", "tiles", "vases"];var special_object_keyword=["barrel", "drum", "pail", "tire"];var special_keyword=["jewellery", "precious metals", "platinum", "gold", "silver", "ruby", "amethyst", "citrine","diamond", "emerald", "kunzite", "opal", "pearl", "peridot", "quartz", "ruby", "sapphire", "tanzanite", "topaz"];var ziprange=["AB37","AB38","AB53","AB56","CA18","CA27","HS1","HS9","IV14","IV28","IV30","IV32","IV40","IV56","IV9","IV9","IV10","IV12","KA27","KA28","LA15","LA23","PA21","PA38","PA42","PA49","PA61","PA78","PA80","PA88","PH17","PH26","PH30","PH44","PH49","PH50","TR21","TR25"];var zipcode=["IV7","PA20","PA60","IV36","PA41"];var zipregion=["IM","ZE","KW"];var chargeobj=["charges_extended_zone", "charges_adult_signature", "charges_saturday_delivery", "charges_insurance", "charges_large_packet", "charges_additional_handling"];var disabledDays=["1/1", "31/8", "25/12", "28/12"];var disabledDays2=["22/4/2011", "29/4/2011", "2/5/2011", "30/5/2011", "26/12/2011", "27/12/2011", "2/1/2012", "6/4/2012", "7/5/2012", "4/6/2012", "5/6/2012", "26/12/2012"];var noinsurance=false;var adult_signature_charge=2.25;//1.95;var saturday_delivery_charge=17;var no_compensation_value_limit=250;var large_handling_charge=30;//27;var large_handling_min_weight=40;var additional_handling_charge=3.15;//2.7;var extended_zone_min_charge=17.10;//14.85;var extended_zone_charge_percent=28;var insurance_goods_min_value=60;var insurance_min_charge=3.65;var insurance_charge_percent=1;var label_delivery_charge=2.50;var residental_delivery_charge=1.95;//1.83;var girth_limit=330;var additional_charge_longest_side=150;var additional_charge_second_longer_side=76;var additional_charge_weight_limit=32;var last_pickup_time=12;function displaySummary(){var charge1=parseFloat(document.getElementById('charges_large_packet').value);var charge2=parseFloat(document.getElementById('charges_additional_handling').value);var charge3=parseFloat(document.getElementById('charges_adult_signature').value);var charge4=parseFloat(document.getElementById('charges_insurance').value);var charge5=parseFloat(document.getElementById('charges_extended_zone').value);var charge6=parseFloat(document.getElementById('charges_saturday_delivery').value);var txt="";var total=charge1+charge2+charge3+charge4+charge5+charge6;if (total>0){txt='<table>';txt=txt+'<tr><td colspan="2"><strong><u>Following charge(s) applied to the basic price:</u></strong></td></tr>';if (charge1>0){txt=txt+'<tr><td><i>- Large packet surcharge</i></td><td align="right">&pound;' +charge1.toFixed(2)+'</td></tr>';}if (charge2>0){txt=txt+'<tr><td><i>- This item requires additional handling</i></td><td align="right">&pound;'+charge2.toFixed(2)+'</td></tr>';}if (charge3>0){txt=txt+'<tr><td><i>- This item requires an adult signature</i></td><td align="right">&pound;'+charge3.toFixed(2)+'</td></tr>';}if (charge4>0){txt=txt+'<tr><td><i>- Insurance surcharge (value &pound;'+document.getElementById('GoodsValue').value+')</i></td><td align="right">&pound;'+charge4.toFixed(2)+'</td></tr>';}if (charge5>0){txt=txt+'<tr><td><i>- "'+document.getElementById('DeliveryPostcode').value+'" is an extended zone area</i></td><td align="right">&pound;'+charge5.toFixed(2)+'</td></tr>';}if (charge6>0){txt=txt+'<tr><td><i>- Saturday delivery surcharge</i></td><td align="right">&pound;'+charge6.toFixed(2)+'</td></tr>';}if (total>0){txt=txt+'<tr><td><strong>Total extra surcharge</strong> (exc VAT)</td><td align="right"><strong><u>&pound;'+total.toFixed(2)+'</u></strong></td></tr>';}txt=txt+'</table>';}document.getElementById('additional_charges').innerHTML=txt;var summary_msg = charge1+"|"+charge2+"|"+charge3+"|"+charge4+"|"+charge5+"|"+charge6;document.getElementById('product_additionalcharges').value=summary_msg;//alert("product_additionalcharges = "+summary_msg);//document.getElementById('variation[4]').onchange();}function switch_off_insurance_checkbox(x){var insurance_checkbox=document.getElementById('RequireInsurance');var insurance_text=document.getElementById('InsuranceText');var insurance_desc=document.getElementById('InsuranceDescription');if (x){insurance_checkbox.checked=false;insurance_checkbox.style.display="none";insurance_desc.style.display="none";insurance_text.innerHTML="";}else{if (parseFloat(document.getElementById('GoodsValue').value)>insurance_goods_min_value) {insurance_checkbox.style.display="";insurance_desc.style.display="";insurance_text.innerHTML="&nbsp;Insurance Required";} else {insurance_checkbox.checked=false;insurance_checkbox.style.display="none";insurance_desc.style.display="none";insurance_text.innerHTML="";}}}function find_special_object() {var package = document.getElementById("ShipmentPackage").value;//alert("Package = "+package);var key=document.getElementById('GoodsDescription').value.toLowerCase();var foundmatch=false;if (package >= 0){for(var j=0;(j<special_object_keyword.length)&&(!foundmatch);j++){if (key.indexOf(special_object_keyword[j])>=0){	foundmatch=true;}}}return foundmatch;}function find_adult_object(key) {var foundmatch=false;for(var j=0;(j<adultobj.length)&&(!foundmatch);j++){if (key.indexOf(adultobj[j])>=0){foundmatch=true;}}return foundmatch;}function find_nocompensation_object(key) {var foundmatch=false;for(var j=0;(j<nocompensation.length)&&(!foundmatch);j++){if (key.indexOf(nocompensation[j])>=0){foundmatch=true;}}return foundmatch;}function check_adult(x){var nomatch=true,j,cost=0;noinsurance=false;var prohibiteditem=false;var key=document.getElementById(x).value.toLowerCase();if (find_adult_object(key)) {nomatch=false;cost=adult_signature_charge;displaySummary();}if (nomatch)for(j=0;(j<prohibit.length)&&(nomatch);j++){if (key.indexOf(prohibit[j])>=0){nomatch=false;cost=0;alert("The item you have described is a prohibited item. We are sorry, but we cannot schedule collection of this item");prohibiteditem=true;}}document.getElementById('AddToCart').style.display=((prohibiteditem)? "none": "");if (nomatch){if (find_nocompensation_object(key)){nomatch=false;cost=0;alert("The item you have described is a restricted item. This means we can schedule a delivery for you but it is carried on a no-compensation basis.");noinsurance=true;}}if (nomatch){var va1=parseFloat(document.getElementById('GoodsValue').value);for(j=0;(j<special_keyword.length)&&(nomatch);j++){if ((key.indexOf(special_keyword[j])>=0)&& (va1> no_compensation_value_limit)){nomatch=false;cost=0;alert("The item with value over "+no_compensation_value_limit+" you have described is a restricted item. This means we can schedule a delivery for you but it is carried on a no-compensation basis.");noinsurance=true;}}}switch_off_insurance_checkbox(noinsurance);document.getElementById('charges_adult_signature').value=cost;displaySummary();}function UKpostcode(postcode){var ucode=postcode.toUpperCase();if (ucode.length> 4){var temp=new Array();temp=ucode.split(' ');if (temp.length<2){var newcode=ucode.substring(0, ucode.length-3)+" "+ucode.substring(ucode.length-3, ucode.length);ucode=newcode;}}return ucode;}function check_collection_postcode(x){var key=UKpostcode(document.getElementById(x).value).replace(/^\s+|\s+$/g,"");document.getElementById(x).value=key;document.getElementById('product_postcodefrom').value=key;}function check_extended_zone(x){var key=UKpostcode(document.getElementById(x).value).replace(/^\s+|\s+$/g,"");var temp=new Array();temp=key.split(' ');var firstpart=temp[0];//alert("First part of post code = "+firstpart);var first2=key.substring(0,2);var nomatch=true;for(var i=0;(i<zipregion.length)&&(nomatch);i++){if (first2==zipregion[i]){nomatch=false;}}if (nomatch)for(var i=0;(i<zipcode.length)&&(nomatch);i++){if (firstpart==zipcode[i]){nomatch=false;}}if (nomatch)for(var i=0;(i<ziprange.length)&&(nomatch);i+=2) {if (firstpart.length==ziprange[i].length) {if ((firstpart>=ziprange[i])&&(firstpart <=ziprange[i+1])) {//alert("Within postcode range "+ziprange[i] + " & " +ziprange[i+1]);nomatch=false;}}}var cost;if (nomatch==false){var weight=document.getElementById('GoodsWeight').value;cost=((weight*extended_zone_charge_percent)/100).toFixed(2);if (cost<extended_zone_min_charge)cost=extended_zone_min_charge;}else cost=0;document.getElementById('charges_extended_zone').value=cost;document.getElementById(x).value=key;document.getElementById('product_postcodeto').value=key;displaySummary();}function check_goods_desc(x){check_adult(x);document.getElementById('product_descriptionofgoods').value=document.getElementById(x).value;check_additional_handling_charge();}function check_insurance_option(fieldChanged){var key=document.getElementById('GoodsValue').value.replace(/^\s+|\s+$/g,"");var val=(isNaN(key))?(0):parseInt(key,10);if (val<0)val=0;document.getElementById('GoodsValue').value=val;var cost=0;if (document.getElementById('RequireInsurance').checked){if (val>insurance_goods_min_value){cost=((val*insurance_charge_percent)/100).toFixed(2);	// add 1% for insuranceif (cost<insurance_min_charge)cost=insurance_min_charge;// min £3.65 for insurance}}document.getElementById('charges_insurance').value=cost;document.getElementById('product_goodsvalue').value=val;check_adult('GoodsDescription');if (!noinsurance){switch_off_insurance_checkbox(false);}if (fieldChanged)document.getElementById('RequireInsurance').checked=false;displaySummary();}function check_goods_value(x){check_insurance_option(true);}function check_insurance(x){check_insurance_option(false);}function upperCase(x){var y=document.getElementById(x).value;document.getElementById(x).value=y.toUpperCase();}function lowerCase(x){var y=document.getElementById(x).value;document.getElementById(x).value=y.toLowerCase();}function check_dates(){var key=document.getElementById('CollectionDate').value;var parts=key.split('/');var myDate=new Date(parts[2], parts[1]-1, parts[0]); //Check for Friday pickupvar weekday=myDate.getDay();var cost;if (weekday==5){document.getElementById('SaturdayDelivery').style.display="";document.getElementById('SaturdayDeliveryText').innerHTML="&nbsp;Saturday Delivery";cost=saturday_delivery_charge;}else{document.getElementById('SaturdayDelivery').style.display="none";document.getElementById('SaturdayDeliveryText').innerHTML="";cost=0;}document.getElementById('charges_saturday_delivery').value=((document.getElementById('SaturdayDelivery').checked)?cost:0);displaySummary();}function check_saturdaydelivery(x){check_dates();}function check_friday_collection(x){check_dates();}function check_additional_handling_charge(){var ahs;var lps=parseFloat(document.getElementById('charges_large_packet').value);// Check whether we already charge for large item if (lps> 1) ahs=0;else{var width=parseFloat(document.getElementById('GoodsWidth').value);var length=parseFloat(document.getElementById('GoodsLength').value);var height=parseFloat(document.getElementById('GoodsHeight').value);var weight=parseFloat(document.getElementById('GoodsWeight').value);var n=[width, length, height];n.sort(function(a,b){return a - b})var spv=parseFloat(document.getElementById('ShipmentPackage').value);//alert("ShipmentPackage = "+spv+ " longest="+n[2]+" second longest="+n[1]+" weight="+weight);if ((n[2]>additional_charge_longest_side)||(n[1]>additional_charge_second_longer_side)||(weight>additional_charge_weight_limit)||(spv>0)||find_special_object()) ahs=additional_handling_charge;else ahs=0;}document.getElementById('charges_additional_handling').value=ahs;var shipmentpack=document.getElementById('ShipmentPackage');var i = shipmentpack.selectedIndex;//alert("Select index="+i);var val="";if(i > 0){val=shipmentpack.options[i].text;}document.getElementById('product_shipmentpackage').value=val;//alert("product_shipmentpackage = "+val);displaySummary();}function CheckDimensionAndWeight(){var width=parseFloat(document.getElementById('GoodsWidth').value);var length=parseFloat(document.getElementById('GoodsLength').value);var height=parseFloat(document.getElementById('GoodsHeight').value);var weight=parseFloat(document.getElementById('GoodsWeight').value);var n=[width, length, height];n.sort(function(a,b){return a - b})var girth=(n[0]+n[1])*2+n[2];var lps;if (girth>girth_limit){//Large handling chargelps=large_handling_charge;//Additional UPS min weight charge for under 40 KGS is 40 KGSif (weight<large_handling_min_weight){document.getElementById('GoodsWeight').value=large_handling_min_weight;document.getElementById('product_actualweight').value=large_handling_min_weight;}}else lps=0;document.getElementById('charges_large_packet').value=lps;check_additional_handling_charge();displaySummary();}function CheckAddressType(){var option=document.getElementByName('variation[3]').selectedIndex;alert("Option="+option);var cost=((option==2)?residental_delivery_charge:0);document.getElementById('charges_resident').value=cost;displaySummary();}function CheckLabelPreference(){var option=document.getElementByName('variation[4]').selectedIndex;alert("Option="+option);var cost=((option==2)?label_delivery_charge:0);document.getElementById('charges_deliver_label').value=cost;displaySummary();}function init(){var dt=new Date();  var h=dt.getHours();<!-- if it is passed 12 noon, set collecton date to next day -->if(h>(last_pickup_time-1))dt.setDate(dt.getDate()+1)<!-- if collecton day is weekend, set to Monday -->var cd=dt.getDay();if(cd==6)dt.setDate(dt.getDate()+2);	<!-- Saturday, add 2 days to make it Monday -->else if(cd==0)dt.setDate(dt.getDate()+1); <!-- Sunday, add 1 days to make it Monday -->var d=dt.getDate();var m=dt.getMonth()+1;document.getElementById('EventDateDay').selectedIndex=d;document.getElementById('EventDateMonth').selectedIndex=m;document.getElementById('EventDateYear').selectedIndex=1;document.getElementById('CollectionDate').value=((d<10)?'0'+d:d)+"/"+((m<10)?'0'+m:m)+"/"+dt.getFullYear();check_friday_collection('CollectionDate');var width=document.getElementById('GoodsWidth').value;var length=document.getElementById('GoodsLength').value;var height=document.getElementById('GoodsHeight').value;var weight=document.getElementById('GoodsWeight').value;document.getElementById('product_w').value=width;document.getElementById('product_l').value=length;document.getElementById('product_h').value=height;document.getElementById('product_actualweight').value=weight;if (!noinsurance){switch_off_insurance_checkbox(false);}CheckDimensionAndWeight();check_additional_handling_charge();check_friday_collection('CollectionDate');}function CheckValidateFields(){document.getElementById('additional_charges').innerHTML="";CheckDimensionAndWeight();check_additional_handling_charge();check_goods_desc('GoodsDescription');check_goods_value('GoodsValue');check_extended_zone('DeliveryPostcode');if (!noinsurance){switch_off_insurance_checkbox(false);}CheckAddressType();CheckLabelPreference();check_friday_collection('CollectionDate');}function TotalExtraCharge(){var chargetotal=0;for(var j=0;(j<chargeobj.length);j++)chargetotal=chargetotal+parseFloat(document.getElementById(chargeobj[j]).value);//alert("Total charge="+chargetotal);return chargetotal;}function disableDays(date){var weekDay=date.getDay();if ((weekDay==0)||(weekDay==6))return [false];var sDate=date.getDate().toString()+"/"+(date.getMonth()+1).toString();if ($.inArray(sDate, disabledDays) !=-1) return [false];else{sDate=sDate+"/"+date.getFullYear().toString();if ($.inArray(sDate, disabledDays2) !=-1) return [false];else return [true];}}function updateEventDate(date){ $("#EventDateDay option:contains("+date.substring(0,2)+")").attr("selected", true);$("#EventDateMonth option:contains("+date.substring(3,5)+")").attr("selected", true);$("#EventDateYear option:contains("+date.substring(6,10)+")").attr("selected", true);check_friday_collection('CollectionDate');<!-- CheckValidateFields();-->}function checkphone(x){var phone=document.getElementById(x).value.replace(/[\(\)\.\-\ ]/g, '');//alert("Phone number = "+phone);var regex = /^[0-9]{6,14}$/;if (regex.test(phone)) {// Valid international phone number} else {// Invalid international phone numberalert("Invalid phone number entered!");phone="";}document.getElementById(x).value=phone;}$(document).ready(init);
