function PollVote(){
	var form = document.forms['ankieta'];
		form.submit();
}

var scroll;
var curPos;
var itemSize= 370;
var maxLength;
var news_timer;
var gal_timer;
var pol_timer;
var curPolPos;

var curPosGal;


window.addEvent("load",function(){
	var myAccordion = new Accordion($('wkomzy_accordion'), 'div.toggler', 'div.element', {
		opacity: false,
		onActive: function(toggler, element){
			toggler.setStyle('color', '#FFFFFF');
			setTimeout(function(){
				link = toggler.getChildren()[1].getChildren()[0].value;

				toggler.getChildren()[1].getElement('a').set('href',link);
			}
			, 1000);
		},
		onBackground: function(toggler, element){
			toggler.setStyle('color', '#FF0000');
			toggler.getChildren()[1].getElement('a').erase('href');
		}
	});
	
	var myAccordion = new Accordion($('bezkomzy_accordion'), 'div.toggler2', 'div.element2', {
		opacity: false,
		onActive: function(toggler, element){
		toggler.setStyle('color', '#FFFFFF');
		setTimeout(function(){
			link = toggler.getChildren()[1].getChildren()[0].value;

			toggler.getChildren()[1].getElement('a').set('href',link);
		}
		, 1000);
	},
	onBackground: function(toggler, element){
		toggler.setStyle('color', '#FF0000');
		toggler.getChildren()[1].getElement('a').erase('href');
	}
	});

});
//polecamy box in main page **********************
window.addEvent("load",function(){
	tape = document.getElementById("polecamy-box-window-tape");
	if( !tape ) return;
	
	itemsPolCount = $$('div.polecamy-box-window-tape-item').length;
	//itemsPolCount = itemsPolCount-1;
//alert(itemsCount);
	$('polecamy-box-window-tape').getChildren()[0].setStyles({display:'block',opacity: 0}).fade('in');;

	curPolPos = 0;
	
	clearTimeout(pol_timer);
	setTimeout("moverightP()", 4000);
});

function moverightP(){
	tape = document.getElementById("polecamy-box-window-tape");
	if( !tape ) return;

	//alert(curPolPos);
	if ((curPolPos+1)==itemsPolCount) nextPos =0; else nextPos = curPolPos+1; 
	$('polecamy-box-window-tape').getChildren()[curPolPos].setStyles({display:'none',opacity: 0});
	if ($('polecamy-box-window-tape').getChildren()[nextPos].getStyle('clear')!='both')
	{
		$('polecamy-box-window-tape').getChildren()[nextPos].setStyles({display:'block',opacity: 0}).fade('in');
		if ((curPolPos+1)==itemsPolCount) curPolPos = 0; else curPolPos++; 

	}
	else 
	{
		curPolPos = 0;
		$('polecamy-box-window-tape').getChildren()[curPolPos].setStyles({display:'block',opacity: 0}).fade('in');
	}
	clearTimeout(pol_timer);
//	alert(curPolPos);
	pol_timer = setTimeout("moverightP()", 4000);
}

function moveleftP(){
	tape = document.getElementById("polecamy-box-window-tape");
	if( !tape ) return;
	//alert(curPolPos);

	if ((curPolPos-1)<0) {nextPos = itemsPolCount-1;} else nextPos = curPolPos-1; 
	
	$('polecamy-box-window-tape').getChildren()[curPolPos].setStyles({display:'none',opacity: 0});
	if ($('polecamy-box-window-tape').getChildren()[nextPos].getStyle('clear')!='both')
	{
		
		$('polecamy-box-window-tape').getChildren()[nextPos].setStyles({display:'block',opacity: 0}).fade('in');
		if ((curPolPos-1)<0) curPolPos =itemsPolCount-1; else curPolPos--; 
	}
	else 
	{
		alert('hgjhj');
		curPolPos =itemsPolCount-1;
		$('polecamy-box-window-tape').getChildren()[curPolPos].setStyles({display:'block',opacity: 0}).fade('in');
	}
	
	clearTimeout(pol_timer);
	pol_timer = setTimeout("moverightP()", 4000);
}
// end of polecamy box section -------------------------


//news box in main page **********************
window.addEvent("load",function(){
	tape = document.getElementById("news-box-window-tape");
	if( !tape ) return;
	
	itemsCount = $$('div.news-box-window-tape-item').length;
//alert(itemsCount);
	$('news-box-window-tape').getChildren()[0].setStyles({display:'block',opacity: 0}).fade('in');;

	curPos = 0;
	
	clearTimeout(news_timer);
	setTimeout("moveright()", 4000);
});

function moveright(){
	tape = document.getElementById("news-box-window-tape");
	if( !tape ) return;

	if ((curPos+1)==itemsCount) nextPos =0; else nextPos = curPos+1; 
	$('news-box-window-tape').getChildren()[curPos].setStyles({display:'none',opacity: 0});
	$('news-box-window-tape').getChildren()[nextPos].setStyles({display:'block',opacity: 0}).fade('in');
	if ((curPos+1)==itemsCount) curPos = 0; else curPos++; 

	clearTimeout(news_timer);
	news_timer = setTimeout("moveright()", 4000);
}

function moveleft(){
	tape = document.getElementById("news-box-window-tape");
	if( !tape ) return;
	//alert(curPos);
	//alert("d");
	if ((curPos-1)<0) {nextPos = itemsCount-1; } else nextPos = curPos-1; 
	
	$('news-box-window-tape').getChildren()[curPos].setStyles({display:'none',opacity: 0});
	$('news-box-window-tape').getChildren()[nextPos].setStyles({display:'block',opacity: 0}).fade('in');
	if ((curPos-1)<0) curPos =itemsCount-1; else curPos--; 
	

	clearTimeout(news_timer);
	news_timer = setTimeout("moveright()", 4000);
}
// end of news box section -------------------------

//gallery box in main page **********************
window.addEvent("load",function(){
	tape = document.getElementById("gallerybox-window-tape");
	if( !tape ) return;
	
	itemsCountGal = $$('div.gallerybox-window-tape-item').length;
	$('gallerybox-window-tape').getChildren()[0].setStyles({display:'block',opacity: 0}).fade('in');;

	curPosGal = 0;
	
	clearTimeout(gal_timer);
	gal_timer = setTimeout("gallerymoveright()", 4000);
});

function gallerymoveright(){
	tape = document.getElementById("gallerybox-window-tape");
	if( !tape ) return;

	if ((curPosGal+1)==itemsCountGal) nextPos =0; else nextPos = curPosGal+1; 
	$('gallerybox-window-tape').getChildren()[curPosGal].setStyles({display:'none',opacity: 0});
	$('gallerybox-window-tape').getChildren()[nextPos].setStyles({display:'block',opacity: 0}).fade('in');
	if ((curPosGal+1)==itemsCountGal) curPosGal =0; else curPosGal++; 

	clearTimeout(gal_timer);
	gal_timer = setTimeout("gallerymoveright()", 4000);
}

function gallerymoveleft(){
	tape = document.getElementById("gallerybox-window-tape");
	if( !tape ) return;
	//alert(curPos);
	//alert("d");
	if ((curPosGal-1)<0) {nextPos = itemsCountGal-1; } else nextPos = curPosGal-1; 
	
	$('gallerybox-window-tape').getChildren()[curPosGal].setStyles({display:'none',opacity: 0});
	$('gallerybox-window-tape').getChildren()[nextPos].setStyles({display:'block',opacity: 0}).fade('in');
	if ((curPosGal-1)<0) curPos =itemsCountGal-1; else curPosGal--; 
	

	clearTimeout(gal_timer);
	gal_timer = setTimeout("gallerymoveright()", 4000);
}
// end of gallery box section -------------------------


function changeMenu(item){
	if (item==0){
		$('orange1').setStyles({display:'block',opacity: 0}).fade('in');
		$('orange2').setStyles({display:'block',opacity: 0}).fade('in');
		$('orange4').setStyles({display:'block',opacity: 0}).fade('in');
		(function() {$('green1').fade('out');}).delay(100);
		(function() {$('green2').fade('out');}).delay(100);
		//(function() {$('green3').fade('out');}).delay(100);
		(function() {$('green4').fade('out');}).delay(100);
	}
	if (item==1){
		$('green1').setStyles({display:'block',opacity: 0}).fade('in');
		$('green2').setStyles({display:'block',opacity: 0}).fade('in');
		//$('green3').setStyles({display:'block',opacity: 0}).fade('in');
		$('green4').setStyles({display:'block',opacity: 0}).fade('in');
		(function() {$('orange1').fade('out');}).delay(100);
		(function() {$('orange2').fade('out');}).delay(100);
		(function() {$('orange4').fade('out');}).delay(100);

	}
}

