$(document).ready(function() {
	
	// Image Slider
	var div_w = 720;
	var lis = $("ul#uAcc li").length;
	var l_w = (div_w - (lis-1)) / lis;
	$("ul#uAcc li").css({"width":l_w,"overflow":"hidden"});
	//$("ul#uAcc").width(1000);
	$("ul#uAcc li:not(:first)").css({"border-left":"1px solid white"});

	$("ul#uAcc li").hover(
		function(e){
			var i_w = $(this).find("img").width();
			var l2_w = (div_w - i_w - (lis-1)) / (lis -1);
			$(this).find("div.bildlegende").show();
			$(this).css({"cursor":"pointer"});
			$("ul#uAcc li").not(this).stop().animate({width:l2_w},{queue:true,duration:400});
			$(this).stop().animate({width:i_w},{queue:true,duration:400});
		},
		function(e){
			$(this).find("div.bildlegende").hide();
			$(this).css({"cursor":"default"});
			$("ul#uAcc li").stop().animate({width:l_w},{queue:false,duration:400});
		}
	);
	
	// Lightbox
	var loadInIframeModal = function(hash){
   		var $trigger = $(hash.t);
		var $modal = $(hash.w);
   		var myUrl = $trigger.attr('href');
   		//var myTitle= $trigger.attr('title');
   		var $modalContent = $("iframe", $modal);
   		$modalContent.html('').attr('src', myUrl);
   		//let's use the anchor "title" attribute as modal window title
   		//$('#jqmTitleText').text(myTitle);
   		//hash.w.fadeIn(600); // hide window
   		$modal.fadeIn(600);
	}
	// initialise jqModal
	$('#modalWindow').jqm({
		modal: false,
		trigger: 'a.lightbox',
		target: '#jqmContent',
		onShow:  loadInIframeModal,
		onHide: function(h) {
 			h.w.fadeOut(600,function(){
    				h.o.remove(); // remove overlay          
    			}); // hide window
 		},
		overlay: 75
	}); 
	
	$('#modalWindowNews').jqm({
		modal: false,
		trigger: 'a.lightboxnews',
		target: '#jqmContentNews',
		onShow:  loadInIframeModal,
		onHide: function(h) {
 			h.w.fadeOut(600,function(){
    				h.o.remove(); // remove overlay          
    			}); // hide window
 		},
		overlay: 75
	});
	
	// News Lightbox
	var shortheight = $("div.news-single-item h2 p img").height() + 32;
	$("ul.news-list-container").css({"margin-top":shortheight});
	
	if($("ul.news-list-container li a").find("span").length == 0){
		$("ul.news-list-container li a:first").wrapInner("<span></span>");
	}
	
});
