$(document).ready(function() {
	$("a[rel^='prettyPhoto']").prettyPhoto({slideshow: false,
		autoplay_slideshow: false,
		theme: 'light_rounded',
		deeplinking: false,
		social_tools: '',
		overlay_gallery: true });
	
	if($('#ANZEIGE_MARKE_ID').length > 0) {
		getModelle();
	}
	
	$('select').change(function() {
		if ($(this).attr('id') == 'ANZEIGE_MARKE_ID') {
			getModelle(); 
		}
	});
	
	$('#SPRACHE').change(function() {
		$('#suchmaske').submit();
	});
	
	$.dateplustimepicker.setDefaults($.dateplustimepicker.regional['de']);
	if($('#as_beginn').length > 0 && $('#as_ende').length > 0) {
		$('#as_beginn').dateplustimepicker({
			dateFormat: 'yy-mm-dd',
			timeFormat: 'hh:mm:ss'
		});
		
		$('#as_ende').dateplustimepicker({
			dateFormat: 'yy-mm-dd',
			timeFormat: 'hh:mm:ss'
		});
	}
	
	if($('#tooltip_kdmodus').length > 0) {
		$('#tooltip_kdmodus').tooltip({
						track: true,
						delay: 0,
						showURL: false,
						fade: 250
					});
		
		$('#tooltip_kdmodus_img').tooltip({
						track: true,
						delay: 0,
						showURL: false,
						fade: 250
					});
	}
	
	if($('#tooltip_kdmodusinfo').length > 0) {
		$('#tooltip_kdmodusinfo *').tooltip({
						track: true,
						delay: 0,
						showURL: false,
						fade: 250
					});
		
		$('#tooltip_kdmodusinfo_img *').tooltip({
						track: true,
						delay: 0,
						showURL: false,
						fade: 250
					});
	}
	
	if($('#tooltip_kdmodusinfodetail').length > 0) {
		$('#tooltip_kdmodusinfodetail').tooltip({
						track: true,
						delay: 0,
						showURL: false,
						fade: 250
					});
	}
	
	if($('#tooltip_kdmodusparkplatz').length > 0) {
		$('#tooltip_kdmodusparkplatz *').tooltip({
						track: true,
						delay: 0,
						showURL: false,
						fade: 250
					});
	}
	
	function getModelle(){
		$('select#ANZEIGE_MODELL_ID').val('');
		$('select#ANZEIGE_MODELL_ID').attr("disabled", "disabled");
		$.ajax ({
			url: "/ajax/get_modelle.php?ANZEIGE_MARKE_ID="+$('#ANZEIGE_MARKE_ID').val(),
			type: "GET",
			cache: false,
			success: function handleResponseModell(reqCode) {
				$('#ANZEIGE_MODELL_ID').html(reqCode);
				$('#ANZEIGE_MODELL_ID').val($('#MODELLTMP').val());
				$('select#ANZEIGE_MODELL_ID').removeAttr("disabled");
			}
		});
	}
});

