	function startSlide(){
		$('.slide-ul').innerfade({
			speed: 2000,
			timeout: 6000,
			type: 'sequence',
			containerheight: '387px'
		});
	}

	$(document).ready(function(){
	
		/*workaround to remove index.php from href*/
		$("a.tablinks").each(function(){
                	var newHREF = '#tab-' + $(this).attr('rel');
                	$(this).attr('href', newHREF); 
      		});

      		/*create tabs*/
			$("#tabs").tabs();
			
		/*select tab from uri*/
			var urlid = jQuery.url.param('id');
			if ( urlid != null ) {
				//alert(urlid);
 				$("#tabs").tabs('select', '#tab-' + urlid);
			} else {
				var urlname = jQuery.url.attr('file');
				if (urlname != null) {
					urlname = urlname.substr(0,urlname.length-5);
					var tabs = $("#tabs .tablinks");
					for (var i = tabs.length - 1; i >= 0; i--){
						var t = tabs[i].title.toLowerCase();
						t = t.replace(/ \/ /g,'-')
							 .replace(/\/ /g,'-')
							 .replace(/ \//g,'-')
							 .replace(/\//g,'-')
							 .replace(/ +/,' ')
							 .replace(/ /,'-');
		//	alert(t + escape(t));	
						t=escape(t).replace(/%E4/g,'ae')
								.replace(/%F6/g,'oe')
								.replace(/%FC/g,'ue')
								.replace(/%DF/g,'ss')
								.replace(/%B0/g,'');			
						
						if (t == urlname.toLowerCase()) {
					     urlid = tabs[i].rel;
					     $("#tabs").tabs('select', '#tab-' + urlid);
					   }
					}
				} 
			}
			
		/*resize content*/
			$("#tabs").bind('tabsshow', function(event, ui) {
    				fix_outerwrap_bug();					
			});			
		
		$("a.tablinks").click(function() {
           		var url = "index.php?id=" + $(this).attr("rel");// ("href").substring(1);
			getContent(url);
			$(this).blur();
			return false;
        	});		
        	
		//Informieren das etwas passiert
		$("#gallery_img").ajaxStart(function() {
			//$(this).fadeOut();
		});
		
		//$("#slide-show").innerfade({ speed: 'slow', timeout: 3000, type: 'sequence', containerheight: '387px' });
		startSlide();
		
		//irgendwie kommt ein tab_pid in die Links per js <- is von dojo
//		$("#topnavi2 a").each(function(){
//			var ref = $(this).attr("href");
//			var pidpos = ref.indexOf("#tab_");
//			if(pidpos > 13) {
//				var pid = ref.substr(pidpos+5);
//				var uidpos = ref.indexOf("id=");			
//				$(this).attr("href","index.php?id="+pid);
//			}
//		});


	});
	
		function getContent(url) {
			$.ajax({
				//erweitere aufzurufenden Link für realurl :)
				//url: url.replace(/\.html/, "/ajax.html"),
				url: url+"&type=111",
				
				//wenn es geklappt hat
				success: function(html) {
					ajaxFlash = $(html).children("#ajaxFlash").html();
					if (ajaxFlash){
					
						$(".tx-lkgalerie-pi2").html(ajaxFlash);
						$( '.tx-lkgalerie-pi2 .media').media({
							width: 959,
							height: 387,
							autoplay: true,
							params:    { opaque: 'wmode' }
						});
					
				/*		$(".tx-lkgalerie-pi2").flash({
							src: ajaxFlash,
							width:959,
							height:387
						});
				*/
					}
					else {
						if( $("#thumbs").attr("id") == "thumbs" ) {
							$("#thumbs").fadeTo('slow','0.05',function() {
								$(this).html(html);
								$(this).fadeTo('slow','1.0');
								bindOnClick();
							});
						} else {
							$("#gallery_img").fadeTo('slow','0.05',function() {
								//$(this).html(html).attr('opacity','0.1');
								//$(this).children("ul").html(html);
								$(this).html(html);
								$(this).fadeTo('slow','1.0');
								startSlide();
							});		
						}
					}										
				}
			});
		}