var ke_modal_overlay=false;;
$.ajaxSetup ({cache: false});


function f(el, url, x, form){
	try{
			$.get(url, function(data) {
				createOverlay(el,data);
			});
	}catch(e){alert(e);}
	activetab=url+el;
	return false;
}


/**
 *
 * @access public
 * @return void
 **/
function fBlock(el, url, x, form){
	try{
			$.get(url, function(data) {
				createOverlay(el,data);
			});
	}catch(e){alert(e);}

	return false;
}

function fFormBlock(el, url, x, form){
	if (form) { vars = $('#'+form).serialize();}
	$.post(url, vars, function(data) {
		if (ke_modal_overlay) {
				if (ke_modal_overlay.isOpened()) {
				var wrap = ke_modal_overlay.getOverlay().find('p:first');
				if (!wrap.length || wrap.length==0) {
					ke_modal_overlay.getOverlay().append('<p></p>');
					var wrap = ke_modal_overlay.getOverlay().find('p:first');
				}
				wrap.html(data);
			}else{
				createOverlay(el,data);
			}
		}else{
			createOverlay(el,data);
		}
		//
	});
	return false;
}



/**
 *
 * @access public
 * @return void
 **/
function createOverlay(el, data){
	ke_modal_overlay=$("#"+el).overlay({
		onBeforeLoad: function() {
			var wrap = this.getOverlay().find('p:first');
			if (!wrap.length || wrap.length==0) {
				this.getOverlay().append('<p></p>');
				var wrap = this.getOverlay().find('p:first');
			}
			wrap.html(data);
		},
		mask: {
			color: '#fff',
			loadSpeed: 200,
			opacity: 0.9
		},
		//effect: 'apple',
		load: false,
		oneInstance: true,
		closeOnClick: false,
		api: true
	}).load();
	$("#"+el).overlay().load();
}




/**
 *
 * @access public
 * @return void
 **/
function fForm(el, url, x, form, nounblock){
	var vars=false;
	$("#"+el).slideUp();
	if (form) { vars = $('#'+form).serialize();}
	//setTimeout($.unblockUI, 2000);
	$.post(url, vars, function(data) {
			$("#"+el).html(data);
			if (x) {$("#"+el).slideDown();}
	});
	return false;
}

/**
 *
 * @access public
 * @return void
 **/
function closePop(el){
try{
	ke_modal_overlay.close();
	$("body").unbind();
}catch(e){}

}


function closer(el, img){
	if (document.getElementById(el).style.display == 'block') {
		$("#"+el).slideUp('slow', function() {});
	}else{
		$("#"+el).slideDown('slow', function() {});
	}
	return closePop(el);
}

function agentCallback(aid){
	fBlock("headerinfo", "ajax.php?t=setcallback&aid="+aid, true);
	return false;
}


/*
 * jquery-periodic.js
 *
 * Adds a "periodic" function to jQuery which takes a callback and
options for the frequency (in seconds) and a
 * boolean for allowing parallel execution of the callback function
(shielded from exceptions by a try..finally block.
 * The first parameter passed to the callback is a controller object.
 *
 * Return falsy value from the callback function to end the periodic
execution.
 *
 * For a callback which initiates an asynchronous process:
 * There is a boolean in the controller object which will prevent the
callback from executing while it is "true".
 *   Be sure to reset this boolean to false when your asynchronous
process is complete, or the periodic execution
 *   won't continue.
 *
 * To stop the periodic execution, you can also call the "stop" method
of the controller object, instead of returning
 * false from the callback function.
 *
 */
 jQuery.periodic = function (callback, options) {
      callback = callback || (function() { return false; });

      options = jQuery.extend({ },
                              { frequency : 3,
                                allowParallelExecution : false},
                              options);

      var currentlyExecuting = false;
      var timer;

      var controller = {
         stop : function () {
           if (timer) {
             window.clearInterval(timer);
             timer = null;
           }
         },
         currentlyExecuting : false,
         currentlyExecutingAsync : false
      };

      timer = window.setInterval(function() {
         if (options.allowParallelExecution || !
(controller.currentlyExecuting || controller.currentlyExecutingAsync))
{
            try {
                 controller.currentlyExecuting =
true;
                 if (!(callback(controller))) {
                     controller.stop();
                 }
             } finally {
              controller.currentlyExecuting = false;
            }
         }
      }, options.frequency * 1000);
};


function startPopup(url, w, h, id) {

	if (!id) {var id='windows1';}
	if (!w) {var w='600';}
	if (!h) {var w='500';}
 fenster = window.open(url, id, "width="+w+",height="+h+",status=no,scrollbars=yes,resizable=yes");
 fenster.focus();
}
























////////////// OLD KRAM

function zeige(klickdatum) {
    var jetzt = new Date();
    var heuteTag = jetzt.getDate();
    var heuteMonat = jetzt.getMonth()+1;
    if((klickdatum <= heuteTag) && (heuteMonat == 12))
    {
      tb_show("Ihr Kalendert&uuml;rchen f&uuml;r den "+klickdatum+".12.2008","tuerchen.php?height=300&width=395&klickdatum="+klickdatum,false);
    }
    else
    {
      alert ("Bitte gedulden Sie sich noch etwas ;-). Heute ist erst der "+heuteTag+"."+heuteMonat+".2008");
    }
  }
