jQuery(document).ready(function() {
	
	/* **************************************************************
	*					Autocomplete
	************************************************************** */
	if ( $('#eventLocation').length ){
		$("#eventLocation").james("/data/autocomplete.php?type=eventLocation",{
	        minlength: 0,
	        method: "post",
	        keydelay: 5,
			onSelect: function (data, json) {
				// Rückgabewerte auf die Felder zip und city aufteilen
				document.getElementById("eventLocation").value = json.location;
			}
	    }); 
	
	
		$("#eventCategory").james("/data/autocomplete.php?type=eventCategory",{
	        minlength: 0,
	        method: "post",
	        keydelay: 5,
			onSelect: function (data, json) {
				// Rückgabewerte auf die Felder zip und city aufteilen
				document.getElementById("eventCategory").value = json.category;
			}
	    }); 
	}
    
    /* **************************************************************
	*					Sortieren
	************************************************************** */
	if ( $('#sortable').length ){
		$("#sortable").sortable({
			cancel: '.nonSortableDiv',
			opacity: 0.6,
			stop: function(event, ui){ 
					
					// Liste mit allen sortierten Objekten erzeugen
					var A_result = $("#sortable").sortable('serialize');
					
					// sendet die Post-Variablen in einem Array an eine Action-Seite, die den DB-Eintrag vornimmt
					$.ajax({data: A_result,
							type: "POST",
							url: G_dataURL+"/sortableSave.php",
							contentType: "application/x-www-form-urlencoded;charset=ISO-8859-15",
							success: function(xml){}
					});
				}
	
		});
	
		$("#sortable li").disableSelection();	
	}
	
	/* **************************************************************
	*					Datums-Felder
	************************************************************** */
	/* ------------- Start & Ende für Suche ---------------------- */
	A_datePickerConfig = G_A_datePickerConfig;
	A_datePickerConfig.minDate=0;
	if ( $('#dateStart').length ){
		$("#dateStart").datepicker(A_datePickerConfig);
	}
	if ( $('#dateEnd').length ){
		$("#dateEnd").datepicker(A_datePickerConfig);
	}
	
	/* ------------- In die Seite integrierter Datums-Picker ---------------------- */
	A_datePickerConfig = G_A_datePickerConfigStandalone;
	A_datePickerConfig['onSelect'] = function(dateText, inst){
										document.getElementById('dateStart').value = dateText; 
									};
	if ( $('#datePicker').length ){
		$("#datePicker").datepicker(A_datePickerConfig);
	}
						

});