// JavaScript Document
// Email configuration functions


function fillProgram(){ 
 // this function is used to fill the program list on load
addOption(document.email_config.program, "Thunderbird", "Thunderbird", "");
addOption(document.email_config.program, "Apple Mail", "Apple Mail", "");
addOption(document.email_config.program, "MS Outlook 2003", "MS Outlook 2003", "");
addOption(document.email_config.program, "MS Outlook 2007", "MS Outlook 2007", "");
addOption(document.email_config.program, "MS Entourage 2004", "MS Entourage 2004", "");
//addOption(document.email_config.program, "MS Entourage 2008", "MS Entourage 2008", "");
addOption(document.email_config.program, "MS Entourage 2008 EWS", "MS Entourage 2008 EWS", "");
}
function SelectProtocol(){
// When an option is selected for 'program', this function populates the SubCatProtocol list

removeAllOptions(document.email_config.SubCatProtocol);
addOption(document.email_config.SubCatProtocol, "", "Select a protocol", "");

if(document.email_config.program.value == 'Thunderbird'){
addOption(document.email_config.SubCatProtocol,"IMAP", "IMAP");
addOption(document.email_config. SubCatProtocol,"POP", "POP");
addOption(document.email_config.SubCatProtocol,"EliApps", "EliApps");
}
if(document.email_config.program.value == 'Apple Mail'){
addOption(document.email_config.SubCatProtocol,"IMAP", "IMAP");
addOption(document.email_config.SubCatProtocol,"POP", "POP");
addOption(document.email_config.SubCatProtocol,"EliApps", "EliApps");
}
if(document.email_config.program.value == 'MS Outlook 2003'){
addOption(document.email_config.SubCatProtocol,"IMAP", "IMAP");
addOption(document.email_config.SubCatProtocol,"POP", "POP");
addOption(document.email_config.SubCatProtocol,"YaleConnect", "YaleConnect");
}
if(document.email_config.program.value == 'MS Outlook 2007'){
addOption(document.email_config.SubCatProtocol,"IMAP", "IMAP");
addOption(document.email_config.SubCatProtocol,"YaleConnect", "YaleConnect");
addOption(document.email_config.SubCatProtocol,"EliApps", "EliApps");
}
if(document.email_config.program.value == 'MS Entourage 2004'){
addOption(document.email_config.SubCatProtocol,"YaleConnect", "YaleConnect");
//}
//if(document.email_config.program.value == 'MS Entourage 2008'){
//addOption(document.email_config.SubCatProtocol,"YaleConnect", "YaleConnect");
}
if(document.email_config.program.value == 'MS Entourage 2008 EWS'){
addOption(document.email_config.SubCatProtocol,"YaleConnect", "YaleConnect");
}

}
function SelectCampus(){
// When an option is selected for 'SubCatProtocol', this function populates the 'SubCatCampus' list

removeAllOptions(document.email_config.SubCatCampus);
addOption(document.email_config.SubCatCampus, "", "Select your campus location", "");

if(document.email_config.SubCatProtocol.value == 'IMAP'){
addOption(document.email_config.SubCatCampus,"New/incoming student (Med or Central)", "New/incoming student (Med or Central)");
addOption(document.email_config.SubCatCampus,"Med", "Med");
addOption(document.email_config.SubCatCampus,"Central", "Central");
addOption(document.email_config.SubCatCampus,"New/incoming Y-NHH House Staff", "New/incoming Y-NHH House Staff");
addOption(document.email_config.SubCatCampus,"EliApps", "EliApps");
}
if(document.email_config.SubCatProtocol.value == 'POP'){
addOption(document.email_config.SubCatCampus,"New/incoming student (Med or Central)", "New/incoming student (Med or Central)");
addOption(document.email_config.SubCatCampus,"Med", "Med");
addOption(document.email_config.SubCatCampus,"Central", "Central");
addOption(document.email_config.SubCatCampus,"New/incoming Y-NHH House Staff", "New/incoming Y-NHH House Staff");
}
if(document.email_config.SubCatProtocol.value == 'YaleConnect'){
addOption(document.email_config. SubCatCampus,"YaleConnect", "YaleConnect");
}
if(document.email_config.SubCatProtocol.value == 'EliApps'){
addOption(document.email_config. SubCatCampus,"EliApps", "EliApps");
}
}

////////////////// 


function removeAllOptions(selectbox)
{
	var i;
	for(i=selectbox.options.length-1;i>=0;i--)
	{
		//selectbox.options.remove(i);
		selectbox.remove(i);
	}
}


function addOption(selectbox, value, text )
{
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;

	selectbox.options.add(optn);
}

function loadInstructions() {
  //Get selected values
  var program=document.email_config.program.value
  var protocol=document.email_config.SubCatProtocol.value
  var campus=document.email_config.SubCatCampus.value
  
  //Direct user to the right instruction page

 //Check Thunderbird 
  if(program=='Thunderbird' && campus=='Central' && protocol=='POP')
    {
	window.location="thunderbird/central-pop.html"	
    }
  if(program=='Thunderbird' && campus=='Central' && protocol=='IMAP')
    {
	window.location="thunderbird/central-imap.html"	
    }
  if(program=='Thunderbird' && campus=='Med' && protocol=='POP')
    {
	window.location="thunderbird/med-pop.html"	
    }
  if(program=='Thunderbird' && campus=='Med' && protocol=='IMAP')
    {
	window.location="thunderbird/med-imap.html"	
    }
   if(program=='Thunderbird' && campus=='New/incoming student (Med or Central)' && protocol=='POP')
    {
	window.location="thunderbird/central-pop.html"	
    }
   if(program=='Thunderbird' && campus=='New/incoming student (Med or Central)' && protocol=='IMAP')
    {
	window.location="thunderbird/central-imap.html"		
    }
  if(program=='Thunderbird' && campus=='EliApps' && protocol=='EliApps')
    {
	window.location="thunderbird/eliapps-thunderbird.html"	
    }
  if(program=='Thunderbird' && campus=='EliApps' && protocol=='IMAP')
    {
	window.location="thunderbird/eliapps-thunderbird.html"	
    }	
  if(program=='Thunderbird' && protocol=='EliApps')
    {
	window.location="thunderbird/eliapps-thunderbird.html"	
    }	
  if(program=='Apple Mail' && campus=='Central' && protocol=='POP')
    {
	window.location="applemail/central-pop.html"	
    }
  if(program=='Apple Mail' && campus=='Central' && protocol=='IMAP')
    {
	window.location="applemail/central-imap.html"	
    }
  if(program=='Apple Mail' && campus=='Med' && protocol=='POP')
    {
	window.location="applemail/med-pop.html"	
    }
  if(program=='Apple Mail' && campus=='Med' && protocol=='IMAP')
    {
	window.location="applemail/med-imap.html"	
    }
  if(program=='Apple Mail' && campus=='EliApps' && protocol=='EliApps')
    {
	window.location="applemail/eliapps-lion.html"	
    }	
  if(program=='Apple Mail' && campus=='EliApps' && protocol=='IMAP')
    {
	window.location="applemail/eliapps-lion.html"	
    }	
  if(program=='Apple Mail' && protocol=='EliApps')
    {
	window.location="applemail/eliapps-lion.html"	
    }	
  if(program=='Apple Mail' && campus=='New/incoming student (Med or Central)' && protocol=='POP')
    {
	window.location="applemail/central-pop.html"	
    }
  if(program=='Apple Mail' && campus=='New/incoming student (Med or Central)' && protocol=='IMAP')
    {
	window.location="applemail/central-imap.html"	
    }
  //Check Outlook 
  if(program=='MS Outlook 2003' && campus=='Central' && protocol=='POP')
    {
	window.location="outlook/central-pop.html"	
    }
  if(program=='MS Outlook 2003' && campus=='Central' && protocol=='IMAP')
    {
	window.location="outlook/central-imap.html"	
    }
 if(program=='MS Outlook 2003' && campus=='New/incoming student (Med or Central)' && protocol=='POP')
    {
	window.location="outlook/central-pop.html"	
    }
  if(program=='MS Outlook 2003' && campus=='New/incoming student (Med or Central)' && protocol=='IMAP')
    {
	window.location="outlook/central-imap.html"	
    }
  if(program=='MS Outlook 2003' && campus=='New/incoming Y-NHH House Staff' && protocol=='POP')
    {
	window.location="outlook/central-pop.html"	
    }
  if(program=='MS Outlook 2003' && campus=='New/incoming Y-NHH House Staff' && protocol=='IMAP')
    {
	window.location="outlook/central-imap.html"	
    }	
  if(program=='MS Outlook 2003' && campus=='Med' && protocol=='POP')
    {
	window.location="outlook/med-pop.html"	
    }
  if(program=='MS Outlook 2003' && campus=='Med' && protocol=='IMAP')
    {
	window.location="outlook/med-imap.html"	
    }
  if(program=='MS Outlook 2003' && campus=='YaleConnect' && protocol=='YaleConnect')
    {
	window.location="/its/connect/windows/pdf/Configuring_Outlook_03_1st_Time.pdf"	
    }	
  if(program=='MS Outlook 2007' && campus=='YaleConnect' && protocol=='YaleConnect')
    {
	window.location="/its/connect/windows/pdf/Configuring%20Exchange%20-%20Outlook%2007%20%28First%20Time%20Outlook%20User%29.pdf"	
    }
  if(program=='MS Outlook 2007' && campus=='Med' && protocol=='IMAP')
    {
	window.location="/its/email/howdoi/outlook/outlook-2007-med-imap.html"	
    }
  if(program=='MS Outlook 2007' && campus=='Central' && protocol=='IMAP')
    {
	window.location="/its/email/howdoi/outlook/outlook-2007-central-imap.html"	
     }
  if(program=='MS Outlook 2007' && campus=='New/incoming student (Med or Central)' && protocol=='IMAP')
    {
	window.location="/its/email/howdoi/outlook/outlook-2007-central-imap.html"	
    }
  if(program=='MS Outlook 2007' && campus=='New/incoming Y-NHH House Staff' && protocol=='IMAP')
    {
	window.location="/its/email/howdoi/outlook/outlook-2007-central-imap.html"
    }	
  if(program=='MS Outlook 2007' && campus=='EliApps' && protocol=='EliApps')
    {
	window.location="outlook/eliapps-outlook-2010.html"	
    }	
  if(program=='MS Outlook 2007' && campus=='EliApps' && protocol=='IMAP')
    {
	window.location="outlook/eliapps-outlook-2010.html"	
    }	
  if(program=='MS Outlook 2007' && protocol=='EliApps')
    {
	window.location="outlook/eliapps-outlook-2010.html"	
    }	

  //Check Entourage 
  if(program=='MS Entourage 2004' && campus=='YaleConnect' && protocol=='YaleConnect')
    {
	window.location="/its/connect/mac/entourage-2004-configuration.pdf"	
 //    }
 //if(program=='MS Entourage 2008' && campus=='YaleConnect' && protocol=='YaleConnect')
  //   {
	window.location="/its/connect/mac/entourage2008-config.html"	
    }
  if(program=='MS Entourage 2008 EWS' && campus=='YaleConnect' && protocol=='YaleConnect')
    {
	window.location="/its/software/mac/entourage/Entourage2008EWSclean.pdf"	
    }
}

