if(typeof jQuery != 'undefined') {
	$(document).ready(function() {
		$('#pics').click(function() {
			$('#news_text').hide(0);
			$('#news_img').show(0);
			$('#news_img .news-single-img').css('visibility', 'visible');
			$('#pics').hide(0);
			$('#text').show(0);
			
			/*$('.news-single-content').jScrollPaneRemove();
			$('.news-single-content').jScrollPane({
				showArrows: true,
				scrollbarWidth: 20
			});*/
			
			return false;
		});
		
		$('#text').click(function() {
			$('#news_img').hide(0);
			$('#news_text').show(0);
			$('#text').hide(0);
			$('#pics').show(0);
			
			/*$('.news-single-content').jScrollPaneRemove();
			$('.news-single-content').jScrollPane({
				showArrows: true,
				scrollbarWidth: 20
			});*/
			
			return false;
		});
		
	});
	
	Shadowbox.loadSkin('classic', '/fileadmin/web/scripts/shadowbox/skin');
	Shadowbox.loadLanguage('en', '/fileadmin/web/scripts/shadowbox/lang');
	Shadowbox.loadPlayer(['img', 'flv', 'html', 'iframe'], '/fileadmin/web/scripts/shadowbox/player');
	
	// load shadowbox
	if(typeof Shadowbox != 'undefined') {
		
		// media opener (shadowbox)
		$(document).ready(function() {
			var sets = new Object;
			var links = new Array;
			
			// init shadowbox
			Shadowbox.init({
				flvPlayer: '/fileadmin/web/scripts/shadowbox/flvplayer.swf',
				skipSetup: true,
				animate: true,
				animateFade: true,
				animSequence: 'sync',			// type of animation used to open the viewport (sync, wh, hw)
				modal: false,					// set this to true to disable closing shadowbox when clicking on the overlay
				autoplayMovies: true,
				showMovieControls: true,
				resizeDuration: 0.35,			// the duration in seconds of the resize animation
				fadeDuration: 0.35,				// the duration in seconds of the fading animation
				initialHeight: 160,				// the startup height of the viewport
				initialWidth: 320,				// the startup width of the viewport
				handleOversize: 'drag',			// you may also use 'none' or 'resize'
				displayNav: true,				// set this to false to disable the navigation
				continuous: false,				// set this to true to be able to jump to the first/last image form the end/start
				enableKeys: true,				// set this to false to disable keyboard interaction
				displayCounter: true,
				counterType: 'default',
				counterLimit: 10,
				viewportPadding: 20,
				
				onOpen: function(element) {
					
				},
				
				onFinish: function(element) {
					
				},
				
				onChange: function(element) {
					
				},
				
				onClose: function(element) {
					
				}
			});
			
			// read all media links
			$('a[rel^=shadowbox]').each(function() {
				
				// set gallery
				if(mode = $(this).attr('rel').match(/:(gallery|slideshow)\./i)) {
					title = $(this).attr('rel').split('.')[1];
					
					if(typeof sets[title] == 'undefined') {
						sets[title] = new Object();
						sets[title].title = title;
						sets[title].items = $('a[rel=' + $(this).attr('rel') + ']');
						sets[title].mode =mode[1];
					}
				} else {
					links.push($(this).get(0));
				}
			});
			
			// set up gallery items
			for(s in sets) {
				options = {
					gallery: sets[s].title,
					continuous: true,
					displayCounter: false
				};
				
				if(sets[s].mode == 'slideshow')
					options.slideshowDelay = 5;
				
				Shadowbox.setup(sets[s].items, options); 
			}
			
			// set up single media items
			if(links.length)
				Shadowbox.setup(links); 
		});
	}
}
