/**
 * popup s plnou verzí
 */
function foto_popup(url)
{
	var w=800;
	var h=600;
	var l = screen.width/2-w/2;
    var t = screen.height/2-h/2-50;
    if (l<0) l = 0;
    if (t<0) t = 0;
	var wf = window.open(url,'car_foto','status=no,width='+w+',height='+h+',resizable=no,menubar=no,location=no,scrollbars=no,toolbar=no,left='+l+',top='+t+'');
	wf.focus();
	return false;
}


/**
 * listování fotkami na kartě
 */
function fPrev()
{
	if (fCurr < 1) return false;
	fSet(fCurr-1);
	fBNext.className = 'button-dw';
	if (fCurr < 1)
		fBPrev.className = 'button-up off';
	else
		fBPrev.className = 'button-up';
	return false;
}


/**
 * listování fotkami na kartě
 */
function fNext()
{
	if (fCurr > fFiles.length - fNum - 1) return false;
	fSet(fCurr+1);
	fBPrev.className = 'button-up';
	if (fCurr > fFiles.length - fNum - 1)
		fBNext.className = 'button-dw off';
	else
		fBNext.className = 'button-dw';
	return false;
}


/**
 * nastaví na kartě fotky, případně loaduje do "cache"
 */
function fSet(from)
{
	fCurr = from;
	for (i = 0; i < fNum; i++)
	{
		if (!fFiles[fCurr+i]) break;
		if (!fImgs[fCurr+i].src)
			fImgs[fCurr+i].src = fFiles[fCurr+i];
		fElems[i].src = fImgs[fCurr+i].src;
		fLinks[i].href = '/Car/bigPhoto/'+fVuzId+'/'+(from+i);
	}
	fLabel.innerHTML='snímky '+(from+1)+'-'+(from+fNum)+' z '+fFiles.length;
}


/**
 * listování v popupu
 */
function fBigPrev()
{
	if (fCurr < 1) return false;
	fSet(fCurr-1);
	fBNext.className = 'button-dw';
	if (fCurr < 1)
		fBPrev.className = 'button-up off';
	else
		fBPrev.className = 'button-up';
	return false;
}


/**
 * listování v popupu
 */
function fBigNext()
{
	if (fCurr > fFiles.length - 2) return false;
	fBigSet(fCurr+1);
	fBPrev.className = 'button yellow prev-noshadow';
	if (fCurr > fFiles.length - 2)
		fBNext.className = 'button yellow next-noshadow off';
	else
		fBNext.className = 'button yellow next-noshadow';
	return false;
}


/**
 * listování v popupu
 */
function fBigPrev()
{
	if (fCurr < 1) return false;
	fBigSet(fCurr-1);
	fBNext.className = 'button yellow next-noshadow';
	if (fCurr < 1)
		fBPrev.className = 'button yellow prev-noshadow off';
	else
		fBPrev.className = 'button yellow prev-noshadow';
	return false;
}


/**
 * nastaví na velkou fotku, případně loaduje do "cache"
 */
function fBigSet(i)
{
	fCurr = i;
	if (!fFiles[i]) return;
	if (!fImgs[i].src)
		fImgs[i].src = fFiles[i];
	fElem.src = fImgs[i].src;
}
 
function goHistory(carId)
{
	if (carId != 0)
		document.location = "/Car/" + carId;
}
