$(document).ready(function() {
 	
	//activate jquery.pngfix for the hole site
	//$(document).pngFix({blankgif:'/fileadmin/templates/images/blank.gif'});
 	
	$("li.root-navi").hover(
		function(){
			$(this).addClass('sfHover'); //IE6 need this extra class to fake a li hover
			$('ul.items-level-2', this).css({'opacity':'1','display':'block'});
			$("div.addInfoContainer").css({'display': 'none'});
		}, 
		function() {
			$(this).removeClass('sfHover');
			//$('ul.items-level-2', this).animate({opacity:'toggle'},'fast');
			$('ul.items-level-2', this).css({'opacity':'0', 'display':'none'});
			$("div.addInfoContainer").fadeOut(200);
			//$("div.addInfoContainer").css({'opacity':'0', 'display':'none'});
			$("div.addInfoContainer").clearQueue();
		} 
	);
	
	$('#wrapper').before('<div class="addInfoContainer"><div class="addInfoContent"><img src="fileadmin/templates/images/addInfoImageBlank.gif" id="addInfoImage"/><div id="addInfoText"></div></div></div>');
	
	$("a.addInfoLoader").hover(
		function(){
			posLeftAddInfo = 0;	
			uid = this.id;
			//get position from open navi
			pos = $(this).closest('ul.items-level-2').offset();	
			posLeft = pos.left;
			
			//get width from actual open navi
			curLevel2_w = $(this).closest('ul.items-level-2').outerWidth();
	
			//correct the position for small submenus -1px
			posLeftAddInfo = posLeft + curLevel2_w -1;
			$("div.addInfoContainer").css({
				'margin-left': posLeftAddInfo+'px'
			}).delay(800).fadeIn('fast', function(){
				loadShortInfo(uid);
			});
				
		}, 
		function() {
			$("div.addInfoContainer").clearQueue();
		} 
	);
	
});
	  
$.fn.hoverClass = function(c) {
	return this.each(function(){
		$(this).hover( 
		function() { $(this).addClass(c);  },
		function() { $(this).removeClass(c); }
		);
	});
};	  

loadShortInfo = function(uid){
	$.ajax({
		url: "index.php",		// Achtung mit RealURL!
		type: "GET",			// Daten per GET verschicken
		data: {
			eID: "pagecontroller",	// die erstellte eID
			uid: uid,	// Benutzereingabe
			shortInfo: true
		},
		dataType: "json",		// das gibts zurück
		
		beforeSend: function()
		{
			$('#addInfoText').html('Inhalt wird geladen...');
			$('#addInfoImage').animate({
				'opacity': 0			
			}, 100, '', function(){
			});
		},
		// Es hat funktioniert?
		success: function(response) 
		{
			description = response.description;
			
			$('#addInfoText').html(response.description);
			$('#addInfoImage').attr('src', response.image);
			
		},
		complete: function(response){
			$('#addInfoImage').css('border', '1px solid #fff').animate({
				'opacity': 1			
			}, 500, '', function(){
			});				
		},
		// Schade, es war ein Fehler
		error: function(error) {
			alert("error");
		}
	});
}







