/* FUNZIONE ADDLOADEVENT */
function addLoadEvent(func) {

	var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

//SET HOME - PREFERITI
function preferiti() {
    if (isExplorer()) window.external.AddFavorite("http://www.diariodelweb.it","DIARIODELWEB.it");   
    else alert("Premi Ctrl+D per aggiungere questo sito nei tuoi Favoriti"); 
}

function isExplorer() {
   if ((navigator.appName=="Microsoft Internet Explorer") && (parseInt(navigator.appVersion)>=4)) return true;
   else if(navigator.appName == "Netscape") return false;   
   else return false;   
}

//SET TABELLA SPECIALI
function tab_Speciali() {
	document.write('<div class="contorno_f">');
		document.write('<div class="speciali">');
			document.write('<h2 class="stirare">Gli speciali del Diario del Web</h2>');
			document.write('<div class="mod_content">');
				document.write('<div class="mod_int stirare">');
					var Url = '/Speciali/Elezioni_regionali/'
					var Ttl = 'Regionali, il caos liste' 
					document.write('<a target="_blank" class="mod_img" href="'+Url+'" title="'+Ttl+'"');
					document.write('<img src="/im/Tuttosu/Speciali.jpg" height="60" width="60" /></a>');
					document.write('<ul>');
							document.write('<li><a target="_blank" href="'+Url+'" title="'+Ttl+'"><strong>'+Ttl+'</strong></a></li>');
						var Url = '/Speciali/Internet/'
						var Ttl = 'Pianeta Internet' 
							document.write('<li><a target="_blank" href="'+Url+'" title="'+Ttl+'"><strong>'+Ttl+'</strong></a></li>');
						var Url = '/Speciali/Conti_pubblici/'
						var Ttl = 'La crisi nei conti' 
							document.write('<li><a target="_blank" href="'+Url+'" title="'+Ttl+'"><strong>'+Ttl+'</strong></a></li>');
						var Url = '/Speciali/Giustizia/'
						var Ttl = 'Il nodo Giustizia' 
							document.write('<li><a target="_blank" href="'+Url+'" title="'+Ttl+'"><strong>'+Ttl+'</strong></a></li>');
						var Url = '/Speciali/Fisco/'
						var Ttl = 'Fisco: tasse sempre su' 
							document.write('<li><a target="_blank" href="'+Url+'" title="'+Ttl+'"><strong>'+Ttl+'</strong></a></li>');
						var Url = '/Speciali/Energia_nucleare/'
						var Ttl = 'La sfida nucleare' 
							document.write('<li><a target="_blank" href="'+Url+'" title="'+Ttl+'"><strong>'+Ttl+'</strong></a></li>');
						var Url = '/Speciali/Amministrazione_Obama/'
						var Ttl = 'Il «flop» Obama' 
							document.write('<li><a target="_blank" href="'+Url+'" title="'+Ttl+'"><strong>'+Ttl+'</strong></a></li>');
					document.write('</ul>');
				document.write('</div>');
			document.write('</div>');
		document.write('</div>');
	document.write('</div>');
}

//SET MENU
function show_Menu(div_id) {
    document.getElementById(div_id).style.display = 'block';
}
function hide_Menu(div_id) {
    document.getElementById(div_id).style.display = 'none';
}

function OAS_RICH_TOP(pos) {
	switch (pos){
		case "Opinioni":
			var uri = 'http://adv.diariodelweb.it/Banner/Chicago-blog.jpg'
			var link = '\'LINK=Leaderboard-ChicagoBlog\'' 
			document.write('<a rel="nofollow" target="_BLANK" href="http://www.chicago-blog.it/" onClick="javascript:ssxl('+link+');"><img width="728" height="90" src="'+uri+'" border=0></a>');
			break;
		case "Google":
			google_ad_client = "pub-1316367769997270";
			google_ad_slot = "7896349348";
			google_ad_width = 728;
			google_ad_height = 90;
			break;
		case "Tradedoubler":
			var uri = 'http://anet.tradedoubler.com/anet?type(js)loc(13938)' + new String (Math.random()).substring (2, 11);
			document.write('<sc'+'ript type="text/javascript" src="'+uri+'" charset="ISO-8859-1"></sc'+'ript>');
			break;
		case "Popcorntv":
			var uri = 'http://adv.diariodelweb.it/Banner/Popcorntv/728x90.jpg'
			var link = '\'LINK=Leaderboard-Popcorntv\'' 
			document.write('<a rel="nofollow" target="_BLANK" href="http://www.popcorntv.it/" onClick="javascript:ssxl('+link+');"><img width="728" height="90" src="'+uri+'" border=0></a>');
			break;
		default:
			var uri = 'http://adv.diariodelweb.it/Banner/Popcorntv/728x90.jpg'
			var link = '\'LINK=Leaderboard-Popcorntv\'' 
			document.write('<a rel="nofollow" target="_BLANK" href="http://www.popcorntv.it/" onClick="javascript:ssxl('+link+');"><img width="728" height="90" src="'+uri+'" border=0></a>');
	}
}


function OAS_RICH_BOX(pos) {
	switch (pos){
		case "Text":
			google_ad_client = "pub-1316367769997270";
			/* DDW - BOX Link */
			google_ad_slot = "0073306611";
			google_ad_width = 336;
			google_ad_height = 280;
			break;
		case "Img":
			google_ad_client = "pub-1316367769997270";
			/* Medium BOX top 300 */
			google_ad_slot = "9440138522";
			google_ad_width = 300;
			google_ad_height = 250;
			break;
		case "All":
			google_ad_client = "pub-1316367769997270";
			/* Medium BOX top 336 */
			google_ad_slot = "4295170479";
			google_ad_width = 336;
			google_ad_height = 280;
			break;
		default:
			var uri = 'http://anet.tradedoubler.com/anet?type(js)loc(25004)' + new String (Math.random()).substring (2, 11);
			document.write('<sc'+'ript type="text/javascript" src="'+uri+'" charset="ISO-8859-1"></sc'+'ript>');
	}
}

function adv_Spn2() {
	var uri = 'http://adv.diariodelweb.it/Banner/Popcorntv/250x90.jpg'
	var link = '\'LINK=Sponsor-Popcorntv\'' 
	document.write('<a rel="nofollow" target="_BLANK" href="http://www.popcorntv.it/" onClick="javascript:ssxl('+link+');"><img width="250" height="90" src="'+uri+'" border=0></a>');
}

function adv_Spn() {
	var uri = 'http://adv.diariodelweb.it/Banner/APCOM/Apcom-TIM_250x90.gif'
	var link = '\'LINK=Sponsor-ApCom\'' 
	document.write('<a rel="nofollow" target="_BLANK" href="http://www.tim.it/i.tim/o32103/servizioitim.do" onClick="javascript:ssxl('+link+');"><img width="250" height="90" src="'+uri+'" border=0></a>');
}

function adv_Box_btt() {
	google_ad_client = "pub-1316367769997270";
	/* DDW - Firma */
	google_ad_slot = "9258799417";
	google_ad_width = 468;
	google_ad_height = 60;
}

function adv_Box_tbl() {
	var uri = 'http://www.diariodelweb.it/im/Chicago-Blog_TAB.jpg';
	var link = '\'LINK=Tabella-ChicagoBlog\'' 
	document.write('<a target="_BLANK" rel="nofollow" href="http://www.chicago-blog.it/" onClick="javascript:ssxl('+link+');"><img width="164" height="27" src="'+uri+'" border=0></a>');
}

function adv_Box_250() {
	var uri = 'http://impit.tradedoubler.com/imp?type(js)g(17997806)a(1585698)' + new String (Math.random()).substring (2, 11);
	document.write('<sc'+'ript type="text/javascript" src="'+uri+'" charset="ISO-8859-1"></sc'+'ript>');
}

function adv_Box_468() {
	var uri = 'http://impit.tradedoubler.com/imp?type(img)g(172888)a(1585698)' + new String (Math.random()).substring (2, 11);
	document.write('<a href="http://clk.tradedoubler.com/click?p=16987&a=1585698&g=172888" target="_BLANK"><img width="468" height="60" src="'+uri+'" border=0></a>');
}

//SET Popup
var p_urlframe 	= (p_urlframe) 	? p_urlframe 	: 'http://adv.diariodelweb.it/Banner/';
var p_urlcss		= (p_urlcss) 		? p_urlcss 		: 'http://www.diariodelweb.it/CSS/';
var p_urlimg		= (p_urlimg) 		? p_urlimg 		: 'http://www.diariodelweb.it/im/';
var p_opacity		= (p_opacity) 	? p_opacity 	: 'n';
var p_topmargin	= (p_topmargin) ? p_topmargin : '';
var p_alldomain	= (p_alldomain) ? p_alldomain : 'n';
var p_border  	= (p_border) 		? p_border 		: 'n';

/* INIZIO CODICE - NON MODIFICARE */
function show_popup_layer(autoclose,cook_time,myframename,myframe_w,myframe_h) {

  //controllo se il browser accetta i cookie
	checkCookie_popup_layer();

	if (cookieenabled == false) {
		return false;
	}

	divpopup_layer 		= 'mypopup_layer';
	divopacita  		= 'div_opacity';
	cook_name   		= window.location.hostname + '_popup_layer';
	cook_domain 		= '';
	var mypagesize 	= getPageSize();
	var mywidth 		= (document.all)? mypagesize[2] : mypagesize[2] -16;
	var objBody 		= document.getElementsByTagName("body").item(0);
	var objHead 		= document.getElementsByTagName("head").item(0);

html_code  = '<div id="popup_layer_container" style="width:' +myframe_w+ 'px;">';
html_code += '<div id="popup_layer_closer">';
html_code += '<a href="javascript:void(0);" onClick="close_layer();return(false);">';
html_code += '<img src="' +p_urlimg+ 'popup_layer_chiudi.gif" alt="" /></a>';
html_code += '</div></div>';
html_code += '<div id="popup_layer_iframe_container" style="width:' +myframe_w+ 'px;">';
html_code += '<iframe id="popup_layer_iframe" src="' +p_urlframe+myframename+ '" ';
html_code += 'style="height:' +myframe_h+ 'px;width:' +myframe_w+ 'px;" ';
html_code += 'frameborder="0" scrolling="no"></iframe>';
html_code += '</div>';

	//vedo se esistono gli elementi base della pagina
	if (objBody != "null" && objHead != "null") {

		//se non c'č il cookie impostato
		if (document.getElementById && ScanCookie_popup_layer(cook_name)==0) {
		
			//stampo i css aggiuntivi
			if (document.getElementById('css_mypopup_layer') != "null") {

				var cssNode 	= document.createElement('link');
				cssNode.id    = 'css_mypopup_layer';
				cssNode.type 	= 'text/css';
				cssNode.rel 	= 'stylesheet';
				cssNode.href 	= p_urlcss + 'popup.css';
				cssNode.media = 'screen';
				objHead.appendChild(cssNode);
				document.getElementById('css_mypopup_layer').disabled = false;
				
				//creo il div contenitore del banner
			 	over_elem 							= document.createElement('div');
			 	over_elem.setAttribute('id',divpopup_layer);
			 	over_elem.style.display = 'none';
			  over_elem.style.width 	= 'auto';
			  over_elem.style.left  	= (mywidth - myframe_w)/2 + 'px';
			  over_elem.innerHTML   	= html_code;

				if (myframe_h > 500) {
		  		over_elem.style.height	= myframe_h + 'px';
				}

				if (p_topmargin != '') {
					over_elem.style.top = p_topmargin + 'px';
				}
				
				if (document.getElementById('css_mypopup_layer').disabled == false) {
  				objBody.insertBefore(over_elem, objBody.firstChild);
					setTimeout('over_elem.style.display = ""',350);
	  		}
	  		
	  		// opzione bordo
				if (p_border == 'n') {
					document.getElementById('popup_layer_iframe').style.borderWidth  = '0';
				}

	  		//vedo se mostrare la cosa scura del div
				if (p_opacity == 'y' && document.getElementById(divpopup_layer)) {

					objOverlay 								= document.createElement('div');
					objOverlay.setAttribute('id',divopacita);
					objBody.appendChild(objOverlay);
					objOverlay.style.position = 'absolute';
					objOverlay.style.top 			= '0';
					objOverlay.style.left 		= '0';
					objOverlay.style.zIndex 	= '90';
				 	objOverlay.style.width 		= '100%';
				 	objOverlay.style.height 	= mypagesize[1] +'px';
				 	
				}
			}

  // nascondo tutte le select
	var selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
			selects[i].style.visibility = "hidden";
	}

	//chiudo popup_layer e setto il cookie
  setTimeout("close_layer()",autoclose);
  CreationCookie_popup_layer(cook_name,false,cook_time,cook_domain);

		} //fine "se non c'č il cookie impostato"
 
	} //se esiste il div di ancoraggio

} //fine funzione


/* FUNZIONE CHIUDI */
function close_layer() {

  if (document.getElementById('css_mypopup_layer')) {
  	document.getElementById('css_mypopup_layer').disabled = true;
  }

	if (document.getElementById(divpopup_layer)) {
		document.getElementById(divpopup_layer).style.display  = 'none';
	}

	if (document.getElementById(divopacita)) {
		document.getElementById(divopacita).style.display  = 'none';
	}

	var selects = document.getElementsByTagName("select");
  for (i = 0; i != selects.length; i++) {
			selects[i].style.visibility = "visible";
	}

} //fine funzione

/* FUNZIONE PER STABILIRE L'ALTEZZA ESATTA DELLA PAGINA */
function getPageSize(){

	var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY) {
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight) {
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;
	
	if (self.innerHeight) {	// all except Explorer
		windowWidth 	= self.innerWidth;
		windowHeight 	= self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		windowWidth 	= document.documentElement.clientWidth;
		windowHeight 	= document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth 	= document.body.clientWidth;
		windowHeight 	= document.body.clientHeight;
	}

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;
}


/* Cookie */
function checkCookie_popup_layer() {

	document.cookie = "testcookie_popup_layer";
	cookieenabled 	= (document.cookie.indexOf("testcookie_popup_layer") != -1) ? true : false;
	return cookieenabled;
}

function ScanCookie_popup_layer(variable) {

 cook    		= document.cookie;
 variable	 += "=";
 place   		= cook.indexOf(variable,0);
 end_popup_layer = '';

 if (place <= -1) {
	return(0);
 } else {
  end_popup_layer = cook.indexOf(";",place);

	if (end_popup_layer <= -1) {
	 return(unescape(cook.substring(place+variable.length,cook.length)));
  } else {
   return(unescape(cook.substring(place+variable.length,end_popup_layer)));
 	}
 }
}

function CreationCookie_popup_layer(nome,valore,durata,dominio) {

	if (dominio != '') {
  	miodominio = "domain= " +dominio+ "; ";
  } else {
  	miodominio = '';
  }

	if (durata != 0) {
   	var calc_durata = parseInt(durata) * 60000;
   	var now 				= new Date();
  	var ex 					= new Date();
  	var valore_c      = escape(valore);
  	ex.setTime(now.getTime() + calc_durata);

		document.cookie = nome+ "=" +valore_c+ " ; path=/; " +miodominio+ "expires=" +ex.toGMTString();
	} else {
		document.cookie = nome+ "=" +valore_c+ "; path=/; " +miodominio+ "expires=";
	}
	
}// fine funzioni

//-->
