function isNumeric(co) { var RegExp = /^(-)?(\d*)(\.?)(\d*)$/; var res = co.toString().match(RegExp); return res; } function validEmail(m){ var ret = true; if (m == ""){return false;} var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; if (!filter.test(m)){ret = false;} return ret; } function trim(str){ if (!str){return "";} if (str == ""){return "";} return str.replace(/^\s+|\s+$/g,""); } function rateItem(pid){ var url = "http://www.onlineflorist.com/jscript/rateItem.php?id=" + pid.toString(); var width = 550; var height = 400; newWin = window.open(url,'rateItem','left='+((screen.width-width)/2.1)+',top='+((screen.height-height)/2)+',menubar=0,scrollbars=0,status=0,location=0,resizable=0,width='+ width.toString() +',height=' + height.toString()); newWin.focus(); } function showOccasions(pid){ var url = "http://www.onlineflorist.com/jscript/showOccasions.php?id=" + pid.toString(); url += "&occasion=" + escape(document.getElementById("occ" + pid.toString()).value); var width = 550; var height = 450; newWin = window.open(url,'showOccasion','left='+((screen.width-width)/2.1)+',top=20,menubar=0,scrollbars=0,status=0,location=0,resizable=0,width='+ width.toString() +',height=' + height.toString()); newWin.focus(); } function addGift(pid,aid){ var url = "http://www.onlineflorist.com/jscript/addGift.php?pid=" + pid.toString() + "&id=" + aid.toString(); var width = 550; var height = 450; newWin = window.open(url,'addGift','left='+((screen.width-width)/2.1)+',top='+((screen.height-height)/2)+',menubar=0,scrollbars=0,status=0,location=0,resizable=0,width='+ width.toString() +',height=' + height.toString()); newWin.focus(); } function openZipLookUp(){ var url = "http://zip4.usps.com/zip4/welcome.jsp"; var width = 800; var height = 500; newWin = window.open(url,'zipLookUp','left='+((screen.width-width)/2.1)+',top=20,menubar=0,scrollbars=1,status=0,location=0,resizable=1,width='+ width.toString() +',height=' + height.toString()); newWin.focus(); } function searchFlowers(){ var el = document.getElementById("txtSearchFlowers"); if (el == null){return;} var code = el.value; code = code.replace("."," "); code = trim(code); if (code == ""){return;} window.location = "http://www.onlineflorist.com/Search+Flowers/" + escape(code) + ".html"; } function getAjax(){ if (window.XMLHttpRequest){return new XMLHttpRequest();}else if(window.ActiveXObject){return new ActiveXObject("Microsoft.XMLHTTP");} return null; } function showModalWindow(ako){ var el = document.getElementById('modalwin'); if (!el){return;} if (ako==1){el.style.visibility = 'visible';}else{el.style.visibility = 'hidden';} } var aLoader = getAjax(); var lastName = ""; var lastClass = ""; var lastCartItem = 0; function checkHurryZip(state){ var el = document.getElementById("txthurryzip"); if (!el){return;} var t = trim(el.value); if (t == "Enter Delivery Zip Code" && state==0){t = "";} if (t == "" && state==1){t = "Enter Delivery Zip Code";} el.value = t; el.focus(); } function checkDeliveryZIP(state){ var el = document.getElementById("txtdestzip"); if (!el){return;} var t = trim(el.value); if (t == "Enter Delivery Zip Code" && state==0){t = "";} if (t == "" && state==1){t = "Enter Delivery Zip Code";} el.value = t; el.focus(); } function checkZIP(code,srcName){ code = trim(code); if (code == "" || code == "Enter Delivery Zip Code"){return;} country = "USA"; var el = document.getElementById(srcName); if (el != null){ lastName = srcName; if (el.className != "errorInput"){lastClass = el.className;} } if (srcName == "txthurryzip"){ el = document.getElementById("rdleftcanada"); if (el != null && el.checked == true){country = "CND";} }else{ el = document.getElementById("rdcanada"); if (el != null && el.checked == true){country = "CND";} } if (aLoader.readyState == 4 || aLoader.readyState == 0){ showModalWindow(1); url = "http://www.onlineflorist.com/jscript/zip.php?code=" + escape(code) + "&country=" + escape(country) + "&srcname=" + escape(srcName); aLoader.open('GET', url, true); aLoader.onreadystatechange = checkZIPOK; aLoader.send(null); } } function checkZIPOK(){ if (aLoader.readyState == 4){ showModalWindow(0); if (lastName != ""){ var el = document.getElementById(lastName); if (el != null){ if (aLoader.responseText == "not found"){ el.className = "errorInput"; addToCartValidateZipError("Please enter a valid ZIP code"); }else{ el.value = aLoader.responseText; el.className = lastClass; addToCartValidateZipError(""); chekZIPisValid(); } el.focus(); } } } } function selectDate(ako){ if (aLoader.readyState == 4 || aLoader.readyState == 0){ url = "http://www.onlineflorist.com/jscript/getdate.php?code=" + escape(ako) + "&offset=" + new Date().getTimezoneOffset().toString(); url += "&pid=" + productID.toString() + "&ptype=" + productType; aLoader.open('GET', url, true); aLoader.onreadystatechange = selectDateOK; aLoader.send(null); } } function selectDateOK(){ if (aLoader.readyState == 4){ var el = document.getElementById("boxcal"); if (el == null){return;} el.innerHTML = aLoader.responseText; if (document.getElementById("frmdate").value == ""){ var pole = document.getElementById("hdautoselect").value.toString().split("|"); setDate(pole[0],pole[1],pole[2]); } } } function setDate(val,lab,ako){ var el = document.getElementById("dateName"); if (el != null){el.innerHTML = lab;} var el = document.getElementById("frmdate"); if (el != null){el.value = val;} if (productType == "gift"){updateGiftPrice();} if (ako < 1 || ako > 31){return;} for(i=1;i<=31;i++){ el = document.getElementById("tdday" + i.toString()); if (el != null){el.className = "calday";} } el = document.getElementById("tdday" + ako.toString()); if (el != null){el.className = "caldaysel";} } function getProductOption(){ var ret = "regular"; if (document.getElementById('rddeluxe') != null && document.getElementById('rddeluxe').checked == true){ret = 'deluxe';} if (document.getElementById('rdpremium') != null && document.getElementById('rdpremium').checked == true){ret = 'premium';} if (document.getElementById('rdexquisite') != null && document.getElementById('rdexquisite').checked == true){ret = 'exquisite';} return ret; } function chekZIPisValid(){ if (lastName == "txthurryzip"){window.location = "http://www.onlineflorist.com/Florist/index.html";return;} if (document.getElementById("txtdestzip") == null){return;} if (document.getElementById("frmdate").value == ""){selectDate("");} isZipValid = 1; if (isCartClicked == 1){addToCart();} } function addToCartValidateZip(){ if (isZipValid == 1){addToCart();return;} var el = document.getElementById("txtdestzip"); if (el == null){return;} var code = trim(el.value); if (code == "" || code == "Enter Delivery Zip Code"){ addToCartValidateZipError("Please enter a valid ZIP code"); return; } addToCartValidateZipError(""); checkZIP(document.getElementById('txtdestzip').value,'txtdestzip'); } function addToCartValidateZipError(msg){ if (document.getElementById("txtdestziperror") == null){return;} document.getElementById("txtdestziperror").innerHTML = msg; var el = document.getElementById("txtdestzip"); el.className = ""; if (msg != ""){el.className = "errorInput";isZipValid=0;} } function addToCart(){ if (productID == 0){return;} isCartClicked = 1; if (isZipValid == 0){addToCartValidateZip();return;} if (aLoader.readyState == 4 || aLoader.readyState == 0){ showModalWindow(1); url = "http://www.onlineflorist.com/jscript/checkout.php?action=addtocart&pid=" + productID.toString(); url += "&option=" + getProductOption() + "&delivery=" + document.getElementById("frmdate").value; url += "&ptype=" + productType; aLoader.open('GET', url, true); aLoader.onreadystatechange = addToCartOK; aLoader.send(null); } } function addToCartOK(){ if (aLoader.readyState == 4){ showModalWindow(0); if (aLoader.responseText != "ok"){alert(aLoader.responseText);return;} window.location = "http://www.onlineflorist.com/cart.php"; } } function saveCartitem(co){ if (co == 0){return;} lastCartItem = co; if (aLoader.readyState == 4 || aLoader.readyState == 0){ showModalWindow(1); url = "http://www.onlineflorist.com/jscript/checkout.php?action=savecartitem&id=" + lastCartItem.toString(); url += "&fname=" + escape(document.getElementById("tfn" + lastCartItem.toString()).value); url += "&address=" + escape(document.getElementById("tad" + lastCartItem.toString()).value); url += "&phonearea=" + escape(document.getElementById("tpa" + lastCartItem.toString()).value); url += "&phonenumber=" + escape(document.getElementById("tpn" + lastCartItem.toString()).value); url += "&occasion=" + escape(document.getElementById("occ" + lastCartItem.toString()).value); url += "&message=" + escape(document.getElementById("msg" + lastCartItem.toString()).value); aLoader.open('GET', url, true); aLoader.onreadystatechange = saveCartitemOK; aLoader.send(null); } } function saveCartitemOK(){ if (aLoader.readyState == 4){ showModalWindow(0); if (lastCartItem == 0){return;} if (aLoader.responseText == ""){return;} try{ var navrat = eval('(' + aLoader.responseText + ')'); document.getElementById("tfn" + lastCartItem.toString()).value = navrat.fname; document.getElementById("tad" + lastCartItem.toString()).value = navrat.address; document.getElementById("tpa" + lastCartItem.toString()).value = navrat.phonearea; document.getElementById("tpn" + lastCartItem.toString()).value = navrat.phonenumber; document.getElementById("msg" + lastCartItem.toString()).value = navrat.message; checkCartItem(lastCartItem,1); }catch(err){alert(err);} } } function saveMessage(co){ if (co == 0){return;} lastCartItem = co; if (aLoader.readyState == 4 || aLoader.readyState == 0){ showModalWindow(1); url = "http://www.onlineflorist.com/jscript/checkout.php?action=savemessage&id=" + lastCartItem.toString(); url += "&occasion=" + escape(document.getElementById("occ" + lastCartItem.toString()).value); url += "&message=" + escape(document.getElementById("msg" + lastCartItem.toString()).value); aLoader.open('GET', url, true); aLoader.onreadystatechange = saveMessageOK; aLoader.send(null); } } function saveMessageOK(){ if (aLoader.readyState == 4){ showModalWindow(0); if (lastCartItem == 0){return;} document.getElementById("msg" + lastCartItem.toString()).value = aLoader.responseText; } } function copyFirst(co){ if (co == 0){return;} lastCartItem = co; if (aLoader.readyState == 4 || aLoader.readyState == 0){ showModalWindow(1); url = "http://www.onlineflorist.com/jscript/checkout.php?action=copyfirst&id=" + lastCartItem.toString(); aLoader.open('GET', url, true); aLoader.onreadystatechange = copyFirstOK; aLoader.send(null); } } function copyFirstOK(){ if (aLoader.readyState == 4){ showModalWindow(0); if (lastCartItem == 0){return;} if (aLoader.responseText == ""){return;} try{ var navrat = eval('(' + aLoader.responseText + ')'); document.getElementById("tfn" + lastCartItem.toString()).value = navrat.fname; document.getElementById("tad" + lastCartItem.toString()).value = navrat.address; document.getElementById("tpa" + lastCartItem.toString()).value = navrat.phonearea; document.getElementById("tpn" + lastCartItem.toString()).value = navrat.phonenumber; document.getElementById("msg" + lastCartItem.toString()).innerHTML = navrat.message; document.getElementById("cmbox" + lastCartItem.toString()).style.display = "block"; document.getElementById("occ" + lastCartItem.toString()).selectedIndex = navrat.occasion; document.getElementById("chk" + lastCartItem.toString()).value = 1; checkCartItem(lastCartItem,0); }catch(err){alert(err);} } } function checkCartItem(id,withSaved){ if (id == 0){return;} ret = true; var el = document.getElementById("tfn" + id.toString()); if (!el){return true;} if (trim(el.value)==""){ret = false;el.className="errorInput";}else{el.className="";} el = document.getElementById("tad" + id.toString()); if (trim(el.value)==""){ret = false;el.className="errorInput";}else{el.className="";} el = document.getElementById("tpa" + id.toString()); if (trim(el.value)==""){ret = false;el.className="errorInput";}else{el.className="";} el = document.getElementById("tpn" + id.toString()); if (trim(el.value)==""){ret = false;el.className="errorInput";}else{el.className="";} if (ret == true){ el = document.getElementById("btncopy" + id.toString()); if (el != null){el.style.display = "none";} if (withSaved == 1){ el = document.getElementById("chk" + id.toString()); if (el != null){el.value = 1;} try{if (checkoutClicked == 1){goToCheckout();};}catch(err){} } }else{ try{checkoutClicked = 0;}catch(err){} } return ret; } function saveSenderEmail(){ var el = document.getElementById('frmsemail'); if (!el){return;} if (el.value == ""){return;} var saveAjax = getAjax(); var url = "http://www.onlineflorist.com/jscript/saveemail.php?email=" + escape(el.value); saveAjax.open('GET', url, true); saveAjax.send(null); }