// titolo = titolo dell'articolo
// file = file xml che contiene il testo dell'articolo
// foto = url immagine da affiancare all'articolo
// imgw = la larghezza dell'immagine
// imgalt = il testo del tooltip che appare passando il mouse sul collegamento
// bandiera = valore numerico che decide le rispettive posizioni (foto - testo)
//				(foto - testo) = 0			(testo - foto) = 1

function vai_text (titolo, foto, fotow, fotoalt, bandiera, notizia, n, day, month, year) {


var iniziale = new String;
var post = new String;
var pre = new String;
var foto2;
var imgw2;
var lcs;
var cs;
var responso;
var len;
var vlen;
var imgw = Number(fotow);


		
		//test_js_xml(file);
		notizia_elab();
		notizia_ret();
		notizia_chiocciola();
		iniziale = '<font size="4">' + notizia.charAt(0) + '</font>';
		notizia = notizia.substring(1);
		notizia = iniziale + notizia;
		var pretitolo = '<h4><span></span><div></div>' + titolo + '</h4>';
		var cale = '<div style="position:relative;left:550px;top:-30px;"><script type="text/javascript">calen(' + n + ',0,0,' + day + ',' + month + ',' + year +');</script></div>';
		var initable = '<table  width="100%"  border="0" align="center" cellpadding="8" cellspacing="3" <tr>';
		var pretesto = '<td><div class="Stile21" >' + notizia + '</div></td>';
		var carfoto = '<td align="center"><a href="' + foto + '" rel="lightbox" ><img src="' + foto + '" alt="' + fotoalt + '" border="0" style="width:' + imgw + 'pt;z-index:4"/></a></td>';
		
		var fine = '</tr></table>';
		
// CONTROLLA CHE NON SIANO DUE FOTO DA [bandiera]
if ( bandiera == "2" ) {
	foto2 = titolo;
	imgw2 = imgw;
	var carfoto2 = '<td align="center"><a href="' + foto2 + '" rel="lightbox" ><img src="' + foto2 + '" alt="' + fotoalt + '" border="0" style="width:' + imgw2 + 'pt;z-index:4"/></a></td>';
document.write ( initable + carfoto + carfoto2 + fine);

return;


}

//ESCLUDE IL TIOLO SE NON E' PASSATO COME ARGOMENTO
if (titolo == "" ) {

		pretitolo = "";
		}
//ESCLUDE L'IMMAGINE
if (foto == "" ) {

		carfoto = "";
		}
//ESCLUDE IL CALENDARIETTO SE NON VIENE PASSATO [DAY] COME ARGOMENTO		
if (day == "" ) {

			cale = "";
			}
//IMPOSTA LA TABLE bandiera = 0 TESTO A SINISTRA E FOTO A DESTRA
//				   bandiera = 1  VICEVERSA
		
if ( bandiera == "0" ) {

document.write ( pretitolo + cale + initable + pretesto + carfoto + fine);
					}
			else
				{
document.write ( pretitolo + cale + initable + carfoto + pretesto + fine);
				}

		return;
		



function notizia_elab() {
		//len = notizia.length;
		responso = notizia.indexOf('@');
		if (responso == -1) {
			return;
			}
			vlen = notizia.lastIndexOf('@');	
			lcs = 0;
			post = notizia;
			notizia = '';	
				do { 
  		 //inizio blocco di istruzioni
  			cs = post.indexOf('@');
			cs = cs +1;
			lcs = lcs + cs;
			pre = post.substring(0, (cs-1));
			responso = pre.indexOf('#');
			//alert(responso);
				if (responso != -1) 	{
						i = pre.indexOf('#');
						link = pre.substring(0,i);
						testo = pre.substring((i+1));
						pre = '<a href="' + link +'" target="_self" style="color:#2BF9E8;font-weight:bold;">' + testo + '</a><font color="#FFFFFF">';
						}
			
			notizia = notizia + pre;
			post = post.substring(cs);
	
  		//fine blocco di istruzioni 
  
				} while(lcs <= vlen);

			pre = post.substring(cs-vlen);
			notizia = notizia + pre ;
			
			return;

}


function notizia_ret() {
		//len = notizia.length;
		responso = notizia.indexOf('^');
		if (responso == -1) {
			return;
			}
			vlen = notizia.lastIndexOf('^');	
			lcs = 0;
			post = notizia;
			notizia = '';	
				do { 
  		 //inizio blocco di istruzioni
  			cs = post.indexOf('^');
			cs = cs +1;
			lcs = lcs + cs;
			pre = post.substring(0, (cs-1)) + '<br>';
			notizia = notizia + pre;
			post = post.substring(cs);
	
  		//fine blocco di istruzioni 
  
				} while(lcs <= vlen);

			pre = post.substring(cs-vlen);
			notizia = notizia + pre ;
			
			return;

}
function notizia_chiocciola() {
		//len = notizia.length;
		responso = notizia.indexOf('|');
		if (responso == -1) {
			return;
			}
			vlen = notizia.lastIndexOf('|');	
			lcs = 0;
			post = notizia;
			notizia = '';	
				do { 
  		 //inizio blocco di istruzioni
  			cs = post.indexOf('|');
			cs = cs +1;
			lcs = lcs + cs;
			pre = post.substring(0, (cs-1)) + '@';
			notizia = notizia + pre;
			post = post.substring(cs);
	
  		//fine blocco di istruzioni 
  
				} while(lcs <= vlen);

			pre = post.substring(cs-vlen);
			notizia = notizia + pre ;
			
			return;

}
}



