function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function openwin(img) {
var top=0;
var left=0;

// Centro immagine nello schermo
top=Math.floor((screen.height-600)/2);
left=Math.floor((screen.width-450)/2); 

popup = window.open("", "", "top="+top+",left="+left+",width="+450+",height="+600+",toolbar=0,location=0,directories=0,status=0,scrollbars=0,resizable=0,copyhistory=0,menuBar=0");
popup_html = '<html>';
popup_html += '<head>';
popup_html += '<meta http-equiv="content-type" content="text/html; charset=utf-8">';
popup_html += "<title>clikka per chiudere</title>";
popup_html += '</head>';
popup_html += '<body marginheight="0" marginwidth="0" topmargin="0" leftmargin="0" rightmargin="0" bgcolor="#000000">';
popup_html += '<center>';
popup_html += '<a href="javascript:self.close();" border="0" title="Clicca per chiudere">';
popup_html += '<img src="'+img+'" border="0">';
popup_html += '</a>';
popup_html += '</center>';
popup_html += '</body>';
popup_html += '</html>';
popup.document.open();
popup.document.write(popup_html);
popup.document.close();
}

function setOpacity() {
  document.getElementById('transparent').style.opacity = 9/10;
  document.getElementById('transparent').style.filter = 'alpha(opacity=' + 80 + ')';
}

function addSmiley(textToAdd) {
	document.form.ccmt.value += textToAdd;
	document.form.ccmt.focus();
}

function addBBcode(tagToAdd) {
	document.form.ccmt.value += tagToAdd;
	document.form.ccmt.focus();
}

function countlines(str)
{
var i=0;
var nblines=2;
do
        {
        i= str.indexOf("<br>",i);
        if (i>=0)
             nblines = nblines +1;
        i++;
        } while(i>0);
return(nblines);
}

function openwindowlink(url, w, h, title, date, comment, iptcexif, medianame, quicktime)
{
var top=0;
var left=0;
var realheight;

// Defining default line height
var lineheightInPixel=16;
var exist=0;

// Computing height along displayed string
realheight=h;
if (quicktime!=0)
    {
    h +=16;
    realheight +=16;
    }
if (title.length !=0)   
    {
    realheight += countlines(title)* lineheightInPixel;
    exist=1;
    }
if (date.length !=0) 
    {
    realheight += countlines(date)* lineheightInPixel;
    exist=1;
    }
if (comment.length !=0)  
    {
    realheight += countlines(comment)* lineheightInPixel;
    exist=1;
    }
if (iptcexif.length !=0) 
    {
    realheight += countlines(iptcexif)* lineheightInPixel;
    exist=1;
    }
if (exist)
    realheight +=25;

// Coordinates of centered window
top=Math.floor((screen.height-realheight)/2);
left=Math.floor((screen.width-w)/2);

// Opening the new window
popup = window.open("", medianame, "top="+top+",left="+left+",width="+w+",height="+realheight+",toolbar=0,location=0,directories=0,status=0,scrollbars=0,resizable=0,copyhistory=0,menuBar=0");
popup_html = '<html>';
popup_html += '<head>';
popup_html += '<meta http-equiv="content-type" content="text/html; charset=utf-8">';
if(quicktime!=0)
    {
    if( title.length==0)
        popup_html += '<title>QuickTime Media<\/title>';
    else
        popup_html += '<title>'+ title +'<\/title>';
    }
else
    popup_html += '<title>clikka per chiudere<\/title>';
	popup_html += '<meta http-equiv="imagetoolbar" content="no">';
	popup_html += '<style type="text/css">';
	popup_html += '<!-- ';
	popup_html += 'body  { margin: 0; font-size: 13px; line-height: 16px; color: #ffffff; } ';
	popup_html += '.iptcexif { color: #999999; } ';
	popup_html += '-->';
	popup_html += '<\/style>';
	popup_html += '<\/head>';
	popup_html += '<body bgcolor="#333333">';
	popup_html += '<a href="javascript:self.close();">';
	popup_html += '<img src="'+url+'" width="'+w+'" height="'+h+'" border="0">';
	popup_html += '<\/a>';
	popup_html += '<div align="center">';
if (title.length !=0)
    {
    popup_html += '<br>';
    popup_html += title;
    popup_html += '<br>';
    }
if (date.length !=0)
    {
    popup_html += '<br>';
    popup_html += date;
    popup_html += '<br>';
    }
if (comment.length !=0)
    {
    popup_html += '<br>';
    popup_html += comment;
    popup_html += '<br>';
    }
if (iptcexif. length !=0)
    {
    popup_html += '<br>';
    popup_html +='<span class="iptcexif">';
    popup_html += iptcexif;
    popup_html +='<\/span>';
    popup_html += '<br>';
    }
popup_html += '<\/div>';
popup_html += '<\/body>';
popup_html += '<\/html>';
popup.document.open();
popup.document.write(popup_html);
popup.document.close();
}