<!--
/*-------------------------------------*/
// THE ULTIMATE special ADVERTISING 	/
//                                    	/
// Creato da Saibal nel Settembre 2006	/
//                                    	/
// Dedicato al mio gatto              	/
//                                    	/
// Last revision: 12/12/07              /
/*-------------------------------------*/
/* ARGOMENTI:
1) tempo di chiusura automatica in millisecondi
2) durata del cookie  (in minuti). se impostata a "0" vale per una sessione
3) nome iframe (la dir www.html.it/ads_pages/)
4) lunghezza dell'iframe in pixel (352 default)
5) altezza dell'iframe in pixel (252 default)
*/

/* parte da aggiungere alla pagina nel BODY:
<!-- special START -->
script type="text/javascript" src="special.js"/script

addLoadEvent(function() { show_special('60000','1','special_php.htm','300','250'); })
<!-- special END -->
*/

///////////////////////////
/* INIZIO CONFIGURAZIONE */
///////////////////////////
//path principale dei CSS
//DEFAULT: http://utenti.html.it/common/css/;
//DEFAULT: http://www.html.it/ads_pages/
var p_urlframe 	= (p_urlframe) 	? p_urlframe 	: ' ';
var p_urlcss		= (p_urlcss) 		? p_urlcss 		: ' ';
var p_urlimg		= (p_urlimg) 		? p_urlimg 		: ' ';
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';
//faccio sparire alcuni elementi dalla pagina
hide_elem 			= new Array();
hide_elem [0]		= 'banner_basso';
hide_elem [1]   = 'bottone_top';
hide_elem [2]   = 'b728x90';
hide_elem [3]   = 'b350center';
hide_elem [4]   = 'b350';
hide_elem [5]   = 'adv120-1';
hide_elem [6]   = 'adv120-2';
hide_elem [7]   = 'adv468';
hide_elem [8]   = 'adv300';
hide_elem [9]   = 'highlight-business-area-banner-300x250';
hide_elem [10]  = '';
hide_elem [11]  = '';
hide_elem [12]  = 'rx-column-banner';
hide_elem [13]  = 'parte_alta_dx';
//array dei siti con sottodominio per cui deve valere il cookie
site_cookname  	= new Array();
site_cookname[0]= ' ';
site_cookname[1]= ' ';
site_cookname[2]= ' ';

////////////////////////////////////
/* INIZIO CODICE - NON MODIFICARE */
////////////////////////////////////
function show_special(autoclose,cook_time,myframename,myframe_w,myframe_h) {

  //controllo se il browser accetta i cookie
	checkCookie_special();

	if (cookieenabled == false) {
		return false;
	}

	divspecial 		= 'myspecial';
	divopacita  		= 'div_opacity';
	cook_name   		= window.location.hostname + '_special';
	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);


	// vedo che parametri dare al cookie (in caso dovesse passare anche subdomain)
	if (p_alldomain == 'y') {
  	for (i=0; i<site_cookname.length; i++) {
			if (window.location.hostname.indexOf(site_cookname[i]) != -1) {
			  cook_name 	= site_cookname[i] + '_footbanner';
				cook_domain	= site_cookname[i];
			}
		}
	}

	//vedo se esistono gli elementi base della pagina
	if (objBody != "null" && objHead != "null") {

		//se non c'è il cookie impostato
		if (document.getElementById && ScanCookie_special(cook_name)==0) {
		
			//stampo i css aggiuntivi
			if (document.getElementById('css_myspecial') != "null") {

				var cssNode 	= document.createElement('link');
				cssNode.id    = 'css_myspecial';
				cssNode.type 	= 'text/css';
				cssNode.rel 	= 'stylesheet';
				cssNode.href 	= p_urlcss + 'special.css';
				cssNode.media = 'screen';
				objHead.appendChild(cssNode);
				document.getElementById('css_myspecial').disabled = false;
				
				//creo il div contenitore del banner
			 	over_elem 							= document.createElement('div');
			 	over_elem.setAttribute('id',divspecial);
			 	over_elem.style.display = 'none';
			  over_elem.style.width 	= 'auto';
			  over_elem.style.left  	= (mywidth - myframe_w)/2 + 'px';
		 

				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_myspecial').disabled == false) {
  				objBody.insertBefore(over_elem, objBody.firstChild);
					setTimeout('over_elem.style.display = ""',350);
	  		}
	  		
	  		// opzione bordo
				if (p_border == 'n') {
					document.getElementById('special_iframe').style.borderWidth  = '0';
				}

	  		//vedo se mostrare la cosa scura del div
				if (p_opacity == 'y' && document.getElementById(divspecial)) {

					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';
				 	
				}
			}



	//chiudo la cagata di special e setto il cookie
  setTimeout("close_layer()",autoclose);
  CreationCookie_special(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_myspecial')) {
  	document.getElementById('css_myspecial').disabled = true;
  }

	if (document.getElementById(divspecial)) {
		document.getElementById(divspecial).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";
	}

	for (i=0; i<hide_elem.length; i++) {
		if (document.getElementById(hide_elem[i])) {
			document.getElementById(hide_elem[i]).style.visibility = '';
	  }
	}
} //fine funzione

//////////////////////////////////////////////////////////
/* FUNZIONE PER STABILIRE L'ALTEZZA ESATTA DELLA PAGINA */
//////////////////////////////////////////////////////////
//funzione presa per gentile concessione di lightbox
//sito ufficiale: http://www.huddletogether.com/projects/lightbox/
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;
}


///////////////////////////////////////////////
/* FUNZIONE CONTROLLA, SCANNA E SETTA COOKIE */
///////////////////////////////////////////////
function checkCookie_special() {

	document.cookie = "testcookie_special";
	cookieenabled 	= (document.cookie.indexOf("testcookie_special") != -1) ? true : false;
	return cookieenabled;
}

function ScanCookie_special(variable) {

 cook    		= document.cookie;
 variable	 += "=";
 place   		= cook.indexOf(variable,0);
 end_special = '';

 if (place <= -1) {
	return(0);
 } else {
  end_special = cook.indexOf(";",place);

	if (end_special <= -1) {
	 return(unescape(cook.substring(place+variable.length,cook.length)));
  } else {
   return(unescape(cook.substring(place+variable.length,end_special)));
 	}
 }
}

function CreationCookie_special(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


///////////////////////////
/* 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();
    }
  }
}

//-->