function initOurBoard(){
	var accOurBoard = new Accordion($('ourBoardContainer'), 'h3.personName', 'div.personInfo', {
		start:'all-closed',
		alwaysHide:true,
		opacity:true,
		onActive: function(toggler, element){
			toggler.addClass("teamMemberActive");
		},
		onBackground: function(toggler, element){
			toggler.removeClass("teamMemberActive");
		}
	});
}

function initSlide(){
	if($('newsNVG')){
		containerHeight = $('listNewsIndex').getCoordinates().height;
		wrapperHeight = $('newsWrap').getCoordinates().height;
		offsetHeight = wrapperHeight - containerHeight + 5;
		var sliding = 0;
		
		if (offsetHeight >= 0){
			$('btnSlideUp').setStyle('display', 'none');
			$('btnSlideDown').setStyle('display', 'none');
		}else{
			var $moveUp = $('btnSlideUp');
			var $moveDown = $('btnSlideDown');
			
			$moveDown.addEvent('mousedown', function(){
				sliding = setInterval(function(){
					tempPosY = $('listNewsIndex').getStyle('top').toInt();
					//alert(tempPosY);
					if(tempPosY > offsetHeight)
						$('listNewsIndex').setStyle('top', tempPosY-1);
					else
						clearInterval(sliding);
				}, 30);
			});
			
			$moveDown.addEvent('mouseout', function(){
				clearInterval(sliding);
			});
			$moveDown.addEvent('mouseup', function(){
				clearInterval(sliding);
			});
			///////////
			$moveUp.addEvent('mousedown', function(){
				sliding = setInterval(function(){
					tempPosY = $('listNewsIndex').getStyle('top').toInt();
					if(tempPosY < 0)
						$('listNewsIndex').setStyle('top', tempPosY+1);
					else
						clearInterval(sliding);
				}, 30);
			});
			
			$moveUp.addEvent('mouseout', function(){
				clearInterval(sliding);
			});
			$moveUp.addEvent('mouseup', function(){
				clearInterval(sliding);
			});
			
		}
	}
}

function initSlideLifeAtNVG(){
	
	if($('ScrollImg')){
		
		var imgs = $$('#ScrollImg_content img');
		var imgsContainer = $('ScrollImg_content');
		var totalWidth = 0;
		var sliding = 0;
		var prevBtn = $('ScrollImg_previous');
		var nextBtn = $('ScrollImg_next');
		///////////////////////////////////
		for (var i=0; i<imgs.length; i++)
			totalWidth += imgs[i].getCoordinates().width.toInt()+12;	
			
		imgsContainer.setStyle('width', totalWidth);
		
		wrapperWidth = $('ScrollImg').getCoordinates().width;
		offsetHeight = wrapperWidth - totalWidth;
		
		/////////////////////////////////////		
		if (offsetHeight >= 0){
			prevBtn.setStyle('display', 'none');
			nextBtn.setStyle('display', 'none');
		}else{
			nextBtn.addEvent('mouseover', function(){
				sliding = setInterval(function(){
					tempPosX = imgsContainer.getStyle('left').toInt();
					if(tempPosX > offsetHeight)
						imgsContainer.setStyle('left', tempPosX-2);
					else
						clearInterval(sliding);
				}, 30);
			});
			
			nextBtn.addEvent('mouseout', function(){
				clearInterval(sliding);
			});
			///////////
			prevBtn.addEvent('mouseover', function(){
				sliding = setInterval(function(){
					tempPosX = imgsContainer.getStyle('left').toInt();
					if(tempPosX < 0)
						imgsContainer.setStyle('left', tempPosX+2);
					else
						clearInterval(sliding);
				}, 30);
			});
			
			prevBtn.addEvent('mouseout', function(){
				clearInterval(sliding);
			});
			
		}
	}
}
	
function flashBanner(containerName){
	if (!$(containerName))
		return;
	////////////////
	var imgs = new Array();
	var fadeInterval = 0;
	var curSlide = 0;
	
	imgs = $$("#"+containerName+" img");
	imgs.each(function(item){
		if (imgs.indexOf(item) > 0)
			item.setStyle("opacity", 0);
	});
	
	setInterval(function(){
		if (curSlide==imgs.length-1)
			tempSlide = 0;
		else
			tempSlide = curSlide + 1;
		///////////
		if (imgs[tempSlide].complete){
			curTween = new Fx.Tween(imgs[curSlide], {duration:2000});
			tempTween = new Fx.Tween(imgs[tempSlide], {duration:2000});
			curTween.start('opacity', '0');
			tempTween.start('opacity', '1');
			
			//imgs[curSlide].fade(0);
			//imgs[tempSlide].fade(1);
			curSlide = tempSlide;	
		}		
	}, 5000);
}
//////////// INIT ////////////////
window.addEvent('domready', function() {
	if ($('ourBoardContainer'))
		initOurBoard();
	
	flashBanner("indexImagesContainer");
	flashBanner("bodyBannerContainer");
	initSlide();
	initSlideLifeAtNVG();
});