/* INIZIO: FUNZIONE --BOOKMARK-- */
function bookmarksite(title, url){
if (document.all)
window.external.AddFavorite(url, title);
else if (window.sidebar);
window.sidebar.addPanel(title, url, "");
}
/* FINE: FUNZIONE --BOOKMARK-- */

/* INIZIO: FUNZIONE --PLACEHOLDER-- */
function clientSideInclude(id, url) {
  var req = false;
  // For Safari, Firefox, and other non-MS browsers
  if (window.XMLHttpRequest) {
    try {
      req = new XMLHttpRequest();
    } catch (e) {
      req = false;
    }
  } else if (window.ActiveXObject) {
    // For Internet Explorer on Windows
    try {
      req = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        req = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {
        req = false;
      }
    }
  }
 var element = document.getElementById(id);
 if (!element) {
  alert("Bad id " + id +
   "passed to clientSideInclude." +
   "You need a div or span element " +
   "with this id in your page.");
  return;
 }
  if (req) {
    // Synchronous request, wait till we have it all
    req.open('GET', url, false);
    req.send(null);
    element.innerHTML = req.responseText;
  } else {
    element.innerHTML =
   "Sorry, your browser does not support " +
      "XMLHTTPRequest objects. This page requires " +
      "Internet Explorer 5 or better for Windows, " +
      "or Firefox for any system, or Safari. Other " +
      "compatible browsers may also exist.";
  }
}
/* FINE: FUNZIONE --PLACEHOLDER-- */

/* INIZIO: FUNZIONE --SENDLINK-- */
u = window.location;
m = "Questa pagina potrebbe interessarti...";
function mailLink(){
      window.location = "mailto:"+document.sendMail.mail.value+"?subject="+m+"&body="+document.title+" "+u;
      return true;
}
/* FINE: FUNZIONE --SENDLINK-- */

/* INIZIO: FUNZIONE --USERNAME-- */
// Boolean variable specified if alert should be displayed if cookie exceeds 4KB
var caution = false;
// name - name of the cookie
// value - value of the cookie
// [expires] - expiration date of the cookie (defaults to end of current session)
// [path] - path for which the cookie is valid (defaults to path of calling document)
// [domain] - domain for which the cookie is valid (defaults to domain of calling document)
// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission
// * an argument defaults when it is assigned null as a placeholder
// * a null placeholder is not required for trailing omitted arguments
function setMyCookie(name, value, expires, path, domain, secure) {
var curCookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "")
if (!caution || (name + "=" + escape(value)).length <= 4000)
document.cookie = curCookie;
else
if (confirm("Cookie exceeds 4KB and will be cut!"))
document.cookie = curCookie;
}

// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist
function getMyCookie(name) {
var prefix = name + "=";
var cookieStartIndex = document.cookie.indexOf(prefix);
if (cookieStartIndex == -1)
return null;
var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length);
if (cookieEndIndex == -1)
cookieEndIndex = document.cookie.length;
return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

// name - name of the cookie
// [path] - path of the cookie (must be same as path used to create cookie)
// [domain] - domain of the cookie (must be same as domain used to create cookie)
// * path and domain default if assigned null or omitted if no explicit argument proceeds
function deleteMyCookie(name, path, domain) {
if (getMyCookie(name)) {
document.cookie = name + "=" + 
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}

// date - any instance of the Date object
// * you should hand all instances of the Date object to this function for "repairs"
// * this function is taken from Chapter 14, "Time and Date in JavaScript", in "Learn Advanced JavaScript Programming"
function fixDate(date) {
var base = new Date(0);
var skew = base.getTime();
if (skew > 0)
date.setTime(date.getTime() - skew);
}

function username() {
var now = new Date();
fixDate(now);
now.setTime(now.getTime() + 31 * 24 * 60 * 60 * 1000);
var name = getMyCookie("name");
if (!name)
name = prompt("Il suo nome:", "Mr./Mrs. X");
setMyCookie("name", name, now);
return "<b>" + name + "</b>";
}
/* FINE: FUNZIONE --USERNAME-- */

/* INIZIO: FUNZIONE --REMVISITE-- */
expDays = 30;
exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

function When(){
	// When
	    	var rightNow = new Date()
		var WWHTime = 0;
		WWHTime = GetCookie('WWhenH')

		WWHTime = WWHTime * 1

		var lastHereFormatting = new Date(WWHTime);  // Date-i-fy that number
	        var intLastVisit = (lastHereFormatting.getYear() * 10000)+(lastHereFormatting.getMonth() * 100) + lastHereFormatting.getDate()
	        var lastHereInDateFormat = "" + lastHereFormatting;  // Gotta use substring functions
	        var dayOfWeek = lastHereInDateFormat.substring(0,3)
	        var dateMonth = lastHereInDateFormat.substring(4,10)
		var hours = "" + lastHereFormatting.getHours()
		var year = lastHereFormatting.getYear()
                if (year < 1000) year+=1900
		var minutes = "" + lastHereFormatting.getMinutes()
		if (minutes.substring(0,1) == minutes){
			minutes = "0" + minutes
		}
	        var WWHText = dateMonth + " " + year + " alle " +  hours + ":" + minutes// display

		SetCookie ("WWhenH", rightNow.getTime(), exp)

	return WWHText;
}

function Count(){
	var psj=0;
	// How many times
		var WWHCount = GetCookie('WWHCount')
		if (WWHCount == null) {
			WWHCount = 0;
		}
		else{
			WWHCount++;
		}
		SetCookie ('WWHCount', WWHCount, exp);

	return WWHCount+1;
}

function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
		return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
	var j = i + alen;
	if (document.cookie.substring(i, j) == arg)
		return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}

function SetCookie (name, value) {
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	document.cookie = name + "=" + escape (value) +
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
	((path == null) ? "" : ("; path=" + path)) +
	((domain == null) ? "" : ("; domain=" + domain)) +
	((secure == true) ? "; secure" : "");
}

function DeleteCookie (name) {
	var exp = new Date();
	exp.setTime (exp.getTime() - 1);
	// This cookie is history
	var cval = GetCookie (name);
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();

}

function remVisite() {
if (Count()==1){
quando="  È la sua prima visita.";
When();
}
else if (Count()>1){
quando="  Bentornato. La sua ultima visita è stata il <b>" + When() +"</b>.";
}
return quando;
}
/* FINE: FUNZIONE --REMVISITE-- */

/* INIZIO: FUNZIONE --DATETIMEMSG-- */
function aggiorna() {

var mesi = new Array("Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre");
var nomeGiorno = new Array('Domenica','Lunedi','Martedi','Mercoledi','Giovedi','Venerdi','Sabato');

Data = new Date()
Giorno = Data.getDate()
Mese = Data.getMonth()
Anno = Data.getFullYear()
Ore = Data.getHours()
Minuti = Data.getMinutes()
Secondi = Data.getSeconds()

if ((Ore > 6) && (Ore < 13)) Saluto = "Buon giorno"

if ((Ore > 12) && (Ore < 18)) Saluto = "Buon pomeriggio"

if ((Ore > 17) && (Ore < 22)) Saluto = "Buona sera"

if (Ore > 21) Saluto = "Buona notte"

if (Ore < 7) Saluto = "Buona notte"

if (Minuti < 10) Minuti = "0" + Minuti

if (Secondi < 10) Secondi = "0" + Secondi

messaggio = Saluto + ", sono le ore " + Ore + ":" + Minuti + "." + Secondi + " di " + nomeGiorno[Data.getDay()] + ", " + Giorno + " " + mesi[Mese] + " " + Anno

if(!document.layers){
  aggsec = setTimeout("aggiorna();",1000);}

if (document.getElementById){
    document.getElementById('clock').innerHTML=messaggio;}

else if (document.all){
    document.all.clock.innerHTML=messaggio;}

else if(document.layers){
    document.write(messaggio);}
}
aggiorna();
/* FINE: FUNZIONE --DATETIMEMSG-- */

/* INIZIO: FUNZIONE --CATCHINGERRORS-- */
function handleErr(msg,url,l)
{
//txt="There was an error on this page.\n\n"
//txt+="Error: " + msg + "\n"
//txt+="URL: " + url + "\n"
//txt+="Line: " + l + "\n\n"
//txt+="Click OK to continue.\n\n"
//alert(txt)
return true
}
/* FINE: FUNZIONE --CATCHINGERRORS-- */

/* INIZIO: FUNZIONE --NEWSSCROLLER-- */
function prepareTags(){
if (ie4||dom){
return '<div align="left" style="position:relative;width:'+scroller_width+';height:'+scroller_height+';overflow:hidden; border: 0px '+border_color+'; border-style: solid;"><div class="tabella"  id="canvas0" style="position:absolute;background-color:'+bgcolor+';width:'+scroller_width+';height:'+scroller_height+';top:'+scroller_height+';filter:alpha(opacity=20);-moz-opacity:0.2;"></div><div class="tabella" id="canvas1" style="position:absolute;background-color:'+bgcolor+';width:'+scroller_width+';height:'+scroller_height+';top:'+scroller_height+';filter:alpha(opacity=20);-moz-opacity:0.2;"></div></div>';
} else if(document.layers){
return '<ilayer id=tickernsmain visibility=hide width='+scroller_width+' height='+scroller_height+' bgColor='+bgcolor+'><layer id=tickernssub width='+scroller_width+' height='+scroller_height+' left=0 top=0>'+scrollercontent[0]+'</layer></ilayer>';
}
}

function moveslide(){
if (curpos>0){
curpos=Math.max(curpos-degree,0);
tempobj.style.top=curpos+"px";
}
else{
clearInterval(dropslide);
if (crossobj.filters)
crossobj.filters.alpha.opacity=100;  //100
else if (crossobj.style.MozOpacity)
crossobj.style.MozOpacity=1;  //1
nextcanvas=(curcanvas=="canvas0")? "canvas0" : "canvas1";
tempobj=ie4? eval("document.all."+nextcanvas) : document.getElementById(nextcanvas);
tempobj.innerHTML=scrollercontent[curindex];
nextindex=(nextindex<scrollercontent.length-1)? nextindex+1 : 0;
setTimeout("rotateslide()",pause);
}
}

function rotateslide(){
if (ie4||dom){
resetit(curcanvas);
crossobj=tempobj=ie4? eval("document.all."+curcanvas) : document.getElementById(curcanvas);
crossobj.style.zIndex++;
if (crossobj.filters)
document.all.canvas0.filters.alpha.opacity=document.all.canvas1.filters.alpha.opacity=20; //20
else if (crossobj.style.MozOpacity)
document.getElementById("canvas0").style.MozOpacity=document.getElementById("canvas1").style.MozOpacity=0.2; //0.2
var temp='setInterval("moveslide()",50)';
dropslide=eval(temp);
curcanvas=(curcanvas=="canvas0")? "canvas1" : "canvas0";
}
else if (document.layers){
crossobj.document.write(scrollercontent[curindex]);
crossobj.document.close();
}
curindex=(curindex<scrollercontent.length-1)? curindex+1 : 0;
}

function resetit(what){
curpos=parseInt(scroller_height)*(1);
var crossobj=ie4? eval("document.all."+what) : document.getElementById(what);
crossobj.style.top=curpos+"px";
}

function startit(){
crossobj=ie4? eval("document.all."+curcanvas) : dom? document.getElementById(curcanvas) : document.tickernsmain.document.tickernssub;
if (ie4||dom){
crossobj.innerHTML=scrollercontent[curindex];
rotateslide();
}
else{
document.tickernsmain.visibility='show';
curindex++;
setInterval("rotateslide()",pause);
}
}
/* FINE: FUNZIONE --NEWSSCROLLER-- */

/* INIZIO: FUNZIONE --HIDEELEMENT-- */
function ShowAndHide(id1,id2){
if(document.getElementById){
    el1=document.getElementById(id1);
    el2=document.getElementById(id2);
    if(el1.style.display=="none"){
        el1.style.display="block";
        el2.style.display="none";
        }
    else{
        el1.style.display="none";
        el2.style.display="block";
        }
    }
}
function showDiv(id1){
if(document.getElementById){
    el=document.getElementById(id1);
    el.style.display="block";
    }
}
function hideDiv(id1){
if(document.getElementById){
    el=document.getElementById(id1);
    el.style.display="none";
    }
}
/* FINE: FUNZIONE --HIDEELEMENT-- */

/* INIZIO: FUNZIONE --XMLNEWS-- */
   function makeArrayNews(xdoc)
   {
     var news = new Array();
     alert('makeArrayNews: start --> quante news: '+newsTemp.length);
     if( xdoc != null )
     {
       var newsTemp = xdoc.getElementsByTagName("news");
       for(var i = 0; i < newsTemp.length; ++i)
       {
         alert(i+'-'+newsTemp[i].firstChild.nodeValue);
         news[i] = newsTemp[i].firstChild.nodeValue;
         alert(i+'-'+news[i]);
       }
     }
     alert('makeArrayNews: end --> quante news: '+newsTemp.length);
     return news;
   }

//<![CDATA[
function CJL_loadXmlDocument(xmlFile, cbFun)
{
   var xdoc;

   if( window.ActiveXObject && /Win/.test(navigator.userAgent) )
   {
      xdoc = new ActiveXObject("Microsoft.XMLDOM");

      xdoc.async = false;
      xdoc.load(xmlFile);

      cbFun(xdoc);

      return true;
   }
   else if( document.implementation && document.implementation.createDocument )
   {
      xdoc = document.implementation.createDocument("", "", null);
      xdoc.load(xmlFile);

      xdoc.onload = function()
      {
         cbFun(xdoc);
      }

      return true;
   }
   else
   {
      return false;
   }
}
//]]>

//<![CDATA[
   var e = document.getElementById("xmlNews");

   function writeXMLData(xdoc)
   {
      var news = xdoc.getElementsByTagName("news");

      for(var i = 0; i < news.length; ++i)
      {
	     e.appendChild(document.createElement("div")).
         innerHTML = '"' + news[i].firstChild.nodeValue + '"';
		 e.style.fontWeight = "bold";
      }
   }

   if( ! CJL_loadXmlDocument("news.xml", writeXMLData) )
   {
      e.appendChild(document.createElement("div")).innerHTML =
	  "Browser doesn't support external XML loading";
   }
//]]>
/* FINE: FUNZIONE --XMLNEWS-- */

/* INIZIO: FUNZIONE --IP_HOST_DATA-- */
var ip_ = '<!--#echo var="REMOTE_ADDR"-->';
var host_ = '<!--#echo var="REMOTE_HOST"-->';

function ipval() {
return ip_;
}

function hostval() {
return host_;
}
/* FINE: FUNZIONE --IP_HOST_DATA-- */

/* INIZIO: FUNZIONE --SENDMAILAPPUNTAMENTI-- */
function mail4meeting(){
      var emailAddr = "plt_talking@eml.cc";
      var subject = "PLT_Talking: richiesta appuntamento per il giorno " + document.validation.date3.value;
      //var body_text = "Nome: " + document.validation.nome.value + "; " + <br/> + "IP: " + ipval() + "; " + <br/> + "HOST: "+ hostval() + "; " + <br/>;
      var body_text = "Nome: " + document.validation.nome.value + ";   " + "E-mail: " + document.validation.email.value + ";   ";
      window.location = "mailto:"+emailAddr+"?subject="+subject+"&body="+body_text;
      //return true;
}
/* FINE: FUNZIONE --SENDMAILAPPUNTAMENTI-- */


/* INIZIO: FUNZIONE --OPENPOPUP-- */
function expandingWindow(website) {
var windowprops='width=1,height=1,scrollbars=no,status=no,resizable=no,location=no'
var heightspeed = 1;
var widthspeed = 1;
var leftdist = 10;
var topdist = 10;
var lunghezza = 500;
var altezza = 560;

if(lunghezza == 0){
lunghezza = window.screen.availWidth;
		}
if(altezza == 0){
altezza = window.screen.availHeight;
}

if (window.resizeTo&&navigator.userAgent.indexOf("Opera")==-1) {
var winwidth = lunghezza;
var winheight = altezza;
var sizer = window.open("","","left=" + leftdist + ",top=" + topdist +","+ windowprops);
for (sizeheight = 1; sizeheight < winheight; sizeheight += heightspeed)
sizer.resizeTo("1", sizeheight);
for (sizewidth = 1; sizewidth < winwidth; sizewidth += widthspeed)
sizer.resizeTo(sizewidth, sizeheight);
sizer.location = website;
}
else
window.open(website,'mywindow');
}
/* FINE: FUNZIONE --OPENPOPUP-- */
