var widthBlock=76;
var widthMargin=4;

var countBlocks=0;
var countVisibleBlocks=3;
var firstVisibleBlock=1;
var lastVisibleBlock=countVisibleBlocks;
var counter=1;
var posNow;
var posFin;
var stepPos=10;
var stepOpacity=100;
var op=100;
var op1=0;
var index=0;
var idT;
var idT1;
var idT2;
var isSlide=false;
var im;
var widthPic=200;
var heightPic=200;
var stepWidthZoom;
var stepHeightZoom;
var bigpic;
var border=15;


function sliderInitialize(){
	elemSlider=document.getElementById('slider');
	elemSliderList=document.getElementById('slider_list');
	elemPicture=document.getElementById('big_pic');
	
	tmp=countVisibleBlocks*widthBlock+(countVisibleBlocks-1)*widthMargin;
	elemSlider.style.width=tmp+'px';
	countBlocks=elemSliderList.getElementsByTagName('li').length;
	tmp=countBlocks*(widthBlock+widthMargin);
	elemSliderList.style.width=tmp+'px';
}

function sliderPrew(){
	if (firstVisibleBlock!=1 && !isSlide && countBlocks>countVisibleBlocks){
		posNow=parseInt(elemSliderList.style.left);
		posFin=parseInt(elemSliderList.style.left)+(widthBlock+widthMargin);
		stepPos=10;
		isSlide=true;
		slideLeft();
		firstVisibleBlock++;
		lastVisibleBlock--;
	}
}

function sliderNext(){
	if (lastVisibleBlock!=countBlocks && !isSlide && countBlocks>countVisibleBlocks){
		posNow=parseInt(elemSliderList.style.left);
		posFin=parseInt(elemSliderList.style.left)-(widthBlock+widthMargin);
		stepPos=-10;
		isSlide=true;
		slideRight();
		firstVisibleBlock--;
		lastVisibleBlock++;
	}
}

function slideLeft(){
	if (posNow+stepPos<=posFin){
		tmp=parseFloat(posNow)+parseInt(stepPos);
		elemSliderList.style.left=tmp+'px';
		posNow=tmp;
		idT=setTimeout("slideLeft()", 50);
	}else{
		clearTimeout(idT);
		isSlide=false;
	}
}

function slideRight(){
	if (posNow+stepPos>=posFin){
		tmp=parseFloat(posNow)+parseInt(stepPos);
		elemSliderList.style.left=tmp+'px';
		posNow=tmp;
		idT=setTimeout("slideRight()", 50);
	}else{
		clearTimeout(idT);
		isSlide=false;
	}
}

function picHide(){
	if  (op>0){
		op-=stepOpacity;
		elemPicture.style.opacity=op/100;
		elemPicture.style.filter="alpha(opacity="+op+")";
		idT1=setTimeout("picHide()", 20);
	}else{
		clearTimeout(idT1);
		elemPicture.src=tabImages[index].src;
		picShow();
	}
}

function picShow(){
	if  (op<100){
		op+=stepOpacity;
		elemPicture.style.opacity=op/100;
		elemPicture.style.filter="alpha(opacity="+op+")";
		idT1=setTimeout("picShow()", 20);
	}else{
		clearTimeout(idT1);
	}
}

function showNewPicture(ind){
	if (idT1) clearTimeout(idT1);
	index=ind;
	picHide();
}

function zoomHorizontal(){
	if  (Math.abs(widthPic-im.width-2*border)>0.1){
		widthPic+=stepWidthZoom;
		document.getElementById('bigpic_back').style.width=widthPic+'px';
		tmp=widthPic/2;
		document.getElementById('bigpic_back').style.marginLeft='-'+tmp+'px';
		idT2=setTimeout("zoomHorizontal()", 50);
	}else{
		clearTimeout(idT2);
		zoomVertical();
	}
}

function zoomVertical(){
	if  (Math.abs(heightPic-im.height-2*border)>0.1){
		heightPic+=stepHeightZoom;
		document.getElementById('bigpic_back').style.height=heightPic+'px';
		tmp=heightPic/2;
		document.getElementById('bigpic_back').style.marginTop='-'+tmp+'px';
		idT2=setTimeout("zoomVertical()", 50);
	}else{
		clearTimeout(idT2);
		bigpic.width=im.width;
		bigpic.height=im.height;
		bigpic.src=im.src;
		bigpic.style.display='block';
		bigpicShow();
	}
}

function bigpicShow(){
	if  (op1<100){
		op1+=stepOpacity;
		bigpic.style.opacity=op1/100;
		bigpic.style.filter="alpha(opacity="+op1+")";
		idT3=setTimeout("bigpicShow()", 20);
	}else{
		clearTimeout(idT3);
		document.getElementById('popup_close').style.display='block';
	}
}

function zoom(){
	document.getElementById('popup_close').onclick = function(e){
		document.getElementById('popup_pic').style.display='none';
		document.getElementsByTagName('html')[0].style.overflow='visible';
		if (navigator.appName.indexOf('Microsoft')!= -1){
			document.getElementsByTagName('html')[0].style.overflowY='scroll';
			document.getElementsByTagName('html')[0].style.overflowX='auto';
		}
	}
	if (navigator.appName.indexOf('Microsoft')!= -1){
		document.getElementById('popup_pic').style.top=document.documentElement.scrollTop+'px';
	}
	
	elem=document.getElementById('popup_pic');
	bigpic=document.getElementById('bigpic');
	document.getElementsByTagName('html')[0].style.overflow='hidden';
	document.getElementsByTagName('html')[0].style.overflowY='hidden';
	document.getElementById('bigpic_back').style.width='200px';
	document.getElementById('bigpic_back').style.height='200px';
	document.getElementById('bigpic_back').style.marginLeft='-100px';
	document.getElementById('bigpic_back').style.marginTop='-100px';
	document.getElementById('bigpic_back').style.background='#ffffff url(/images/splash/ico-loading.gif) center center no-repeat';
	document.getElementById('bigpic_border').style.paddingTop=border+'px';
	document.getElementById('bigpic_border').style.paddingLeft=border+'px';
	bigpic.style.display='none';
	document.getElementById('popup_close').style.display='none';
	elem.style.display='block';
	widthPic=200;
	heightPic=200;
	op1=0;
	im = new Image();
	im.onload = function(){
		document.getElementById('bigpic_back').style.background='#ffffff';
		stepWidthZoom=(im.width-widthPic+2*border)/10;
		stepHeightZoom=(im.height-heightPic+2*border)/10;
		zoomHorizontal();
	}
	im.src=tabImagesBig[index];
}

var tabImages=new Array();
var tabImagesBig=new Array();
