/************
	funzioni.js
	
	funzioni per le pagine delle gallerie
	
	4-4-2009
//*/

/***************************
	crea un oggetto galleria
*/
function CreaGalleria( pautore, pida, pidg ){
	aGallerie[++idGalleria] = new Object(); 
	aGallerie[idGalleria].nome = pautore;
	aGallerie[idGalleria].aut = pida;
	aGallerie[idGalleria].gal = pidg;
}


/****************************
	crea un oggetto galleria
	versione 2: deve coesistere con la prima!!
*/
function CreaGalleria_2( pida, pidg ){
	aGallerie[++idGalleria] = new Object(); 
	aGallerie[idGalleria].nome = aAutori[pida].path;
	aGallerie[idGalleria].aut = pida;
	aGallerie[idGalleria].gal = pidg;
}

/**************************************
mostra video tutte le gallerie aggiunte
*/
function VisGallerie(){

	// imposta il numero di colonne in base alla dimensione dello schermo
	var c = 5; 		// numero di colonne: default=5
	var w = "20%";	// larghezza colonna: default=20%
	if( screen.width <= 900  ){ c=4; w="25%"; }
	if( screen.width >= 1200 ){ c=6; w="16%"; }

	var a, g, pa, pg, t, n;

	//INIZIO DELLA TABELLA CON LE ANTEPRIME DELLE GALLERIE DEI SOCI
	document.write("<TABLE width=100% border=1>");

	// Esegue il ciclo principale sull'array aGallerie[]. Ogni riga è formata da 4,5 o 6 anteprime.
	for (j = 1; j < aGallerie.length; j++){

		if( j % c == 1 ) { document.write("<TR height=160>"); }	// Inizia una nuova riga
		
		a = aGallerie[j].aut;		//ID autore
		g = aGallerie[j].gal;		//ID galleria
		pa = aAutori[a].path;
		pg = aAutori[a].gallerie[g].path;
		t = aAutori[a].gallerie[g].titolo;
		n = aGallerie[j].nome;
		
		document.write("<TD class=Anteprime valign=middle align=center width='",w,"' height=160>");
		document.write("	<A class=BodyLinkGal href='", pg, "/index.htm'>");
		document.write("    <IMG style='border-color:#000000' src='", pg, aAutori[a].gallerie[g].iconaP, "' border=2><BR>[ ", t, " ]</A>");
		document.write("    <BR><A class=BodyLinkAut href='", pa, "/index.htm'>", n, "</A></TD>");
		
		if( j % c == 0 ) { document.write("</TR>"); }	// Termina la riga

	}

	// Esegue un ciclo per completare la riga per le volte in cui il numero delle gallerie non è multiplo di 4,5,6
	if ( aGallerie.lenght-1 % c != 0 ){

		j = aGallerie.length - 1;
		
		while ( j % c != 0 ){
			j++; 		document.write("<TD class=Anteprime>&nbsp;</TD>");	// scrive una cella vuota
		}
		
		document.write("</TR>");	// Termina la riga
		
	}

	document.write("</TABLE>");	// FINE DELLA TABELLA CON LE ANTEPRIME DELLE GALLERIE DEI SOCI

}


//FINE
