jQuery.noConflict();


var corrente = 0;

var carattere = Array("À","Á","Â","Ã","Ä","Å","Æ","Ç","È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","×","Ø","Ù","Ú","Û","Ü","Ý","Þ","ß","à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò","ó","ô","õ","ö","÷","ø","ù","ú","û","ü","ý","þ","ÿ","\"","&","<",">","€","ˆ","˜","…","™","'");


var sostituto = Array("&Agrave;","&Aacute;","&Acirc;","&Atilde;","&Auml;","&Aring;","&AElig;","&Ccedil;","&Egrave;","&Eacute;","&Ecirc;","&Euml;","&Igrave;","&Iacute;","&Icirc;","&Iuml;","&ETH;","&Ntilde;","&Ograve;","&Oacute;","&Ocirc;","&Otilde;","&Ouml;","&times;","&Oslash;","&Ugrave;","&Uacute;","&Ucirc;","&Uuml;","&Yacute;","&THORN;","&szlig;","&agrave;","&aacute;","&acirc;","&atilde;","&auml;","&aring;","&aelig;","&ccedil;","&egrave;","&eacute;","&ecirc;","&euml;","&igrave;","&iacute;","&icirc;","&iuml;","&eth;","&ntilde;","&ograve;","&oacute;","&ocirc;","&otilde;","&ouml;","&divide;","&oslash;","&ugrave;","&uacute;","&ucirc;","&uuml;","&yacute;","&thorn;","&yuml;","&quot;","&amp;","&lt;","&gt;","&euro;","&circ;","&tilde;","&hellip;","&trade;","&acute;");


function subchar(stringa)
{
	var nuovo = stringa;
	
	for(y=0;y<carattere.length;y++)
	{
		nuovo = nuovo.replace(carattere[y],sostituto[y]);
	}
	
	return nuovo;
}


function leggiXML()
{
	
	jQuery('<ul id="myMenu">').html('').appendTo('#elenco_news');
		
	jQuery.ajax({
		type: "GET",
		url: "../public/cms_testata.xml",
		dataType: "xml",
		success: function(xml) {
			jQuery(xml).find('notizia').each(function(){
				var titolo = jQuery(this).find('titolo').text();
					//titolo = subchar(titolo);
					titolo = titolo.replace(/\*/g,"<br>");
				
				var occhiello = jQuery(this).find('occhiello').text();
					//occhiello = subchar(occhiello);
					occhiello = occhiello.replace(/\*/g,"<br>");
					
				var corpo_notizia = jQuery(this).find('testo').text();
					corpo_notizia = corpo_notizia.replace(/\*/g,"<br>");
					//testo = subchar(testo);
					
				var immagine = jQuery(this).find('immagine').text();
				
				var link_url = jQuery(this).find('link_url').text();
				
				
				corrente +=1;
				
				var schedeHTML = "<div class=\"img_news\"><img src=\"http://www.ilas.com/"+immagine+"\" width=\"495\" height=\"280\" alt=\"notizia\"/></div>";
				schedeHTML += "<div class=\"testo_news\">";
				schedeHTML += "<div class=\"titolo_news\">"+titolo+"</div>";
				schedeHTML += "<div class=\"sottotitolo_news\">"+occhiello+"</div>";
						
				schedeHTML += "<div class=\"textbox\" id=\"textbox"+corrente+"\">";
								
				schedeHTML += "<div class=\"articolo_news\" id=\"testo"+corrente+"\">"+corpo_notizia+"</div></div>";
				schedeHTML += "<div class=\"scroll_area\" id=\"scroll_area"+corrente+"\">";
				schedeHTML += "<div class=\"scroll\" id=\"scroll"+corrente+"\"></div>";
				schedeHTML += "</div><div class=\"my_link\"><br><br><a href=\""+link_url+"\">link &raquo;</a></div>";
				schedeHTML += "</div>";
						jQuery('<div class="clearfloat"></div>').html('').appendTo('#contenitore_news_right');
			jQuery('</ul>').html('').appendTo('#elenco_news');
				
				if(corrente ==1)
				{
					jQuery('<li class=\"news_title_li_hover\" id=\"news_li_'+(corrente)+'\"></li>').html("<a href=\"#nogo\" onclick=\"slida("+(corrente)+")\">"+titolo+"</a>").appendTo('#myMenu');
					jQuery('<div class=\"singola_news\" id=\"scheda_news_'+(corrente)+'\" style=\"left:0px;\"></div>').html(schedeHTML).appendTo('#contenitore_news_right');
				}
				else
				{
					if(corrente%2 == 0)
					{
						jQuery('<li class=\"news_title_li_pari\" id=\"news_li_'+(corrente)+'\"></li>').html("<a href=\"#nogo\" onclick=\"slida("+(corrente)+")\">"+titolo+"</a>").appendTo('#myMenu');
						jQuery('<div class=\"singola_news\" id=\"scheda_news_'+(corrente)+'\"></div>').html(schedeHTML).appendTo('#contenitore_news_right');
					}
					else
					{
						jQuery('<li class=\"news_title_li\" id=\"news_li_'+(corrente)+'\"></li>').html("<a href=\"#nogo\" onclick=\"slida("+(corrente)+")\">"+titolo+"</a>").appendTo('#myMenu');
						jQuery('<div class=\"singola_news\" id=\"scheda_news_'+(corrente)+'\"></div>').html(schedeHTML).appendTo('#contenitore_news_right');
					}
				}
				

				//alert(schedeHTML);
				
			});
			settaScrollNews();
		}
	});
}
