// selectHandler()
// function to handle when a user selects a grade from the drop down list
//
function selectHandler(type, id) {

     if(type == 'processes') {
     
       var url = 'searchProcesses.cfm?type=' + type + '&id=' + id;
     
     }
     
     else if(type == 'applications') {
       
     	// check for automotive
     	if(id == 13)      	
   		var url = 'results.cfm?type1=' + type + '&id1=' + id + '&type2=' + type + '&id2=' + id;
     	else
     		var url = 'searchApps.cfm?type=' + type + '&id=' + id;
     
     }
     
     else if(type == 'polymer_types') {
       
     	// check for automotive    	
    	if(id == 6)      	
		var url = 'results.cfm?type1=' + type + '&id1=' + id + '&type2=' + type + '&id2=' + id;
     	else
	        var url = 'searchTypes.cfm?type=' + type + '&id=' + id;
       
     }
     
     document.location.href = url;       
   
}


function showResults(type1, id1, type2, id2) {

   var url = 'results.cfm?type1=' + type1 + '&id1=' + id1 + '&type2=' + type2 + '&id2=' + id2;
  
   document.location.href = url;

}



// deleteHandler() 
// function to confirm deleting data
//
function deleteHandler(type, name) {

   if(type == 'grades') {
      if(document.adminForm.grades.options.selectedIndex != -1) {
         if (confirm("Are you sure you want to delete this grade?")) 
            document.location.href = "deleteItem.cfm?type=grades&id=" + document.adminForm.grades.options[document.adminForm.grades.options.selectedIndex].value;
      }
      else
         alert('You must first select a grade to delete');
   }
   else if(type == 'applications') {
      if(document.adminForm.applications.options.selectedIndex != -1) { 
         if (confirm("Are you sure you want to delete this application?")) 
            document.location.href = "deleteItem.cfm?type=applications&id=" + document.adminForm.applications.options[document.adminForm.applications.options.selectedIndex].value;
      }
      else
         alert('You must first select an application to delete');   
   }
   else if(type == 'product_types') {
      if(document.adminForm.product_types.options.selectedIndex != -1) {
         if (confirm("Are you sure you want to delete this product type?")) 
            document.location.href = "deleteItem.cfm?type=product_types&id=" + document.adminForm.product_types.options[document.adminForm.product_types.options.selectedIndex].value;
      }
      else
         alert('You must first select a product type to delete');   
   }
   
}



// editHandler() 
// function to confirm deleting data
//
function editHandler(type, name) {

   if(type == 'grades') {
      if(document.adminForm.grades.options.selectedIndex != -1) 
         document.location.href = "editItem.cfm?type=grades&id=" + document.adminForm.grades.options[document.adminForm.grades.options.selectedIndex].value;
      else
         alert('You must first select a grade to edit');
   }
   else if(type == 'applications') {
      if(document.adminForm.applications.options.selectedIndex != -1)  
         document.location.href = "editItem.cfm?type=applications&id=" + document.adminForm.applications.options[document.adminForm.applications.options.selectedIndex].value;
      else
         alert('You must first select an application to edit');   
   }
   else if(type == 'product_types') {
      if(document.adminForm.product_types.options.selectedIndex != -1) 
         document.location.href = "editItem.cfm?type=product_types&id=" + document.adminForm.product_types.options[document.adminForm.product_types.options.selectedIndex].value;
      else
         alert('You must first select a product type to edit');   
   }
   
}



// displayMessage()
// function to present the user with an alert box
//
function displayMessage(msg) {
  if (msg != '') 
    alert(msg)
}
