$(document).ready(function(){

	$('#subcontent').hide();

	$('.post-content #postLink a').click(function() {	
										
	var myContentToLoad=($(this).attr("href"))+' #content-to-load';
     
		$('#subcontent').slideDown({ duration: 1000, easing: "easeOutQuad", complete: function() {
	
			$('#subcontent .loading').hide().load(myContentToLoad,'',function(){	
			
				handleNewsLoading();
			})
		}
	});
	
		return false;
	});
	
	
	function handleNewsLoading(){
		
		$('#subcontent .loading').show();
		
		
		/*--initalisiert die img buttons--*/
		$('.thumbs li a').lightBox({fixedNavigation:true, overlayOpacity:0.7});
		
		/*--initalisiert die scrollpane--*/
		$('#article-pane').jScrollPane({scrollbarWidth:5});
		
		
	}
	
	
	
	
	
	/*-- LOOK INSIDE sub Layer aurufen/ Inhalt liegt in der ensprechenden html Seite-----------------------------------------*/
	$('#btn-lookinside').click(function() {
										
		var mySubpage=($('#btn-lookinside a').attr("href"))	;
	
		var myContentToLoad=($('#btn-lookinside a').attr("href"))+' #content-to-load';
		
		
	
		$('#subcontent').slideDown({ duration: 1000, easing: "easeOutQuad", complete: function() {
			$('#subcontent .loading').hide().load(myContentToLoad,'',function(){	
				
				handleLoading(mySubpage);
				
				
			})
		}
		});
	
		return false;
	});
	
	
	
	/*--- LOOK INSIDE Weiche */
	function handleLoading(mySubpage){
	
		$('#subcontent .loading').fadeIn(300);	
			//book pageflip
			switch(mySubpage) {
			case '/index.php?id=7':
		
				loadBookSwf();
			
				break;
			
			// imfs videoseite  	
			case '/index.php?id=18':
				loadImfsMenue();
				iniVideoBtn();
				loadVideoPlayerSwf()
				
				break;
				
			}
		
	}
	
	
	
	/*--imfs video menue------------------------------------------*/
	function loadImfsMenue(){
    	$("div.scrollable").scrollable({
			size: 3
		});  
	}
	
	
	
	/*--imfs video menue btn------*/
	function iniVideoBtn(){
		$("div.scrollable a").mouseover(function(){
			var myBtn= ($(this));
					
		 });
	

	
		$('div.scrollable ul.items li a').click(function() {
												 
			var myId= ($(this).attr("id"));
			
			callFlashPlayVideo(myId);
			showDescription(myId);	
			return false;
		 });
	
	
	}
	function showDescription(myId){
		
		var tt=($('#tooltip_'+myId));
		var txt = tt.html()
		
		$('#description').html(txt)
	}
	
	
	
	
	/*externe VideoSteuerung  */
	var flashVideoPlayer;
    
    /* flashplayer initialisieren */
    function initializeVideoPlayer() {
        var isIE = navigator.appName.indexOf("Microsoft") != -1;
        flashVideoPlayer = (isIE) ? window['videoplayer'] : document['videoplayer'];
			
	}
	
	/*externe funktion in der swf aufrufen*/
	function callFlashPlayVideo(id) {
		var flv="../../../assets/files/flv/video_"+id+".flv"
	
      flashVideoPlayer.playVideo(flv);
    }
	
	
	/*load swf files*/
	function loadBookSwf(){
		var so = new SWFObject("assets/templates/book-flash/loader.swf", "skatebook", "898", "600", "8", "ffffff");
		
		so.addParam("allowFullScreen", "false");
		so.addParam("wmode", "transparent")
		so.write("bookFlashContent");
	}
	
	
	
	function loadVideoPlayerSwf(){
		
		var so = new SWFObject("assets/templates/videoplayer/videoPlayer.swf", "videoplayer", "480", "320", "8", "000000");
		so.addParam("allowFullScreen", "false");
		so.write("videoFlashContent");
		 initializeVideoPlayer()
		
	}
	
	
	
	
	
	
	
	$('.btn_close').click(function() {
		$('#subcontent .loading').hide()
	
		$('#subcontent').slideUp({ duration: 500, easing: "easeInOutQuad", complete: showBg});
		
		
		function showBg(){
				$('#subcontent .bg').css("display","block");
		}
		
		return false;
	});
	
	
	
	
	
	
 
	
	
	
	
	

	
	/* kann auch über btn lookinside augerufen werden, binz zu faul zum umschtreiben */
	/* sub page "about"*/
	
	$('#bookSub_8').click(function() {
							
		var toLoad=($('#bookSub_8 a').attr("href"))+' #content-to-load';
			

		$('#subcontent').slideDown({ duration: 1000, easing: "easeOutQuad", complete: function() {
			$('#subcontent .loading').hide().load(toLoad,'',function(){
				$('#subcontent .loading').fadeIn(300);								  
			})
		}
		});
	
		return false;
	});
	
	
	/* sub page "pro readers"*/

	$('#bookSub_6').click(function() {
									 
		var toLoad=$('#bookSub_6 a').attr("href")+' #content-to-load';
		
		$('#subcontent').show();
		$('#subcontent .bg').css("display","none");
	
		$('#subcontent .loading').hide().load(toLoad,'',showCont());
		
		function showCont(){
		
				$('#subcontent .loading').fadeIn(1000);		
		}
		
		return false;
	});
	
	
	
	
	
	/*---galery clicks---*/
	
	$('ul.items li a').click(function() {
						
		var toLoad=($(this).attr("href"))+' #content-to-load';
	
		
		$('#subcontent').slideDown({ duration: 1000, easing: "easeOutQuad", complete: function() {
																							  
			$('#subcontent .loading').hide().load(toLoad,'',function(){
					 $('.thumbs li a').lightBox({fixedNavigation:true, overlayOpacity:0.7});
				
				$('#subcontent .loading').fadeIn(300);								  
			})
		}
		});
	
		return false;
	});
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	function iniScrollbar(){
	
				// this initialises the  scollpanes on the page.
				
		$('#scrollbox').jScrollPane();
               
	
		};


	
});
