var params = {
	galery:
	{
 		galleryBackgroundId :'layer-background',
 		galleryLayerId:'layer-image',
 		galleryBackgroundClose:true,
 		galleryClass: 'gallery',
 		galleryHorizontalMargin: 20,
 		galleryLoop:false,
		galleryOnPhotoLoad:function()
		 {	
		 	if(this.photos[this.photoElement.galleryIndex].caption.length == 1)
		 		$('caption').style.display = 'none';
		 	else
		 		$('caption').style.display = '';
		 		
		 		return true;
		 },
 		galleryOnPhotoError:function()
 		{
    		return true;
   		}
	},
	 slider_scroll:{
	 	slideShowClass: 'slideshow',
		slideShowTransType: 'scroll',
		slideShowCurrent: 0,
		slideShowLoop: false,
		slideShowWaitTime: 5000,
		slideShowOnShowSlide:function()
		{
			if($('galeria_left') != undefined)
			{
				if(this.currentSlide == 0)
					$('galeria_left').style.display = 'none';
				else
					$('galeria_left').style.display = '';
			}
			
			if($('galeria_right') != undefined)
			{
				if(this.currentSlide + 2 == this.getCount())
					$('galeria_right').style.display = 'none';
				else
					$('galeria_right').style.display = '';
			}
			
			if($('gal_act') != undefined)
				$('gal_act').innerHTML = (parseInt(this.currentSlide)+1)+'-'+(parseInt(this.currentSlide)+2);
			return true;
		}
	 }
};

function class_timer(czas, func) {
	
	this.czas = czas;
	this.func = func;
	
	this.start();
}

class_timer.prototype.start = function() {
	
	this.time = setInterval(this.func, this.czas);
};

class_timer.prototype.reset = function() {
	
	this.stop();
	this.start();
};

class_timer.prototype.stop = function() {
	
	clearInterval(this.time);
};

function extendForm() 
{
	FSite2.extendForm(document.body,params.galery);
	FSite2.extendForm(document.body,params.slider_scroll);
}
var slider_big;
var slider_right;


var flash_slide = (function(){
	var flash,elements,slideshow;
	
	return {
		init:function(){
			flash = FSite2.getElementsByClassName('right_menu_flash')[0];
			elements = FSite2.getElementsByClassName('element_p',flash);
			slideshow = FSite2.getElementsByClassName('slideshow_f')[0]; 
			
			for(var i = 0;i<elements.length;i++)
			{
				elements[i].onclick = function() {
					var id = this.id.split('_')[1];
					slideshow._slideShow.showSlide(parseInt(id,10));
				}
			}
		}
	};
	
}());

var sectionId;
function ready()
{
	var is_flash = DetectFlashVer(8,0,0);

	if(is_flash === true)
	{
		so = new SWFObject('/static/swf/topElteco.swf', 'flash', 960, 331, 8, '#ffffff');
		so.addParam('menu', false);
		so.addParam('wmode', 'transparent');
		so.addVariable('databasePath', '/slideshow.php');
		so.addVariable('sectionId', sectionId);
		so.write('flash'); 
	}
	else
	{
		$('nakladka').style.display = 'block';
		FSite2.getElementsByClassName('slideshow_f')[0].style.display = 'block';
		FSite2.getElementsByClassName('right_menu_flash')[0].style.display = 'block';
		slider_opacity = {
			slideShowClass: 'slideshow_f',
			slideShowTransTime: 500,
			slideShowWaitTime: 5000,
			slideShowTransType: 'opacity',
			slideShowCurrent: 0,
			slideShowLoop: true,
			slideShowOnShowSlide:function(){
				var id = this.currentSlide;
				var flash = FSite2.getElementsByClassName('right_menu_flash');
				var active = FSite2.getElementsByClassName('active',flash[0])[0];
				FSite2.unsetElementClass(active,'active');
				FSite2.setElementClass($('pf_'+id),'active');
			}
		}
		
		FSite2.extendForm(document.body,slider_opacity);
		
		flash_slide.init();
		
	}

	
	slider_big = null;
	slider_right = null;
	
	extendForm();
	
		if($('slider_gallery') != undefined)
		{
			FSite2.galleries.certyfikaty.loop = true;
			var slideshow_s = FSite2.getElementsByClassName('slideshow_s');
			
			if(slideshow_s.length > 0)
			{
				var wszystkich_slidow_big = parseInt(FSite2.getElementsByClassName('slideshow_slide', slideshow_s[0]).length);
				
				if(wszystkich_slidow_big > 2)
				{
					slider_big = new class_slider(wszystkich_slidow_big - 1);	
					slider_big.showFast(1);	
				}
			}
		}
		
		if($('slider_gallery_right') != undefined)
		{
			var slideshow_r = FSite2.getElementsByClassName('slideshow_r');
			
			if(slideshow_r.length > 0)
			{
				var wszystkich_slidow_right = parseInt(FSite2.getElementsByClassName('slideshow_slide', slideshow_r[0]).length);
				
				if(wszystkich_slidow_right > 1)
				{
					slider_right = new class_slider_right(wszystkich_slidow_right);
					slider_right.odswiez();
				}
			}
		}
		
		GoogleMap.init();
		
		
		
		
}

FSite2.ready(ready);

