function openBrWindow(theURL,winName,features,formid) { //v2.0

/*
This routine creates a pop-up window, and ensures that it takes focus. It is
intended to be called from an anchor tag.

Calling sequence:

<a href="theURL"
        onclick="return openBrWindow('theURL','winName','features', formid)" >
  Text of link
</a>
features can= scrollbars=yes,resizable=yes,top=10,left=10,width=550,height=500 etc.
*/
  var ptxt1 = eval("document."+formid+".ItemTxt1");
  var ptxt2 = eval("document."+formid+".ItemTxt2");
  var ptxt3 = eval("document."+formid+".ItemTxt3");
  var ptxt4 = eval("document."+formid+".ItemTxt4");
  var popt1 = eval("document."+formid+".ItemOpt1");
  var popt2 = eval("document."+formid+".ItemOpt2");
  var popt3 = eval("document."+formid+".ItemOpt3");
  var popt4 = eval("document."+formid+".ItemOpt4");
  var pqty  = eval("document."+formid+".ItemQty ");
  if (ptxt1)   var qtxt1 = ptxt1.value;   else qtxt1 = " ";
  if (ptxt2)   var qtxt2 = ptxt2.value;   else qtxt2 = " ";
  if (ptxt3)   var qtxt3 = ptxt3.value;   else qtxt3 = " ";
  if (ptxt4)   var qtxt4 = ptxt4.value;   else qtxt4 = " ";
  if (popt1)   var qopt1 = popt1.value;   else qopt1 = " ";
  if (popt2)   var qopt2 = popt2.value;   else qopt2 = " ";
  if (popt3)   var qopt3 = popt3.value;   else qopt3 = " ";
  if (popt4)   var qopt4 = popt4.value;   else qopt4 = " ";
  if (pqty)    var qqty  = pqty.value;    else qqty  = " ";

  qtxt1 = encodeURI(qtxt1);
  qtxt2 = encodeURI(qtxt2);
  qtxt3 = encodeURI(qtxt3);
  qtxt4 = encodeURI(qtxt4);
  qopt1 = encodeURI(qopt1);
  qopt2 = encodeURI(qopt2);
  qopt3 = encodeURI(qopt3);
  qopt4 = encodeURI(qopt4);

  var extras = "&ThisTxt1="+qtxt1+"&ThisTxt2="+qtxt2+"&ThisTxt3="+qtxt3+"&ThisTxt4="+qtxt4+"&ThisOpt1="+qopt1+"&ThisOpt2="+qopt2+"&ThisOpt3="+qopt3+"&ThisOpt4="+qopt4+"&ThisQty="+qqty;
  var FullUrl = theURL + extras;
//  alert(FullUrl);
  var imageWindow = window.open(FullUrl,winName,features);
  if (window.focus) imageWindow.focus();
  return false;
}

function NewUrl(theURL,formid,ProdType) { //v2.0
/*
This routine creates a url with form data included. It is intended to be called from an anchor tag.

Calling sequence:

<a href="theURL"
        onclick="return openBrWindow('theURL','winName','features', formid)" >
  Text of link
</a>

Note Prod types are
1, no centres, lasers, ribbons
2, 4 centres
3, centres
4, lasers
5, ribbons
6, centres and ribbons

*/
  var qitemcentre     = "";
  var qitemcentre0    = "";
  var qitemcentre1    = "";
  var qitemcentre2    = "";
  var qitemcentre3    = "";
  var qselectedcentre = "";
  var qselectedlaser  = "";
  var qselectedribbon = "";

  switch (ProdType)
  { case 1: {
               break;
            }
    case 2: {
               var pitemcentre0 = eval("document."+formid+".ItemCentre[0]");
               var pitemcentre1 = eval("document."+formid+".ItemCentre[1]");
               var pitemcentre2 = eval("document."+formid+".ItemCentre[2]");
               var pitemcentre3 = eval("document."+formid+".ItemCentre[3]");
               if (pitemcentre0) { if (pitemcentre0.checked == true )    qitemcentre = pitemcentre0.value    ; }
               if (pitemcentre1) { if (pitemcentre1.checked == true )    qitemcentre = pitemcentre1.value    ; }
               if (pitemcentre2) { if (pitemcentre2.checked == true )    qitemcentre = pitemcentre2.value    ; }
               if (pitemcentre3) { if (pitemcentre3.checked == true )    qitemcentre = pitemcentre3.value    ; }
               break;
            }
    case 3: {
               var pselectedcentre = eval("document."+formid+".SelectedCentre ");
               if (pselectedcentre)    qselectedcentre = pselectedcentre.value;   else qselectedcentre = "";
               break;
            }
    case 4: {
               var pselectedlaser  = eval("document."+formid+".SelectedLaser  ");
               if (pselectedlaser )    qselectedlaser  = pselectedlaser.value ;   else qselectedlaser  = "";
               break;
            }
    case 5: {
               var pselectedribbon = eval("document."+formid+".SelectedRibbon ");
               if (pselectedribbon)    qselectedribbon = pselectedribbon.value;   else qselectedribbon = "";
               break;
            }
    case 6: {
               var pselectedcentre = eval("document."+formid+".SelectedCentre ");
               var pselectedribbon = eval("document."+formid+".SelectedRibbon ");
               if (pselectedcentre)    qselectedcentre = pselectedcentre.value;   else qselectedcentre = "";
               if (pselectedribbon)    qselectedribbon = pselectedribbon.value;   else qselectedribbon = "";
               break;
            }
  }

  var psofar     = eval("document."+formid+".QtySoFar" );
  var ptotal     = eval("document."+formid+".TotalQty" );
  var pitemid    = eval("document."+formid+".ItemID"   );
  var psectcodea = eval("document."+formid+".SectCodeA");
  var pqty       = eval("document."+formid+".ItemQty"  );
  if (psofar    )  var qsofar     = psofar.value        ;   else qsofar     = "";
  if (ptotal    )  var qtotal     = ptotal.value        ;   else qtotal     = "";
  if (pitemid   )  var qitemid    = pitemid.value       ;   else qitemid    = "";
  if (psectcodea)  var qsectcodea = psectcodea.value    ;   else qsectcodea = "";
  if (pqty      )  var qqty       = pqty.value          ;   else qqty       = "";

  var ptxt1 = eval("document."+formid+".ItemTxt1");
  var ptxt2 = eval("document."+formid+".ItemTxt2");
  var ptxt3 = eval("document."+formid+".ItemTxt3");
  var ptxt4 = eval("document."+formid+".ItemTxt4");
  var popt1 = eval("document."+formid+".ItemOpt1");
  var popt2 = eval("document."+formid+".ItemOpt2");
  var popt3 = eval("document."+formid+".ItemOpt3");
  var popt4 = eval("document."+formid+".ItemOpt4");
  if (ptxt1)   var qtxt1 = ptxt1.value;   else qtxt1 = "";
  if (ptxt2)   var qtxt2 = ptxt2.value;   else qtxt2 = "";
  if (ptxt3)   var qtxt3 = ptxt3.value;   else qtxt3 = "";
  if (ptxt4)   var qtxt4 = ptxt4.value;   else qtxt4 = "";
  if (popt1)   var qopt1 = popt1.value;   else qopt1 = "";
  if (popt2)   var qopt2 = popt2.value;   else qopt2 = "";
  if (popt3)   var qopt3 = popt3.value;   else qopt3 = "";
  if (popt4)   var qopt4 = popt4.value;   else qopt4 = "";
  qtxt1 = encodeURI(qtxt1);
  qtxt2 = encodeURI(qtxt2);
  qtxt3 = encodeURI(qtxt3);
  qtxt4 = encodeURI(qtxt4);
  qopt1 = encodeURI(qopt1);
  qopt2 = encodeURI(qopt2);
  qopt3 = encodeURI(qopt3);
  qopt4 = encodeURI(qopt4);

  var extras = "&QtySoFar="+qsofar+"&TotalQty="+qtotal+"&ItemID="+qitemid+"&ItemCentre="+qitemcentre;
      extras =  extras+"&SelectedCentre="+qselectedcentre +"&SelectedLaser="+qselectedlaser+"&SelectedRibbon="+qselectedribbon;
      extras =  extras+"&SectCodeA="+qsectcodea;
      extras =  extras+"&ThisTxt1="+qtxt1+"&ThisTxt2="+qtxt2+"&ThisTxt3="+qtxt3+"&ThisTxt4="+qtxt4;
      extras =  extras+"&ThisOpt1="+qopt1+"&ThisOpt2="+qopt2+"&ThisOpt3="+qopt3+"&ThisOpt4="+qopt4+"&ThisQty="+qqty;

  var FullUrl = theURL + extras;
//  alert(FullUrl);
  window.location = FullUrl;
  return false;
}


function openPopup (imageURL, caption) {

/*
This routine creates a pop-up window, and ensures that it takes focus. It is
intended to be called from an anchor tag. The new window will resize itself to
the optimum size, so we make it as large as the largest required window to
overcome bugs in various manifestations of various browsers.

Author:   John Gardner
Written:  8th November 2003
Updated:  27th January 2004

Calling sequence: <a href="a.jpg" onClick="return openPopup('a.jpg','Caption');">

The first parameter is the URL of the image to be opened, and the second
parameter is the caption for the image which is displayed in the window title
and in the alt property of the image tag.

Note that the calling sequence will simply open the image in the main window if
JavaScript isn't enabled.

*/

  // Constants - change these to suit your requirements Note that the defaultWidth
  // and defaultHeight variables should be set to more than your largest image to
  // overcome a bug in Mozilla (at least up to Firefox 0.9).

  var windowTop = 10;                // Top position of popup
  var windowLeft = 10                // Left position of popup
  var defaultWidth = 500;             // Default width (for browsers that cannot resize)
  var defaultHeight = 550;            // Default height (for browsers that cannot resize)
  var onLoseFocusExit = false;         // Set if window to exit when it loses focus
  var undefined;

  // Set up the window open options
  var Options = "width=" + defaultWidth + ",height=" + defaultHeight + ",top=" + windowTop + ",left=" + windowLeft + ",resizable,scrollbars"

  // Now write the HTML markup to the new window, ensuring that we insert the
  // parameter URL of the image and the parameter description of the image in
  // the right place.
  var myScript = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n" +
    "<html>\n" +
    "<head>\n" +
    "<title>" + caption + "\</title>\n" +
    "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\n" +
    "<meta http-equiv=\"Content-Language\" content=\"en-gb\">\n" +
    "<script language=\"JavaScript\" type=\"text/javascript\">\n" +
    "function resizewindow () {\n" +
    "  var width = document.myimage.width;\n" +
    "  var height = document.myimage.height;\n";

  // Netscape
  if (navigator.appName.indexOf("Netscape") != -1) {
    myScript = myScript +  "  window.innerHeight = height;\n  window.innerWidth = width;\n"
  }

  // Opera
  else if (navigator.appName.indexOf("Opera") != -1) {
    myScript = myScript +  "  window.resizeTo (width+12+25, height+31+25);\n"
  }

  // Microsoft
  else if (navigator.appName.indexOf("Microsoft") != -1) {
    myScript = myScript + "  window.resizeTo (width+12+25, height+31+50);\n"
  }

  // Assume a frig factor for any other browsers
  else {
    myScript = myScript + "  window.resizeTo (width+14+25, height+34+25);\n"
  }

  myScript = myScript + "}\n" + "window.onload = resizewindow;\n" +
    "</script>\n</head>\n" + "<body ";

  // If the window is required to close when it loses focus.
  if (onLoseFocusExit) {myScript = myScript + "onblur=\"self.close()\" ";}

  myScript = myScript + "style=\"margin: 0px; padding: 0px;\">\n" +
    "<div align='center'><img src=\"" + imageURL + "\" alt=\"" + caption + "\" title=\"" + caption + "\" name=\"myimage\">\n" +
    "</div></body>\n" +  "</html>\n";

  // Diagnostic - uncomment the next line if you wish to see the script generated.
  //alert (myScript);

  // Create the popup window
  var imageWindow = window.open ("","imageWin",Options);
  imageWindow.document.write (myScript);
  imageWindow.document.close ();
  if (window.focus) imageWindow.focus();
  return false;
}