/* Copyright 2002, Prelude Systems, Inc.  All Rights Reserved. www.prelude.com  Duplication, 
Retransmission or Reproduction in part or whole is forbidden without Written Consent of Prelude Systems Inc. */
var changeflag = false;
var multiMode=0;


function CursorDefault()
{
   this.window.status="";
   if (navigator.appName == "Microsoft Internet Explorer")
   {
      if (parent.SPEEDFRAME != null)
      {
         if (parent.SPEEDFRAME.document.body != null)
         {
            parent.SPEEDFRAME.document.body.style.cursor="default";
         }
      }
      document.body.style.cursor="default";
   }
}
function CursorWait()
{
   this.window.status="Retrieving Data Please Wait";
   if (navigator.appName == "Microsoft Internet Explorer")
   {
      document.body.style.cursor="wait";
   }
}
function change()
{
   changeflag="true";
}
function changeMultiCart()
{
   changeflag="true";
   if (document.forms[0].ActiveCartId != null)
   {
      document.forms[0].ActiveCartId.disabled=true;
   }
   multiMode=1;
}
function changeMultiFavorite()
{
   changeflag="true";
   if (document.forms[0].ActiveFavoriteId != null)
   {
      document.forms[0].ActiveFavoriteId.disabled=true;
   }
   multiMode=2;
}
function changeMultiCartAndFavorite()
{
   changeflag="true";
   if (document.forms[0].ActiveCartId != null && document.forms[0].ActiveFavoriteId != null)
   {
      document.forms[0].ActiveCartId.disabled=true;
      document.forms[0].ActiveFavoriteId.disabled=true;
   }
   multiMode=3;
}
function checkChange()
{
   if (changeflag==null)
   {
      changeflag=false;
   }

   if (changeflag=="true")
   {
      if (confirm("Data On This Page Was Changed.  Would You Like to Save Those Changes?"))
      {
         document.forms[0].submit();
      }
   }
}
function convertText(qtyFieldName)
{
   var pattern = /\s+/ig;
   var formName=document.forms[0].name;
   var txtFld=eval("document."+formName+"."+qtyFieldName);
   var newVal=txtFld.value.replace(pattern,"^");
   txtFld.value=newVal;
}
function replaceSpaces(conversionString)
{
   var pattern = /\s+/ig;
   var pattern2 = /\"+/ig;
   conversionString = conversionString.replace(pattern,"^")
   conversionString = conversionString.replace(pattern2,"{");
   return conversionString;
}
function specialReset()
{
   var activeFavorite=document.forms[0].ActiveFavoriteId.selectedIndex;
   //alert("acttive favorite is "+activeFavorite);
   document.forms[0].reset();
   document.forms[0].ActiveFavoriteId.setSelectedIndex=1;
}
function postIt()
{
   changeflag="false";
   CursorWait();
   if (multiMode==1 || multiMode==3)
   {
      document.forms[0].ActiveCartId.disabled=false;
   }
   if (multiMode==2 || multiMode==3)
   {
      document.forms[0].ActiveFavoriteId.disabled=false;
   }
   document.forms[0].submit();
}
function postIt2()
{
   changeflag="false";
   displayBlock("UpdateDiv10");
   displayBlock("UpdateDiv11");
   CursorWait();
   if (multiMode==1 || multiMode==3)
   {
      document.forms[0].ActiveCartId.disabled=false;
   }
   if (multiMode==2 || multiMode==3)
   {
      document.forms[0].ActiveFavoriteId.disabled=false;
   }
   document.forms[0].submit();
}
function postItnClose()
{
   CursorWait();
   document.forms[0].submit();
   parent.close();

}
function go(tarurl,loc,waitFlag)
{
   if (waitFlag==1)
   {
      CursorWait();
   }
   window.open(tarurl,loc);
}    

/**
   Opens up a new browser window with the contents and options specified.  
   @param tarurl A string specifying the URL to open in the new window
   @param waitFlag Yes/No flag specifying if you want the cursor to change to wait status, i.e an hourglass
   @param title The name of the new window that is to be opened
   @param width Width of the new window you want to open.  Can be expressed in pixels or a percentage.
                The percentage will be based on the screen size or the current browser window size depending
                on how the option screenOption is set
   @param height Height of the new window you want to open.  Can be expressed in pixels or a percentage.
                The percentage will be based on the screen size or the current browser window size depending
                on how the option screenOption is set.
   @param resizableFlag Whether or not we want to user to be able to resize the window
   @param scrollBarFlag If you want the new window to have scrollbars
   @param toolBarFlag If you want the new window to have the standard toolbar across the top
   @param locationFlag If yes, creates a location entry field
   @param directoriesFlag If yes, creates the standard browser directory buttons, such as What's New 
                          and What's Cool.
   @param statusFlag Creates the status bar on the bottom of the browser window
   @param menuBarFlag Creates the menu on top of the browser window
   @param copyHistoryFlag Not sure what the heck this flag does
   @param screenOption If this is set to 1, then the size of the window will be based on the screen
                       resolution size.  If screenOption is 0 then size is based on current size of browser window
*/
function goWindow(tarurl,waitFlag,title,width,height,resizableFlag,scrollBarFlag,toolBarFlag,locationFlag,directoriesFlag,statusFlag,menuBarFlag,copyHistoryFlag,screenOption)
{
   if (waitFlag==1)
   {
      CursorWait();
   }
   var optionString="";
   var percentLoc = width.indexOf("%");
   if (percentLoc > -1)
   {
      var widthPercent = (width.substring(0,percentLoc) / 100);
      var newWidth = 800;
      var left=0;
      var topPos=0;
      if (screenOption==1)
      {
         newWidth = screen.width*widthPercent;
         left = (screen.width) ? (screen.width-newWidth)/2 : 0;
      } else
      {
         if (document.layers)
         {
            newWidth=window.innerWidth*widthPercent;
            left=(window.innerWidth) ? ((window.innerWidth-newWidth)/2)+window.screenX : 0;
         } else if (document.all)
         {
            newWidth = document.body.clientWidth*widthPercent;
            left=(document.body.clientWidth) ? (document.body.clientWidth-newWidth)/2 : 0;
         }
      }
      optionString="width="+Math.round(newWidth)+",left="+Math.round(left);
   } else
   {
      if (width>0)
      {
         optionString="width="+width;
      } else
      {
         optionString="width=800";
      }
   }
   var percentLoc = height.indexOf("%");
   if (percentLoc > -1)
   {
      var heightPercent = (height.substring(0,percentLoc) / 100);
      var newHeight = 400;
      var topPos=0;
      if (screenOption==1)
      {
         newHeight = screen.height*heightPercent;
         topPos = (screen.height) ? (screen.height-newHeight)/2 : 0;
      } else
      {
         if (document.layers)
         {
            newHeight=window.outerHeight*heightPercent;
            topPos = (window.outerHeight) ? ((window.outerHeight-newHeight)/2)+window.screenY : 0;
         } else if (document.all)
         {
            newHeight = (document.body.clientHeight*1.25)*heightPercent;
            topPos = (document.body.clientHeight) ? ((document.body.clientHeight*1.25)-newHeight)/2 : 0;
         }
      }
      optionString=optionString+",height="+Math.round(newHeight)+",top="+Math.round(topPos);
   } else
   {
      if (height>0)
      {
         optionString=optionString+",height="+height;
      } else
      {
         optionString=optionString+",height=400";
      }
   }
   if (resizableFlag==1)
   {
      optionString=optionString+",resizable=yes";
   } else
   {
      optionString=optionString+",resizable=no";
   }
   if (scrollBarFlag==1)
   {
      optionString=optionString+",scrollbars=yes";
   } else
   {
      optionString=optionString+",scrollbars=no";
   }
   if (toolBarFlag==1)
   {
      optionString=optionString+",toolbar=yes";
   } else
   {
      optionString=optionString+",toolbar=no";
   }
   if (locationFlag==1)
   {
      optionString=optionString+",location=yes";
   } else
   {
      optionString=optionString+",location=no";
   }
   if (directoriesFlag==1)
   {
      optionString=optionString+",directories=yes";
   } else
   {
      optionString=optionString+",directories=no";
   }
   if (statusFlag==1)
   {
      optionString=optionString+",status=yes";
   } else
   {
      optionString=optionString+",status=no";
   }
   if (menuBarFlag==1)
   {
      optionString=optionString+",menubar=yes";
   } else
   {
      optionString=optionString+",menubar=no";
   }
   if (copyHistoryFlag==1)
   {
      optionString=optionString+",copyhistory=yes";
   } else
   {
      optionString=optionString+",copyhistory=no";
   }
   window.open(tarurl,title,optionString)
}
function doTip(evt,txt)
{
// depricated 
}
function hideTip() 
{
   // Going to be Depricated in next Release
}

/** Code to place a checkmark for all products in the Mark For Favorites column.
    This code needs to have a hidden field somewhere in the calling .jsp page to 
    work correctly which must be named tableLength and have VALUE equal to the 
    number of dataTable rows
    Ex:  <INPUT TYPE="HIDDEN" NAME="tableLength" VALUE="<%=liRows%>">   
*/
function markAll()
{
   var fieldName;
   var formName=document.forms[0].name;
   var length = eval("document." + formName + ".tableLength.value");
   for (x=0; x < length; x++)
   {
      fieldName=eval("document." + formName + ".ptcFlg_" + x);
      if (fieldName != null)
      {
         fieldName.checked=true;
         change();
      }
   }
}
function markAll1(lineNum)
{
   var fieldName;
   var formName=document.forms[0].name;
   fieldName=eval("document." + formName + ".ptcFlg_" + lineNum);
   if (typeof fieldName != "undefined")
   {
      fieldName.checked=true;
   }
   change();
}
/**
   This function will close the current browser window that calls this function
*/
function closeWindow()
{
   parent.close();
}
/**
 * This method checks to see if the user hit 'enter'.  If they did, we either execute the form's POST method
 * or the field's 'ONBLUR' event depending on what was passed in the 'mode' variable.  
 */
function detectEnter(e,mode)
{
   var nav4 = window.Event ? true : false;
   if (nav4)
   {
      var whichCode = e.which
   } else
   {
      if (e.type=="keypress")
      {
         var whichCode=e.keyCode
      }
   }
   if (e.type == "keypress" && whichCode=="13")
   {
      if (mode == "post")
      {
         postIt();
      } else
      {
         e.srcElement.blur();
      }
   }
}
/**
   This function displays/hides a section of HTML code.  Typically the block of code is 
   within tags that have an ID associated with them.  You pass that tag id to this function.  
*/
function displayBlock(elementId)
{
   var styleObject = document.getElementById(elementId);
   if (styleObject.style.display == "none")
   {
      styleObject.style.display = "";
   } else
   {
      styleObject.style.display = "none";
   }
}
function displayMenuBlock(elementId,menuGroup)
{
   for (x=0;x<=5;x++)
   {
      // reset all menu options to closed or none
      var xstyleObject = new getObj("menu_"+x);
      xstyleObject.style.display = "none";
      xstyleObject.style.color="blue";
      var xob= new getObj("menuGroup"+x);
      // reset all menu groups to standard colors
      xob.style.color="#0000ff";
      var styleObject = new getObj(elementId);
   }
      if (styleObject.style.display == "none")
      {
         styleObject.style.display = "";
         // set menu group to different color so know its selected
         var ob = new getObj(menuGroup);
         ob.style.color = "black";
      } else
      {
         styleObject.style.display = "none";
      }
}
   function getObj(name)
   {
      if (document.getElementById)
      {
         this.obj = document.getElementById(name);
         this.style = document.getElementById(name).style;
      } else if (document.all)
      {
         this.obj = document.all[name];
         this.style = document.all[name].style;
      } else if (document.layers)
      {
         this.obj = document.layers[name];
         this.style = document.layers[name];
      }
    }

   function printWindow()
   {
      if (window.print)
      {
         window.print() ;  
      } else
      {
         var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
         document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
         WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = "";  
      }
   }
   function validatePhone(field,msg,country)
   {
      var formName=document.forms[0].name;
      var areaCodePat = /(\d{3})-(\d{3})-(\d{4})/;
      var fld = eval("document."+formName+"."+field);
      var phone=fld.value;
      var phoneMatch = phone.match(areaCodePat);
      var countryCheck = eval("document."+formName+"."+country+".value");
      if (phone != "" && phoneMatch == null && countryCheck == "US")
      {
         alert(msg);
         fld.focus();
      }
   }
   function validateZip(field,msg,country)
   {
      var formName=document.forms[0].name;
      var zipCodePat = /(\d{5})-(\d{4})/;
      var fld = eval("document."+formName+"."+field);
      var zip = fld.value;
      var zipMatch = zip.match(zipCodePat);
      var countryCheck = eval("document."+formName+"."+country+".value");
      if (zip.length > "5" && zip != "")
      {
         if (zipMatch == null && countryCheck == "US")
         {
            alert(msg);
            fld.focus();
         }
      } else
      {
         if (zip != "" && zip.length < "5" && countryCheck == "US")
         {
            alert(msg);
            fld.focus();
         }
      }
   }

/**
   This function validates the cart quantity that the user entered.  
   If the Enforce Min Sell Qty flag is "Y", then this function will verify that the quantity
   entered is greater than the minimum sell qty AND is a multiple of the minimum selling quantity.
   Currently the selling package quantity is only used to initially default the quantity but not
   used for any kind of validation.  
   @param lineNum The line number of the product the user changed quantities on
   @param minSellQty The minimum quantity is used is allowed to buy of this product.  Also used
                     to see if the entered quantity is a multiple of this quantity
   @param increment The quantity that will be added when the user hits the up arrow
   @param defQty The quantity that defaults in the quantity box, comes from Selling Package Qty in ADS
   @param inCartQty The current cart quantity that the user entered
   @param enforceFlag Y/N flag to determine if we are enforcing the minimum sell quantities
   @param minOrderQty is the limit the web user can purchase this products
   @param maxOrderQty is the limit the web user can purchase for this product
 */
   function qtyValidate(lineNum,minSellQty,increment,defQty,inCartQty,enforceFlag,minOrderQty,maxOrderQty)
   {
      var currentQty = eval("document.forms[0].icQty_" + lineNum + ".value");
      var currentQtyField = eval("document.forms[0].icQty_" + lineNum);
      var newCurrentQty=currentQty;
      if (isNaN(currentQty))
      {
         alert( "Not a Valid Number");
         currentQtyField.focus();
         return;
      }
      var msg="";
      if (currentQty.indexOf("+") > -1)
      {
         newCurrentQty = inCartQty + parseInt(eval("document.forms[0].icQty_" + lineNum + ".value"));
      } else if (currentQty.indexOf("-") > -1)
      {
         newCurrentQty = inCartQty + parseInt(eval("document.forms[0].icQty_" + lineNum + ".value"));
      }

      if (enforceFlag && newCurrentQty!="0" && minSellQty!="0")
      {
         var remainder = newCurrentQty % increment;
         if (newCurrentQty < minSellQty)
         {
            msg="The Quantity Entered Cannot Be Less Than " + minSellQty + ". The Quantity Has Been Changed to the Minimum Selling Quantity.\n";
            currentQtyField.value = minSellQty;
            currentQtyField.focus();
         } else if (remainder > 0)
         {
            if (enforceFlag)
            {
               msg="The Quantity Entered Is Not A Multiple Of This Product's Package Quantity. Quantity Has Been Rounded Up.\n";
               currentQtyField.value = (newCurrentQty - remainder) + increment;
               currentQtyField.focus();
            }
         }
      }
      if (minOrderQty!="0" && maxOrderQty!="0" && newCurrentQty!="0")
      {
         if (newCurrentQty < minOrderQty)
         {
            msg="The Quantity Entered Cannot Be Less Than " + minOrderQty + ". Quantity Has Been Changed To Minimum Ordering Level.\n";
            currentQtyField.value = minOrderQty;
            currentQtyField.focus();
         } else if (newCurrentQty > maxOrderQty)
         {
            msg="The Quantity Entered May Not Exceed " + maxOrderQty + ". Quantity Has Been Changed To Maximum Ordering Level.\n";
            currentQtyField.value = maxOrderQty;
            currentQtyField.focus();
         }
      }
      if (msg != "")
      {
         alert(msg);
      } else
      {
         if (newCurrentQty!="0")
         {
            currentQtyField.value = newCurrentQty;
            fieldName=eval("document.forms[0].ptcFlg_" + lineNum);
            if (fieldName != null)
            {
            //  fieldName.checked=true;
            }
            change();
         }
      }
   }
/*
Date Check functions
*/
   function checkdate(objName,leadTime) 
   {
      var datefield = objName;
      if (objName.value.length == 0)
      {
         return;
      }
      if (objName.value.length <6)
      {
         alert("That date is invalid.  Please try again.");
         datefield.select();
         datefield.focus();
         return false;
      }
      if (chkdate(objName) == false)
      {
         datefield.select();
         alert("That date is invalid.  Please try again.");
         datefield.focus();
         return false;
      } else
      {
         var leadDate=calcLeadTimeDate(objName,leadTime);
         if (checkLeadTime(objName,leadDate) == false)
         {
            alert("date Entered must be Greater than "+leadDate);
            datefield.select();
            datefield.focus();
            return false;
         } else
         {
            return true;
         }
      }
   }
   function chkdate(objName)
   {
      var strDatestyle = "US"; //United States date style
      //var strDatestyle = "EU";  //European date style
      var strDate;
      var strDateArray;
      var strDay;
      var strMonth;
      var strYear;
      var intday;
      var intMonth;
      var intYear;
      var booFound = false;
      var datefield = objName;
      var strSeparatorArray = new Array("-"," ","/",".");
      var intElementNr;
      var err = 0;
      var strMonthArray = new Array(12);
      strMonthArray[0] = "Jan";
      strMonthArray[1] = "Feb";
      strMonthArray[2] = "Mar";
      strMonthArray[3] = "Apr";
      strMonthArray[4] = "May";
      strMonthArray[5] = "Jun";
      strMonthArray[6] = "Jul";
      strMonthArray[7] = "Aug";
      strMonthArray[8] = "Sep";
      strMonthArray[9] = "Oct";
      strMonthArray[10] = "Nov";
      strMonthArray[11] = "Dec";
      strDate = datefield.value;
      if (strDate.length < 1)
      {
         return true;
      }
      for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++)
      {
         if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1)
         {
            strDateArray = strDate.split(strSeparatorArray[intElementNr]);
            if (strDateArray.length != 3)
            {
               err = 1;
               return false;
            } else
            {
               strDay = strDateArray[0];
               strMonth = strDateArray[1];
               strYear = strDateArray[2];
            }
            booFound = true;
         }
      }
      if (booFound == false)
      {
         if (strDate.length>5)
         {
            strDay = strDate.substr(0, 2);
            strMonth = strDate.substr(2, 2);
            strYear = strDate.substr(4);
         }
      }
      if (strYear.length < 2)
      {
         strYear=fmt00(strYear);
      }
      if (strYear.length == 2)
      {
         strYear = '20' + strYear;
      }
      // US style
      if (strDatestyle == "US")
      {
         strTemp = strDay;
         strDay = strMonth;
         strMonth = strTemp;
      }
      intday = parseInt(strDay, 10);
      if (isNaN(intday))
      {
         err = 2;
         return false;
      }
      intday=fmt00(intday);
      intMonth = parseInt(strMonth, 10);
      if (isNaN(intMonth))
      {
         for (i = 0;i<12;i++)
         {
            if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase())
            {
               intMonth = i+1;
               strMonth = strMonthArray[i];
               i = 12;
            }
         }
         if (isNaN(intMonth))
         {
            err = 3;
            return false;
         }
      }
      intMonth=fmt00(intMonth);
      intYear = parseInt(strYear, 10);
      if (isNaN(intYear))
      {
         err = 4;
         return false;
      }
      if (intMonth>12 || intMonth<1)
      {
         err = 5;
         return false;
      }
      if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1))
      {
         err = 6;
         return false;
      }
      if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1))
      {
         err = 7;
         return false;
      }
      if (intMonth == 2)
      {
         if (intday < 1)
         {
            err = 8;
            return false;
         }
         if (LeapYear(intYear) == true)
         {
            if (intday > 29)
            {
               err = 9;
               return false;
            }
         } else
         {
            if (intday > 28)
            {
               err = 10;
               return false;
            }
         }
      }
      intYear=fmt00(intYear);
      if (strDatestyle == "US")
      {
         datefield.value = fmt00(intMonth) + "/" + fmt00(intday)+"/" + fmt00(strYear);
      } else
      {
         datefield.value = fmt00(intday) + " " + strMonthArray[intMonth-1] + " " + fmt00(strYear);
      }
      return true;
   }
   function LeapYear(intYear)
   {
      if (intYear % 100 == 0)
      {
         if (intYear % 400 == 0)
         {
            return true;
         }
      } else
      {
         if ((intYear % 4) == 0)
         {
            return true;
         }
      }
      return false;
   }
   function doDateCheck(from, to)
   {
      if (Date.parse(from.value) <= Date.parse(to.value))
      {
         return true;
         //   alert("The dates are valid.");
      } else
      {
         if (from.value == "" || to.value == "")
            alert("Both dates must be entered.");
         else
            alert("To date must occur after the from date.");
      }
   }
   function calcLeadTimeDate(dte,leadDays)
   {
      var sysDate=new Date();
      var dys=sysDate.getDate()+leadDays;
      var dateplusLead = new Date(sysDate.getYear(),sysDate.getMonth(),dys);
      return dateplusLead;
   }
   function checkLeadTime(dte,leadDate)
   {
      var testDate     = new Date(dte.value);
      if ( testDate <= leadDate)
      {
         return false;
      } else
      {
         return true;
      }
   }
   function fmt00(b)
   {
      var d = b.value;
      // fmt00: Tags leading zero onto numbers 0 - 9.
      // Particularly useful for displaying results from Date methods.
      //
      if (parseInt(b) < 0) var neg = true;
      if (Math.abs(parseInt(b)) < 10)
      {
         b = "0"+ Math.abs(b);
      }
      if (neg) b = "-"+b;
      return b;
   }
/**
 * 1/16/04 (SRG) - made changes to clearField(), performSearch(), SearchDetectEnter() and convertSearch() to make
 * the retrieval of fields more generic.  Before we were relying on 'document.forms[0]....', but if we move the 
 * search function to somewhere like the menu bar, then the fields are not in a 'form' and must be retrieved some
 * other way such as 'getElementsByName'.  
 */
   function clearField()
   {
      var searchFld = document.getElementsByName("dsearchText");
      if (searchFld[0].value == "Enter Product#")
      {
         searchFld[0].value="";
      }
//ISM
      searchFld[0].value="";
//ISM
   }
/**
 * Takes the contents of one variable 'qtyFieldName', converts spaces within it, checks for single character keywords
 * and then passes the converted keyword to 'hfield'.  
 */
   function convertSearch(qtyFieldName,hfield)
   {
      var pattern = /\s+/ig;
      var pattern2 = /\"+/ig;
      var formName=document.forms[0].name;
      var sfld=document.getElementsByName(qtyFieldName);
      /* this removes duplicate spaces */
      var _regExp=/\s\s/gi;
      var _foundStr="";
      var newVal=sfld[0].value;
      while (newVal.match(_regExp)!=null)
      {
         _foundStr=newVal.match(_regExp)[0];
         newVal=newVal.replace(new RegExp(_foundStr,"gmi")," ");
      }
      var error=false;
      var nstring=newVal.split(" ");
      for (var i=nstring.length;i>=0;i--)
      {
         if ((nstring[i]!=null ))
         {
            if (nstring[i].length<=1)
            {
               alert("Search Field contains a single Character and must Be corrected before Search Operation");
               error=true;
            }
         }
      }
      /*convert spaces into ^ for transmission */
      newVal=newVal.replace(pattern,"^");
      newVal=newVal.replace(pattern2,"{");
      var tfld=document.getElementsByName(hfield);
      tfld[0].value=newVal;
      if (error)
      {
         return false;
      } else
      {
         return true;
      }
   }
/**
 * Checks if the user hit the enter key.  If we do find the enter key then we run the performSearch() routine.  
 * This method is only used from the search field in advertiseFrame.jsp.  
 */
   function SearchDetectEnter(e)
   {
      var nav4 = window.Event ? true : false;
      
      if (nav4)
      {
         var whichCode = e.which
      } else
      {
         if (e.type=="keypress")
         {
            var whichCode=e.keyCode
         }
      }
      if (e.type == "keypress" && whichCode=="13")
      {
         window.status= "Retrieving Data Please Wait";
         performSearch();
      }
   }
   function performSearch()
   {
      if (convertSearch('dsearchText','searchText'))
      {
         var keywords;
         var searchFld = document.getElementsByName("searchText");
         var refineFld = document.forms[0].refineButton;

         if (refineFld != null)
         {
            if (refineFld.checked == true)
            {
               keywords = searchFld[0].value + "$REFINE$";
            } else
            {
               keywords = searchFld[0].value;
            }
         } else
         {
            keywords = searchFld[0].value;
         }
         if (document.forms[0].req != null)
         {
            document.forms[0].req.value="viaListProducts.jsp?searchText="+keywords+"&modifier=SEARCH&reqTitle=TITLE_VIASEARCHRESULT";
         }
         document.forms[0].action="viaListProducts.jsp?searchText="+keywords+"&modifier=SEARCH&reqTitle=TITLE_VIASEARCHRESULT";
         postIt();
      }
   }
/** Code to place a checkmark for all products in the Delete Item column.
 This code needs to have a hidden field somewhere in the calling .jsp page to 
 work correctly which must be named tableLength and have VALUE equal to the 
 number of dataTable rows
 Ex:  <INPUT TYPE="HIDDEN" NAME="tableLength" VALUE="<%=liRows%>">   
*/
   function DeleteAll()
   {
      var fieldName;
      var formName=document.forms[0].name;
      var qtyField;
      var length = eval("document." + formName + ".tableLength.value");
      for (x=0; x < length; x++)
      {
         qtyField=eval("document."+formName+".icQty_" + x);
         qtyField.value = 0;
         fieldName=eval("document." + formName + ".ptcFlg_" + x);
         if (fieldName != null)
         {
            fieldName.checked=true;
         }
      }
      change();
      postIt();
   }
   function textCounter( field, maxlimit ) 
   {
      if ( field.value.length > maxlimit )
      {
         field.value = field.value.substring( 0, maxlimit );
         alert( 'Text value can only be '+maxlimit+' characters in length.' );
         return false;
      }
   }
   function changeField(FieldName,vlu)
   {

      var formName=document.forms[0].name;
      var txtFld=eval("document."+formName+"."+FieldName);
     // alert("value is "+txtFld.value);
      txtFld.value=vlu;
     // alert("value is "+txtFld.value);
   }

   
