// JavaScript Document
<!-- Begin
//-----------------------------------------------------------------------------------------
//This function makes checkboxes behave like radio buttons.  This is helpful for several   
//reasons.  The user can tab through each check box.  With radio buttons, the user can only
//tab to the first radio box.  Also, the user can uncheck a box.  This is not possible with
//radio buttons.  Once one is clicked, it stays clicked (unless you want to write some     
//scripts to deal with it.                                                                 
//-----------------------------------------------------------------------------------------
function radioCheckboxGroup (checkbox) 
{
   var checkboxGroup = checkbox.form[checkbox.name];
	
	
   //Loop through the checkboxes.                                                          
   for (var c = 0; c < checkboxGroup.length; c++)
   {	
   //If it is not the checkbox that was passed in, uncheck it.		                         
      if (checkboxGroup[c] != checkbox)
      {
   		checkboxGroup[c].checked = false;
		
		}
   }		
}
//conflict for msu-purpose & responsibilities
// group 0 really
var conflictGroup0 = new Array ("diffconv","cmecfv311","lrnstyle1","corevalu1","retiremnt1","decimake","strongemo","coutreach1");
// group 1 really
var conflictGroup1 = new Array ("provship1","lrnstyle2","msucourt","mstrybnc1","tsptreas1","stratwrk1","credcnsl1");
// group 6
var conflictGroup2 = new Array ("provship2","mstrybnc2","corevalu2","credcnsl2","lovehate","retiremnt2","msucourtcont");
//conflicts for winds that blow section 1
// group 3 really
var conflictGroup3 = new Array ("stratwrk2","coutreach2","cmecfv312","tsptreas2","lovehate","thankgod");
//conflict for msu-purpose & responsibilities
var conflictGroup4 = new Array ("msucm1","itpa1","tlc2","scwg2","gtj2","wnkm2");
var conflictGroup5 = new Array ("msucm1","frp3","itpa2","fp3","sag2","tdbc2","lfys2");
var conflictGroup6 = new Array ("msucm1","frp4","wigj1","yycr1","cylp2","cffle2");
var conflictGroup7 = new Array ("msucm1","cpd1","ryws2","yycr2","wigj2","cwii2","wbdd5","cmos1");
// conflicts for winds that blow section 2
var conflictGroup8 = new Array ("wbdd3","itpa1","tlc2","scwg2","gtj2","wnkm2");
var groups =9;



// This function  used to check class conflicts
function checkConflict(checkbox)
{

// value of the clicked checked box
var checkval =checkbox.value;
// name of the check box group that the clicked check box is a memeber of
var checkboxGroup = checkbox.name;
//alert(checkboxGroup);
var elementsInForm=document.form.elements.length;
//1. loop thru the conflict groups
for (k=0; k<groups;k++)
{
  // 2. check the checkbox against a conflictGroup 
  if (isInConflictGroup(k,checkval))
  {
    // 3. if the checkbox in in the conflict check every other checkbox... make sure not in same conflict group
    for (i = 0; i < elementsInForm; i++)
    {
      if (document.form.elements[i].type =="checkbox" && 
	    document.form.elements[i].name!=checkboxGroup &&
		 isInConflictGroup(k, document.form.elements[i].value) &&
		  document.form.elements[i].checked)
	     {
         alert("This class conflicts with another currently selected class"  );
	     checkbox.checked =false;
          }
     }
  }
}

}

function isInConflictGroup(i,choice)
{

 var length = eval("conflictGroup" + i).length;
 var found =false;
 for ( j=0; j< length; j++)
 {
  if (eval("conflictGroup" + i)[j]==choice)
    found=true;

 }
 return found;
}
//  End -->