/* OVERLAY AD */
function show_ad(divid)
{
if (getCookieOverAd('over13') != '1')
{
  document.getElementById(divid).style.display = 'block';
  setCookieOverAd('over13','1','180');
  setTimeout("close_ad('overlayad')",10000);
}
}

function close_ad(divid)
{
	document.getElementById(divid).style.display = 'none';
}

getCookieOverAd=function(Name){ 
  var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
  if (document.cookie.match(re)) //if cookie found
    return document.cookie.match(re)[0].split("=")[1] //return its value
  return ""
}

setCookieOverAd=function(name, value, expires){
  var d = new Date;
  d.setSeconds(d.getSeconds()+expires);
  var d_exp = d.toUTCString();
  document.cookie = name+"="+value+";path=/" //cookie value is domain wide (path=/)
}
/* END OVERLAY AD */

/* AJAX */

function initxml() {
	var http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	if (!http_request) {
		alert('Giving up :( Non riesco a creare una istanza XMLHTTP');
		return false;
	}

	return(http_request);
}

function onStateChange(obj, idObj) {

	if (obj.readyState == 4) {
		if (obj.status == 200) {
			document.getElementById(idObj).innerHTML=obj.responseText; 
		}
	}
}

function onStateChangeCG(obj, idObj) {

	if (obj.readyState == 4) {
		if (obj.status == 200) {
			document.getElementById(idObj).innerHTML=obj.responseText;
			document.getElementById("cntCommentTitolo").innerHTML = addUrlCG(document.getElementById("cntCommentTitolo").innerHTML);
			document.getElementById("cntCommentTesto").innerHTML = addUrlCG(document.getElementById("cntCommentTesto").innerHTML);
		}
	}
}

/* END AJAX */

/* QUERYSTRING */

/* Client-side access to querystring name=value pairs
	Version 1.3
	28 May 2008
	
	License (Simplified BSD):
	http://adamv.com/dev/javascript/qslicense.txt
*/
function Querystring(qs) { // optionally pass a querystring to parse
	this.params = {};
	
	if (qs == null) qs = location.search.substring(1, location.search.length);
	if (qs.length == 0) return;

// Turn <plus> back to <space>
// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
	qs = qs.replace(/\+/g, ' ');
	var args = qs.split('&'); // parse out name/value pairs separated via &
	
// split out each name=value pair
	for (var i = 0; i < args.length; i++) {
		var pair = args[i].split('=');
		var name = decodeURIComponent(pair[0]);
		
		var value = (pair.length==2)
			? decodeURIComponent(pair[1])
			: name;
		
		this.params[name] = value;
	}
}

Querystring.prototype.get = function(key, default_) {
	var value = this.params[key];
	return (value != null) ? value : default_;
}

Querystring.prototype.contains = function(key) {
	var value = this.params[key];
	return (value != null);
}

/* END QUERYSTRING */

function show_date() {
	var DaysOfWeek = new Array(7);
		DaysOfWeek[0] = "Domenica";
		DaysOfWeek[1] = "Lunedi";
		DaysOfWeek[2] = "Martedi";
		DaysOfWeek[3] = "Mercoledi";
		DaysOfWeek[4] = "Giovedi";
		DaysOfWeek[5] = "Venerdi";
		DaysOfWeek[6] = "Sabato";

	var MonthsOfYear = new Array(12);
		MonthsOfYear[0] = "Gennaio";
		MonthsOfYear[1] = "Febbraio";
		MonthsOfYear[2] = "Marzo";
		MonthsOfYear[3] = "Aprile";
		MonthsOfYear[4] = "Maggio";
		MonthsOfYear[5] = "Giugno";
		MonthsOfYear[6] = "Luglio";
		MonthsOfYear[7] = "Agosto";
		MonthsOfYear[8] = "Settembre";
		MonthsOfYear[9] = "Ottobre";
		MonthsOfYear[10] = "Novembre";
		MonthsOfYear[11] = "Dicembre";

		var Digital = new Date();
		var day = Digital.getDay();
		var mday = Digital.getDate();
		var month = Digital.getMonth();
		var hours = Digital.getHours();
		var minutes = Digital.getMinutes();
		var seconds = Digital.getSeconds();

		parseInt(hours) < 10 ? hours = "0" + hours : null;
		parseInt(minutes) < 10 ? minutes = "0" + minutes : null;

		myclock = '';
		myclock += DaysOfWeek[day]+' '+mday+' '+MonthsOfYear[month]+' '+hours+':'+minutes;
		document.write(myclock);
}

function setHome()
{
	if (navigator.appName.indexOf("Explorer")>=0)
	{
		document.body.style.behavior='url(#default#homepage)';
		document.body.setHomePage("http://www.affaritaliani.it/");
	}
	else if (navigator.appName.indexOf("Netscape")>=0 || navigator.appName.indexOf("Opera")>=0)
		document.location.href = "http://www.affaritaliani.it//sethome_firefox.html";
}

function ox_pub(n)
{
   var m3_u = (location.protocol=='https:'?'https://ads.arcuspubblicita.it/ox/www/delivery/ajs.php':'http://ads.arcuspubblicita.it/ox/www/delivery/ajs.php');
   var m3_r = Math.floor(Math.random()*99999999999);
   if (!document.MAX_used) document.MAX_used = ',';
   document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
   document.write ("?zoneid=" + n + "&amp;source=_blank");
   document.write ('&amp;cb=' + m3_r);
   if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
   document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
   document.write ("&amp;loc=" + escape(window.location));
   if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
   if (document.context) document.write ("&context=" + escape(document.context));
   if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
   document.write ("'><\/scr"+"ipt>");
}
/* END PUBLIREDAZIONALI */

function chk_search(chk_form_search)
{

if(chk_form_search.rdsearch[1].checked == true)
{
	document.location.href = "http://www.affaritaliani.it/websearch/?cx=partner-pub-5288674212710730:ufqkgtqxru1&cof=FORID:11&ie=ISO-8859-1&q=" + chk_form_search.q.value + "&sa=Cerca";
	return(false);
}
else
	return(true);
}

function striptxtHTML(str){
var re = /(<([^>]+)>)/gi;
str = str.replace(re, "");
re = /'/gi;
str = str.replace(re, "");
return(str);
}

/* ADSENSE */

/* AFC */

function google_ad_request_done(google_ads) {
var s = '', t = '', c = '', i;

if (google_ads.length == 0) {
return;
}

switch(google_ad_layout)
{
case "ads_top_body":
{
	s += '<a class="ads_by_google" href=\"' + google_info.feedback_url + '\">Annunci Google</a><br>';

	if (google_ads.length == 1)
		t = "_targeting";

	for(i = 0; i < google_ads.length; ++i) {
		s += '<div class="announce"><a class="title' + t + '" target="_blank" href="' + 
		google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
		google_ads[i].visible_url + '\';return true">' + 
		google_ads[i].line1 + '</a><br><a class="announce_url' + t + '" target="_blank" href="'+
		google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
		google_ads[i].visible_url + '\';return true">' + 
		google_ads[i].visible_url + '</a><span class="announce_description' + t + '">' +
		google_ads[i].line2 + ' ' +google_ads[i].line3 + '</span> </div>';
	}
	break;
}

case "adsense_300x250":
{
	if (google_ads.length == 1)
	{
		s += '<div style="padding-right: 10px; text-align: right;"><a class="ads_by_google" href=\"' + google_info.feedback_url + '\">Annunci Google</a></div>';
		s += '<div style="margin: 50px 0 60px 0;">';
		c = ' style="text-align: center;"';
		t = '_targeting';
	}
	else
		s += '<a class="ads_by_google" href=\"' + google_info.feedback_url + '\">Annunci Google</a><br>';

	for(i = 0; i < google_ads.length; ++i) {
		s += '<div class="announce"' + c + '> <a class="title' + t + '" target="_blank" href="' + 
		google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
		google_ads[i].visible_url + '\';return true">' + 
		google_ads[i].line1 + '</a><span class="announce_description' + t + '"><br>' +
		google_ads[i].line2 + '<br>' + google_ads[i].line3 + '</span><br><a class="announce_url' + t + '" target="_blank" href="' + 
		google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
		google_ads[i].visible_url + '\';return true">' + 
		google_ads[i].visible_url + '</a></div>';
	}
	if (google_ads.length == 1)
		s += '</div>';
	break;
}

case "adsense_bottom":
{
	s += '<a class="ads_by_google" href=\"' + google_info.feedback_url + '\">Annunci Google</a><br>' 

	if (google_ads.length == 1)
		t = "_targeting";

	for(i = 0; i < google_ads.length; ++i) {
		s += '<div class="announce"> <a class="title' + t + '" target="_blank" href="' + 
		google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
		google_ads[i].visible_url + '\';return true">' + 
		google_ads[i].line1 + '</a><span class="announce_description' + t + '"><br>' +
		google_ads[i].line2 + ' ' +google_ads[i].line3 + '</span><br><a class="announce_url' + t + '" target="_blank" href="' + 
		google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
		google_ads[i].visible_url + '\';return true">' + 
		google_ads[i].visible_url + '</a></div>';
	}
	break;
}

case "adsense_top_news":
{
	s += '<a class="ads_by_google" href=\"' + google_info.feedback_url + '\">Annunci Google</a><br>';
	s += '<div style="width: 620px; height: 70px;">';

	if (google_ads.length == 1)
		t = '_targeting';
	else
		c = 'width: 260px; float: left; ';

	for(i = 0; i < google_ads.length; ++i) {
		s += '<div class="announce" style="' + c + 'margin-right: 40px;"> <a class="title' + t + '" target="_blank" href="' + 
		google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
		google_ads[i].visible_url + '\';return true">' + 
		google_ads[i].line1 + '</a><span class="announce_description' + t + '"><br>' +
		google_ads[i].line2 + ' ' +google_ads[i].line3 + '</span><br><a class="announce_url' + t + '" target="_blank" href="' + 
		google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
		google_ads[i].visible_url + '\';return true">' + 
		google_ads[i].visible_url + '</a></div>';
	}
	s += '</div>';
	break;
}

default:
{
	s += '<a href=\"' + google_info.feedback_url + '\" class="adsense_annunci">Annunci Google</a><br>' 

	for(i = 0; i < google_ads.length; ++i) {
	s += '<br><a style="text-decoration: none;" href="' + 
	google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
	google_ads[i].visible_url + '\';return true" target="_blank"><span class="adsense_titolo"> <b>' + 
	google_ads[i].line1 + '</b></span></a><br><span class="adsense_testo">' +
	google_ads[i].line2 + ' ' +google_ads[i].line3 + '</span><br><span><a class="adsense_link" href="' + 
	google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
	google_ads[i].visible_url + '\';return true" target="_blank">' + 
	google_ads[i].visible_url + '</span></a><br>';
	}
}
}
document.write(s);
return;
}

function show_google_afc(type, ad_channel, num_ads, skip)
{
ad_title = document.title.replace(" - Affaritaliani.it","");
if (!num_ads) num_ads = 5;
if (!ad_channel) ad_channel = '9821690123';
//if (type == 'adsense_bottom' || type == 'adsense_300x250')
//	google_targeting = "content";
google_ad_layout = type;
google_ad_client = 'pub-5288674212710730';
google_ad_channel = ad_channel;
google_ad_section = 'default';
google_ad_output = 'js';
google_max_num_ads = num_ads;
google_skip = skip;
google_hints = ad_title;
google_ad_type = 'text';
google_feedback = 'on';
google_language = 'it';
}

/* END AFC */

function hideAdsense(critAd)
{
 	var Url = new String(document.location.href).toLowerCase();

	/* nascondi 300 nelle notizie
	if (Url.indexOf(".html")>0 && critAd == "checkadsense300x250")
		document.getElementById("checkadsense300x250").style.display='none';
	*/

	if (Url.indexOf("sessoscritto")>0)
		document.getElementById(critAd).style.display='none';
	if (Url.indexOf("/rubriche/eros/")>0)
		document.getElementById(critAd).style.display='none';
	if (Url.indexOf("/bottaerisposta/")>0)
		document.getElementById(critAd).style.display='none';
	if (Url.indexOf("urbino-uccide-a-bastonate-bagagliaio131108")>0)
		document.getElementById(critAd).style.display='none';
	if (Url.indexOf("/coffee/covergirl")>0)
	{
		document.getElementById(critAd).style.display='none';
	}
	else if (Url.indexOf("/coffee/video/")>0)
	{
		document.getElementById(critAd).style.display='none';
	}
	else if (Url.indexOf("/coffee/")>0)
	{
		document.getElementById(critAd).style.display='none';
	}
	if (Url.indexOf("/night/")>0)
		document.getElementById(critAd).style.display='none';
	if (Url.indexOf("calendari")>0)
		document.getElementById(critAd).style.display='none';
}

/* AFS */

function GetParam(name)
{
  var match = new RegExp(name + "=(.+)[&]","i").exec(location.search);
  if (match==null)
  {
	  match = new RegExp(name + "=(.+)","i").exec(location.search);
  }

  if (match==null)
  {
	  return null;
  }

  match = match + "";
  result = match.split(",");
  return result[1];
}

function google_afs_request_done(google_ads)
{
  var google_num_ads = google_ads.length;
  if (google_num_ads <= 0)
  {
	  return;
  }

  var wideAds = "";
  var narrowAds = "";

  for(i = 0; i < google_num_ads; i++)
  {
	  if (google_ads[i].type=="text/wide")
	  {
			wideAds += '<div class="announce"><a class="title" target="_blank" href="' + 
			google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
			google_ads[i].visible_url + '\';return true">' + 
			google_ads[i].line1 + '</a><br><a class="announce_url" target="_blank" href="'+
			google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
			google_ads[i].visible_url + '\';return true">' + 
			google_ads[i].visible_url + '</a><span class="announce_description">' +
			google_ads[i].line2 + '</span> </div>';
	  }

	  else
	  {
			narrowAds+='<div class="announce"> <a class="title" target="_blank" href="' + 
			google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
			google_ads[i].visible_url + '\';return true">' + 
			google_ads[i].line1 + '</a><span class="announce_description"><br>' +
			google_ads[i].line2 + ' ' + google_ads[i].line3 + '</span><br><a class="announce_url" target="_blank" href="' + 
			google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
			google_ads[i].visible_url + '\';return true">' + 
			google_ads[i].visible_url + '</a></div>';
	  }
  }

	if (narrowAds != "")
	{
	  narrowAds = '<a class="ads_by_google" href=\"http://services.google.com/feedback/online_hws_feedback\">Annunci Google</a><br>' + narrowAds;
	}

	if (wideAds != "")
	{
	  wideAds = '<a class="ads_by_google" href=\"http://services.google.com/feedback/online_hws_feedback\">Annunci Google</a><br>' + wideAds;
	}

	document.getElementById("ads_top_body").innerHTML = wideAds;
	document.getElementById("adsense_bottom").innerHTML = narrowAds;
}

function show_google_afs(ad_channel, num_ads, queryafs)
{
var qs = new Querystring();
if (!num_ads) num_ads = "w3n6";
if (!ad_channel) ad_channel = '5431770532';
if (!queryafs)
{
	google_afs_query = qs.get("q");
}
else
{
	google_afs_query = queryafs;
}
// google_afs_query = GetParam('q');
google_afs_ad = num_ads;
google_afs_client = 'pub-5288674212710730';
google_afs_channel = ad_channel;
google_afs_hl = 'it';
}

/* END AFS */

/* END ADSENSE */

/* CHANGE SPALLA */

function change_spalla(which)
{
	if(which == 1)
	{
		document.getElementById("spalla1").style.display = 'block';
		document.getElementById("spalla2").style.display = 'none';
		document.getElementById("spalla3").style.display = 'none';
		document.getElementById("spalla_btn1").innerHTML = "1";
		document.getElementById("spalla_btn2").innerHTML = "<a href=\"javascript:change_spalla('2')\">2</a>";
		document.getElementById("spalla_btn3").innerHTML = "<a href=\"javascript:change_spalla('3')\">3</a>";
		document.getElementById("spalla_btn1").style.backgroundColor = '#DBDAD2';
		document.getElementById("spalla_btn2").style.backgroundColor = '#FFFFFF';
		document.getElementById("spalla_btn3").style.backgroundColor = '#FFFFFF';
	}

	if(which == 2)
	{
		document.getElementById("spalla1").style.display = 'none';
		document.getElementById("spalla2").style.display = 'block';
		document.getElementById("spalla3").style.display = 'none';
		document.getElementById("spalla_btn1").innerHTML = "<a href=\"javascript:change_spalla('1')\">1</a";
		document.getElementById("spalla_btn2").innerHTML = "2";
		document.getElementById("spalla_btn3").innerHTML = "<a href=\"javascript:change_spalla('3')\">3</a>";
		document.getElementById("spalla_btn1").style.backgroundColor = '#FFFFFF';
		document.getElementById("spalla_btn2").style.backgroundColor = '#DBDAD2';
		document.getElementById("spalla_btn3").style.backgroundColor = '#FFFFFF';
	}

	if(which == 3)
	{
		document.getElementById("spalla1").style.display = 'none';
		document.getElementById("spalla2").style.display = 'none';
		document.getElementById("spalla3").style.display = 'block';
		document.getElementById("spalla_btn1").innerHTML = "<a href=\"javascript:change_spalla('1')\">1</a";
		document.getElementById("spalla_btn2").innerHTML = "<a href=\"javascript:change_spalla('2')\">2</a>";
		document.getElementById("spalla_btn3").innerHTML = "3";
		document.getElementById("spalla_btn1").style.backgroundColor = '#FFFFFF';
		document.getElementById("spalla_btn2").style.backgroundColor = '#FFFFFF';
		document.getElementById("spalla_btn3").style.backgroundColor = '#DBDAD2';
	}
}

/* END CHANGE SPALLA */

/* SHOWCOMMENTS */

function showcomments(idNews)
{
	var qs = new Querystring();
	var page = qs.get("page");
	var tbk = qs.get("tbk");

	if(tbk)
	{
		document.getElementById("ContentNews").style.display='none';
		if (page)
			urlcomment = "/static/script/showComment.aspx?idContent="+idNews+"&tbk="+tbk+"&pg="+page;
		else
			urlcomment = "/static/script/showComment.aspx?idContent="+idNews+"&tbk="+tbk;
		document.getElementById("ContentComment").innerHTML="<div style='width: 660px; height: 60px; margin-bottom: 20px; border: solid 1px #E5E5E5;'><div style='position: absolute; margin: 20px 0 0 20px;'><img src='/static/img/loading.gif'></div><div class='wait' style='position: absolute; margin: 22px 0 0 54px;'>Sto caricando il commento...</div></div>"; 
		http_request_cmt = initxml();
		http_request_cmt.open('GET', urlcomment, true);
		if (idNews == "20174")
			http_request_cmt.onreadystatechange = function() { onStateChangeCG(http_request_cmt, "ContentComment"); };
		else
			http_request_cmt.onreadystatechange = function() { onStateChange(http_request_cmt, "ContentComment"); };
		http_request_cmt.send(null);
	}
	if(page)
		urlcommentslist = "/static/script/showComments.aspx?idContent="+idNews+"&page="+page;
	else
		urlcommentslist = "/static/script/showComments.aspx?idContent="+idNews;

	document.getElementById("ContentListComments").innerHTML="<div style='width: 660px; height: 60px; margin-bottom: 20px; border: solid 1px #E5E5E5;'><div style='position: absolute; margin: 20px 0 0 20px;'><img src='/static/img/loading.gif'></div><div class='wait' style='position: absolute; margin: 22px 0 0 54px;'>Sto caricando la lista dei commenti...</div></div>"; 
	http_request_cmtlist = initxml();
	http_request_cmtlist.open('GET', urlcommentslist, true);
	http_request_cmtlist.onreadystatechange = function() { onStateChange(http_request_cmtlist, "ContentListComments"); };
	http_request_cmtlist.send(null);
}

/* END SHOWCOMMENTS */

function addUrlCG(strCG)
{
	strCGtmp = "";
	for(i=0;i<(strCG.length);++i)
	{
		if(!isNaN(strCG.charAt(i)) && strCG.charAt(i) != " ")
		{
			num = String(addUrlCG_findnum(strCG,i));
			if (num != "")
			{
				strCGtmp += '<a href="/interactive/vota.asp?id=' + num + '" target="_blank"><font color="#e03501"><b>' + num + '</b></font></a>';
				i = i + 5;
			}
			else
				strCGtmp += strCG.charAt(i);
		}
		else
			strCGtmp += strCG.charAt(i);
	}
return(strCGtmp);
}


function addUrlCG_findnum(str,n)
{
	numb = "";

	if(str.charAt(n-1)>='0' && str.charAt(n-1)<='9')
			return(numb);
	for(k=0;k<6;++k)
	{
		if(!isNaN(str.charAt(n+k)) && str.charAt(n+k) != " ")
			numb = numb + str.charAt(n+k);
		else
		{
			numb = "";
			break;
		}
	}
	if(str.charAt(n+6)>='0' && str.charAt(n+6)<='9')
			numb = "";
	return(numb);
}

/* STARS */

function showstars(idnews)
{
	http_request = initxml();
	http_request.open('GET', '/static/stars/starshow.asp?idnews=' + idnews, true);
	http_request.onreadystatechange = function() { onStateChange(http_request, "showstars"); };
	http_request.send(null);
}

function showstars_tags(idnews)
{
	var http_request = false;
	http_request = initxml();
	http_request.open('GET', '/static/stars/starshow.asp?idnews=' + idnews, true);
	http_request.onreadystatechange = function() { onStateChange(http_request, "showstars"+idnews); };
	http_request.send(null);
}

function votestars(idnews,thevote)
{
	url = "/static/stars/starsvote.asp?idnews=" + idnews + "&stars=" + thevote;
	http_request = initxml();
	http_request.open('GET', url, true);
	http_request.onreadystatechange = function() { document.getElementById("votestars").innerHTML="Grazie. Il tuo voto e' stato registrato"; };
	http_request.send(null);
	showstars(idnews);
}

function starsover(whichstars)
{
	for(i=1;i<=whichstars;++i)
	{
		starimg = eval("document.stars" + i);
		starimg.src="/static/img/star.gif";
	}
}

function starsout()
{
	for(i=1;i<=5;++i)
	{
		starimg = eval("document.stars" + i);
		starimg.src="/static/img/starw.gif";
	}
}

/* END STARS */

/* RANK */

function rank_change(rankwhat)
{
if(rankwhat == 0)
{
	document.getElementById("starheader").innerHTML = 'Le notizie pi&#249; gradite';
	document.getElementById("stararrowleft").innerHTML = '&lt;';
	document.getElementById("stararrowright").innerHTML = '<a href="javascript:rank_change(1)">></a>';
	document.getElementById("stararrowleft").style.backgroundColor = '#FFB072';
	document.getElementById("stararrowright").style.backgroundColor = '#E03501';
	document.getElementById("starbyrank").style.display = 'block';
	document.getElementById("starbyvote").style.display = 'none';
	document.getElementById("starbycomments").style.display = 'none';
}
if(rankwhat == 1)
{
	document.getElementById("starheader").innerHTML = 'Le notizie pi&#249; votate';
	document.getElementById("stararrowleft").innerHTML = '<a href="javascript:rank_change(0)"><</a>';
	document.getElementById("stararrowright").innerHTML = '<a href="javascript:rank_change(2)">></a>';
	document.getElementById("stararrowleft").style.backgroundColor = '#E03501';
	document.getElementById("stararrowright").style.backgroundColor = '#E03501';
	document.getElementById("starbyrank").style.display = 'none';
	document.getElementById("starbyvote").style.display = 'block';
	document.getElementById("starbycomments").style.display = 'none';
}
if(rankwhat == 2)
{
	document.getElementById("starheader").innerHTML = 'Le notizie pi&#249 commentate';
	document.getElementById("stararrowleft").innerHTML = '<a href="javascript:rank_change(1)"><</a>';
	document.getElementById("stararrowright").innerHTML = '<a href="javascript:rank_change(3)">></a>';
	document.getElementById("stararrowleft").style.backgroundColor = '#E03501';
	document.getElementById("stararrowright").style.backgroundColor = '#E03501';
	document.getElementById("starbyrank").style.display = 'none';
	document.getElementById("starbyvote").style.display = 'none';
	document.getElementById("starbycomments").style.display = 'block';
	document.getElementById("starbyusers").style.display = 'none';
}
if(rankwhat == 3)
{
	document.getElementById("starheader").innerHTML = 'Gli utenti pi&#249 attivi';
	document.getElementById("stararrowleft").innerHTML = '<a href="javascript:rank_change(2)"><</a>';
	document.getElementById("stararrowright").innerHTML = '>';
	document.getElementById("stararrowleft").style.backgroundColor = '#E03501';
	document.getElementById("stararrowright").style.backgroundColor = '#FFB072';
	document.getElementById("starbyrank").style.display = 'none';
	document.getElementById("starbyvote").style.display = 'none';
	document.getElementById("starbycomments").style.display = 'none';
	document.getElementById("starbyusers").style.display = 'block';
}
}

/* END RANK */

/* BETSHOP RANDOM */
function showbetshop(tipo)
{
 	var Url = new String(document.location.href).toLowerCase();

	if (Url.indexOf("/sport/")>0 || Url.indexOf("/entertainment/")>0 || Url.indexOf("/giochiescommesse/")>0)
	{
		betrnd = Math.floor(Math.random()*100+1);
		if (tipo == '500')
		{
			if(betrnd <= 70)
					document.write("<div><object height=\"42\" width=\"670\"><param name=\"movie\" value=\"http://www.affaritaliani.it/static/upl/pok/poker420x26.swf\" /> <embed src=\"http://www.affaritaliani.it/static/upl/pok/poker420x26.swf\" width=\"670\" height=\"42\" type=\"application/x-shockwave-flash\"></embed></object></div><br><br>");
			else
				document.write("<div><object height=\"42\" width=\"670\"><param name=\"movie\" value=\"http://www.affaritaliani.it/static/upl/cal/0002/calcio420x26.swf\" /> <embed src=\"http://www.affaritaliani.it/static/upl/cal/0002/calcio420x26.swf\" width=\"670\" height=\"42\" type=\"application/x-shockwave-flash\"></embed></object></div><br><br>");
		}
		if (tipo == '234')
		{
			if(betrnd <= 70)
					document.write("<div style='margin-top:20px;'><object height=\"90\" width=\"234\"><param name=\"movie\" value=\"http://www.affaritaliani.it/static/upl/pok/poker235x90.swf\" /> <embed src=\"http://www.affaritaliani.it/static/upl/pok/poker235x90.swf\" width=\"234\" height=\"90\" type=\"application/x-shockwave-flash\"></embed></object></div>");
			else
				document.write("<div style='margin-top:20px;'><object height=\"90\" width=\"234\"><param name=\"movie\" value=\"http://www.affaritaliani.it/static/upl/cal/0002/calcio235x90.swf\" /> <embed src=\"http://www.affaritaliani.it/static/upl/cal/0002/calcio235x90.swf\" width=\"234\" height=\"90\" type=\"application/x-shockwave-flash\"></embed></object></div>");
		}
	}
}
/* END BETSHOP RANDOM */

/* LIST POLLS */

function listpolls(idnews)
{
	var http_request = false;
	http_request = initxml();
	http_request.open('GET', '/static/script/listpolls.asp?idnews=' + idnews, true);
	http_request.onreadystatechange = function() { onStateChange(http_request, "listpolls"); };
	http_request.send(null);
}

/* END LIST POLLS */

/* LIST PARLIAMONE */

function listparliamone(idnews)
{
	var Url = new String(document.location.href).toLowerCase();
	// SOLO HP
	if (Url.indexOf(".html")<0 || Url.indexOf("index.html")>=0)
	{
		document.getElementById("parliamone").innerHTML="<div style='width: 300px;'><div style='height: 200px; margin: 0px; border: solid 1px black; padding: 4px 10px 10px 10px;'><div style='position: absolute; margin: 40px 0 0 40px;'><img src='/static/img/wait30.gif'></div><div class='wait' style='position: absolute; margin: 46px 0 0 80px'>Carico i commenti...</div></div></div>"; 
		var http_request = false;
		http_request = initxml();
		http_request.open('GET', '/static/files/comments_parliamone_' + idnews + '.htm', true);
		http_request.onreadystatechange = function() { onStateChange(http_request, "parliamone"); };
		http_request.send(null);
	}
}

/* END PARLIAMONE */

/* LISTA CANALE NEWS */
function listnews(listnewsdiv)
{
	var idch = 0;
 	var Url = new String(document.location.href).toLowerCase();

	if (Url.indexOf("/mediatech/")>0) idch=109;
	if (Url.indexOf("/entertainment/")>0) idch=112;
	if (Url.indexOf("/cronache/")>0) idch=4;
	if (Url.indexOf("/politica/")>0) idch=6;
	if (Url.indexOf("/economia/")>0) idch=3;
	if (Url.indexOf("/sport/")>0) idch=82;
	if (Url.indexOf("/culturaspettacoli/")>0) idch=88;
	if (Url.indexOf("/milano/")>0) idch=87;
	if (Url.indexOf("/sociale/")>0) idch=232;
	if (Url.indexOf("/viaggi/")>0) idch=249;

	if (idch > 0)
	{
		http_request_listnews = initxml();
		http_request_listnews.open('GET', '/static/generated/archivio_news_' + idch + '.htm', true);
		http_request_listnews.onreadystatechange = function() { onStateChange(http_request_listnews, listnewsdiv); };
		http_request_listnews.send(null);
	}
}
/* END LISTA CANALE NEWS */

function ticker_start() {
var ultimissime_tot = ultimissime_get_total();
ultimissime_rotate_content(0, ultimissime_tot);
}

function ultimissime_get_total(){
var totalcontent = 0;
if (document.all){
while (eval("document.all.ultimissime"+totalcontent))
totalcontent++;
}
else{
while (document.getElementById("ultimissime"+totalcontent))
totalcontent++;
}
return(totalcontent);
}

function ultimissime_rotate_content(num, tot)
{
var delay = 5000;
ultimissime_expand_one(num, tot);
num=(num<tot-1)? num+1: 0;
setTimeout(function(){ ultimissime_rotate_content(num,tot) },delay);
}

function ultimissime_contract_all(tot){
for (y=0;y<tot;y++){
if (document.all)
eval("document.all.ultimissime"+y).style.display="none";
else
document.getElementById("ultimissime"+y).style.display="none";
}
}

function ultimissime_expand_one(which, tot){
ultimissime_contract_all(tot);
if (document.all)
eval("document.all.ultimissime"+which).style.display="inline";
else
document.getElementById("ultimissime"+which).style.display="inline";
}

var current_gallery= 0;
var max_gallery= 0;

function init_gallery(count_gallery)
{
  	current_gallery=1;
	max_gallery= count_gallery; 
	document.getElementById("arrowright").innerHTML ='<a href="javascript:gallery_change(2)"><img border="0" width="22" height="41" src="/static/img/destra_on.gif"></a>';
	document.getElementById("arrowleft").innerHTML ='<img border="0" width="22" height="41" src="/static/img/sinistra_off.gif">';
	document.getElementById("gallery1").style.display = 'block';
	document.getElementById("gallery2").style.display = 'block';
}

function gallery_change(numgallery)
{
	if(current_gallery > numgallery ) 
	{
		document.getElementById("gallery"+ (current_gallery-1) ).style.display = 'block';
		document.getElementById("gallery"+ (current_gallery+1) ).style.display = 'none';
	}

	current_gallery=numgallery;

	var prev= numgallery -1;
	var next= numgallery +1;

	if (numgallery >1)
	{
		document.getElementById("arrowleft").innerHTML = '<a href="javascript:gallery_change('+ prev +')"><img border="0" width="22" height="41" src="/static/img/sinistra_on.gif"></a>';
		document.getElementById("arrowright").innerHTML = '<a href="javascript:gallery_change('+ next +')"><img border="0" width="22" height="41" src="/static/img/destra_on.gif"></a>';
		document.getElementById("gallery"+ prev).style.display = 'none';
		document.getElementById("gallery"+ next).style.display = 'block';
	}
	else
		init_gallery(max_gallery);

	if(numgallery==max_gallery-1)
	{
		document.getElementById("arrowleft").innerHTML = '<a href="javascript:gallery_change('+ prev +')"><img border="0" width="22" height="41" src="/static/img/sinistra_on.gif"></a>';
		document.getElementById("arrowright").innerHTML = '<img border="0" width="22" height="41" src="/static/img/destra_off.gif">';
		document.getElementById("gallery"+ prev).style.display = 'none';
		document.getElementById("gallery"+ next).style.display = 'block';
	}
}

function hlappbox(id,s)
{
	var ab = document.getElementById("appbox"+id);
	if (s == 1) ab.style.display = 'block';
	else ab.style.display = 'none';
}

function ifrHeight()  
{ 
	var ifrHeight=document.getElementById('publiframe').contentWindow.document.body.scrollHeight; 
	document.getElementById('publiframe').height=ifrHeight; 
}
