function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i>d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_nbGroup(event, grpName) { //v3.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : args[i+1];
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    if ((nbArr = document[grpName]) != null)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = args[i+1];
      nbArr[nbArr.length] = img;
  } }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i>a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function doComments(stockNumber) {
  window.open("comments.jsp?stockNumber="+stockNumber,"comments","personalbar=no,toolbar=no,status=no,scrollbars=yes,location=no,resizable=yes,menubar=no,top=130,left=150,width=420,height=365"); 
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

function isQuantityValid(item) {
  if (!(isInteger(item.value) || isWhitespace(item.value))) {
    item.focus();
    item.select();
    alert("Please enter only positive integers for the quantity.");
    return false;
  }
  return true;
}

function isQuantityOk(stockno, quantity) {
  if (!isWhitespace(stockno.value) && isWhitespace(quantity.value)) {
    quantity.focus();
    quantity.select();
    alert("Please enter a value for the quantity.");
    return false;
  }
  return true;
}

function encode(str) {
  var i;
  var returnString = "";
  for (i = 0; i < str.length; i++)
  {   
    var c = str.charAt(i);

    if (((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) ||
        ((c >= "0") && (c <= "9")) || 
        c == "-" || c == "_" || c == "." || c == "*" || c == "+") {
      returnString += c;
    } else {
      holdString = "%" + str.charCodeAt(i).toString(16);
      returnString += holdString;
    }
  }

  return returnString;
}

function doSubmit(target) {
  var form = window.document.BodyForm;
  form.target.value = target;
  form.submit();
}

function doPrevNext(target, field) {
  var form = window.document.BodyForm;
  var form2 = window.document.BodyForm;
  if (isWhitespace(form.SearchString.value))
    form2.target.value = target;
  else
    form2.target.value = target + "&SearchString=" + encode(field.value);
  form2.submit();
}

function doSearch(field) {
  var form = window.document.BodyForm;
  var list = form.check1.value;
  if (isWhitespace(form.SearchString.value)) {
    form.SearchString.focus();
    form.SearchString.select();
    alert("Please enter a value for the search string.");
    return;
  }

  if (list == "2")
    form.target.value = 'OrderPad.jsp?action=search' + "&SearchString=" + encode(field.value) +
                         "&SearchPrev=yes";
  else
    form.target.value = 'OrderPad.jsp?action=search' + "&SearchString=" + encode(field.value) +
                         "&SearchPrev=no";
  form.submit();
}

function doEnter(field) {
  if (window.event && window.event.keyCode == 13) {
    var form = window.document.BodyForm;
	var list = form.check1.value;
    if (isWhitespace(form.SearchString.value)) {
      form.SearchString.focus();
      form.SearchString.select();
      alert("Please enter a value for the search string.");
      return;
    }
    if (list == "2")
      form.target.value = 'OrderPad.jsp?action=search' + "&SearchString=" + encode(field.value) +
                           "&SearchPrev=yes";
    else
      form.target.value = 'OrderPad.jsp?action=search' + "&SearchString=" + encode(field.value) +
                           "&SearchPrev=no";
    form.submit();
  } else {
    return true;
  }
}

function doNewLookup() {
  var form = window.document.OrderPadLookup;
  var savedItem = null;

  for (var i = 0; i < form.elements.length; i++) {
    var item = form.elements[i];
    if (item.type == "text") {
      if (!isWhitespace(item.value)) {
         savedItem = item;
         break;
      }
    }
  }

  if (window.document.OrderPadLookup.Source[0].checked == true)
    source = window.document.OrderPadLookup.Source[0].value;
  else if (window.document.OrderPadLookup.Source[1].checked == true)
    source = window.document.OrderPadLookup.Source[1].value;
  else if (window.document.OrderPadLookup.Source[2].checked == true)
    source = window.document.OrderPadLookup.Source[2].value;
  else {
    alert("Please select the list type for the lookup.");
    return;
  }

  if (savedItem == null) {
    doSubmit("OrderPad.jsp?action=lookup&ItemSource=" + source);
  } else {
    doSubmit("OrderPad.jsp?action=lookup&ItemIndex=" + savedItem.name + "&ItemValue=" + encode(savedItem.value) + "&ItemSource=" + source);
  }
}

function doOnChange(thisItem) {
  if (!isWhitespace(thisItem.value)) {
    var form = window.document.OrderPadLookup;
    for (var i = 0; i < form.elements.length; i++) {
      var testItem = form.elements[i];
      if (testItem.type == "text") {
        if (testItem != thisItem)
          testItem.value = "";
      }
    }
  }
}

var tearWin = null;

function tearoff(url) {
  if ((tearWin != null) && (!tearWin.closed))
    tearWin.close();
  tearWin = window.open(url, "name", 'personalbar=no,toolbar=no,status=no,scrollbars=yes,location=no,resizable=yes,menubar=no,width=515,height=480');
}

function clearCart() {
  	if (confirm("Are you sure you would like to remove all items from the shopping cart?")) {
	    doSubmit('customerinfo.jsp?action=clear');
	}
}

var message = "Please go back and make the correction before continuing.";

function checkOrderPad() {
     if (window.document.BodyForm.message.value!="") {
	    alert("Please go back and make the correction before continuing.");
	    return;
	  } else {
	    doSubmit('OrderPad.jsp'); 
	  }
}	

function checkManualEntry() {
     if (window.document.BodyForm.message.value!="") {
	    alert("Please go back and make the correction before continuing.");
	    return;
	  } else {
	    doSubmit('manualentry.jsp'); 
	  }
}	 

function checkOrderReview() {
     if (window.document.BodyForm.message.value!="") {
	    alert("Please go back and make the correction before continuing.");
	    return;
	  } else {
	    doSubmit('OrderReview'); 
	  }
}

function checkOrderClear() {
	   clearCart();
}	 

function checkOrderHistory() {
     if (window.document.BodyForm.message.value!="") {
	    alert("Please go back and make the correction before continuing.");
	    return;
	  } else {
	    doSubmit('OrdersForCustomer'); 
	  }
}

function checkHelp() {
     if (window.document.BodyForm.message.value!="") {
	    alert("Please go back and make the correction before continuing.");
	    return;
	  } else {
	    showHelp(); 
	  }
}	

function checkGo() { 
  doSearch(window.document.BodyForm.SearchString);
}

if (navigator.appName == "Microsoft Internet Explorer") {
   document.write("<link rel='stylesheet' href='tech.css' type='text/css'>");
}
if(navigator.appName == "Netscape") {
   document.write("<link rel='stylesheet' href='netscape.css' type='text/css'>");
}

function doFieldActive(field) {
  field.className = "bodyValuesFocus";
} 	

function doFieldInactive(field) {
  field.className = "bodyValues";
}

function showContact() {
 var tmp = window.showModalDialog("contact.jsp","","dialogWidth=620px;dialogHeight:300px;center:yes;edge:raised;help:no;resizable:yes;status:no;scroll:yes");
} 

function showHelp(url) {
  var tmp = window.showModalDialog(url,"","dialogWidth=800px;dialogHeight:590px;center:yes;edge:raised;help:no;resizable:yes;status:no;scroll:yes");
}

function setSearchValue(inVal) {
  var f = document.BodyForm;
  f.SearchString.value = inVal;
  checkGo();
}

function showCatalogForm() {
 window.open("http://www.bestbuyfloral.com/catalog_request_form.htm", "CatalogForm", 'personalbar=no,toolbar=no,status=no,scrollbars=yes,location=no,resizable=yes,menubar=no,top=10,left=10,width=680,height=580');
}
