window.onload = initForm;

function initForm() {
     document.getElementById("Seminar").selectedIndex = 0;
     document.getElementById("Seminar").onchange = populateDays;
}

function populateDays() {

     var locationStr = this.options[this.selectedIndex].value;
     //Delete all options
     document.getElementById("Location").options.length = 0;

     //Repopulate options based on users choice
     if (locationStr == ""){
 	   							//Text, value 	       
           document.getElementById("Location").options[0] = new Option('Location & Date');
	
	}


     if (locationStr == "session"){
 	   	   //Text, value 
         document.getElementById("EmailSubject").value = 'Seminar Registration';
         document.getElementById("Location").options[0] = new Option('TBA');

	}

     if (locationStr == "workshop"){
        							//Text, value
         document.getElementById("EmailSubject").value = 'Workshop Registration';
         document.getElementById("ToEmail").value = 'london@larlyn.com';
         document.getElementById("Location").options[0] = new Option('London - Tuesday, October 25, 2011 - 6:00pm to 8:00pm');
         //document.getElementById("Location").options[1] = new Option('Edmonton - Thursday, June 16, 2011 - 7:00pm to 9:00pm');
         //document.getElementById("Location").options[2] = new Option('Burlington - Tuesday, June 28, 2011 - 10:00am to 12:00pm');
         //document.getElementById("Location").options[3] = new Option('Markham - Wednesday, June 29, 2011 - 10:00am to 12:00pm');
         //document.getElementById("Location").options[4] = new Option('Calgary - May 13th', 'Calgary - May 13th');
         //document.getElementById("Location").options[5] = new Option('Edmonton - May 15th', 'Edmonton - May 15th');
         //document.getElementById("Location").options[6] = new Option('Fort McMurray - June 19th', 'Fort McMurray - June 19th');
        }
}

function correctEmail() {
    //will need to add an extra check in the future for seminar vs workshop
    var index = document.getElementById("Location").selectedIndex;
    if (index == 0) {
        document.getElementById("ToEmail").value = 'london@larlyn.com';
    }
    if (index == 1) {
        document.getElementById("ToEmail").value = 'edmonton@larlyn.com';
    }
    if (index == 2) {
        document.getElementById("ToEmail").value = 'burlington@larlyn.com';
    }
    if (index == 3) {
        document.getElementById("ToEmail").value = 'markham@larlyn.com';
    }
}
