var collectionAlbum = new Array();
var thumbsByPage = 25;
var fotowindow;


function Album( vDiretorio , vNumFotos )
{
	this.dir = vDiretorio;
	this.NumFotos = vNumFotos;

	//metodos:
	this.showPage = showPage;
	this.popUpFoto = popUpFoto;
	this.changeFoto = changeFoto;


	collectionAlbum.push( this );
	this.vID = collectionAlbum.length - 1;
}



function showPage( vPage )
{
	vStartThumb = ((vPage - 1) * thumbsByPage ) + 1;
	vHTML = ""
	for( i = vStartThumb ; i < (vStartThumb + thumbsByPage) && i <= this.NumFotos ; i ++ )
	{
		vHTML += "<a class='thumb' href='#' onClick='collectionAlbum[" + this.vID + "].popUpFoto(" + i + ")'>";
		vHTML += "<img src='" + this.dir + "/thumb" + i + ".jpg' border='0' /></a>";

	}
	vHTML += "<br style='clear:left' />";
	numPages = Math.ceil( this.NumFotos / thumbsByPage );
	if( numPages != 1 )
	{
		vHTML += "<div class='barraPaginacao'>Páginas: "
		for( i = 1 ; i <= numPages ; i ++ )
		{
			if( i == vPage )
			{
				vHTML += "&nbsp;" + i + "&nbsp;";
			}else{
				vHTML += "<a href='#' onClick='collectionAlbum[" + this.vID + "].showPage("+ i + ")'>" + i + "</a>";
			}
		}
		vHTML += "</div>"
	}
	document.getElementById("conteudo_centro").innerHTML = vHTML;
	for( i = 0 ; i <= 2 ; i ++ )
	{
		if( i == this.vID )
			{document.getElementById("tab"+ i).className = "selectedtab"}
		else
			{document.getElementById("tab"+ i).className = "tab"}
	}
}

function popUpFoto( vNumber )
{
	fotowindow=dhtmlmodal.open('EmailBox', 'div', 'Windowfoto', 'Album de Foto - Vida Nova' , 'width=505px,height=525px,center=1,resize=0,scrolling=0' , 'recal');
	this.changeFoto( vNumber );
}

function changeFoto( vNumber )
{
	vHTML = "<div style='width:100%;text-align:center;'><img src='"+ this.dir + "//foto" + vNumber + ".jpg' style='text-align:center;margin:0 auto;' /> <br />";
	if( vNumber > 1 ) 
		{vHTML += "<a href='#' class='linkAnt' onClick='collectionAlbum[" + this.vID + "].changeFoto(" + (vNumber-1 ) + ")'><< Anterior</a>"}
	
	if( vNumber < this.NumFotos )
		{vHTML += "<a href='#' class='linkProx' onClick='collectionAlbum[" + this.vID + "].changeFoto(" + (vNumber+1 ) + ")'>Próxima >></a>"}

	vHTML += "</div>"
	fotowindow.load('inline', vHTML , 'Album de Foto - Vida Nova' );
}