// Updates the number of equipment 
function updateEquipmentAmount(form, aID) {
   if(form != null) {
      form.aID.value = aID;
      form.submit();
   }
}

function setSelectedItem(field, val) {
   if(field != null && val != "") {
      field.selectedIndex = getSelectedIndex(field, val);
   }
}

// Return the selected item
function getSelectedIndex(obj, val) {
   if(obj != null) {
      for(i=0; i<obj.options.length; i++) {
          if(obj.options[i].value == val) {
             return i;
 	  }
      }
   }
   return 0;
}

// Opens a window to display a brochure
function openBrochure(url) {
   window.open(url,'','toolbar=no,location=0,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=0,width=760,height=580');   
}

// Open a preview window to show an image
function openImagePreview(url, image, desc) {
   nUrl = url+"?image="+image+"&desc="+desc;
   window.open(nUrl,'ImagePreviewWin','toolbar=no,location=0,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=0,width=250,height=300');   
}

// Confirms the detetion of an item
function confirmDelete(url, msg) {
   if(url != "" && msg != "") {
      if(confirm(msg)) {
         window.location = url;
      }
    }
}

// Opens a contacts window
function requestContact(url) {
   window.open(url,'','toolbar=no,location=0,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=0,width=360,height=600');   
}