
function showmap( data ){

	var url = 'http://www.ekm-mittelsachsen.de/map.php?q='+escape( data );

	window.open( url, "Anfahrt", "width=600,height=500,left=350,top=200");

}


$[ "ui" ][ "autocomplete" ].prototype["_renderItem"] = function( ul, item) {
return $( "<li></li>" ) 
  .data( "item.autocomplete", item )
  .append( $( "<a></a>" ).html( item.label ) )
  .appendTo( ul );
};


$(document).ready(function(){

        $( ".datepicker" ).datepicker({ clickInput:true,
showOn: "button",
buttonImage: "fileadmin/templates/js/datepicker/cal.jpg",
buttonImageOnly: true,
minDate: new Date(2011, 0, 1),
maxDate: new Date(2012, 11, 31)
});
$( ".datepicker" ).datepicker( "option", "dateFormat", 'dd.mm.yy' ); 

$.datepicker.regional['de'] = {clearText: 'löschen', clearStatus: 'aktuelles Datum löschen',
                closeText: 'schließen', closeStatus: 'ohne Änderungen schließen',
                prevText: '<zurück', prevStatus: 'letzten Monat zeigen',
                nextText: 'Vor>', nextStatus: 'nächsten Monat zeigen',
                currentText: 'heute', currentStatus: '',
                monthNames: ['Januar','Februar','März','April','Mai','Juni',
                'Juli','August','September','Oktober','November','Dezember'],
                monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
                'Jul','Aug','Sep','Okt','Nov','Dez'],
                monthStatus: 'anderen Monat anzeigen', yearStatus: 'anderes Jahr anzeigen',
                weekHeader: 'Wo', weekStatus: 'Woche des Monats',
                dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
                dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
                dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
                dayStatus: 'Setze DD als ersten Wochentag', dateStatus: 'Wähle D, M d',
                dateFormat: 'dd.mm.yy', firstDay: 1,
                initStatus: 'Wähle ein Datum', isRTL: false};
        $.datepicker.setDefaults($.datepicker.regional['de']);





	$('#abfall_ort').keypress(function( event ){

		if( event.which == 13 ){

			if( $('.ui-autocomplete > li').length ==1 ){

				var tmp = $("#abfall_ort").autocomplete('widget');


			}

		}

	});

	$('.kontakt_table .contenttable tr > td:first-child').each(function( index, el ){

		$( el ).css({
			width: 150
		})

	});


	$.ajax({
	  url: 'http://www.ekm-mittelsachsen.de/index.php?eID=abfallabc',
	  dataType: 'json',
	  success: function(data){

			$("#abfallabc_input").autocomplete({
				source: data,
				minLength: 3,
				select: function(event, ui) {
				
					window.location = "http://www.ekm-mittelsachsen.de/index.php?id=28&tx_abfallabc_pi1[showUid]="+ui.item.id+'&tx_abfallabc_pi1[searchphrase]='+escape(ui.item.label);
				
				}
		});


	  }
	});

	$('.abfall_tabcontent .alt').parent().hide();

	$('body').append('<div id="movie"></div>');



	$("#abfall_strassen").autocomplete({
			source: function(request, response){
					
					var url = "index.php?id=14&action=autocompleteStrassen&oid="+$('#abfall_ort_id').val();

					$.getJSON(url, {
					term: request.term
					}, response);
				
			},
			minLength: 3,
			delay: 500,
			select: function(event, ui) {

				$('#abfall_strassen_id').val(ui.item.id);
				$('#abfallkalender_form').submit();

	

			},

			close: function(event, ui){
				
					var value = $('#abfall_strassen').val();
					value = value.replace(/<[/]*[^>]*>/gi, "");
					$('#abfall_strassen').val(value);
					 

			}
		});

		$("#abfall_ort").autocomplete({
			source: "index.php?id=14&action=autocompleteOrte",
			minLength: 3,
			delay: 500,
			select: function(event, ui) {

				$('#abfall_ort_id').val(ui.item.id);

				if(ui.item.type == '1'){
					
					$('#street_input').slideUp();
					$('#abfallkalender_form').submit();

				}else{

					$('#street_input').slideDown();

				}
			
			},

			close: function(event, ui){
				
					var value = $('#abfall_ort').val();
					value = value.replace(/<[/]*[^>]*>/gi, "");
					$('#abfall_ort').val(value);
					 

			}
		});

	

});

function strip_tags($text){
 
}


var abfall_termine = false;


var abfall = {
	
	terminToggle: function(){
			
			if(abfall_termine){
				$('.abfall_tabcontent .alt').parent().hide();
				abfall_termine = false;
			}else{
				$('.abfall_tabcontent .alt').parent().show();
				abfall_termine = true;
			}

	},

	print: function(url){

		window.open(url, "Zweitfenster", "width=1000,height=800,left=200,top=100");
		return false;

	}
}





var tab  = {

	'open': function(id){
			$('.abfall_termine').removeClass('active');
			$('#tabcontent_'+id).addClass('active');
			$('ul.tabs li').removeClass('active');
			$('#tab_'+id).addClass('active');

	}


}

var karte = {

'show': function(id){

	
	$('#'+id).show();

},

'hideAll': function(){

	$('#karte img').hide();

}

}


var month = {

'data': {
	'abfall_ort_id': null,
	'abfall_strassen_id': null,
	'abfall_month': null,
	'abfall_year': null
},

'next': function(){

	month.data.abfall_month = month.data.abfall_month+1;
	month.run();
	if(month.data.abfall_month > 1){
		 $('#abfall_month_prev').show(); 
	}

	if(month.data.abfall_month >= 12){
		 $('#abfall_month_next').hide(); 
	}

},

'prev': function(){

	month.data.abfall_month = month.data.abfall_month-1;
	month.run();

	if(month.data.abfall_month <= 1){
		 $('#abfall_month_prev').hide(); 
	}

	if(month.data.abfall_month < 12){
		 $('#abfall_month_next').show(); 
	}
	

},

'run': function(){
	$('.inactive').show();
	$.ajax({
	  type: 'GET',
	  url: 'index.php?id=14&action=getKalenderByMonth',
	  data: month.data,
	  success: month.success,
	  dataType: 'JSON'
	});


},

'success': function(el){
	$('.inactive').hide();
	data = $.parseJSON(el);
	$('#abfall_kalender_inner').html(data.html);
	$('#abfall_kalender_month').html(data.month_name);

}

}


