var selectProgramText = "";
var selectDateText = "";
var selectCountryText = "";

var lists = new Array();
lists[''] = new Array();
lists[''][0] = new Array(
	'- First Select Programme -'
);
lists[''][1] = new Array( 
	''
);

lists['Management Diploma'] = new Array();
lists['Management Diploma'][0] = new Array(
	'- Select Date -',
	'July 2010',
	'January 2011',
	'July 2011',
	'January 2012',
	'July 2012',
	'January 2013'

);
lists['Management Diploma'][1] = new Array(
	'',
	'2010/2',
	'2011/1',
	'2011/2',
	'2012/1',
	'2012/2',
	'2013/1'	
);

lists['Bachelor of Business Administration'] = new Array();
lists['Bachelor of Business Administration'][0] = new Array(
	'- Select Date -',
	'August 2010',
	'February 2011',
	'August 2011',
	'February 2012',
	'August 2012',
         'February 2013'
);
lists['Bachelor of Business Administration'][1] = new Array(
	'',
	'2010/2',
	'2011/1',
	'2011/2',
	'2012/1',
	'2012/2',
	'2013/1'	
);
lists['Post-Graduate Certificate'] = new Array();
lists['Post-Graduate Certificate'][0] = new Array(
	'- Select Date -',
	'July 2010',
	'January 2011',
	'July 2011',
	'January 2012',
	'July 2012',
	'January 2013'
);
lists['Post-Graduate Certificate'][1] = new Array(
	'',
	'2010/2',
	'2011/1',
	'2011/2',
	'2012/1',
	'2012/2',
	'2013/1'	
);
lists['Post Graduate Diploma (PGD)'] = new Array();
lists['Post Graduate Diploma (PGD)'][0] = new Array(
	'- Select Date -',
	'August 2010',
	'February 2011',
	'August 2011',
	'February 2012',
	'August 2012',
         'February 2013'
);
lists['Post Graduate Diploma (PGD)'][1] = new Array(
	'',
	'2010/2',
	'2011/1',
	'2011/2',
	'2012/1',
	'2012/2',
	'2013/1'	
);

lists['MBA and Certification Courses'] = new Array();
lists['MBA and Certification Courses'][0] = new Array(
	'- Select Date -',
	'July 2010',
	'January 2011',
	'July 2011',
	'January 2012',
	'July 2012',
	'January 2013'
);
lists['MBA and Certification Courses'][1] = new Array(
	'',
	'2010/2',
	'2011/1',
	'2011/2',
	'2012/1',
	'2012/2',
	'2013/1'	
);

lists['Language Instruction and Preparatory Course'] = new Array();
lists['Language Instruction and Preparatory Course'][0] = new Array(
	'- Select Date -',
	'July 2010',
	'January 2011',
	'July 2011',
	'January 2012',
	'July 2012',
	'January 2013'
);
lists['Language Instruction and Preparatory Course'][1] = new Array(
	'',
	'2010/2',
	'2011/1',
	'2011/2',
	'2012/1',
	'2012/2',
	'2013/1'		
);



function fillList( box, arr ) {
	// arr[0] holds the display text
	// arr[1] are the values
	
	//selecting the first item
	$("select[id$='VisitDateSel']").append("<option selected value=''>" + selectDateText + "</option>")
	
	for ( i = 1; i < arr[0].length; i++ ) {
	
		$("select[id$='VisitDateSel']").append("<option value='" + arr[1][i] + "'>" + arr[0][i] + "</option>")
	}
	
}

$(document).ready(function(){
	
	$("select[id$='VisitDateSel']").change(function () {
			
		var VisitPicked = $(this).val();
		
		$("input[id$='VisitDate']").val(VisitPicked);
			
	}).change();
	
	//setting text (based on language) for "select a program", "select a date", and "select a country"
	switch ("English") {
		case "English":
			selectProgramText = "- Select a Program -";
			selectDateText = "- Select Date -";
			selectCountryText = "- Select a Country -";
			break;
		case "French":
			selectProgramText = "- Selectionnez un programme -";
			selectDateText = "- Selectionnez une date -";
			selectCountryText = "- Selectionnez un pays -";
			break;
		case "German":
			selectProgramText = "- Programmauswahl -";
			selectDateText = "- Programmbeginn -";
			selectCountryText = "- Länderauswahl -";
			break;
		case "Portuguese":
			selectProgramText = "- Selecciona um Programma -";
			selectDateText = "- Seleccionar data -";
			selectCountryText = "- Seleccione um país -";
			break;
		case "Spanish":
			selectProgramText = "- Selecciona un programa -";
			selectDateText = "- Selecciona una fecha -";
			selectCountryText = "- Selecciona un país -";
			break;
		case "Italian":
			selectProgramText = "- Corso intensivo di lingua inglese -";
			selectDateText = "- Selezioni una data -";
			selectCountryText = "- Seleziona un paese -";
			break;
	}
	
	//changing "select a program" text
	$("select[id$='Program'] option:first").text(selectProgramText);
	
	//changing "select a country" text
	$("select[id$='CountryID'] option:first").text(selectCountryText);
	
});

// This function performs a drop down list option change by first
// emptying the existing option list and then assigning a new set

function changeList( box ) {
	// Isolate the appropriate list by using the value
	// of the currently selected option

	list = lists[box.options[box.selectedIndex].value];

	// Next empty the slave list

	$("select[id$='VisitDateSel'] option").remove();

	// Then assign the new list values

	fillList( $("select[id$='VisitDateSel']"), list );
}