// Set the selected option for a combo box
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 openWin(name, url, w, h, scbr, rz) {
   ref = window.open(url,name,'toolbar=no,location=0,directories=no,status=yes,menubar=no,scrollbars='+scbr+',resizable='+rz+',copyhistory=0,width='+w+',height='+h);   
   ref.focus();
}

// 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;
      }
    }
}

