/*jquery my GALLERY */
/* Xenios Galerie 2011-02-14 */

var posLeft;
var slideCounter;
var oneSlide = 182;
var mySlideStartLeft=0;
var slideStartPos=0;
var navEnable = 1;
var stepPos = 0;
var ButtonFade = 450;
var IMG_FadeOutTime = 275;
var IMG_FadeInTime = 250;
var GalleryFade = 1000;
var GalleryTimeout = 6000;
var BtnFade= BtnFade;
var BTN_Border_Color_1 = '#FED060';
var BTN_Border_Color_2 = '#FFF6E3';


function XeniosGalleryFade() {
	/* für die grossen bilder einfaches faden ... */
	jQuery('#imageFade').innerfade({ 
		animationtype: 'fade', 
		speed: GalleryFade, 
		timeout: GalleryTimeout, 
		type: 'sequence', 
		containerheight: 'auto', 
		runningclass: 'innerfade'
	});
} /* eof XeniosGalleryFade */
function checkPos() {
	var reta = (slideCounter*oneSlide)-1;
	return reta;
}
function checkPosSliderButtons(inNmbr) {
	
	stepPos+=inNmbr; 
	
	if(stepPos>0) {
		jQuery('div.NaviLeft').show({opacity:1},ButtonFade);
	} else {
		jQuery('div.NaviLeft').hide({opacity:0},ButtonFade);
	}	
	
	if(stepPos<(slideCounter-1)) {
		jQuery('div.NaviRight').show({ opacity:1},ButtonFade);
	} else {
		jQuery('div.NaviRight').hide({ opacity:0},ButtonFade);
	} 
		
}
function initSlideGallery() {

	// blendet die Buttons ein wenn notwendig
	checkPosSliderButtons(0);	
	
	// set new Pos-Vars
	slideStartPos = jQuery('#thumbsDisplay_Mover').position();
	mySlideStartLeft = slideStartPos.left;

	// init ALL
	jQuery('img.IMGthumb').css('opacity', '0.85');
	
	// init 1st
	jQuery('img#th_0').css('border', '1px solid '+BTN_Border_Color_1).css('opacity', '1');
	
	// Thumbs
	jQuery('img.IMGthumb').hover(
		function () { jQuery(this).fadeTo(BtnFade, 1); }, 
		function () { jQuery(this).fadeTo(BtnFade, 0.85); }
	);
	jQuery('img.IMGthumb').click(function(){
	
		var test = jQuery(this).attr('rel').split('|');
		jQuery('#thumbsDisplay_Mover img.IMGthumb').css('border', '1px solid '+BTN_Border_Color_2);
		jQuery(this).css('border', '1px solid '+BTN_Border_Color_1);
		var einBild = jQuery('#BigContainer img').first();
		var zweiBild = einBild.clone();
		einBild.css('z-index',10);
		zweiBild.css('z-index',20).css('opacity',0.5).attr('src',test[0]).attr('title',test[1]).attr('alt',test[2]).appendTo(jQuery('#BigContainer')).fadeTo(IMG_FadeInTime,1);
		einBild.fadeTo(IMG_FadeOutTime,0,function() { jQuery(this).remove(); });
	});
	
	jQuery('div.NaviLeft').hover(
		function () { if( stepPos>0 && navEnable===1 ) { jQuery(this).fadeTo(BtnFade, 1);}},
		function () { jQuery(this).fadeTo(BtnFade, 0.55); }
	);	
	jQuery('div.NaviLeft').click(function(){
		if( stepPos>0 && navEnable===1) { 
		navEnable = 0; 
		jQuery('#thumbsDisplay_Mover').animate( {'left': '+='+oneSlide+'px'}, 700, 'easeInOutSine', function() { checkPosSliderButtons(-1); navEnable = 1; });
		}
	});
	
	jQuery('div.NaviRight').hover(
		function () { if( stepPos<slideCounter && navEnable===1 ) { jQuery(this).fadeTo(BtnFade, 1);}}, 
		function () { jQuery(this).fadeTo(BtnFade, 0.55); }
	);			
	jQuery('div.NaviRight').click(function(){
		if( stepPos<slideCounter && navEnable===1 ) {
			navEnable = 0; 
			jQuery('#thumbsDisplay_Mover').animate({'left': '-='+oneSlide+'px'},700,'easeInOutSine',function() { checkPosSliderButtons(1); navEnable = 1; });
		}
	});			 

} /* eof: initSlideGallery */

/* ONLOAD */
jQuery(document).ready(function(){
	if(jQuery('#thumbsDisplay_Mover').length>0) {initSlideGallery();}
	XeniosGalleryFade();
});			 
