// basket.js

// Scripts for use in basket.php


  // Initially, no element has the focus and we don't want to bypass the onUnload() checks
  focusElement = '';

  //bypassUnloadChecks = 0;

  function setPosition( postop, posleft ) {
    document.body.scrollTop  = postop;
    document.body.scrollLeft = posleft;
    //<?php if ( $formfocus ) echo "document.basketform.$formfocus.focus();\n    if ( document.basketform.$formfocus.type == 'text' ) \n     document.basketform.$formfocus.select();\n"; ?>
  }

  function trackFocus( element ) {
    focusElement = element;
  }
  
  function doSubmit() {
    document.basketform.scrolltop.value = document.body.scrollTop;
    document.basketform.scrollleft.value = document.body.scrollLeft;
    document.basketform.qtyfocus.value = focusElement.name;
    document.basketform.submit();
  }
  
  function doLink( linkurl ) {
    linkurl = linkurl + "&top=" + document.body.scrollTop  + "&left=" + document.body.scrollLeft;
    location.href = linkurl;
  }
  
  function viewWine( wineid ) {
    settings = "width=400,height=300,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=0";
    popupWindow = window.open( "viewwine.php?id=" + wineid, "Wine", settings );
    popupWindow.focus();
  }
  
  function viewOffer( offerid ) {
    settings = "width=400,height=300,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=0";
    popupWindow = window.open( "viewoffer.php?id=" + offerid, "Offer", settings );
    popupWindow.focus();
  }
  
  function changeQuantity( offerid ) {
    settings = "width=300,height=250,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=0";
    popupWindow = window.open( "changequantity.php?id=" + offerid, "Offer", settings );
    popupWindow.focus();
  }
