// course data
var linkbox_data16268 = {"21":{"link":"","courses":[{"title":"FACE-Projekt","link":"forschungsanstalt-geisenheim\/ueber-uns\/a-z\/face\/index.html"},{"title":"Trockenstresstoleranz bei Schnittrosen","link":"fachgebiet-zierpflanzenbau\/projekte\/trockenstresstoleranz-von-schnittrosen\/index.html"},{"title":"Kolumnargen beim Apfel","link":"fachgebiet-obstbau\/forschung\/funktionelle-charakterisierung-des-kolumnar-gens-beim-apfel\/index.html"},{"title":"Geisenheimer Bew\u00e4sserungssteuerung","link":"fachgebiet-gemuesebau\/geisenheimer-steuerung\/index.html"},{"title":"Wertgebende Inhaltsstoffe Wein","link":"fachgebiet-weinbau\/forschung\/wertgebende-inhaltsstoffe\/index.html"},{"title":"Neue Rebsorten","link":"fachgebiet-rebenzuechtung-und-rebenveredlung\/forschung\/edelreiser\/neue-kreuzungen\/index.html"}]}};

jQuery( document ).ready( function() {
	fillCourseDropdown16268();
} );

function fillCourseDropdown16268( field )
{
	// Set select to the element "selectbox."
	var select = document.forms.nidag_linkbox_form16268.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_data16268[field] == undefined ) {
		// collect all courses..
		for( var field in linkbox_data16268 )
			for( var course in linkbox_data16268[field]['courses'] )
				fieldData[ linkbox_data16268[field]['courses'][course]['title'] ] = linkbox_data16268[field]['courses'][course]['link'];
	}
	else {
		// collect courses of chosen field..
		for( var course in linkbox_data16268[field]['courses'] )
			fieldData[ linkbox_data16268[field]['courses'][course]['title'] ] = linkbox_data16268[field]['courses'][course]['link'];
	}
	// add options to dropdown..
	addFieldOptions16268( fieldData );
}

function addFieldOptions16268( 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_form16268.course.options[ document.forms.nidag_linkbox_form16268.course.options.length ] = new Option(
			keys[i],
			fieldData[keys[i]],
			false,
			false
		);
	}
}

function submitLinkbox16268()
{
	if( document.forms.nidag_linkbox_form16268.course.selectedIndex == 0 ) {
		// link to field selection..
		var target = linkbox_data16268[ document.forms.nidag_linkbox_form16268.field.options[document.forms.nidag_linkbox_form16268.field.selectedIndex].value ]['link'];
		if( target != undefined && target != "" )
			document.location.href = target;
	}
	else {
		// link to course selection..
		var target = document.forms.nidag_linkbox_form16268.course.options[ document.forms.nidag_linkbox_form16268.course.selectedIndex ].value;
		if( target != undefined && target != "" )
			document.location.href = target;
	}

	return false;
}
