var winOpenOpts = "\'toolbar=0,location=0,directories=0,status=no," +
                  "menubar=0,scrollbars=1,resizable=1,copyhistory=0," +
		  "width=300,height=250\'";

var unit = "";
var adname = "";
var ademail = "";

// ///////////////////////////////////////////////////////////////////////////
function iut_open ( what ) {
// Open a new window.  Use for consistant sizing.
  window.open( what,'iut',winOpenOpts);
}


// ///////////////////////////////////////////////////////////////////////////
function req_plan ( ) {
// REQUEST FORM - Open the appropriate list of plans based on the major
  if (document.iut.newunit.selectedIndex > 0) {
       iut_open("plan_" +	
	        (document.iut.newunit.options[document.iut.newunit.selectedIndex].value.substring(0,2)).toLowerCase() + 
		".html" );
  }
  else {
       alert("You must select the unit you wish to transfer to, before you can choose your major.");
	document.iut.newunit.focus();
  }

}


// ///////////////////////////////////////////////////////////////////////////
function def_adv ( ) {
// Define advisor's name and email based on advisor id
  if (document.iut.advID.value.length != 7) {
      alert("You must supply the advisor's empl id, which is seven digits in length.");
      document.iut.advID.focus();
  }
  else {
  switch (document.iut.advID.value) {
    case "9000001" : unit    = "AS";
                     adname  = "Test,AS";
	 	     ademail = "l0brag01@louisville.edu";
		     break;
    case "9000002" : unit    = "BU";
                     adname  = "Test,BU";
	 	     ademail = "l0brag01@louisville.edu";
		     break;
    case "9000003" : unit    = "ED";
                     adname  = "Test,ED";
	 	     ademail = "l0brag01@louisville.edu";
		     break;
    case "9000004" : unit    = "MU";
                     adname  = "Test,MU";
	 	     ademail = "l0brag01@louisville.edu";
		     break;
    case "9000005" : unit    = "NU";
                     adname  = "Test,NU";
	 	     ademail = "l0brag01@louisville.edu";
		     break;
    case "9000006" : unit    = "SS";
                     adname  = "Test,SS";
	 	     ademail = "l0brag0101@louisville.edu";
    case "9000007" : unit    = "ZZ";
		     adname  = "Braggs,Lamar";
	             ademail = "l0brag0101@gwise.louisville.edu";
			break;
    case "9000008" : unit    = "DS";
                     adname  = "Test,DS";
	 	     ademail = "l0brag01@louisville.edu";
		     break;
	case "9000009" : unit    = "SW";
                     adname  = "Test,SW";
	 	     ademail = "l0brag01@louisville.edu";
		     break;
    case "1023424" : unit    = "AS";
		     adname  = "Rohmann,Meg";
		     ademail = "m0rohm01@gwise.louisville.edu";
		     break;
			 case "1028819" : unit    = "AS";
		     adname  = "Forney,Beth";
		     ademail = "emforn01@gwise.louisville.edu";
		     break;
    case "1112871" : unit    = "AS";
		     adname  = "Noffke,Maggie";
		     ademail = "mlnoff01@gwise.louisville.edu";
		     break;
    case "1026172" : unit    = "AS";
		     adname  = "Schoening,Ellen";
		     ademail = "e0scho01@gwise.louisville.edu";
		     break;
    case "1024683" : unit    = "BU"; 
	             adname  = "Bell,Jane";
		     ademail = "jlbell01@gwise.louisville.edu";
                     break;	 
    case "1028087" : unit    = "BU"; 
	             adname  = "Williams,Wendell";
		     ademail = "will01@gwise.louisville.edu";
                     break;	 
    case "1024159" : unit    = "BU"; 
	             adname  = "Payton,Danielle";
		     ademail = "dnpayt01@gwise.louisville.edu";
                     break;	 
    case "1022481" : unit    = "BU"; 
	             adname  = "Hawkins,Carol";
		     ademail = "cahawk01@gwise.louisville.edu";
                     break;	 
    case "1028815" : unit    = "BU"; 
	             adname  = "McAllister,Victoria";
		     ademail = "vlmcal01@gwise.louisville.edu";
                     break;	 
    case "1028672" : unit    = "BU"; 
	             adname  = "Raisor,Kathleen";
		     ademail = "k0rais01@gwise.louisville.edu";
                     break;	 
    case "1028055" : unit    = "BU"; 
	             adname  = "Meyer,Ann";
		     ademail = "ammeye01@gwise.louisville.edu";
                     break;	 
    case "1027548" : unit    = "BU"; 
	             adname  = "Smith,Linda";
		     ademail = "lwsmit01@gwise.louisville.edu";
                     break;	 
    case "1025681" : unit    = "BU"; 
	             adname  = "Allen,Nora";
		     ademail = "nkalle01@gwise.louisville.edu";
                     break;	 
    case "1234709" : unit    = "ED";
                     adname  = "Armstrong, Kirsten";
                     ademail = "kaschm01@gwise.louisville.edu";
                     break;
    case "1051717" : unit    = "ED";
		     adname  = "Cox,Kristin";
		     ademail = "klmatt01@louisville.edu";
		     break;
    case "1026365" : unit    = "ED";
		     adname  = "Hampton,Betty";
		     ademail = "blhamp01@gwise.louisville.edu";
		     break;
    case "1591279" : unit    = "ED";
		     adname  = "Johnson,Tia";
		     ademail = "t0duma02@gwise.louisville.edu";
		     break;
    case "1023641" : unit    = "ED";
		     adname  = "Barrow,Il";
		     ademail = "iybarr01@gwise.louisville.edu";
		     break;
    case "1439160" : unit    = "ED";
		     adname  = "King,John";
		     ademail = "j0king0101@gwise.louisville.edu";
		     break;
    case "1116555" : unit    = "ED";
		     adname  = "Wagner,Laura";
		     ademail = "llwagn01@louisville.edu";
		     break;
    case "1028065" : unit    = "ED";
		     adname  = "Dorsey,Robin";
		     ademail = "rldors01@gwise.louisville.edu";
		     break;
    case "1025264" : unit    = "ED";
		     adname  = "Boots,Greg";
		     ademail = "gmboot01@gwise.louisville.edu";
		     break;
    case "1027533" : unit    = "ED";
		     adname  = "Morkin,Jody";
		     ademail = "jjmork01@gwise.louisville.edu";
		     break;
    case "1354791" : unit    = "ED";
		     adname  = "Bergman,Mathew";
		     ademail = "mjberg04@gwise.louisville.edu";
		     break;
    case "1281451" : unit    = "MU";
		     adname  = "Cade,Blair";
		     ademail = "b0cade01@louisville.edu";
		     break;
    case "1024636" : unit    = "MU";
		     adname  = "Loree,Lizbeth";
		     ademail = "lalore01@gwise.louisville.edu";
		     break;
    case "1266584" : unit    = "ED";
                     adname  = "Boam,Melissa";
                     ademail = "mawale01@gwise.louisville.edu";
                     break;
	case "1593613" : unit    = "ED";
                     adname  = "Stout,Julie";
                     ademail = "jastou02@gwise.louisville.edu";
                     break;
    case "1278588" : unit    = "NU";
		     adname  = "Pack,Alona"; 
		     ademail = "ahpack01@gwise.louisville.edu";
		     break;
    case "1027788" : unit    = "NU";
		     adname  = "Frost,Laura"; 
		     ademail = "llfros01@gwise.louisville.edu";
		     break;
    case "1585059" : unit    = "NU";
		     adname  = "Landis,WmJustin";
    		     ademail = "wjland01@gwise.louisville.edu";
		     break;
    case "1046294" : unit    = "NU";
		     adname  = "Cantrell,Steve";
    		     ademail = "lscant01@gwise.louisville.edu";
		     break;
    case "1114070" : unit    = "NU";
                     adname  = "Bailey,Becky";
                     ademail = "bkbail01@gwise.louisville.edu";
                     break;
    case "1313679" : unit    = "NU";
                     adname  = "Hart,Trish";
                     ademail = "p0hart01@louisville.edu";
                     break;
	case "1340397" : unit    = "NU";
                     adname  = "Larkin,Megan";
                     ademail = "melark01@louisville.edu";
                     break;
    case "1029168" : unit    = "SS";
		     adname  = "Frank,Marita";
		     ademail = "marita.frank@louisville.edu";
		     break;
    case "1025141" : unit    = "SS";
		     adname  = "Best,Susan";
		     ademail = "smbest01@gwise.louisville.edu";
		     break;
    case "1022801" : unit    = "SS";
		     adname  = "Harris,Mike";
		     ademail = "mrharr01@gwise.louisville.edu";
		     break;
    case "1028090" : unit    = "SS";
		     adname  = "Lochner,Vivian";
		     ademail = "v0loch01@gwise.louisville.edu";
		     break;
    case "1030432" : unit    = "SS";
		     adname  = "Hart,Brenda";
		     ademail = "bghart01@gwise.louisville.edu";
		     break;
    case "1023838" : unit    = "SS";
		     adname  = "Elles,Leigh Ann";
		     ademail = "laelle01@gwise.louisville.edu";
		     break;
    case "1303507" : unit    = "SS";
		     adname  = "Vaughn,Heidi";
		     ademail = "hkvaug01@gwise.louisville.edu";
		     break;
    case "1023717" : unit    = "SS";
		     adname  = "Murphy,Paula";
		     ademail = "pmmurp01@gwise.louisville.edu";
		     break;
    case "1392846" : unit    = "SS";
		     adname  = "Brammer,Tom";
		     ademail = "ttbram01@louisville.edu";
		     break;
    case "1027607" : unit    = "DS";
		     adname  = "Benningfield, Robin";
		     ademail = "robin.benningfield@louisville.edu";
		     break;
    case "1348125" : unit    = "DS";
                     adname  = "Miller, Rachel";
                     ademail = "r0mill05@gwise.louisville.edu";
                     break;
    case "1308173" : unit    = "DS";
		     adname  = "Foster,Dianne";
		     ademail = "ddfost01@gwise.louisville.edu";
		     break;
	case "1320558" : unit    = "SW";
		     adname  = "Rowan,Noell";
		     ademail = "nlrowa01@gwise.louisville.edu";
		     break;		
	case "1362985" : unit    = "SW";
		     adname  = "Morgan,Geri";
		     ademail = "glmorg02@gwise.louisville.edu";
		     break;		 
	case "1130811" : unit    = "SW";
		     adname  = "Sullivan,Dana";
		     ademail = "djsull01@gwise.louisville.edu";
		     break;		 
			 	 
    default : alert("The emplid of the advisor, " + document.iut.advID.value + " does not exist in the look-up table.");
              document.iut.advID.focus();
  } }

  document.iut.newunit.value = unit + "DEG";
  document.iut.advName.value = adname;
  document.iut.advEmail.value = ademail;

  if (unit == "AS" || unit == "SC" || unit == "SS" || unit == "NU" || unit == "SW") { document.iut.appr.checked = 0; }
  else { document.iut.appr.checked = 1; } 

  switch (unit) {
   case "AS" : document.iut.newunitD.value = "Arts & Sciences"; break;
   case "BU" : document.iut.newunitD.value = "Business"; break;
   case "DS" : document.iut.newunitD.value = "Dentistry"; break;
   case "ED" : document.iut.newunitD.value = "Education"; break;
   case "MU" : document.iut.newunitD.value = "Music"; break;
   case "NU" : document.iut.newunitD.value = "Nursing"; break;
   case "SS" : document.iut.newunitD.value = "Speed (Engineering)"; break;
   case "SW" : document.iut.newunitD.value = "Social Work"; break;
   case "Z1" : document.iut.newunitD.value = "Testing 1"; break;
   case "ZZ" : document.iut.newunitD.value = "Testing Z"; break;
  }



  return unit;
}

// ///////////////////////////////////////////////////////////////////////////
function ref_plan ( ) {
// REFERRAL FORM - Open the appropriate list of plans based on the major

  var unit = "";
  var rsn  = "";

  unit = def_adv();	

  if (chk_rsn() > 0) {

    rsn  = document.iut.reason.options[document.iut.reason.selectedIndex].value;

    if (unit == "SS" && rsn == "COND") { iut_open("plan_sc.html"); }
    else { if (unit) { iut_open("plan_"+unit.toLowerCase()+".html"); } }
  }

}

// ///////////////////////////////////////////////////////////////////////////
function chk_rsn() {
// Make sure reason is defined
  if (document.iut.p_action.selectedIndex == 0) {
    alert("Please select a program action before choosing the academic plan.");
    document.iut.p_action.focus();
    return(-1);
  }
  else {
    if (document.iut.p_action.selectedIndex == 1 &&
        document.iut.reason.selectedIndex == 0) {
      alert("Please select an action reason before choosing the academic plan.");
      document.iut.reason.focus();
      return(-1);
    }
    else {
      return(1);
    }
  }

}

// ///////////////////////////////////////////////////////////////////////////
function calc_hrs() {
// Define default hours of restriction
  actn = document.iut.p_action.options[document.iut.p_action.selectedIndex].value;
  rsn  = document.iut.reason.options[document.iut.reason.selectedIndex].value;
  trm = document.iut.term.options[document.iut.term.selectedIndex].value.substring(3,4);

  var hrs = "";

  if (actn == "ADMT") {
    switch (rsn) {
      case "COND" : if (unit == "AS") { hrs = "13"; } else { hrs = "14"; } break;
      case "LL  " : hrs = "14"; break;
      case "PROB" : hrs = "13"; break;
      default     : hrs = "0";
    }

    //If a summer term, then only 10 hours.
    if (trm == "5" && hrs != "0") { hrs = "10"; }
    
  }
  else {
    hrs = "n/a";
  }

  document.iut.hrs.value  = hrs;
}


// ///////////////////////////////////////////////////////////////////////////
function set_major (plan_cd, plan_descr ) {
// Set acad plan and description from pop-up window
     opener.document.iut.acadplan.options[0].value = plan_cd;
     opener.document.iut.acadplan.options[0].text  = plan_descr.substring(0,40) + "...";
     opener.document.iut.acadplanD.value = plan_descr;
     self.close();
}


// ///////////////////////////////////////////////////////////////////////////
function set_term ( ) {
// set term description
     document.iut.termD.value = document.iut.term.options[document.iut.term.selectedIndex].text;
}

// ///////////////////////////////////////////////////////////////////////////
function set_unit_req ( ) {
// set unit description on request form
     document.iut.newunitD.value = document.iut.newunit.options[document.iut.newunit.selectedIndex].text;
     document.iut.oldunitD.value = document.iut.oldunit.options[document.iut.oldunit.selectedIndex].text;
}
    
// ///////////////////////////////////////////////////////////////////////////
function set_unit_ref ( ) {
// set unit description on referral form
     def_adv();	
     document.iut.oldunitD.value = document.iut.oldunit.options[document.iut.oldunit.selectedIndex].text;
}
    

