var thisContent = 1;
//var nContents = 2;
//var hrs = new Array();
//hrs[0] = '/competitions/description/12/states';
//hrs[1] = '/competitions/description/9/states';

//var cont = new Array();
//cont[1] = '/img/1.jpg';
//cont[2] = '/img/2.jpg';


var maxPicWidth  = 719;
var minPicWidth  = 463;
var minSideWidth = 280;
var maxSideWidth = 300;
var offsetConst  = 20;
var nextid;
var timeoutID;


function mvis()
{
	gid('main-list').style.display = 'inline';
}


function ChangePicDiv()
{
try {
	gid('v_cover').style.display = 'none';
} catch(ex) {}
curWidth = gid('extdiv').offsetWidth;
st = gid('picdiv').style;
sd = gid('sidediv').style;
st.width = '';
if(curWidth <= (maxPicWidth)) 
{
	st.backgroundPosition = 'center center';
	sd.width = '';
	sd.display = 'none';
}
else 
{
	tWidth = (curWidth - minSideWidth)
	if(tWidth >= maxPicWidth)
	{
		st.width = maxPicWidth + 'px';
		st.backgroundPosition = 'right top';
		sd.width = (curWidth - maxPicWidth - (offsetConst*2)) + 'px';
		sd.left = (maxPicWidth + offsetConst) + 'px';
	}
	else
	{
		if(tWidth <= minPicWidth) tWidth = minPicWidth;
		st.width = tWidth + 'px';
		st.backgroundPosition = 'center center';
		sd.width = (curWidth - tWidth - (offsetConst*2)) + 'px';
		sd.left = (tWidth + offsetConst) + 'px';
	}
	sd.display = 'block';
	
	if(timeoutID) clearInterval(timeoutID);
	timeoutID = window.setInterval("show_vitr('/ajax/showvitr/"+ (curWidth - maxPicWidth - (offsetConst*2)) +"','sidediv')",30000);
}


}

function chCol()
{
	if(nContents == 1) gid('s1').style.display='none';
	else
	{
	for(i=1; i<= nContents; i++)
	{
	gid('s' + i).style.display='block';
	sto = gid('s' + i).style;
	if(i == thisContent)
		{
			sto.backgroundPosition = 'center top';
		}
		else
		{
			sto.backgroundPosition = 'center bottom';
		}
	}
	}

}


function doNext(ev)
{
if(nextid) clearTimeout(nextid);
layerObject = document.getElementById('picdiv').style;


if((thisContent+1) > nContents) thisContent=1;
else thisContent++;
layerObject.backgroundImage = 'url('+ cont[thisContent] +')';
st = gid('picdiv');

ex = gid('extdiv');
ex.style.backgroundColor = cColor[thisContent-1];

st.onclick = function(ev) {
	window.location.href = hrs[thisContent-1];
}

//cnu = document.getElementById('cnu');
//cnu.innerHTML = thisContent + '/' + nContents;

	chCol();

	if (window.event) {
		window.event.cancelBubble = true;
	}
	else if(ev) {
		ev.stopPropagation();
	}



nextid = window.setTimeout("doNext(null)", 10000);


}


function doPrev(event)
{
layerObject = document.getElementById('picdiv').style;



if((thisContent-1) <= 0) thisContent=nContents;
else thisContent--;
layerObject.backgroundImage = 'url('+ cont[thisContent] +')';
//cnu = document.getElementById('cnu');
//cnu.innerHTML = thisContent + '/' + nContents;

}
