﻿// <!--

function ByID(name){
	//alert(name);
	return document.getElementById(name);
}

function ChangeInstitution(institutionsObj, array, array2, departmentObj){
	for(var i = (departmentObj.options.length-1) ; i >= 0 ; i--){
		departmentObj.options.remove(i);
	}
	
	for(var i = (ByID("TeacherDD").options.length-1) ; i >= 0 ; i--){
		ByID("TeacherDD").options.remove(i);
	}
	
	for(j = 0 ; j < array[institutionsObj.selectedIndex].length ; j++){
		oOption = document.createElement("OPTION");
		departmentObj.options.add(oOption);
		oOption.innerText = array[institutionsObj.selectedIndex][j][1];
		oOption.value = array[institutionsObj.selectedIndex][j][0];
	}
	
	for(j = 0 ; j < array2[institutionsObj.selectedIndex].length ; j++){
		oOption = document.createElement("OPTION");
		ByID("TeacherDD").options.add(oOption);
		oOption.innerText = array2[institutionsObj.selectedIndex][j][1];
		oOption.value = array2[institutionsObj.selectedIndex][j][0];
	}
}

function SetDepartment(value){
	for(i = 0 ; i < ByID("DepartmentDD").options.length ; i++){
		if(ByID("DepartmentDD").options(i).value == value){
			ByID("DepartmentDD").options(i).selected = true;
		}
	}
}

function SetTeacher(value){
	for(i = 0 ; i < ByID("TeacherDD").options.length ; i++){
		if(ByID("TeacherDD").options(i).value == value){
			ByID("TeacherDD").options(i).selected = true;
		}
	}
}

function SetSourceField(value){
	ByID("SourceTxt").style.display = "none";
	ByID("FileBlock").style.display = "none";
	switch (value){
		case "1": // URL
			if(ByID("SourceTxt").value == "")
				ByID("SourceTxt").value = "http://";
			ByID("SourceTxt").style.display = "block";
			break;
		case "2": // File
			ByID("FileBlock").style.display = "block";
			break;
	
	}
}

function SetAnswerField(value){
	ByID("AnswerTxt").style.display = "none";
	ByID("FileBlock2").style.display = "none";
	switch (value){
		case "1": // URL
			if(ByID("AnswerTxt").value == "")
				ByID("AnswerTxt").value = "http://";
			ByID("AnswerTxt").style.display = "block";
			break;
		case "2": // File
			ByID("FileBlock2").style.display = "block";
			break;
	
	}
}

// -->