// Custom Open Window Routines
var rptWindow;

function newWindow(newlocation)
{
   if(rptWindow) {
      rptWindow.close();
   }

   rptWindow = window.open(newlocation,'rptWindow','width=700,height=700,scrollbars=yes,toolbar=no,resizable=yes');
}

function detailWindow(newlocation)
{
   if(rptWindow) {
      rptWindow.close();
   }

   rptWindow = window.open(newlocation,'rptWindow','width=500,height=600,scrollbars=no,toolbar=no,resizable=yes');
}

function getProduct()
{
   // Do some basic validation of form.  User must choose one of the options.
   var txtLbsID = 'NULL';
   for(var i = 0; i < document.frmFindCameraCase.rdoLbsID.length; i++) {
      if(document.frmFindCameraCase.rdoLbsID[i].selected) {
         txtLbsID = document.frmFindCameraCase.rdoLbsID[i].value;
      }
   }

   var txtCCID = 'NULL';
   for(var i = 0; i < document.frmFindCameraCase.cboCCID.length; i++) {
      if(document.frmFindCameraCase.cboCCID[i].selected) {
         txtCCID = document.frmFindCameraCase.cboCCID[i].value;
      }
   }

   var txtLength = document.frmFindCameraCase.txtLength.value;
   var txtWidth = document.frmFindCameraCase.txtWidth.value;
   var txtDepth = document.frmFindCameraCase.txtDepth.value;
   var optionsSelected = 0;

   // Validate input
   if(txtLbsID != 'NULL')
      optionsSelected++;

   if(txtCCID != 'NULL')
      optionsSelected++;

   if((txtLength.length > 0) || (txtWidth.length > 0) || (txtDepth.length > 0))
      optionsSelected++;

   if(optionsSelected == 0) {
      alert('You must choose one of the options to continue.');
      return false;
   }

   if(optionsSelected > 1) {
      alert('Multiple options seleted.  You must choose one of the options to continue.');
      return false;
   }

   if((txtLbsID == 'SKIP') || (txtCCID == 'SKIP')) {
      document.frmFindCameraCase.action = '/products/lenscases.asp';
   }

   // Execute form
   document.frmFindCameraCase.submit();
}
