// BROWSER SNIFFER 
 var ie = (navigator.appName == "Microsoft Internet Explorer") ? true : false;
 

//MM PRELOAD
	function MM_preloadImages() { //v3.0
	  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}


// POPUP
	// Popup per modulo pf_banner
	function popUpHome() {
		if (readCookie('popup') != 'visto') {
			createCookie('popup','visto',0);
			var sinistra = Math.floor((screen.width-300)/2);
			var sopra = Math.floor((screen.height-300)/2);
			window.open('popup_banner.php','popupHome','width=300,height=300,top='+sopra+',left='+sinistra+',resizable=no,scrollbars=no');
		}
	}
	// Popunder per modulo pf_banner
	function popUnderHome() {
		if (readCookie('popunder') != 'visto') {
			createCookie('popunder','visto',0);
			var sinistra = Math.floor((screen.width-500)/2);
			var sopra = Math.floor((screen.height-500)/2);
			window.open('popunder_banner.php','popunderHome','width=500,height=500,top='+sopra+',left='+sinistra+',resizable=no,scrollbars=no');
		}
	}
	// Dettaglio
	function popupDettaglio(aid) {
		var sinistra = Math.floor((screen.width-640)/2);
		var sopra = Math.floor((screen.height-520)/2);
		window.open("pkg_details.php?aid="+aid+"","dettaglio","width="+640+",height="+520+",top="+sopra+",left="+sinistra+"");
	}
	// Dettaglio Cart
	function popupDettaglioCart(aid) {
		var sinistra = Math.floor((screen.width-640)/2);
		var sopra = Math.floor((screen.height-520)/2);
		window.open("pkg_details_cart.php?aid="+aid+"","dettaglioCart","width="+640+",height="+520+",top="+sopra+",left="+sinistra+"");
	}
	// Immagini
	function popupImmagini(aid) {
		var sinistra = Math.floor((screen.width-640)/2+15);
		var sopra = Math.floor((screen.height-520)/2+15);
		window.open("pkg_images.php?aid="+aid+"","immagini","width="+640+",height="+520+",top="+sopra+",left="+sinistra+"");
	}
	// Immagini Cart
	function popupImmaginiCart(aid) {
		var sinistra = Math.floor((screen.width-640)/2+15);
		var sopra = Math.floor((screen.height-520)/2+15);
		window.open("pkg_images_cart.php?aid="+aid+"","immaginiCart","width="+640+",height="+520+",top="+sopra+",left="+sinistra+"");
	}
	// WebRadio
	function popupRadio() {
		var sinistra = Math.floor((screen.width-380)/2);
		var sopra = Math.floor((screen.height-132)/2);
		radio = window.open("popup_radio.php","radio","width="+380+",height="+132+",top="+sopra+",left="+sinistra+"");
	}
	// WebCam
	function popupCam(postazione) {
		var sinistra = Math.floor((screen.width-640)/2);
		var sopra = Math.floor((screen.height-520)/2);
		if(!postazione) {
			// apro la piantina delle cam
			window.open("popup_cam.php","cam","width="+640+",height="+520+",top="+sopra+",left="+sinistra+"");
		} else {
			// apro una cam specifica
			window.open("popup_cam.php?id="+postazione+"","cam","width="+640+",height="+520+",top="+sopra+",left="+sinistra+"");
		}
	}
	// Faq
	function popupFaq(fid) {
		var sinistra = Math.floor((screen.width-640)/2+15);
		var sopra = Math.floor((screen.height-520)/2+15);
		window.open("popup_faq.php?fid="+fid+"","faq","width="+640+",height="+520+",top="+sopra+",left="+sinistra+"");
	}


// COOKIES: crea, legge, cancella.
	function createCookie(name,value,days)
	{
		if (days)
		{
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	}
	
	function readCookie(name)
	{
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++)
		{
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}
	
	function eraseCookie(name)
	{
		createCookie(name,"",-1);
	}

/* popUp TEMPORANEO
	function popUpHome() {
		var sinistra = Math.floor((screen.width-300)/2);
		var sopra = Math.floor((screen.height-300)/2);
		window.open('popup_home_statico.html','popupHome','width=300,height=300,top='+sopra+',left='+sinistra+',resizable=no,scrollbars=no');
	}
	if (location.href == 'http://www.partifacile.it' || location.href == 'http://www.partifacile.it/'  || location.href == 'http://www.partifacile.it/index.php' ){
		popUpHome()
	};
	*/
	/*
	if (readCookie('popup') != 'visto') {
		createCookie('popup','visto',0);
		popUpHome();
	}
*/

/* RANDOM WEBCAM
	totCam = 2; // da aggiornare al variare del totale screenshot
	var cam = new Array();
		cam[1] = "03";
		cam[2] = "05";
	function randomWebcam() {
		casuale = (Math.floor(Math.random()*totCam))+1;
		codice = "<a href='javascript:;' onClick='popupCam("+cam[casuale]+")'>";
		codice += "<img src='webcam/"+cam[casuale]+".jpg'>";
		codice += "</a>";
		document.write(codice);
	}
*/

