<!--
/*-------------------------------------*/
//THE ULTIMATE INTERSTITIAL ADVERTISING /
//                                    	/
//  Creato da Saibal nel Dicembre 2007	/
//                                    	/
// 			    Dedicato a Vilma            /
//                                    	/
// Last revision: 16/12/07              /
/*-------------------------------------*/
/* ARGOMENTI:
1) nome della pagina contenente codice adserver su http://www.html.it/ads_pages/
2) durata del cookie  (in minuti). se impostata a "0" vale per una sessione
*/

/* parte da aggiungere alla pagina nel BODY:
<!-- INTERSTITIAL START -->
<script type="text/javascript" src="http://utenti.html.it/common/js/interstitial.js"></script>
<script type="text/javascript">
var subdom_inc = 'n';
show_interstitial('interstitial_webnews.php','15');
</script>
<!-- INTERSTITIAL END -->
*/

///////////////////////////
/* INIZIO CONFIGURAZIONE */
///////////////////////////
var back_url 		= escape(window.location);
var p_alldomain	= (p_alldomain) 	? p_alldomain 	: 'n';
var p_urlpage 	= (p_urlpage) 		? p_urlpage 		: 'http://www.puntoshop.tv/ita/';
//array dei siti con sottodominio per cui deve valere il cookie
site_cookname  	= new Array();
site_cookname[0]= 'puntoshop.it';
site_cookname[1]= 'puntoshopfranchising.it';


function show_interstitial(mypage,cook_time) {

  //controllo se il browser accetta i cookie
	checkCookie_interstitial();

	if (cookieenabled == false) {
		return false;
	}

	cook_name   		= window.location.hostname + '_interstitial';
	cook_domain 		= '';

	// 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] + '_interstitial';
				cook_domain	= site_cookname[i];
			}
		}
 	}

	//se non c'è il cookie impostato
	if (ScanCookie_interstitial(cook_name)==0) {

  	base_domain 	= window.location.hostname;
  	split_domain 	= window.location.hostname.split(".");

		if (split_domain[1] != undefined) {
  		ref_domain  	= split_domain[1];
  	} else {
  		ref_domain    = 'puntoshop.tv/ita/';
  	}

		CreationCookie_interstitial(cook_name,false,cook_time,cook_domain);
		top.window.location = p_urlpage+mypage+'?backto='+back_url+'&site='+base_domain+'&ref='+ref_domain;
  
	}
}

///////////////////////////////////////////////
/* FUNZIONE CONTROLLA, SCANNA E SETTA COOKIE */
///////////////////////////////////////////////
function checkCookie_interstitial() {

	document.cookie = "testcookie_interstitial";
	cookieenabled 	= (document.cookie.indexOf("testcookie_interstitial") != -1) ? true : false;
	return cookieenabled;
}

function ScanCookie_interstitial(variable) {

 cook    		= document.cookie;
 variable	 += "=";
 place   		= cook.indexOf(variable,0);
 end_interstitial = '';

	if (place <= -1) {
  	return(0);
 	} else {
  	end_interstitial = cook.indexOf(";",place)

		if (end_interstitial <= -1) {
  		return(unescape(cook.substring(place+variable.length,cook.length)));
  	} else {
  		return(unescape(cook.substring(place+variable.length,end_interstitial)));
  	}
 	}
}

function CreationCookie_interstitial(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      = escape(valore);
  	ex.setTime(now.getTime() + calc_durata);

		document.cookie = nome+ "=" +valore+ " ; path=/; " +miodominio+ "expires=" +ex.toGMTString();
	} else {
		document.cookie = nome+ "=" +valore+ "; path=/; " +miodominio+ "expires=";
	}
	
}// fine funzioni
//-->