var pos_spider_box_kg;var pos_spider_box_from;var pos_spider_box_to;var pos_spider_box_quotes;function pos_spider_box_to_update(){var from = pos_spider_box_from.options[pos_spider_box_from.selectedIndex].value;var qurl = 'http://spider.my/shipping-to/from-'+from+'.js';var script = document.createElement('script');script.setAttribute('src', qurl);document.getElementsByTagName("head")[0].appendChild(script);}function pos_spider_box_quote(){pos_spider_box_quotes = document.getElementById('pos.spider.box.quotes');pos_spider_box_quotes.innerHTML = "...";var kg = pos_spider_box_kg.value;/* numeric test from http://stackoverflow.com/questions/18082/validate-numbers-in-javascript-isnumeric */if (!isNaN(parseFloat(kg)) && isFinite(kg) && kg >= 0 && kg != ''){var from = pos_spider_box_from.options[pos_spider_box_from.selectedIndex].value;var to = pos_spider_box_to.options[pos_spider_box_to.selectedIndex].value;var qurl = 'http://spider.my/shipping-quote/'+kg+'-to-'+to+'-ex-'+from+'.js';var script = document.createElement('script');script.setAttribute('src', qurl);document.getElementsByTagName("head")[0].appendChild(script);}else{pos_spider_box_quotes.innerHTML = kg + "?";}}var divPosSpider = document.getElementById('pos.spider.box');divPosSpider.style.width="200px";divPosSpider.style.height="250px";divPosSpider.style.backgroundColor="#fffcf8";var dBox = document.createElement("div");dBox.style.cssText = "height:258px;border-style:solid;border-width:1px;border-color:#08c;";var dL = document.createElement("div");dBox.appendChild(dL);var link = document.createElement("a");dBox.appendChild(link);link.href = "http://spider.my/";link.title = "Shipping quotes by spider.my";var im = document.createElement("img");link.appendChild(im);im.src = "http://spider.my/static/media/myspider.200.png";im.style.cssText = "border-style:none;border-width:0px;";dL = document.createElement("div");dBox.appendChild(dL);dL.setAttribute("style", "margin:2px 2px 2px 4px;");dC = document.createElement("div");dL.appendChild(dC);dC.setAttribute("style", "float:left;width:80px;");dC.innerHTML = "From";dC = document.createElement("div");dL.appendChild(dC);pos_spider_box_from = document.createElement("select");dC.appendChild(pos_spider_box_from);pos_spider_box_from.setAttribute("id", "pos.spider.box.from");pos_spider_box_from.setAttribute("onchange", "pos_spider_box_to_update();");pos_spider_box_from.setAttribute("style", "width:96px;");var origin = "Johor|MY-01|Kedah|MY-02|Kelantan|MY-03|Kuala Lumpur|MY-14|Labuan|MY-15|Malaysia|MY|Melaka|MY-04|Negeri Sembilan|MY-05|Pahang|MY-06|Perak|MY-08|Perlis|MY-09|Pulau Pinang|MY-07|Putrajaya|MY-16|Sabah|MY-12|Sarawak|MY-13|Selangor|MY-10|Terengganu|MY-11".split('|');var i;for (i = 0; i < origin.length; i++){var opt = document.createElement("option");opt.innerHTML = origin[i];opt.value = origin[++i];if (opt.value == 'MY') opt.selected = true;pos_spider_box_from.appendChild(opt);}var dL = document.createElement("div");dBox.appendChild(dL);dL.setAttribute("style", "margin:4px;");var dC = document.createElement("div");dL.appendChild(dC);dC.setAttribute("style", "float:left;width:80px;");dC.innerHTML = "Weight (kg)";dC = document.createElement("div");dL.appendChild(dC);try{pos_spider_box_kg = document.createElement('<input value="?" onchange="pos_spider_box_quote();" style="width: 90px;" id="pos.select.box.kg" type="text">');document.write("<!-- Only Internet Explorer creates elements this way -->")}catch(err){pos_spider_box_kg = document.createElement("input");pos_spider_box_kg.setAttribute("type", "text");pos_spider_box_kg.setAttribute("id", "pos.select.box.kg");pos_spider_box_kg.setAttribute("style", "width:90px;");pos_spider_box_kg.setAttribute("onchange", "pos_spider_box_quote();");pos_spider_box_kg.setAttribute("value", "?");}dC.appendChild(pos_spider_box_kg);dL = document.createElement("div");dBox.appendChild(dL);dL.setAttribute("style", "margin:2px 2px 2px 4px;");dC = document.createElement("div");dL.appendChild(dC);dC.setAttribute("style", "float:left;width:80px;");dC.innerHTML = "To";dC = document.createElement("div");dL.appendChild(dC);pos_spider_box_to = document.createElement("select");dC.appendChild(pos_spider_box_to);pos_spider_box_to.setAttribute("id", "pos.spider.box.to");pos_spider_box_to.setAttribute("onchange", "pos_spider_box_quote();");pos_spider_box_to.setAttribute("style", "width:96px;");dL = document.createElement("hr");dBox.appendChild(dL);pos_spider_box_quotes = document.createElement("div");dBox.appendChild(pos_spider_box_quotes);pos_spider_box_quotes.setAttribute("id", "pos.spider.box.quotes");pos_spider_box_quotes.setAttribute("style", "margin:4px;");divPosSpider.appendChild(dBox);pos_spider_box_to_update();
