// $Id: script.js,v 1.20 2007-05-15 08:07:24 fmenegoni Exp $

// F1 front-end/back-end toggle
	if (document.all) {
		document.onhelp = function() {
			location.href = 'admin/';
			return false;
		}
	} else {
		document.onkeydown = function (evt) {
			if (evt.keyCode == '112') {
				location.href = 'admin/';
				return false;
			}
		}
	}

// POPUP CENTRATA
function popupCentrata(nomefile,nomefinestra,larghezza,altezza) {
	var sinistra = Math.floor((screen.width-larghezza)/2);
	var sopra = Math.floor((screen.height-altezza)/2);
	window.open (nomefile,nomefinestra,"width=" + larghezza + ",height=" + altezza + ",top=" + sopra + ",left=" + sinistra + ",resizable=yes");
}

// POPUP GALLERY
	function popupGallery(pid) {
		var sinistra = Math.floor((screen.width-740)/2);
		var sopra = Math.floor((screen.height-580)/2);
		window.open("popup_gallery.php?pid="+pid+"","gallery","width="+740+",height="+580+",top="+sopra+",left="+sinistra+"");
	}

// POPUP IMG ANNUNCIO
	function popupImgAnnuncio(immagine) {
		var sinistra = Math.floor((screen.width-600)/2);
		var sopra = Math.floor((screen.height-600)/2);
		window.open("popup_img_annuncio.php?img="+immagine+"","zoom","width=600,height=600,top="+sopra+",left="+sinistra+"");
	}

// POPUP VOTO ANNUNCIO
	function popupVotoAnnuncio(id) {
		var sinistra = Math.floor((screen.width-600)/2);
		var sopra = Math.floor((screen.height-600)/2);
		window.open("popup_voto_annuncio.php?id="+id+"","voto","width=300,height=300,top="+sopra+",left="+sinistra+"");
	}

// ROLLOVER PER TUTTI I PULSANTI DEL SITO
window.onload = rolloverPulsanti;
function rolloverPulsanti() {
	tuttiInput = document.getElementsByTagName('input');
	for (i=0; i<tuttiInput.length; i++) {
		if (tuttiInput[i].type == 'submit' || tuttiInput[i].type == 'button' || tuttiInput[i].type == 'reset') {
			tuttiInput[i].onmouseover = function() { this.style.borderStyle = 'inset'; this.style.backgroundColor = '#a00' };
			tuttiInput[i].onmouseout = function() { this.style.borderStyle = ''; this.style.backgroundColor = '' };
		}
	}
}

// CARICAMENTO CSS
document.writeln("<link rel='stylesheet' href='css/css.css'><link rel='stylesheet' href='css/print.css' media='print'>")

//MM ROLLOVER
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];}}
}

// COOKIES: CREA, LEGGI, ELIMINA.
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);
}


