/**  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * central jQuery init block with local plugins/functions a.s.o.
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * @project LIGA
 * @notes alle CSS-Abhaengigkeiten sind ggf. projektspezifisch anzupassen!
 * @see http://docs.jquery.com/Selectors
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * BaseIdea 4 switchStylestyle (extra files): By Kelvin Luck ( http://www.kelvinluck.com/ )
 * Under an Attribution, Share Alike License
 * @notes  piPatched: all Cookie functions jQuerysed (C)pinuts.de
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 */
 
 
	// cookie functions http://www.quirksmode.org/js/cookies.html
	jQuery.fn.createCookie = function(name,value,days) {
		if (days)
		{
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	}
	jQuery.fn.readCookie = function(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++)
		{
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) {
					return c.substring(nameEQ.length,c.length);
			}
		}
		return null;
	}
	jQuery.fn.eraseCookie = function(name) {
		$(this).createCookie(name,"",-1);
	}



/**
 * toggle box (slide up/down)
 */ 
function toggleBox(id) {
    $(id).click(function(){
        $(id+"Box").slideToggle(1000);
        $(id).toggleClass("open");
        $(id).toggleClass("close");
      });
}
/**
 * re-positioning relative
 * @param id STRING id of the o to move to
 * @param relObj jquery-selector with is the base object
 * @param x INTEGER relativ Position 
 * @param y INTEGER relativ Position 
 */ 
function jRelPos(id, relObj, x, y)
{
	var pos = $(relObj).position();
	$("#"+id).css("left",pos.left - x);
	$("#"+id).css("top",pos.top - y);
}

/**
 * show glossarlayer
 * @param layerId id of the glossarlayer
 * @param element jquery-selector for the positioning
 */ 
function showGlossar(layerId, element) {
	jRelPos(layerId, element, 50, 25);
    $('#'+layerId).show();
}

/**
 * Sitemapfilter
 * @param was STRING part to show
 * @mantis #20408
 */ 
function jSetSiteMapFilter(was)
{
	switch (was)
	{
		case 0:
			$("#Versorgung").show();
			$("#Zielgruppe").show();
			$("#Themen").show();
			$("#Service").show();
		break;
		case 1:
			$("#Versorgung").show();
			$("#Zielgruppe").hide();
			$("#Themen").hide();
			$("#Service").hide();
		break;
		case 2:
			$("#Versorgung").hide();
			$("#Zielgruppe").show();
			$("#Themen").hide();
			$("#Service").hide();
		break;
		case 3:
			$("#Versorgung").hide();
			$("#Zielgruppe").hide();
			$("#Themen").show();
			$("#Service").hide();
		break;
		case 4:
			$("#Versorgung").hide();
			$("#Zielgruppe").hide();
			$("#Themen").hide();
			$("#Service").show();
		break;
	}
}

/** ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * init all parts with j
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 */
$(function(){
			//SB-Custom-Version-4jQ
			Shadowbox.init();

			//UI-Tabs
			if ( $('#tabs').length ) {
				$("#tabs").tabs();
				$('.ui-tabs-panel table tr td:first-child').attr({style:"width:150px"});
			}

			//Farbwechsel
			$('div#Textblock table tr:even').addClass("AutoWechsel");

			//4iframe: gotototop
			if ( $('#innerbox').length ) {
				$('#innerbox').bind('load',function(){
					$(document).scrollTop(0);
				})
			}

			//Glossar
			if ( $('span.showGlossar').length ) {
			 $('span.showGlossar').mouseover(function(){
				var sID = $(this).attr('rel');
				jRelPos(''+sID+'', this, 0, -30);
				 $('#'+sID).show();
			 });
			 $('span.showGlossar').mouseout(function(){
				var sID = $(this).attr('rel');
				 $('#'+sID).hide();
			 });
/*			 
			 $('div.glossarLayer').mouseout(function(){
				 $(this).hide();
			 });
*/			 
			}

});


