﻿function showfoto(id)
{
   var l = Math.floor((screen.width-800)/2);
   var t = Math.floor((screen.height-600)/2);
   window.open("foto.aspx?id="+id,"","width=" + 800 + ",height=" + 600 + ",top=" + t + ",left=" + l);
}

function vedipedi(id)
{
   var l = Math.floor((screen.width-800)/2);
   var t = Math.floor((screen.height-600)/2)-26;
   window.open(id,"","resizable=yes,scrollbars=yes, width=" + 800 + ",height=" + 600 + ",top=" + t + ",left=" + l);
}

function newdesc()
{
   var l = Math.floor((screen.width-800)/2);
   var t = Math.floor((screen.height-600)/2);
   window.open("messaggio.aspx","","width=" + 580 + ",height=" + 340 + ",top=" + t + ",left=" + l);
  //window.showModalDialog("messaggio.aspx,"","width=" + 800 + ",height=" + 600 + ",top=" + t + ",left=" + l);
}

function findObj(theObj, theDoc)
{
  var p, i, foundObj;
  
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  
  return foundObj;
}

function SendEmail()
{
    var onome=findObj("nome");
    var oemail=findObj("email");
    var oprivacy=findObj("privacy");
    if(onome.value=="")
    {
        window.alert("Inserire il nome.");
        return;
    }
    if(!ControllaMail(oemail.value))
    {
        window.alert("Email non corretta.");
        return;
    }
    if(oprivacy.checked)
    {
        var l = Math.floor((screen.width-300)/2);
        var t = Math.floor((screen.height-100)/2);
        window.open("semail.aspx?email="+oemail.value+"&nome="+onome.value,"","width=" + 300 + ",height=" + 100 + ",top=" + t + ",left=" + l);       
    }
    else
    {
        window.alert("Accetta il trattamento dei dati (d.l. 196/03)");
    }
}

function ControllaMail(EmailAddr)
{
    var Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
    if (Filtro.test(EmailAddr))
    {
        return true;
    }
    else
    {
        return false;
    }
}

opac = 0; 
function fadeIn() 
{ 
ie5 = (document.all && document.getElementById); 
ns6 = (!document.all && document.getElementById); 
if(opac!= 100){ 
opac+=1; 
if(ie5) document.getElementById('layerauguri').filters.alpha.opacity = opac; 
if(ns6) document.getElementById('layerauguri').style.MozOpacity = opac/100; 
setTimeout('fadeIn()', 3); 
} 
}
 
 function posiziona_layer(lar,alt)
 {
    var lay=document.getElementById('layerauguri');
    lay.style.top=screen.height/2 - alt/2;
    lay.style.left=screen.width/2 - lar/2;
 }

function chiudi()
{
 document.getElementById('layerauguri').style.visibility = "hidden";
}
