  $(function() {
    $( "#datepicker" ).datepicker({
	  showOn: "button",
	  buttonImage: "img/calendar.gif",
	  buttonImageOnly: true,
	  buttonText: 'Sichtbarkeitsdatum wählen',	  
	  closeText: 'schließen', closeStatus: 'ohne Änderungen schließen',
      prevText: '&#x3c;zurück', prevStatus: 'letzten Monat zeigen',
      nextText: 'Vor&#x3e;', 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	  
    });
  });
  
  $(document).ready( function(){ $('#news').innerfade({ speed: 'slow', timeout: 5000, type: 'sequence', containerheight: '30px' }); } ); 

  function clean_datepicker() {
    document.getElementById('datepicker').value = "";
  }
  
  function delete_text(id) {
	Check = confirm("Wollen Sie diesen Beitrag wirklich löschen?");
	if ( Check == true ) {
	  ajax_delete_text(id);
	}
  }
  
  function getXmlHttpRequestObject() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest(); //Not IE
	} else if(window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP"); //IE
	} else {
		//Display your error message here. 
		//and inform the user they might want to upgrade
		//their browser.
		alert("Your browser doesn't support the XmlHttpRequest object.  Better upgrade to Firefox.");
	}
}

var receiveReq = getXmlHttpRequestObject();

function ajax_delete_text(id) {	
	//If our XmlHttpRequest object is not in the middle of a request, start the new asyncronous call.
	if (receiveReq.readyState == 4 || receiveReq.readyState == 0) {
		//Setup the connection as a GET call to SayHello.html.
		//True explicity sets the request to asyncronous (default).		
		receiveReq.open("GET", 'textdel.php?delete=J&id=' + id, true);				
		//Set the function that will be called when the XmlHttpRequest objects state changes.
		receiveReq.onreadystatechange = ajax_delete_text_ergebnis; 
		//Make the actual request.
		receiveReq.send(null);
	}			
}

function ajax_delete_text_ergebnis() {
	//Check to see if the XmlHttpRequests state is finished.
	if (receiveReq.readyState == 4) {
		//Set the contents of our span element to the result of the asyncronous call.				
		//alert(receiveReq.responseText);
		if ( receiveReq.responseText == "OK" ) {		
		  //alert("Bericht gelöscht!");
		  location.href = "index.php";
        } else {		          
		  alert("Bericht kann nicht gelöscht werden!");
		}
	}
}
  
