//--------------------AddtoCart function sjm. ----------------------------------// var msg; //variable for checkfields function; declare outside so they can be referenced w/in AddtoCart var msgflag; //variable for checkfields function; declare outside so they can be referenced w/in AddtoCart var Chkstr; var MatchResult; var myRE; function AddtoCart() { msgflag = "false"; //set to false so a value can be referenced later //validate relo fields if the product is a relo report Chkstr = new String(window.location); myRE = new RegExp("e186-71", "i"); //set string we are checking for not to be case sensitive MatchResult = Chkstr.match(myRE); if (MatchResult !=null) { checkfields(document.ProdCart); } //call remaining functions isIntegerInRange(document.ProdCart.itemquantity.value); calcUnitPrice(document.ProdCart); calcUnitDisc(document.ProdCart); //set target url and submit only if data passed validation test in checkfields function if (msgflag == "false") { if (window.location.host=='lnwebdev01.realtors.org') { //beta url //alert("price: " + document.ProdCart.itemunitprice.value); //alert("list price: " + document.ProdCart.listunitprice.value); //alert("original price: " + document.ProdCart.originalunitprice.value); document.ProdCart.action="https://ecommercebeta.realtors.org/recn/bskt/BasketServlet?transaction=additem"; document.ProdCart.submit(); } //test url //document.ProdCart.action="http://10.3.1.17/recn/bskt/BasketServlet?transaction=additem"; //document.ProdCart.submit(); } else { //production url document.ProdCart.action="https://ecommerce.realtors.org/recn/bskt/BasketServlet?transaction=additem"; document.ProdCart.submit();} } } //end AddtoCart function //****************************** function stringFilter (input) { filteredValues = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,"; // Characters stripped out var i; var returnString = ""; for (i = 0; i < input.length; i++) { // Search through string and append to unfiltered values to returnString. var c = input.charAt(i); if (filteredValues.indexOf(c) == -1) returnString += c; } return returnString; } //****************************** function isIntegerInRange(input) { if ((input == null) || (input.length == 0) || (input == 0)) { //check for null or value of zero and set to one if true document.ProdCart.itemquantity.value = 1; } else { var num = stringFilter(input); //change type to integer via parseInt so that the comparison will work both in JavaScript 1.2 (which typechecks in equality comparisons) //and JavaScript 1.1 and before (which doesn't) //check that value is not greater than max and reduce to max if true if (parseInt(num) <= 99999) { document.ProdCart.itemquantity.value = stringFilter(input); } else { document.ProdCart.itemquantity.value = 99999; } } } //****************************** function calcUnitPrice(form) { //set variables for quantity, anonymous, quantity ranges and corresponding prices Anon = form.anonymous.value; Qty = form.itemquantity.value; Rang = 1; LRng1 = form.LowQRange1.value; HRng1 = form.HighQRange1.value; LRng2 = form.LowQRange2.value; HRng2 = form.HighQRange2.value; LRng3 = form.LowQRange3.value; HRng3 = form.HighQRange3.value; Mprice1 = form.MPriceRange1.value; Mprice2 = form.MPriceRange2.value; Mprice3 = form.MPriceRange3.value; NMprice1 = form.NMPriceRange1.value; NMprice2 = form.NMPriceRange2.value; NMprice3 = form.NMPriceRange3.value; //added orginal price fields 4/14/09 Oprice1 = form.OPriceRange1.value; Oprice2 = form.OPriceRange2.value; Oprice3 = form.OPriceRange3.value; //find out which range the quantity is (there are three possible ranges) //if ((parseInt(Qty) >= parseInt(LRng1)) && (parseInt(Qty) < parseInt(HRng2))) { // Rang = 1; // } //else //if ((parseInt(Qty) >= parseInt(LRng2)) && (parseInt(Qty) < parseInt(HRng3))) { // Rang = 2; // } //else { // Rang = 3; // } //find out which range the quantity is (there are three possible ranges). if (parseInt(LRng2) != 0) //if second range is zero, there is only one range so disregard bumping range to 2. { if (parseInt(Qty) > parseInt(HRng1)) { Rang = 2; } } if (parseInt(LRng3) != 0) //if third range is zero, there are ony two ranges so disregard bumping up to 3. { if (parseInt(Qty) >= parseInt(LRng3)) { Rang = 3; } } //if user is anonymous, grab corresponding non-member price for that quantity range; //otherwise, grab corresponding member price for quantity range if (Anon == "Y") { switch (parseInt(Rang)) { case 1: document.ProdCart.itemunitprice.value = NMprice1; break case 2: document.ProdCart.itemunitprice.value = NMprice2; break case 3: document.ProdCart.itemunitprice.value = NMprice3; } } else { switch (parseInt(Rang)) { case 1: document.ProdCart.itemunitprice.value = Mprice1; break case 2: document.ProdCart.itemunitprice.value = Mprice2; break case 3: document.ProdCart.itemunitprice.value = Mprice3; } } //Added 4/14/09: grab the list price and original price as well. These prices are also based on range but will be the same whether or not the user is anonymous. switch (parseInt(Rang)) { case 1: document.ProdCart.listunitprice.value = NMprice1; document.ProdCart.originalunitprice.value = Oprice1; break case 2: document.ProdCart.listunitprice.value = NMprice2; document.ProdCart.originalunitprice.value = Oprice2; break case 3: document.ProdCart.listunitprice.value = NMprice3; document.ProdCart.originalunitprice.value = Oprice3; } } //****************************** function calcUnitDisc(form) { //set variables for price and discount percentage price = form.itemunitprice.value; discper = form.ProdDiscount.value; //calculate the actual discount in dollars; discount is a percentage so multiply that by the correct unit price var totaldisc = (price * discper); //round the resulting dollar amount to a max of two decimal points var rounddisc = Math.round(totaldisc * 100) / 100; document.ProdCart.itemunitdiscount.value = rounddisc; } //****************************** function checkfields(form) { msgflag = "false"; //(re)set to false msg="The following fields require a value:\r"; if ((form.ReloYear.options[form.ReloYear.selectedIndex].text == "No reports currently available") || (form.ReloYear.options[form.ReloYear.selectedIndex].text == "-choose a year-")) { // ....... year validation (null) .... msg+="\r--Year"; msgflag="true"; } if (form.ReloState.options[form.ReloState.selectedIndex].text == "-choose a state-") { // ....... state validation (null) .... msg+="\r--State"; msgflag="true"; } if (form.ReloCounty.options[form.ReloCounty.selectedIndex].text == "-choose a county-") { // ....... county validation (null) ... msg+="\r--County"; msgflag="true"; } if (msgflag == "true") { //.......if there are fields with any errors, prompt user alert(msg+"\r\rPress the OK button below to return the form and make corrections."); } } //----------------------End AddtoCart function sjm.------------------------------// //---------ViewCart function--------------------------------------------------------------// function ViewCart(viewurl) { //Pass the catalogurl and the sessionid directly and obtain the rest of the link from a computed field on the form //(catalogurl was not being read properly when passed by Notes and sessionid needs to be dynamic). var fullurl = viewurl + document.ProdCart.catalogurl.value + "&catalogsessionid=" + document.ProdCart.catalogsessionid.value; //alert(fullurl); window.location=fullurl; } //---------End ViewCart function------------------------------------------------------------// // ........................................... Search function for Order Entry.............................................. function entsub2OE(event) { var isNav4=false; var isIE4=false; // find browser type and version if (navigator.appVersion.indexOf("4.")>=0) { if(navigator.appName=="Netscape") { isNav4=true; } if(navigator.userAgent.indexOf("MSIE")>0) { isIE4=true; } } // use the appropriate event property for the detected browser if (isNav4) { if ( event.which == "13" ) { window.location='/prodser.nsf/ProdAssistSrchResults?ReadForm&memberid='+document.ProdCart.memberid.value+'&userflag='+document.ProdCart.UserFlag.value+'&Query='+escape('('+document.productSrch2.Query.value+'*)'); event.returnValue = false; } } else { if ( event.keyCode=="13" ) { window.location='/prodser.nsf/ProdAssistSrchResults?ReadForm&memberid='+document.ProdCart.memberid.value+'&userflag='+document.ProdCart.UserFlag.value+'&Query='+escape('('+document.productSrch2.Query.value+'*)'); event.returnValue = false; } } } // ........................................... End Search Function for Order Entry..............................................