// JavaScript Document
var bannerkey=Math.ceil(Math.random()*10000);

function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}

function checkVersion()
{
  var msg = "You're not using Internet Explorer.";
  var ver = getInternetExplorerVersion();

  if ( ver > -1 )
  {
    if ( ver >= 8.0 ) 
      msg = "You're using a recent copy of Internet Explorer.";
    else
      msg = "You should upgrade your copy of Internet Explorer.";
  }
  alert( msg );
}

/* Legge un parametro -name- dalla query string */
function getParameterByName( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}


function Fetch() {
 this.result = null;
 this.Xml = function(params) {
  this.post(params, 'xml');
 };
 this.Html = function(params) {
  this.post(params, 'html');
 };
 this.Json = function(params) {
  this.post(params, 'json');
 };
 this.post = function (params, dataType) {
  var result   = null;
  var response = $.post("service.php",params,function(data) { 
         result = data;
		 },dataType);
  this.result  = result;
 };
}


function CaricaCartoon_old(xml) {
	$(xml).find('cartoon').each(function() {
				var txthtml='';
				$(xml).find('itemcartoon').each(function() {
					var id = $(this).find('id').text();
					var urlimg = $(this).find('image').text();
					var testo = $(this).find('testo').text();
					var link = $(this).find('link').text();
					if(urlimg!=null && urlimg!="") {
						txthtml='<li>' + '<a href="'+ link +'" title="'+ testo +'"><img src=\''+ urlimg +'\' alt="'+ testo +'"/>' + '</li></a>' + txthtml;
					}
				});
				$('<ul id="listacartoni"></ul>').html(txthtml).appendTo('#barracartoni');
			});
}

function CaricaBanner(xml, posizione) {
	var txthtml='';
	$(xml).find('banner').each(function() {		
		$(xml).find('itembanner').each(function() {
			var id = $(this).find('id').text();
			var urlimg = $(this).find('image').text();
			var testo = $(this).find('testo').text();
			var link = $(this).find('link').text();			
			if(posizione=="banneralto") {
				if(id!=null && id=="1") {
					txthtml='<a href=\''+link+'\'><img src=\''+ urlimg +'\' alt=\''+testo+'\' id="bannerAltoimg" height="87" width="726" border="0" /></a>';
				}
			}
			else {
				if(id!=null && id=="2") {
					txthtml='<a href=\''+link+'\'><img src=\''+ urlimg +'\' alt=\''+testo+'\' id="boxbannerimg" height="250" width="300" border="0" /></a>';
				}
			}
		});
	});
	if(posizione=="banneralto") {
		$('<div id="banneralto"></div>').html(txthtml).appendTo('#bannercontainer1');
	}
	else {
		$('<div id="boxbanner"></div>').html(txthtml).appendTo('#bannercontainerdx1');
	}
}



function CaricaNovita(xml) {
$(xml).find('areanews').each(function() {	
				var txthtml='';
				$(xml).find('itemareanews').each(function() {
					var id = $(this).find('id').text();
					var urlimg = $(this).find('image').text();
					var testo = $(this).find('testo').text();
					var descrizione = $(this).find('descrizione').text();
					var link = $(this).find('link').text();						
					if(testo!=null && testo!="") {
						txthtml='<div style="width: 162px; height: 62px; float: left;"><div class="boxfotoeditoriale"><a href="' + link + '"><img src="'+urlimg+'" border="0" /></a></div></div>'+'<div class="testoboxgrande"><strong>' + testo + '</strong><br />' + descrizione + '<br />' + '<img src="img/pallarossa.gif" align="left" hspace="3" vspace="2" />' + '<a href="' + link + '" class="linktestoboxgrande"> vai </a></div>';
						$('<span></span>').html(txthtml).appendTo('#testonovita');
					}
				});				
			});
}

function LoadBoxLanciSmall(xml) {
$(xml).find('areaboxlancismall').each(function() {	
				var txthtml='';
				var txthtmlDopoImg ='<div id="topboxlancios"><img src="img/topboxdx.gif" width="307" height="2" /></div><div id="centerboxlancios"><div id="testolancios">';
				var txthtmlDopo='</div></div><div id="bottomboxlancios"></div>';
				$(xml).find('itemarealancios').each(function() {
					var id = $(this).find('id').text();
					var urlimg = $(this).find('image').text();
					var testo = $(this).find('testo').text();
					var descrizione = $(this).find('descrizione').text();
					var link = $(this).find('link').text();	
					var titolobox = $(this).find('titolobox').text();
					var targetlink = $(this).find('target').text();
					var target1 = "_self";
					if(targetlink!=null && targetlink!="") {
						if(targetlink=="true") {
							target1 = "_blank";
						}	
					}		
					var txthtmlTitoloBox = '<div id="titololancios" name="titololancios" ><strong>'+titolobox+'</strong></div>';				
					if(testo!=null && testo!="") {
						txthtml= txthtmlTitoloBox + txthtmlDopoImg + '<div class="boxfotoeditoriale"><a href="' + link + '" target="' + target1 + '"><img src="'+urlimg+'" border="0" /></a></div>'+'<div class="testoboxgrande"><strong>' + testo + '</strong><br />' + descrizione + '<br />' + '<img src="img/pallarossa.gif" align="left" hspace="3" vspace="2" />' + '<a href="' + link + '"target="' + target1 + '" class="linktestoboxgrande"> vai </a></div>';
						txthtml= txthtml + txthtmlDopo;
						$('<div id="boxlancios"></div>').html(txthtml).appendTo('#boxlancismall');
					}
				});				
			});
}

function LoadBoxLancioBig(xml) {
$(xml).find('areaboxlancibig').each(function() {	
				var txthtml='';
				var txthtmlDopoImg = '<div id="topboxlanciobig"><img src="img/topboxdx.gif" width="307" height="2" /></div><div id="centerboxlanciobig"><div id="testolanciobig">';
				var txthtmlDopo='</div></div><div id="bottomboxlanciobig"></div>';
				$(xml).find('itemarealanciob').each(function() {
					var id = $(this).find('id').text();
					var urlimg = $(this).find('image').text();
					var testo = $(this).find('testo').text();
					var descrizione = $(this).find('descrizione').text();
					var link = $(this).find('link').text();	
					var titolobox = $(this).find('titolobox').text();
					var targetlink = $(this).find('target').text();
					var target1 = "_self";
					if(targetlink!=null && targetlink!="") {
						if(targetlink=="true") {
							target1 = "_blank";
						}	
					}
					var txthtmlTitoloBox = '<div id="titololanciobig" name="titololanciobig" ><strong>'+titolobox+'</strong></div>';				
					if(testo!=null && testo!="") {
						txthtml= txthtmlTitoloBox + txthtmlDopoImg + '<div class="boxfotoeditoriale"><a href="' + link + '" target="' + target1 + '"><img src="'+urlimg+'" border="0" /></a></div>'+'<div class="testoboxgrande"><strong>' + testo + '</strong><br />' + descrizione + '<br />' + '<img src="img/pallarossa.gif" align="left" hspace="3" vspace="2" />' + '<a href="' + link + '"target="' + target1 + '" class="linktestoboxgrande"> vai </a></div>';
						txthtml= txthtml + txthtmlDopo;
						$('<div id="boxlanciobig"></div>').html(txthtml).appendTo('#boxlancibig');
					}
				});				
			});
}

function LoadBoxBottom(xml) {
	$(xml).find('areaboxlancibottom').each(function() {	
				var txthtml='';
				var txthtmlDopoImg ='<div id="topboxbottom"><img src="img/topboxdx.gif" width="307" height="2" /></div><div id="centerboxbottom"><div id="testolanciobottom">';
				var txthtmlDopo='</div></div><div id="bottomboxbottom"></div>';
				$(xml).find('itemarealanciobottom').each(function() {
					var urlimg = $(this).find('image').text();
					var testo = $(this).find('testo').text();
					var descrizione = $(this).find('descrizione').text();
					var link = $(this).find('link').text();	
					var titolobox = $(this).find('titolobox').text();
					var targetlink = $(this).find('target').text();
					var target1 = "_self";
					if(targetlink!=null && targetlink!="") {
						if(targetlink=="true") {
							target1 = "_blank";
						}	
					}		
					var txthtmlTitoloBox = '<div id="titololanciobottom" name="titololanciobottom" ><strong>'+titolobox+'</strong></div>';				
					if(testo!=null && testo!="") {
						txthtml= txthtmlTitoloBox + txthtmlDopoImg + '<div class="boxfotoeditoriale"><a href="' + link + '" target="' + target1 + '"><img src="'+urlimg+'" border="0" /></a></div>'+'<div class="testoboxgrande"><strong>' + testo + '</strong><br />' + descrizione + '<br />' + '<img src="img/pallarossa.gif" align="left" hspace="3" vspace="2" />' + '<a href="' + link + '"target="' + target1 + '" class="linktestoboxgrande"> vai </a></div>';
						txthtml= txthtml + txthtmlDopo;
						$('<div id="boxbottom"></div>').html(txthtml).appendTo('#boxlancibottom');
					}
				});				
			});
}




function CaricaGioco(xml) {
	$(xml).find('areagioca').each(function() {
				var txthtml='';
				$(xml).find('itemareagioca').each(function() {
					var id = $(this).find('id').text();
					var urlimg = $(this).find('image').text();
					var testo = $(this).find('testo').text();
					var descrizione = $(this).find('descrizione').text();
					var link = $(this).find('link').text();					
					if(testo!=null && testo!="") {
						txthtml='<div style="width: 162px; height: 62px; float: left;"><div class="boxfotoeditoriale"><img src="'+urlimg+'" /></div></div>'+'<div class="testoboxgrande"><strong>' + testo + '</strong><br />' + descrizione + '<br />' + '<img src="img/pallarossa.gif" align="left" hspace="3" vspace="2" />' + '<a href="' + link + '" class="linktestoboxgrande">vai</a></div>';					
						$('<span></span>').html(txthtml).appendTo('#testogioco');
					}
				});				
			});
}

function CaricaLanci(xml) {
	$(xml).find('lanci').each(function() {
				var txthtml='';
				var tagfoto='';
				$(xml).find('itemlanci').each(function() {
					var id = $(this).find('id').text();
					var urlimg = $(this).find('image').text();
					var testo = $(this).find('testo').text();
					var descrizione = $(this).find('descrizione').text();
					var link = $(this).find('link').text();						
					if(testo!=null && testo!="") {												
						if(urlimg!=null && urlimg!="") {
							tagfoto='<div style="width: 115px; height: 101px; float: left; margin-bottom: 5px;"><div class="boxfotoeditoriale"><img src="'+urlimg+'" /></div></div>';							
						}
						else {
							tagfoto='';
						}
						txthtml=txthtml+tagfoto+'<div class="testoboxgrandefotopiccole"><strong>' + testo + '</strong><br />' + descrizione + '<br />' + '<img src="img/pallarossa.gif" align="left" hspace="3" vspace="2" />' + ' <a href="' + link + '" class="linktestoboxgrande">vai</a></div><br clear="all" />';			
					}
				});	
				if(txthtml!="") {
					$('#newscontainer').show(function() {
						$('<span></span>').html(txthtml).appendTo('#testolanci');
					});
				}
			});
}

function CaricaSondaggi(xml) {
	$(xml).find('sondaggio').each(function() {
				var txthtml='';
				var tagfoto='';
				$(xml).find('itemsondaggio').each(function() {
					var id = $(this).find('id').text();
					var urlimg = $(this).find('image').text();
					var testo = $(this).find('testo').text();
					var descrizione = $(this).find('descrizione').text();
					var link = $(this).find('link').text();
					var visibile= $(this).find('visibile').text();					
					if(visibile=="1") {
						if(testo!=null && testo!="") {
							if(urlimg!=null && urlimg!="") {
								tagfoto='<div style="width: 115px; height: 101px; float: left; margin-bottom: 5px;"><div class="boxfotoeditoriale"><img src="'+urlimg+'" /></div></div>';							
							}
							else {
								tagfoto='';
							}
							txthtml=txthtml+tagfoto+'<div class="testoboxgrandefotopiccole"><strong>' + testo + '</strong><br />' + descrizione + '<br />' + '<img src="img/pallarossa.gif" align="left" hspace="3" vspace="2" />' + ' <a href="' + link + '" class="linktestoboxgrande">vai</a></div><br clear="all" />';														
							$('#sondaggicontainer').show(function() {
								$('<span></span>').html(txthtml).appendTo('#testosondaggi');								  
							});
						}
					}
					else 
					{
						if(!$('#sondaggicontainer').is(":hidden")) {
							$('#sondaggicontainer').hide('fast');
						}
					}
				});				
			});
}

function LoadSondaggi(xml) {
	$(xml).find('sondaggio').each(function() {
				var txthtml='';
				var tagfoto='';
				$(xml).find('itemsondaggio').each(function() {
					var id = $(this).find('id').text();
					var urlimg = $(this).find('image').text();
					var testo = $(this).find('testo').text();
					var descrizione = $(this).find('descrizione').text();
					var link = $(this).find('link').text();
					var visibile= $(this).find('visibile').text();					
					if(visibile=="1") {
						if(testo!=null && testo!="") {
							if(urlimg!=null && urlimg!="") {
								tagfoto='<div style="width: 115px; height: 101px; float: left; margin-bottom: 5px;"><div class="boxfotoeditoriale"><img src="'+urlimg+'" /></div></div>';							
							}
							else {
								tagfoto='';
							}
							txthtml=txthtml+tagfoto+'<div class="testoboxgrandefotopiccole"><strong>' + testo + '</strong><br />' + descrizione + '<br />' + '<img src="img/pallarossa.gif" align="left" hspace="3" vspace="2" />' + ' <a href="' + link + '" class="linktestoboxgrande">vai</a></div><br clear="all" />';														
							$('#sondaggicontainer').show(function() {
								$('<span></span>').html(txthtml).appendTo('#testosondaggi');								  
							});
						}
					}
					else 
					{
						if(!$('#sondaggicontainer').is(":hidden")) {
							$('#sondaggicontainer').hide('fast');
						}
					}
				});				
			});
}


function CaricaNuovoGioco(xml) {
	$(xml).find('areanuovogioco').each(function() {
				var txthtml='';
				$(xml).find('itemareanuovogioco').each(function() {
					var id = $(this).find('id').text();
					var urlimg = $(this).find('image').text();
					var testo = $(this).find('testo').text();
					var descrizione = $(this).find('descrizione').text();
					var link = $(this).find('link').text();					
					if(testo!=null && testo!="") {
						txthtml='<div style="width: 115px; height: 101px; float: left;"><div class="boxfotoeditoriale"><img src="'+urlimg+'" /></div></div>'+'<div class="testoboxgrande"><strong>' + testo + '</strong><br />' + descrizione + '<br />' + '<img src="img/pallarossa.gif" align="left" hspace="3" vspace="2" />' + '<a href="' + link + '" class="linktestoboxgrande">vai</a></div>';				
						$('<span></span>').html(txthtml).appendTo('#testonuovogioco');
					}
				});				
			});
}

function CaricaDettaglioGioco(xml) {
	var flashfile="";	
	$(xml).find('areainternagioco').each(function() {		
				var txthtml='';
				$(xml).find('itemareainternagioco').each(function() {
					var id = $(this).find('id').text();
					var urlimg = $(this).find('image').text();
					var testo = $(this).find('testo').text();
					var descrizione = $(this).find('descrizione').text();
					flashfile = $(this).find('flash').text();
					if(testo!=null && testo!="") {
						txthtml=testo;
						$('<span></span>').html(txthtml).appendTo('#titoloGiocoSwf');						
					}
				});
			});	
	$('#titoloGiocoSwf').show();
	$('#titoloGiocoDcr').hide();
	return flashfile;
}

function CaricaDettaglioGiocoDcr(xml) {
	var flashfile="";
	var vettorerisultato="";
	$(xml).find('areainternagioco').each(function() {		
				var txthtml='';
				$(xml).find('itemareainternagioco').each(function() {
					var id = $(this).find('id').text();
					var urlimg = $(this).find('image').text();
					var testo = $(this).find('testo').text();
					var descrizione = $(this).find('descrizione').text();
					flashfile = $(this).find('flash').text();
					vettorerisultato=id+";;"+urlimg+";;"+testo+";;"+descrizione+";;"+flashfile;
					if(testo!=null && testo!="") {
						txthtml=testo;
						$('<span></span>').html(txthtml).appendTo('#titoloGiocoDcr');
					}
				});
			});	
	$('#titoloGiocoSwf').hide();
	$('#titoloGiocoDcr').show();
	return vettorerisultato;
}

function CaricaPiuVotato(xml) {
	$(xml).find('areapiuvotato').each(function() {
				var txthtml='';
				$(xml).find('itemareapiuvotato').each(function() {
					var id = $(this).find('id').text();
					var urlimg = $(this).find('image').text();
					var testo = $(this).find('testo').text();
					var descrizione = $(this).find('descrizione').text();
					var link = $(this).find('link').text();					
					if(testo!=null && testo!="") {
						txthtml='<div style="width: 115px; height: 101px; float: left;"><div class="boxfotoeditoriale"><img src="'+urlimg+'" /></div></div>'+'<div class="testoboxgrande"><strong>' + testo + '</strong><br />' + descrizione + '<br />' + '<img src="img/pallarossa.gif" align="left" hspace="3" vspace="2" />' + '<a href="' + link + '" class="linktestoboxgrande"> vai </a></div>';				
						$('<span></span>').html(txthtml).appendTo('#testopiuvotato');
					}
				});				
			});
}

/*function LoadWallpaper(xml,pagesize) {
	var numitem = 0;
	var pagine = 0;
	var txthtml='';
	var contatore=0;
	var numpagina=0;
	$(xml).find('areawallpaper').each(function() {
				$(xml).find('itemareawallpaper').each(function() {
					//dati XML
					var id = $(this).find('id').text();
					var urlimg = $(this).find('image').text();
					var testo = $(this).find('testo').text();
					var descrizione = $(this).find('descrizione').text();
					var link = $(this).find('link').text();	
					
					if((numitem==0) || (numitem % pagesize==0)) {
						numpagina++;
						contatore=0;
						txthtml=txthtml+"<span "+"id='page"+numpagina+"'";
						if (numpagina==1){
							txthtml=txthtml+"style='display: inline; min-height: 435px;'";
						} else {
							txthtml=txthtml+"style='display: none; min-height: 435px;'";	
						} 
						txthtml=txthtml+">";
					}
					
					if(testo!=null && testo!="") {
						txthtml=txthtml+'<table cellpadding="4" cellspacing="0" border="0" width="100%"><tr><td valign="top" width="123px"><div style="width: 115px; height: 101px; float: left;"><div class="boxfotoeditoriale"><img src="'+urlimg+'" /></div></div></td><td valign="top" align="left">'+'<div class="testoboxgrande"><strong>' + testo + '</strong><br />' + descrizione + '<br />' + '<img src="img/pallarossa.gif" align="left" hspace="3" vspace="2" />' + ' <a href="' + link + '" class="linktestoboxgrande">vai</a></div></td></tr></table><br /><div align="center"><img src="img/separatore.gif" align="center" /></div><br clear="all" />';					
						contatore++;
					}
					
					numitem++;
					
					if((numitem==pagesize) || (numitem % pagesize==0)) {
						
						txthtml=txthtml+"</span>";
					}
							
				})
			})
			
			if (numitem % pagesize!=0){
				txthtml=txthtml+"</span>";
			}
			
			if(numitem % 2){
				//pari
				pagine = Math.floor(numitem / pagesize);
			} else {
				//dispari
				pagine = (Math.floor(numitem / pagesize))+1;
			}
		
			$('<p></p>').html(txthtml).appendTo('#testowallpaper');
			return pagine;
}*/


function LoadWallpaper(xml,pagesize) {
	var numitem = 0;
	var pagine = 0;
	var txthtml='';
	var contatore;
	var numpagina=0;
	$(xml).find('areawallpaper').each(function() {
				$(xml).find('itemareawallpaper').each(function() {
					//dati XML
					var id = $(this).find('id').text();
					var urlimg = $(this).find('image').text();
					var testo = $(this).find('testo').text();
					var descrizione = $(this).find('descrizione').text();
					var link = $(this).find('link').text();	
					
					if((numitem==0) || (numitem % pagesize==0)) {
						numpagina++;
						contatore=0;
						txthtml=txthtml+"<span "+"id='page"+numpagina+"'";
						if (numpagina==1){
							txthtml=txthtml+"style='display: inline; min-height: 435px;'";
						} else {
							txthtml=txthtml+"style='display: none; min-height: 435px;'";	
						} 
						txthtml=txthtml+">";
					}
					
					if(testo!=null && testo!="") {
						txthtml=txthtml+'<table cellpadding="4" cellspacing="0" border="0" width="100%"><tr><td valign="top" width="123px"><div style="width: 115px; height: 101px; float: left;"><div class="boxfotoeditoriale"><img src="'+urlimg+'" /></div></div></td><td valign="top" align="left">'+'<div class="testoboxgrande"><strong>' + testo + '</strong><br />' + descrizione + '<br />' + '<img src="img/pallarossa.gif" align="left" hspace="3" vspace="2" />' + ' <a href="' + link + '" class="linktestoboxgrande">vai</a></div></td></tr></table><br /><div align="center"><img src="img/separatore.gif" align="center" /></div><br clear="all" />';					
						contatore++;
					}
					
					numitem++;
					
					if((numitem==pagesize) || (numitem % pagesize==0)) {
							
						txthtml=txthtml+"</span>";
					}
							
				})
			})
			
			if (numitem % pagesize!=0){
				var j=contatore;
				for (j=contatore;j<pagesize;j++){
					txthtml=txthtml+"<table cellspacing='0' cellpadding='4' border='0' width='100%'><tbody><tr><td width='123' valign='top'><div style='width: 115px; height: 142px; float: left;'></div></td><td align='left' valign='top'></td></tr></tbody></table>";
				}	
				
				txthtml=txthtml+"</span>";
			}
			
			if(numitem % 2){
				//pari
				pagine = Math.floor(numitem / pagesize);
			} else {
				//dispari
				pagine = (Math.floor(numitem / pagesize))+1;
			}
		
			$('<p></p>').html(txthtml).appendTo('#testowallpaper');
			return pagine;
}




function ShowPage(totpage, numpage) {
	Refresh(totpage);
	var nomeid = "page"+numpage;
	var pageObj = document.getElementById(nomeid);
	pageObj.style.display = 'inline';
   	pageObj.style.visibility = 'visible';
   	pageActive = numpage;	
}

function Refresh(numpage) {
	var i=1;
	for (i=1;i<=numpage;i++){
		var nomeid = "page"+i;
		var pageObj = document.getElementById(nomeid);
		pageObj.style.display = 'none';
   		pageObj.style.visibility = 'hidden';
	}	
}	

function NextPage(totpage) {
	if(pageActive == totpage){
		pageActive = 1;
	}else {
		pageActive++;
	} 
	Refresh(totpage);	
	ShowPage(totpage, pageActive);
}

function PrevPage(totpage) {
	if(pageActive == 1){
		pageActive = totpage;
	}else {
		pageActive--;
	} 
	Refresh(totpage);	
	ShowPage(totpage, pageActive);
}

function ShowNav(numpage) {
	var txthtml='';
	txthtml=txthtml+'<a class="" rel="prev" href="javascript:PrevPage('+numpage+');">&laquo;</a>';
	for (i=1;i<=numpage;i++){
		txthtml= txthtml+"<a rel='"+i+"' href='javascript:ShowPage("+numpage+","+i+");'>"+i+"</a>";	
	}	
	txthtml=txthtml+'<a class="" rel="next" href="javascript:NextPage('+numpage+');">&raquo;</a>';
	
	$('<div id="nav" class="nav"></div>').html(txthtml).appendTo('#testonav');
}						

function CaricaWallpaper(xml,pagesize) {
	$(xml).find('areawallpaper').each(function() {
				var txthtml='';
				var contatore=0;
				var pagina=1;
				$(xml).find('itemareawallpaper').each(function() {
					var id = $(this).find('id').text();
					var urlimg = $(this).find('image').text();
					var testo = $(this).find('testo').text();
					var descrizione = $(this).find('descrizione').text();
					var link = $(this).find('link').text();	
					if(contatore==0) {
						txthtml=txthtml+"<span>";
					}
					if(testo!=null && testo!="") {
						txthtml=txthtml+'<table cellpadding="4" cellspacing="0" border="0" width="100%"><tr><td valign="top" width="123px"><div style="width: 115px; height: 101px; float: left;"><div class="boxfotoeditoriale"><img src="'+urlimg+'" /></div></div></td><td valign="top" align="left">'+'<div class="testoboxgrande"><strong>' + testo + '</strong><br />' + descrizione + '<br />' + '<img src="img/pallarossa.gif" align="left" hspace="3" vspace="2" />' + ' <a href="' + link + '" class="linktestoboxgrande">vai</a></div></td></tr></table><br /><div align="center"><img src="img/separatore.gif" align="center" /></div><br clear="all" />';				
						
					}
					contatore=contatore+1;
					if(contatore==pagesize) {
						txthtml=txthtml+"</span>";
						contatore=0;
					}					
				})
				$('<p></p>').html(txthtml).appendTo('#testowallpaper');
			})
}

function CaricaIcone(xml) {
	$(xml).find('areaicone').each(function() {
				var txthtml='';
				$(xml).find('itemareaicone').each(function() {														
					var id = $(this).find('id').text();
					var urlimg = $(this).find('image').text();
					var testo = $(this).find('testo').text();
					var descrizione = $(this).find('descrizione').text();
					var link = $(this).find('link').text();					
					if(testo!=null && testo!="") {
						txthtml='<div class="boxfotoicone" style="padding-right:5px;"><img src="'+urlimg+'" /></div>'+'<div class="testoboxgrande"><strong>' + testo + '</strong><br />' + descrizione + '<br /><br />' + '<a href="' + link + '" class="linktestoboxgrande">Scarica le icone</a></div>';				
						$('<span></span>').html(txthtml).appendTo('#testoicone');
					}
				})
				
			})
}

function CaricaSuonerie(xml) {
	$(xml).find('areasuonerie').each(function() {
				var txthtml='';
				$(xml).find('itemareasuonerie').each(function() {														
					var id = $(this).find('id').text();
					var urlimg = $(this).find('image').text();
					var testo = $(this).find('testo').text();
					var descrizione = $(this).find('descrizione').text();
					var link = $(this).find('link').text();					
					if(testo!=null && testo!="") {
						txthtml='<div class="boxmp3player" style="padding-right:10px; height:36px; display:block;"><img src="img/mp3player.png" /></div>'+'<div class="testoboxgrande"><strong>' + testo + '</strong><br />' + descrizione + '<br /><br />' + '<a href="' + link + '" class="linktestoboxgrande">Scarica lo screensaver</a></div><br />';				
						$('<span></span>').html(txthtml).appendTo('#testosuonerie');
					}
				})
				
			})
}

function CaricaVederci(xml) {
	$(xml).find('testi').each(function() {
				var txthtml='';
				$(xml).find('itemtesto').each(function() {														
					var id = $(this).find('id').text();					
					var testo = $(this).find('testo').text();
					var descrizione = $(this).find('descrizione').text();								
					if(testo!=null && testo!="") {
						txthtml='<div class="testoboxgrande"><strong>' + testo + '</strong><br />' + descrizione + '<br />' + '</div>';				
						$('<span></span>').html(txthtml).appendTo('#testocomevederci');
					}
				});				
			});
}

function CaricaNews(xml) {
	$(xml).find('articolo').each(function() {
		var txthtml='';
		var testoparagrafi='';
		var tagimage='';
		$(xml).find('itemarticolo').each(function() {
			var id = $(this).find('id').text();					
			var testo = $(this).find('testo').text();			
			txthtml=testo;
			$(xml).find('paragrafi').each(function() {
				$(xml).find('paragrafo').each(function() {
					var image = $(this).find('image').text();					
					var image_position = $(this).find('image_position').text();
					var descrizione = $(this).find('descrizione').text();
					if(descrizione!=null && descrizione!="") {
						if(image!=null && image!="") {
							tagimage='<img src='+image+' align='+image_position+' vspace="3" hspace="7" />';
						}
						else {
							tagimage='';
						}
						testoparagrafi = testoparagrafi + '<p>' + tagimage + descrizione + '</p><br clear="all" />';		
					}
				});				
						
			});			
			$('<span></span').html(testo).appendTo('#titolonewscontainer');
			$('<span></span>').html(txthtml).appendTo('#testonewsdettagliotitolo');
			$('<span></span>').html(testoparagrafi).appendTo('#testonewsdettaglio');		
		});
	});
}

function CaricaOraInOnda(xml) {
	$(xml).find('areaorainonda').each(function() {
				var txthtml='';
				$(xml).find('itemareaorainonda').each(function() {
					var id = $(this).find('id').text();
					var urlimg = $(this).find('image').text();
					var testo = $(this).find('testo').text();
					var descrizione = $(this).find('descrizione').text();
					var link = $(this).find('link').text();					
					if(testo!=null && testo!="") {
						txthtml='<div style="width: 115px; height: 101px; float: left;"><div class="boxfotoeditoriale"><img src="'+urlimg+'" /></div></div>'+'<div class="testoboxgrande"><strong>' + testo + '</strong><br />' + descrizione + '<br />' + '<img src="img/pallarossa.gif" align="left" hspace="3" vspace="2" />' + ' <a href="' + link + '" class="linktestoboxgrande">vai</a></div><br clear="all" />';				
						$('<span></span>').html(txthtml).appendTo('#testoorainonda');
					}
				})
				
			})
}

function CaricaProssimoProgramma(xml) {
	$(xml).find('areaprossimoprogramma').each(function() {
				var txthtml='';
				$(xml).find('itemareaprossimoprogramma').each(function() {
					var id = $(this).find('id').text();
					var urlimg = $(this).find('image').text();
					var testo = $(this).find('testo').text();
					var descrizione = $(this).find('descrizione').text();
					var link = $(this).find('link').text();					
					if(testo!=null && testo!="") {
						txthtml='<div style="width: 115px; height: 101px; float: left;"><div class="boxfotoeditoriale"><img src="'+urlimg+'" /></div></div>'+'<div class="testoboxgrande"><strong>' + testo + '</strong><br />' + descrizione + '<br />' + '<img src="img/pallarossa.gif" align="left" hspace="3" vspace="2" />' + ' <a href="' + link + '" class="linktestoboxgrande">vai</a></div><br clear="all" />';				
						$('<span></span>').html(txthtml).appendTo('#testoprossimoprogramma');
					}
				})
				
			})
}

function CaricaPrimoPiano(xml) {
	$(xml).find('areaprimopiano').each(function() {
				var txthtml='';
				$(xml).find('itemareaprimopiano').each(function() {
					var id = $(this).find('id').text();
					var urlimg = $(this).find('image').text();
					var testo = $(this).find('testo').text();
					var descrizione = $(this).find('descrizione').text();
					var link = $(this).find('link').text();					
					if(testo!=null && testo!="") {
						txthtml='<div style="width: 87px; height: 68px; float: left;"><div class="boxfotoeditoriale"><img src="'+urlimg+'" /></div></div>'+'<div class="testoboxgrande"><strong>' + testo + '</strong><br />' + descrizione + '<br />' + '<img src="img/pallarossa.gif" align="left" hspace="3" vspace="2" />' + ' <a href="' + link + '" class="linktestoboxgrande">vai</a></div><br clear="all" />';				
						$('<span></span>').html(txthtml).appendTo('#testoprimopiano');
					}
				})
				
			})
}
/*img/programmaprimopiano.jpg*/
function CaricaPrimoPianoProgrammi(xml) {
	$(xml).find('areaprimopiano').each(function() {
				var txthtml='';
				$(xml).find('itemareaprimopiano').each(function() {
					var id = $(this).find('id').text();
					var urlimg = $(this).find('image').text();
					var testo = $(this).find('testo').text();
					var descrizione = $(this).find('descrizione').text();
					var link = $(this).find('link').text();					
					if(urlimg!=null && urlimg!="") {
						txthtml= '<a href="' + link + '" class="linktestoboxgrande">'+'<img src="' + urlimg + '" width="293" height="220" />'+'</a>';				
						$('<span></span>').html(txthtml).appendTo('#imgprimopiano');
					}
				})
				
			})
}

function CaricaNuovoVideo(xml) {
	$(xml).find('areanuovovideo').each(function() {
				var txthtml='';
				$(xml).find('itemareanuovovideo').each(function() {
					var id = $(this).find('id').text();
					var urlimg = $(this).find('image').text();
					var testo = $(this).find('testo').text();
					var descrizione = $(this).find('descrizione').text();
					var link = $(this).find('link').text();					
					if(testo!=null && testo!="") {
						txthtml='<div style="width: 87px; height: 68px; float: left;"><div class="boxfotoeditoriale"><img src="'+urlimg+'" /></div></div>'+'<div class="testoboxgrande"><strong>' + testo + '</strong><br />' + descrizione + '<br />' + '<img src="img/pallarossa.gif" align="left" hspace="3" vspace="2" />' + ' <a href="' + link + '" class="linktestoboxgrande">vai</a></div><br clear="all" />';				
						$('<span></span>').html(txthtml).appendTo('#testonuovovideo');
					}
				})
				
			})
}




function CaricaProgrammiInterno(xml) {
	$(xml).find('areainterna').each(function() {
				var txthtml='';
				var txthtmlStr='';
				var txthtmlInt='';
				var txthtmlLinkRitorna='<a href="programmi.html"><img src="img/btntornaprogrammi.png" width="171" height="22" border="0" id="btntornaprogrammi" name="btntornaprogrammi" /></a>';
				var txthtmlDefault='<div id="contentprogrammadescr" style="background: url(img/sfondostelle.jpg) no-repeat;">';
						
				$(xml).find('itemareainterna').each(function() {
					var txthtmlContent='';
					var id = $(this).find('id').text();
					var urlimg = $(this).find('image').text();
					var testo = $(this).find('testo').text();
					var descrizione = $(this).find('descrizione').text();
					var link = $(this).find('link').text();	
					var imgbackground = $(this).find('imagebackground').text();	
					
					if((imgbackground=="/") || (imgbackground==null || imgbackground=="")) {
						txthtmlContent = txthtmlDefault;
					} else {
						txthtmlContent = '<div id="contentprogrammadescr" style="background: url('+imgbackground+') no-repeat;">';
					}
							  			
					if(testo!=null && testo!="") {
						txthtml='<div style="width: 178px; height: 154px;  float: left; margin: 0px 10px 0px 0px;"><div class="boxfotoeditoriale"><img src="'+urlimg+'" hspace="0px" vspace="0px" /></div></div>'+'<div class="testoboxgrande"><strong>' + testo + '</strong><br />' + descrizione + '<br />' + '</div><br clear="all" />';				
						if((imgbackground=="/") || (imgbackground==null || imgbackground=="")) {
							txthtml = '<div id="testointerno" style="height: 255px; overflow: auto; scrollbar-base-color: #680001; scrollbar-3dlight-color:#680001; scrollbar-arrow-color:#DF0F03; scrollbar-darkshadow-color :#DF0F03; scrollbar-face-color:#680001; scrollbar-highlight-color:#680001; scrollbar-shadow-color:#680001; scrollbar-track-color:#DF0F03; margin-bottom: 10px;"><span>'+txthtml+'</span></div>';
						} else {
							txthtml = '<div id="testointerno" style="height: 255px; overflow: auto; scrollbar-base-color: #680001; scrollbar-3dlight-color:#680001; scrollbar-arrow-color:#DF0F03; scrollbar-darkshadow-color :#DF0F03; scrollbar-face-color:#680001; scrollbar-highlight-color:#680001; scrollbar-shadow-color:#680001; scrollbar-track-color:#DF0F03; margin-bottom: 10px;"><span>'+txthtml+'</span></div>';
						}	
						txthtmlInt = txthtml + txthtmlLinkRitorna;
						txthtmlStr = txthtmlContent + txthtmlInt + '</div>';
						$('<span></span>').html(txthtmlStr).appendTo('#centerboxprogrammi');
					}

				})
				
			})
}





