$(document).ready(function() {
	/**
	* Callback for gallerific keyboard navigation so that it can be turned on or off
	*
	*/
	GKeyboardNav = {
		flag: true,
		/**
		 * Returns whether or not the keyboard navigation must be enabled
		 *
		 * @returns boolean
		 */
		isEnabled: function()
		{
		    return this.flag;
		}
	};

	$(function() {
			var $contenttab = $( "#tabs" ).tabs({
				ajaxOptions: {
					error: function( xhr, status, index, anchor ) {
						$( anchor.hash ).html(
							" <img src='/gdkpimages/new_gdkp/scrabbi_fancy.png'/> ");
					}
				},
				load: function(event, ui) {
					$('a.openTab', ui.panel).click(function() {
					    if($(this).attr('id')) {
						tmp_paket = $(this).attr('id');
					    } else {
						tmp_paket = 251;
					    }
					    $contenttab.tabs('select', $(this).attr('name'));
					    $contenttab.tabs('option','enable', $(this).attr('name'));
					    return false;
					});
				},
				show: function(event, ui) {
					$('a.openTab', ui.panel).click(function() {
					    if($(this).attr('id')) {
						tmp_paket = $(this).attr('id');
					    } else {
						tmp_paket = 251;
					    }
					    $contenttab.tabs('select', $(this).attr('name'));
					    $contenttab.tabs('option','enable', $(this).attr('name'));
					    return false;
					});
				}
			});
			window.location.hash="";
			window.location.hash.replace("#", "");
	});

	/* Slide Animation 3 Kategorien */
	lastBlock = $("#a1");
	maxWidth = 590;
	minWidth = 150;

	$("ul li .switch").hover(
	function(){
	        $(lastBlock).animate({width: minWidth+"px"}, { queue:false, duration:800 });
	        $(this).animate({width: maxWidth+"px"}, { queue:false, duration:800});
        	lastBlock = this;
	});


	/* Tooltip Effekt und Fuktion in den Kategorien */
	$(".tipi").tooltip();

	/* This is basic - uses default settings */
	
	$("a#single_image").fancybox();
	
	/* Using custom settings */
	
	$("a#inline").fancybox({
	});
	
	$("a#outline").fancybox({
	});

	/* Apply fancybox to multiple items */
	
	$("a.group").fancybox({
		'transitionIn'	:	'fade',
		'transitionOut'	:	'fade',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	false
	});
	



	// increase the default animation speed to exaggerate the effect
	$.fx.speeds._default = 1000;
	$(function() {
		$( "#dialog" ).dialog({
			autoOpen: false,
			show: "blind",
			hide: "fade",
			modal: true
		});


		$( "#opener" ).click(function() {
			$( "#dialog" ).dialog( "open" );
			return false;
		});
		
		$( "#closer" ).click(function() {
			$( "#dialog" ).dialog( "close" );
			return false;
		});
	});
//});

//jQuery(document).ready(function($) {
	// We only want these styles applied when javascript is enabled
	$('div.navigation').css({'width' : '400px', 'float' : 'left'});
	$('div.content').css('display', 'block');

	// Initially set opacity on thumbs and add
	// additional styling for hover effect on thumbs
	var onMouseOutOpacity = 0.67;
	$('#thumbs ul.thumbs li').opacityrollover({
		mouseOutOpacity:   onMouseOutOpacity,
		mouseOverOpacity:  1.0,
		fadeSpeed:         'fast',
		exemptionSelector: '.selected'
	});

	// Initialize Advanced Galleriffic Gallery
				var gallery = $('#thumbs').galleriffic({
					delay:                     2500,
					numThumbs:                 16,
					preloadAhead:              10,
					enableTopPager:            true,
					enableBottomPager:         false,
					maxPagesToShow:            7,
					imageContainerSel:         '#slideshow',
					controlsContainerSel:      '#controls',
					captionContainerSel:       '#caption',
					loadingContainerSel:       '#fancybox-loading',
					renderSSControls:          true,
					renderNavControls:         true,
					playLinkText:              'Slideshow',
					pauseLinkText:             'Pause',
					prevLinkText:              '&lsaquo;&lsaquo;&lsaquo; ',
					nextLinkText:              ' &rsaquo;&rsaquo;&rsaquo;',
					nextPageLinkText:          'Next &rsaquo;',
					prevPageLinkText:          '&lsaquo; Prev',
					enableHistory:             false,
					autoStart:                 false,
					syncTransitions:           true,
					defaultTransitionDuration: 900,
					onSlideChange:             function(prevIndex, nextIndex) {
						// 'this' refers to the gallery, which is an extension of $('#thumbs')
						this.find('ul.thumbs').children()
							.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
							.eq(nextIndex).fadeTo('fast', 1.0);
						// Re-enable keyboard navigation globally 
					        GKeyboardNav.flag = true;  
					},
					onPageTransitionOut:       function(callback) {
						this.fadeTo('fast', 0.0, callback);
					},
					onPageTransitionIn:        function() {
						this.fadeTo('fast', 1.0);
					},
					enableKeyboardNavFunc: function(){ 
     						return GKeyboardNav.isEnabled(); 
					}
	});
//	$('.filtergame').click(function() {
//		$('#activefilter').text($(this).attr('id'));
//		var game = $(this).attr('id');
//		$('#thumbs').find('li').each(function(i) {
//			if($(this).hasClass(game)) {
//				alert($(this).attr('class'));
//				alert(game);
//			} else {
//				alert('Remove: '+$(this).attr('name'));
//				if (!gallery.removeImageByHash($(this).attr('name')))
//					alert("already removed");
//			}
//		});
//		$('li.all').hide();
//		$('li.'+$(this).attr('id')).show();
//		alert($(this).attr('id'));
//	});

});	

