// course data
var linkbox_data20710 = {"23":{"link":"","courses":[{"title":"Technik","link":"fachgebiet-technik\/startseite\/index.html"},{"title":"Betriebswirtschaft und Marktforschung","link":"fachgebiet-betriebswirtschaft-und-marktforschung\/startseite\/index.html"},{"title":"Phytomedizin","link":"fachgebiet-phytomedizin\/startseite\/index.html"},{"title":"Bodenkunde und Pflanzenern\u00e4hrung","link":"fachgebiet-bodenkunde-und-pflanzenernaehrung\/startseite\/index.html"},{"title":"Botanik","link":"fachgebiet-botanik\/startseite\/index.html"},{"title":"Zierpflanzenbau","link":"fachgebiet-zierpflanzenbau\/startseite\/index.html"},{"title":"Obstbau","link":"fachgebiet-obstbau\/startseite\/index.html"},{"title":"Gem\u00fcsebau","link":"fachgebiet-gemuesebau\/startseite\/index.html"},{"title":"Mikrobiologie und Biochemie","link":"fachgebiet-mikrobiologie-und-biochemie\/startseite\/index.html"},{"title":"Weinanalytik und Getr\u00e4nkeforschung","link":"fachgebiet-weinanalytik-und-getraenkeforschung\/startseite\/index.html"},{"title":"Kellerwirtschaft","link":"fachgebiet-kellerwirtschaft\/startseite\/index.html"},{"title":"Weinbau","link":"fachgebiet-weinbau\/startseite\/index.html"},{"title":"Rebenz\u00fcchtung und Rebenveredlung","link":"fachgebiet-rebenzuechtung-und-rebenveredlung\/startseite\/index.html"}]},"24":{"link":"","courses":[]}};

jQuery( document ).ready( function() {
	fillCourseDropdown20710();
} );

function fillCourseDropdown20710( field )
{
	// Set select to the element "selectbox."
	var select = document.forms.nidag_linkbox_form20710.course;
	// Set options to an array of all "option" tags that
	// are children of the select element.
	var options = select.getElementsByTagName("option");
	// Loop through the array of options and remove each
	// each one from the parent's childNode list.
	for( i=(options.length - 1); i > 0; i-- )
		select.removeChild(options[i]);

	fieldData = new Array();
	
	if( field == undefined || linkbox_data20710[field] == undefined ) {
		// collect all courses..
		for( var field in linkbox_data20710 )
			for( var course in linkbox_data20710[field]['courses'] )
				fieldData[ linkbox_data20710[field]['courses'][course]['title'] ] = linkbox_data20710[field]['courses'][course]['link'];
	}
	else {
		// collect courses of chosen field..
		for( var course in linkbox_data20710[field]['courses'] )
			fieldData[ linkbox_data20710[field]['courses'][course]['title'] ] = linkbox_data20710[field]['courses'][course]['link'];
	}
	// add options to dropdown..
	addFieldOptions20710( fieldData );
}

function addFieldOptions20710( fieldData )
{
	// sort courses alphabetically..
	keys = new Array();
	for( var course in fieldData )
		keys[ keys.length ] = course;

	keys.sort();

	// fill in new options..
	for( var i=0; i < keys.length; i++ ) {
		document.forms.nidag_linkbox_form20710.course.options[ document.forms.nidag_linkbox_form20710.course.options.length ] = new Option(
			keys[i],
			fieldData[keys[i]],
			false,
			false
		);
	}
}

function submitLinkbox20710()
{
	if( document.forms.nidag_linkbox_form20710.course.selectedIndex == 0 ) {
		// link to field selection..
		var target = linkbox_data20710[ document.forms.nidag_linkbox_form20710.field.options[document.forms.nidag_linkbox_form20710.field.selectedIndex].value ]['link'];
		if( target != undefined && target != "" )
			document.location.href = target;
	}
	else {
		// link to course selection..
		var target = document.forms.nidag_linkbox_form20710.course.options[ document.forms.nidag_linkbox_form20710.course.selectedIndex ].value;
		if( target != undefined && target != "" )
			document.location.href = target;
	}

	return false;
}
