var httpRequest; var POST_CountryID = 0; var POST_PostCode = ""; function CancelRequest() { CloseDialogWindow(); } //*************************************************************************** //*************************************************************************** function ShowDialogWindow() { getElementById_s("PostageDialog").style.display = "block"; } function CloseDialogWindow() { getElementById_s("PostageDialog").style.display = "none"; } //*************************************************************************** //*************************************************************************** function useHttpResponse() { if (httpRequest.readyState==4) { if (httpRequest.status==200) { window.status = "Done."; DisplayPostageResult(httpRequest.responseText); getElementById_s("PostResult").innerHTML = "
" + getElementById_s("PostResult").innerHTML + "
"; getElementById_s("PostageDialog").style.display = "none"; httpRequest.close; } } } function CheckBeforeRequestPostage(CountryCbo, PCText) { /* Function uses functions in formcheck.js and basket_post_js.php */ FormatPostCode(PCText, getElementById_s('DelivCountry')); if ((CountryCbo.value == 226) || (CountryCbo.value == 1)) { if (CheckUKPostCode(PCText)) { RequestPostage(CountryCbo.value, PCText.value); } } else { RequestPostage(CountryCbo.value, PCText.value); } } function RequestPostage(CountryID, PostCode) { if (getElementById_s("PostResult")) { POST_CountryID = CountryID; POST_PostCode = PostCode; window.status = "Retreiving price..."; getElementById_s("PostResult").innerHTML = "
Waiting for postage calculation..."; httpRequest = getXmlRequest(); if (httpRequest) { var thisURL = "calc_postage2.php?CID=" + escape(CountryID) + "&PC=" + escape(PostCode) + "&Rnd=" + Math.random(); httpRequest.open("GET", thisURL, true); httpRequest.onreadystatechange = useHttpResponse; httpRequest.send(null); } else { alert2 ("There was an error sending the price request.","Error"); } } } function DisplayPostageResult(ResultStr) { var ThisObj = getElementById_s("PostResult"); var Temp; var ResultArr; var StrCharge = 0; var StrStatus = ""; var StrService = ""; /* Following line replaces ALL INSTANCES (g) of new line (\n), carriage return (\r) and space (\s) characters and then splits the line into an array */ ResultArr = ResultStr.replace(/\n/g, "").replace(/\r/g, "").replace(/\s/g, "").split(";"); for (a=0; a1) { temp = ResultArr[a].split(":"); TempHandle = temp[0]; TempData = temp[1]; if (TempHandle=="STATUS") StrStatus = TempData; if (TempHandle=="DESCRIPTION") StrService = TempData; if (TempHandle=="CHARGE") StrCharge = TempData; } } switch (StrStatus) { case "OK": ThisObj.innerHTML = "Postage: £" + StrCharge; break; case "NO-SIZE": ThisObj.innerHTML = "Sorry, we do not have the weight or dimensions of 1 or more items in your basket. You can still place your order, it just means we will have to work out the postage manually in the same way as we always have."; break; case "NO-ITEM": ThisObj.innerHTML = "There are no items in your basket."; break; case "NO-RATE": ThisObj.innerHTML = "Sorry, we do not have a cost in our database for this combination of weight, size and destination. You can still place your order, it just means we will have to work out the postage manually in the same way as we always have."; break; } } function getXmlRequest() { try { req = new XMLHttpRequest(); } catch(err1) { try { req = new ActiveXObject("msxml2.XMLHTTP"); } catch(err2) { try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch(err3) { req = false; } } } return req; } function ShowPostageDialog() { Code = "

Delivery Location

"; Code += "
"; Code += "
"; Code += "

"; Code += "\n


"; Code += "\n"; Code += "\n"; Code += "\n
"; getElementById_s("PostageDialog").innerHTML = Code; for (a=0; a < getElementById_s("DelivCountry").options.length; a++) { if (getElementById_s("DelivCountry").options[a].value==POST_CountryID) { getElementById_s("DelivCountry").selectedIndex = a; } } ShowDialogWindow(); getElementById_s("DelivPostCode").focus(); CentreObject (getElementById_s("PostageDialog")); } function CentreObject(object) { object.style.position = "absolute"; object.style.left = "50%"; object.style.top = "50%"; object.style.marginLeft = "-" + parseInt(object.offsetWidth / 2) + "px"; object.style.marginTop = "-" + parseInt(object.offsetHeight / 2) + "px"; }