// JavaScript Document function ajaxFunction(getVals, targetId) { //alert("in"); var browserType; var xmlHttp; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } } xmlHttp.onreadystatechange=function() { if(xmlHttp.readyState==4 && targetId != "none") { if(targetId == "cart") { window.location = "index.php?p=cart"; return; } if(targetId == "paypal") return true; document.getElementById(targetId).innerHTML = xmlHttp.responseText; } } xmlHttp.open("GET", "functions/ajaxWork.php?"+getVals, true); xmlHttp.send(null); } function addToCart(id) { var qty = document.getElementById(id).value; //var color = document.getElementById('color').value; if(qty != "" && qty != null && IsNumeric(qty)) { /*if(document.getElementById('color').value == "none") { alert("Please select a color!"); document.getElementById('color').focus(); return; }*/ ajaxFunction("qty="+qty+"&id="+id, 'cart'); //window.location = "index.php?p=cart"; } else { alert("Please enter a valid quantity!"); document.getElementById(id).value = ""; document.getElementById(id).focus(); } } function updateCart(id) { var qty = document.getElementById(id).value; if(qty == null || qty == "") qty = 0; if(IsNumeric(qty)) { ajaxFunction("qty="+qty+"&id="+id, "none"); return; } else { alert("Please enter a valid quantity!"); document.getElementById(id).value = ""; } } function saveFreightRate(obj) { var rate = obj.options[obj.selectedIndex].value; var loc = obj.options[obj.selectedIndex].innerHTML; if(rate != "none") { ajaxFunction("freight="+rate+"&loc="+loc, "showFreightRate"); } else { document.getElementById('showFreightRate').innerHTML = ""; document.getElementById('showFreightLoc').innerHTML = ""; } if(!IsNumeric(rate)) rate = 0; //ajaxFunction("freight="+rate+"&location="+loc, "none"); setTimeout("window.location = 'index.php?p=cart'", 60); } function IsNumeric(sText) { var ValidChars = "0123456789."; var IsNumber=true; var Char; for (i = 0; i < sText.length && IsNumber == true; i++) { Char = sText.charAt(i); if (ValidChars.indexOf(Char) == -1) { IsNumber = false; } } return IsNumber; } function validateCart(type) { var text; for(i=0; i