$(function() {
	$('#favButton').button({
		icons: {
			primary: "ui-icon-note"
		}
	});
	$('#favButton').click(function () { location.href = favUrl});
	$('#resetSearch').button({
		icons: {
			primary: "ui-icon-delete"
		}
	});
	$('#resetSearch').click(function () { location.href = resetUrl});
	$('#fewogleButton, #sucheButton').button({
		icons: {
			primary: "ui-icon-search"
		}
	});
	$('#fewogleButton, #sucheButton').click(function () {
		$('#profewoListeLoadingDiv').show();
		$('#profewoListeHauptDiv').hide();
		var timeoutSuche = setTimeout(function () { suche();}, 1000); 
	});
	$('.objButton').button({
		icons: {
			primary: "ui-icon-circle-triangle-e"
		}
	});
	$('select').change(function () { 
		if (dynamicSearchTrigger) {
			//$('select').attr('disabled', true);
			$('#profewoListeLoadingDiv').show();
			$('#profewoListeHauptDiv').hide();
			var timeoutSuche = setTimeout(function () { suche();}, 1000);
		}
	});	
	$(' #fewogle').change(function () { selectColor(this); });	
	$('select').click(function () { dynamicSearchTrigger = true; });
	var selectArray = $('select');	
	for (var i=0; i<selectArray.length; i++) {
		selectColor(selectArray[i]);
	}
	selectColor(document.getElementById('fewogle'));
});

var dynamicSearchTrigger = false;

function selectColor(obj) {
	if (obj.value!='-1' && obj.value!='0' && obj.value!='' && obj.value!='Suche') {
		$('#'+obj.id + ' > option').css('backgroundColor', 'transparent')
		$('#'+obj.id + ' > option').css('fontWeight', 'normal')
		$('#' + obj.id).css('backgroundColor', '#CCFFCC')
		$('#' + obj.id).css('fontWeight', 'bold');
	}
	else {
		$('#'+obj.id + ' > option').css('backgroundColor', 'transparent')
		$('#' + obj.id).css('backgroundColor', '#FFF')
		$('#' + obj.id).css('fontWeight', 'normal');
	}
}
