function makeDiv( classe, str ) {
	if (str != "") {
		return "<div class='" + classe + "'>" + str + "</div>";
	}
	return "";
}

function objMenuPage( voce, link, rollover ) {
	this.voce = voce;
	this.link = link;
	this.rollover = rollover;
	
	this.getLink = function() {
		var mylist = this.link.split(".");
		var m = mylist[0];
		var s = mylist[1];
		var p = mylist[2];
		var str = "?m=" +m;
		if (s) str += "&s=" + s;
		if (p) str += "&p=" + p;
		return str;
	}
}


function objPhotoGallery( voce, rollover, testo ) {
	this.voce = voce;
	this.rollover = rollover;
	this.testo = testo;
}

function objPage( tipo ) {
	this.tipo		  = tipo;
	this.titolo		  = "";
	this.sottoTitolo  = "";
	this.nota1		  = "";
	this.nota2		  = "";
	this.nota3		  = "";
	this.immagine     = "";
	this.box1	      = "";
	this.box2	      = "";
	this.box1Immagine = "";
	this.box2Immagine = "";
	this.box3Immagine = "";
	this.box4Immagine = "";
	this.ILayer 	  = "";
	this.menu		  = new Array();
	this.menuIndex	  = 0;
	this.moreInfo	  = "";
	this.flashPath    = "";
	this.flashX		  = 0;
	this.flashY		  = 0;
	this.photoGallery = new Array();
	this.photoIndex	  = 0;
	
	this.setTitolo = function( str ) { this.titolo = str; }
	this.setSottoTitolo = function( str ) { this.sottoTitolo = str; }
	this.setNota1 = function( str ) { this.nota1 = str; }
	this.setNota2 = function( str ) { this.nota2 = str; }
	this.setNota3 = function( str ) { this.nota3 = str; }
	this.setImmagine = function( str ) { this.immagine = str; }
	this.setBox1 = function( str ) { this.box1 = str; }
	this.setBox2 = function( str ) { this.box2 = str; }
	this.setBox1Immagine = function( str ) { this.box1Immagine = str; }
	this.setBox2Immagine = function( str ) { this.box2Immagine = str; }
	this.setBox3Immagine = function( str ) { this.box3Immagine = str; }
	this.setBox4Immagine = function( str ) { this.box4Immagine = str; }
	this.setFlash = function( path, x, y ) {
		this.flashPath = path;
		this.flashX = x;
		this.flashY = y;
	}
	this.setILayer = function( link ) {
		this.ILayer = "<iframe src='" + link + "' width='600' height='400'></ilayer>";
	}
	
	this.addMenu = function( voce, link, rollover ) {
		var myObj = new objMenuPage( voce, link, rollover );
		this.menu[ this.menuIndex++ ] = myObj;
	}
	
	this.addPhotoGallery = function( voce, rollover, testo ) {
		var myObj = new objPhotoGallery( voce, rollover, testo );
		this.photoGallery[ this.photoIndex++ ] = myObj;
	}

	this.setMoreInfo = function( str ) { this.moreInfo = str; }
		
	this.getTitolo = function() { return makeDiv( "titolo", this.titolo ); }
	this.getSottoTitolo = function() { return makeDiv( "sottoTitolo", this.sottoTitolo ); }
	this.getNota1 = function() { return makeDiv( "nota1", this.nota1 ); }
	this.getNota2 = function() { return makeDiv( "nota2", this.nota2 ); }
	this.getNota3 = function() { return makeDiv( "nota3", this.nota3 ); }
	this.getImmagine = function() {
		if (this.immagine != "") {
			return "<div class='immagine'><img id='imgCentrale' src='" + this.immagine + "' /></div>";
		}
		return "<div class='immagine'><img id='imgCentrale' class='noborder' src='../../img/trasparente.gif' /></div>";
	}
	this.getBox1Immagine = function() {
		if (this.box1Immagine != "") {
			return "<div class='immagine'><img src='" + this.box1Immagine + "' /></div>";
		}
		return "";
	}
	this.getBox2Immagine = function() {
		if (this.box2Immagine != "") {
			return "<div class='immagine'><img src='" + this.box2Immagine + "' /></div>";
		}
		return "";
	}
	this.getBox3Immagine = function() {
		if (this.box3Immagine != "") {
			var str = "<div class='moreInfo'><a href='javascript:openMoreInfo()'>" + voceMoreInfo + "</a></div>";
			return str + "<div class='immagine'><img src='" + this.box3Immagine + "' /></div>";
		}
		return "";
	}
	this.getBox4Immagine = function() {
		if (this.box4Immagine != "") {
			return "<div class='immagine'><img src='" + this.box4Immagine + "' /></div>";
		}
		return "";
	}
	this.getBox1 = function() {
		var str = this.getBox1Immagine();
		if (str == "" ) {
			return makeDiv( "box1", this.box1 );
		} else {
			return '<table width="100%"  border="0" cellspacing="0" cellpadding="0"><tr><td width="99%">' + makeDiv( "box1", this.box1 ) + '</td><td width="1%" nowrap="nowrap">' + str + '</td></tr></table>';
		}
	}
	this.getBox2 = function() {
		var str = this.getBox2Immagine();
		if (str == "" ) {
			return makeDiv( "box2", this.box2 );
		} else {
			return '<table width="100%"  border="0" cellspacing="0" cellpadding="0"><tr><td width="99%">' + makeDiv( "box2", this.box2 ) + '</td><td width="1%" nowrap="nowrap">' + str + '</td></tr></table>';
		}
	}
	this.getMenu = function() {
		if (this.menuIndex == 0) return "";
		var str = '<table width="100%" height="242" border="0" cellspacing="0" cellpadding="0"><tr><td valign="middle">';
		for (var i = 0; i < this.menuIndex; i++) {
			str += '<a onmouseover="rollover(\'' + this.menu[i].rollover + '\')" onmouseout="rolloverReset()" href="layer.html' + this.menu[i].getLink() + '">' + this.menu[i].voce + '</a>';
		}
		str += '</td></tr></table>';
		return str;
	}
	this.getMoreInfo = function() {return makeDiv( "content", this.moreInfo );}
	
	this.getFlash = function() {
		if (this.flashPath == "") return "";
		return '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="' + this.flashX + '" height="' + this.flashY + '" id="myflashid" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="' + this.flashPath + '" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="' + this.flashPath + '" quality="high" bgcolor="#ffffff" width="' + this.flashX + '" height="' + this.flashY + '" name="welPage" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
	}
	this.getPhotoGallery = function() {
		if (this.photoIndex == 0) return "";
		var str = '';
		for (var i = 0; i < this.photoIndex; i++) {
			if (i > 0) str += " | ";
			str += '<a onclick="rolloverGallery(\'' + this.photoGallery[i].rollover + '\', ' + i + ')" href="#">' + this.photoGallery[i].voce + '</a>';
		}
		str += '<br />&nbsp;<br />';
		return str;
	}
	
	this.getILayer = function() { return this.ILayer; }


}

function newLayer( tipo ) {
	return new objPage( tipo );
}
