function loadDocumentReadyScripts(){
	// SID Varible falls verfügbar ermitteln
	var sessionid = "";
	if (SessID){
		sessionid = SessID;
	}

	/*	
	// wg. Opera und old Firefox deaktiviert
	$("#button_submit, #button_normal, #button_normal2").ready(function(){	
		// javascript submit button einschalten UND normalen submitbutton ausschalten
		// damit browser die keine javascript unterstützen auch submiten können ;-)
		$('#button_submit').css('display', 'inline-block'); 
		$('#button_normal').css('display', 'inline-block');
		$('#button_normal2').css('display', 'inline-block');
		$('.old_submitbutton').css('display', 'none');
	});
	*/
  
	//Display Umkreissuche
	$("#cockpit_head_button1, #cockpit_umkreissuche .closebutton a").click(function(){	
		 if ($("#cockpit_umkreissuche").is(":hidden")) {
		    $("#cockpit_umkreissuche").slideDown("slow");
			$('#cockpit_head_button1 div').attr("id", 'current');
		  } else {
		    // schliessen
			$('*').css('cursor', 'wait'); 
			$('#cockpit_head_button1 div').attr("id", '');
			$("#cockpit_umkreissuche").hide();
			// neu laden
			location.href=location.protocol+"//" + location.host + location.pathname + "?displayUmkreis=off" + sessionid;
		  }
	});

	
	//ValidFKT PLZ
	function validPLZ() {
		var item = $("input[name='umkreisPLZ']");
		var plz = item.val();
		var retVal = false;		
		if (plz.length <= 5 && plz.length > 0) {			
			
			$.ajax({
				url: "ajax/web/cockpit.php",  				
				type: "POST",
				dataType: "xml",
				async: false,
				data: ({plz: plz, action: "checkplz"}),
				timeout: 3000,
  				success: function(xml){				
					if ($("status", xml).text() == "ERROR") {
						item.next("span").text($("message", xml).text());
						item.next("span").css({'color': 'red'});
						item.css({'border-color': 'red'});
						item.focus();
					} else {
						item.css({'border-color': ''});
						item.next("span").text("");
					}
  				}
			});
			
		} else {
			item.css({'border-color': ''});
			item.next("span").text("");
			retVal = true;
		}

		// Ermittung ob Fehler ausgetaucht		
		if(item.next("span").text()==""){
			retVal = true;
		}else{
			retVal = false;
		}
		return retVal;   
	}



	//check PLZ if valid
	$("input[name='umkreisPLZ']").blur(function(){		
		validPLZ();		
		return false;
	});


	//starte PLZ Umkreissuche wenn Umkreiskm sich ändern aber nur, wenn PLZ eingegeben ist
	$("select[name='umkreisKM']").change(function () {		
		var plz = $("input[name='umkreisPLZ']").val();
		var km = $("select[name='umkreisKM']").val();
		
		if(plz.length==5){
			$('*').css('cursor', 'wait'); 
			location.href=location.protocol+"//" + location.host + location.pathname + "?displayUmkreis=on&umkreisPLZ="+plz+"&umkreisKM="+km + sessionid;
		}		     		
	});
	

	//UMKREIS Submit prüfen
    $("#cockpit_umkreissuche form").submit(function() {
		var plzItem = $("input[name='umkreisPLZ']");
		var kmItem = $("select[name='umkreisKM']");		
		var plz = plzItem.val();
		var km = kmItem.val();
		
		if(!validPLZ()){
			return false;
		}
		
		if(plz.length==5 && km.length>0){
			$('*').css('cursor', 'wait'); 
			return true;	
		} else {
			if(plz.length != 5){
				plzItem.next("span").css({'color': 'red', 'font-weight': 'bold'});
				plzItem.next("span").text("PLZ fehlt!").show().fadeOut(3000);
			}				
			if(km.length < 1){
				kmItem.next("span").css({'color': 'red', 'font-weight': 'bold'});
				kmItem.next("span").text("Km fehlt!").show().fadeOut(3000);
			}	
			return false;	
		}
    });
	
	
	//Display Neuesuche
	$("#cockpit_head_button2, #cockpit_neusuche .closebutton a").click(function(){
		var displayparameter = "off";
		if ($("#cockpit_neusuche").is(":hidden")) {
		    // aktivieren
			displayparameter = "on";		  
		} else {
		    // schliessen
			displayparameter = "";		  		
		}
		$('*').css('cursor', 'wait'); 
		$('#cockpit_head_button2 div').attr("id", '');
		$("#cockpit_neusuche").hide();
		// neu laden
		location.href=location.protocol+"//" + location.host + location.pathname + "?neue="+displayparameter + sessionid;  
	});




	//Display Veranstalter
	$("#cockpit_head_button3, #cockpit_veranstaltersuche .closebutton a").click(function(){
		if ($("#cockpit_veranstaltersuche").is(":hidden")) {
		    // zeigen
		    $("#cockpit_veranstaltersuche").slideDown("slow");
			$('#cockpit_head_button3 div').attr("id", 'current');	  
		} else {
			// schliessen
			$('*').css('cursor', 'wait'); 
			$('#cockpit_head_button3 div').attr("id", '');
			$("#cockpit_veranstaltersuche").hide();
			// neu laden			
			location.href=location.protocol+"//" + location.host + location.pathname + "?veranstalter_user_id=" + sessionid;  
		}
	});

	//Display Suchfilter beim klick in das Suchenfeld
	$("#stichwortsuche input.stichwortsuche").click(function(){
		if ($("#cockpit_umkreissuche").is(":hidden")) {
		    // zeigen
			$("#cockpit_umkreissuche").slideDown("slow");
			$('#cockpit_head_button1 div').attr("id", 'current');
		}			 

		
		if ($("#cockpit_veranstaltersuche").is(":hidden")) {
		    // zeigen
		    $("#cockpit_veranstaltersuche").slideDown("slow");
			$('#cockpit_head_button3 div').attr("id", 'current');
		}
		
		if ($("#cockpit_ortsuche").is(":hidden")) {
		    // zeigen
		    $("#cockpit_ortsuche").slideDown("slow");
			$('#cockpit_head_button4 div').attr("id", 'current');	  
		}
	});	
	
	
	//select Veranstalter wechsel
	$("select[name='veranstalter']").change(function () {		
		$('*').css('cursor', 'wait');
		var veranstalter_user_id = $("select[name='veranstalter']").val(); 
		location.href=location.protocol+"//" + location.host + location.pathname + "?&veranstalter_user_id="+veranstalter_user_id + sessionid;
	});


	//Ort 
	$("#cockpit_head_button4, #cockpit_ortsuche .closebutton a").click(function(){
		if ($("#cockpit_ortsuche").is(":hidden")) {
		    // zeigen
		    $("#cockpit_ortsuche").slideDown("slow");
			$('#cockpit_head_button4 div').attr("id", 'current');	  
		} else {
			// schliessen
			$('*').css('cursor', 'wait'); 
			$('#cockpit_head_button4 div').attr("id", '');
			$("#cockpit_ortsuche").hide();
			// neu laden			
			location.href=location.protocol+"//" + location.host + location.pathname + "?ort_id=" + sessionid;  
		}
	});

	//select Ort wechsel
	$("select[name='ort']").change(function () {		
		$('*').css('cursor', 'wait');
		var ort_id = $("select[name='ort']").val(); 
		location.href=location.protocol+"//" + location.host + location.pathname + "?&ort_id="+ort_id + sessionid;
	});  
	
	
	//copy paste bei bestimmten unterdrücken 
	
	// deaktivieren da bei einigen browsern schwierigkeiten mit "ins feld klicken"
	//document.oncontextmenu = function() {return false;}
	/*
	 * deaktiviert da bei best. IE's keine Inputfelder mehr anklickbar sind
	$("input[name='user_email'], " +
	  "input[name='user_email_repeat'], " +
	  "input[name='lastschrift_bank_blz'], " +
	  "input[name='lastschrift_bank_ktonr'], " +
	  "input[name='lastschrift_bank_ktonr2']").bind('paste', function(e) {
        var feld = $(this);
        feld.val('');
        return false;
    });
    */
	
	//beim Laden der Seite
	if($("#errSeatsKommaList").length) {								
		var lueckeSeatId = $("#errLueckenSeatId").val();
		var kommaListString = $("#errSeatsKommaList").val();
		var abfallenderSeatId = $("#errAbfallenderSeat").val();
		//var helperString = 'new Array('+kommaListString+')';
		//alert(helperString);
		//var seatArray = eval(helperString);
		//alert(seatArray.length);		
		var seatArray = kommaListString.split(',');
		
		// markiert alle urspruenglich angehackte Sitzplätze
		for (var i = 0; i < seatArray.length; ++i) {						
			//alert(seatArray[i]);
			var checkbox = $("[value="+seatArray[i]+"][type=checkbox]");
			checkbox.attr('checked', true);
		}
		
		// Zeigt Lücke
		var luecke = $("[value='"+lueckeSeatId+"'][type=checkbox]");  
		luecke.wrap('<span></span>').parent().css({background:"black", border:"3px yellow solid"});
		luecke.qtip({ 
			 show: {when: false, // Don't specify a show event
			 ready: true // Show the tooltip when ready
			}, 
			hide: { when: { event: 'click' } },
			style: { 
				name: 'cream', 
				tip: true, 
				background: '#FFFDDF', 
				color: 'black',  
				border: {width: 1, radius: 5, color: 'black' }
			 },
			position: {
				corner: {
					target: 'topMiddle',
					tooltip: 'bottomMiddle'
				}
			},
			content: { text: '<b>Unzul&auml;ssige</b> Sitzplatz-L&uuml;cke wurde automatisch geschlossen!' }
		});
		
		// markiert Lücke als angehackt ... aufschliessen
		var lueckecheckbox = $("[value="+lueckeSeatId+"][type=checkbox]");
		lueckecheckbox.attr('checked', true);
		
		// demarkiert auf der anderen Seite den abfallenden Platz ... aufschliessen
		var abfallcheckbox = $("[value="+abfallenderSeatId+"][type=checkbox]");
		abfallcheckbox.attr('checked', false);

	}else{
		// nur wenn die Sitzplatzlueckenmeldung nicht aktiviert ist
		// Grund: brint Performance bei Sitzplatzlueckenmeldung 
		$('a img[title]').qtip({ 
			style: { 
				name: 'cream', 
				tip: true, 
				background: '#FFFDDF', 
				color: 'black',  
				border: {width: 2, radius: 5, color: '#FFF126' }
			 },
			position: {
				corner: {
					target: 'bottomMiddle',
					tooltip: 'topMiddle'
				}
			}
		});
	};
	
	function confirm(message, callback) {
		
		$('#confirm').modal({			
			closeHTML: "<a href='#' title='Schliessen' class='modal-close'>x</a>",
			position: ["20%",],
			overlayCss: {backgroundColor:"#444444"},
			overlayId: 'confirm-overlay',
			opacity:80,
			minHeight:400,
			minWidth: 600,			
			containerId: 'confirm-container', 
			onShow: function (dialog) {
				$('.message', dialog.data[0]).append(message);

				// if the user clicks "yes"
				$('.yes', dialog.data[0]).click(function () {
					// call the callback
					if ($.isFunction(callback)) {
						callback.apply();
					}
					// close the dialog
					$.modal.close();
				});
			},
			onOpen: function (dialog) {
				dialog.overlay.fadeIn(200, function () {
					dialog.data.hide();
					dialog.container.fadeIn(200, function () {
						dialog.data.slideDown(200);
					});
				});
			},	
			onClose: function (dialog) {
					dialog.container.fadeOut(300, function () {
							$.modal.close();
					});
			}
		});
	}
	
	
	//Platzkategorie wechseln 
	$(".pm_table .pm_free img").click(function(e){
		e.preventDefault();
		
		var id = $(this).attr('id');		
		confirm(cat_key[id][0], function () {			
			window.location.href = cat_key[id][1];
		});
		
	});	
	

	
	
}
