// JavaScript Document

this.BasisPlaner = function(){
$("#Suchbegriff").unautocomplete().autocomplete("/najax/DocsSucheHome.cms", {
		width: "700",
		max:50,
		minChars:3,
		scrollHeight:400,
		selectFirst: true,
	});
	$("#Suchbegriff").result(function(event, data, formatted) {
		if(data[1]>0){
			$('#Suchbegriff').val('');
			document.location.href="/nano.cms/dokumentation/details/"+data[1];
//			document.location.href="/nano.cms/kongressprogramm/details?ID="+data[1];
		}else{
			$('#Suchbegriff').val(data[1]);
			$('#Hauptsuche').submit();
		}
	});
	if($('#Suchbegriff').val()!='' && $('#Suchbegriff').val()!='Suche')
		$("#Suchbegriff").focus();
}
this.BasisDokumentation = function(){
	$("#Suchbegriff").unautocomplete().autocomplete("/najax/DocsSucheHome.cms", {
		width: "700",
		max:50,
		minChars:3,
		scrollHeight:400,
		selectFirst: true,
	});
	$("#Suchbegriff").result(function(event, data, formatted) {
		if(data[1]>0){
			$('#Suchbegriff').val('');
			document.location.href="/nano.cms/dokumentation/details/"+data[1];
		}else{
			$('#Suchbegriff').val(data[1]);
			$('#Hauptsuche').submit();
		}
	});
	if($('#Suchbegriff').val()!='' && $('#Suchbegriff').val()!='Suche')
		$("#Suchbegriff").focus();
}
this.BasisNews = function(){
	$("#Suchbegriff").unautocomplete().autocomplete("/najax/NewsSuche.cms", {
		width: "700",
		max:50,
		minChars:3,
		scrollHeight:400,
		selectFirst: true,
	});
	$("#Suchbegriff").result(function(event, data, formatted) {
		if(data[1]>0){
			$('#Suchbegriff').val('');
			document.location.href="/nano.cms/news/details/"+data[1];
		}else{
			$('#Suchbegriff').val(data[1]);
			$('#Hauptsuche').submit();
		}
	});
	if($('#Suchbegriff').val()!='' && $('#Suchbegriff').val()!='Suche')
		$("#Suchbegriff").focus();
}
$(document).ready(function(){
	BasisPlaner();
});





















/** Start Tooltip **/
this.Tooltip = function(){
	$("a.Tooltip").each(function(){
		$(this).append('<img src="/kriminalpraevention/Images/Icons/Info.gif" width="16" height="16" style="margin-left:4px"alt="Information" class="Tooltip" title="'+ $(this).attr('Title') +'"/>');
	})
	/* CONFIG */		
		xOffset = -10;
		yOffset = -150;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	$("img.Tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";								  
		$("body").append("<p id='Tooltip'>"+ this.t +"</p>");
		$("#Tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		$("#Tooltip").remove();
    });	
	
	$("img.Tooltip").mousemove(function(e){
		$("#Tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
	$("a.Tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<p id='Tooltip'>"+ this.t +"</p>");
		$("#Tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		$("#Tooltip").remove();
    });	
	$("a.Tooltip").mousemove(function(e){
		$("#Tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			

};

// starting the script on page load
$(document).ready(function(){
	Tooltip();
});
/** End Tooltip **/


(function( $ ) {
  $.fn.blink = function( options ) {

    var settings = {
      maxBlinks    : undefined,
      blinkPeriod  : 1000,
      onMaxBlinks  : function() {},
      onBlink      : function(i) {},
      speed        : undefined
    };

    if(options) {
      $.extend(settings, options);
    }

    var blinkElem = this;
    var on = true;
    var blinkCount = 0;
    settings.speed = settings.speed ? settings.speed : settings.blinkPeriod/2;

    /* The function that does the actual fading. */
    (function toggleFade() {
      var maxBlinksReached = false;
      if(on){
        blinkElem.fadeTo(settings.speed, 0.01);
      } else {
        blinkCount++;
        maxBlinksReached = (settings.maxBlinks && (blinkCount >= settings.maxBlinks));
        blinkElem.fadeTo(settings.speed, 1, function() {
          settings.onBlink.call(blinkElem, blinkCount);
          if(maxBlinksReached) {
            settings.onMaxBlinks.call();
          }
        });
      }
      on = !on;

      if(!maxBlinksReached) {
        setTimeout(toggleFade, settings.blinkPeriod/2); // #3
      }
    })();

    return this; // Returning 'this' to maintain chainability.
  };
})(jQuery);



/** Start veraltet **/
function TextCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit)
field.value = field.value.substring(0, maxlimit);
else 
countfield.value = maxlimit - field.value.length;
}
/** Ende veraltet **/

function setFlashHeight(divid, newH){
	if($('#FlashHolder').length> 0){
		document.getElementById(divid).style.height = newH+"px";
		document.getElementById('FlashHolder').style.height = newH+"px";
	}
}


