/// ........................................ Cookie By Saad ..........................................var catalogsessionid;function initializepage() {//Look for catalogsessionid in cookie firstvar cookies=document.cookie;catalogsessionid = getcatalogsessionid("catalogsessionid", cookies, ";");//If cookies aren't enabled, first determine if customer is coming from an external site. If so, a new catalogsessionid must be generated for them.if (catalogsessionid==null) {if (document.referrer.substring (0, 30).toLowerCase() != "") {catalogsessionid=randomnum();}else {var URLcatalogsessionid = new String(document.URL);catalogsessionid=getcatalogsessionid("catalogsessionid", URLcatalogsessionid, "&");}}//Append catalogsessionid to all links on the current page, regardless of whether cookies are enabled or not//setlinks(catalogsessionid); //turned off b/c causing a problem with js and anchor linksdocument.ProdCart.catalogsessionid.value = catalogsessionid;catalogsessionid}function randomnum() {var TodaysDate=new Date();var rn = Math.floor(16000*Math.random()+1)+"-"+TodaysDate.getHours()+TodaysDate.getMinutes()+TodaysDate.getSeconds(); return rn;}function setlinks(v) {var x = "";for (var i = 0; i < document.links.length; i++) {chklink = document.links[i].href;if (chksubstring("javascript:", chklink))	x = "a"else	if (chksubstring("#", chklink))		x = "b"	else//Use the search property of the link object to append the catalogsessionid		document.links[i].search=document.links[i].search + "&catalogsessionid=" +v }} function getcatalogsessionid(name, inputstring, trunc) {//Simply parses out catalogsessionid from either the cookie or URL passed to functioninputstring = inputstring + trunc;inputstring = inputstring.toLowerCase();var start=inputstring.indexOf(name + "=");if (start>-1) {start=inputstring.indexOf("=", start)+1}var end = inputstring.indexOf(trunc, start);if (start==-1 || end==-1) {value=null}else {var value=unescape(inputstring.substring(start,end))}return value;}function chksubstring(partstring, fullstring) {//alert(partstring)//alert(fullstring)var ptr = fullstring.indexOf(partstring)if (ptr < 0) return falseelsereturn true}// ...........................................  Cookie function Ends Saad .............................................. //---------ShoppingCart function--------------------------------------------------------------//function ShoppingCart(viewurl) {//Pass in the first part of the url and add the parameters here//(note:  catalogurl was not being read properly when passed by Notes and sessionid needs to be dynamic).var StoreParams = "&associd="+ document.ProdCart.associd.value + "&storeid=" + document.ProdCart.storeid.value + "&assocpayment=" + document.ProdCart.assocpayment.value + "&catalogurl=" + document.ProdCart.catalogurl.value;var UserParams = "&memberid=" + document.ProdCart.memberid.value + "&anonymous=" + document.ProdCart.anonymous.value + "&loginname=" + document.ProdCart.loginname.value+ "&catalogsessionid=" + document.ProdCart.catalogsessionid.value+ "&viewmode=" + document.ProdCart.viewmode.value;var fullurl = viewurl + StoreParams + UserParams;//alert(fullurl);window.location=fullurl;}//---------End --------------------------------------------------------////________TriplePlay function for homepage______________________////track forwarderid in url for Triple Play - Temporary Solution for 8/28/03 - 9/25/03:  kick off FIDTrack agent if there is a value in the forwarderid field (grabbed from the querystring)//var FID = document.ProdCart.forwarderid.value;//if (FID.length != 0)  {//location.href="/prodser.nsf/TrackFID?OpenAgent&FID=" + document.ProdCart.forwarderid.value + "&SID=" + document.ProdCart.catalogsessionid.value//}//track forwarderid in url for Triple Play - Final Solution for after 9/25/03:  kick off Create transaction on ecomm. side if there is a value in the forwarderid field (grabbed from the querystring).function TriplePlay () {var FID = document.ProdCart.forwarderid.value;if (FID.length != 0)  {  if (window.location.host=='lnwebdev01.realtors.org') {    //beta url    document.ProdCart.action="https://ecommercebeta.realtors.org/recn/bskt/BasketServlet?transaction=create"; }    //test url//document.ProdCart.action="http://10.3.1.17/recn/bskt/BasketServlet?transaction=create"; }  else {   //production url   document.ProdCart.action="https://ecommerce.realtors.org/recn/bskt/BasketServlet?transaction=create"; }document.ProdCart.submit();}}//________End TriplePlay function for homepage______________________////________Search function for Store Navi______________________//function entsub2(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/RSResults?ReadForm&Query='+escape('('+document.productSrch2.Query.value+'*)');		event.returnValue = false;	}} else {	if ( event.keyCode=="13" ) {window.location='/prodser.nsf/RSResults?ReadForm&Query='+escape('('+document.productSrch2.Query.value+'*)');		event.returnValue = false;	}}}//________End Search function for homepage______________________////--------------------AddItems function----------------------------------//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 AddItems() {msgflag = "false";  //set to false so a value can be referenced later//validate relocation report fields if the product is a relocation 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(); } else {   //production url   document.ProdCart.action="https://ecommerce.realtors.org/recn/bskt/BasketServlet?transaction=additem";    document.ProdCart.submit();}   }     } //end AddItems 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/8/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/8/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.------------------------------////--------------------AddThisItem function----------------------------------//function AddThisItem(product, form) {//grab values from form to pass to agentvar username = form.loginname.value;var memid = form.memberid.value;var anon = form.anonymous.value;var itemdesc = form.itemdescription.value;var catsession = form.catalogsessionid.value;  form.action="/prodser.nsf/webSubmitItem?openagent&loginname=" + username + "&memberid=" + memid + "&anon=" + anon + "&itemdesc=" + itemdesc + "&catsession=" + catsession + "&itemid=" + product;  form.submit();}//--------------------End AddThisItem function----------------------------------//