

var newwindow;



function poptastic(url,nome)

{

	newwindow=window.open(url,nome,'height=600,width=600,resizable=1,scrollbars=1');

	if (window.focus) {newwindow.focus()}

}

















function mostra(targetId)

{

	if (document.getElementById) 

		{

			target = document.getElementById(targetId);

			if (target.style.display == "none")

				{target.style.display = "";} 

				else

				{target.style.display = "none";}

		}

	

	}









function confermainvio(){

/*funzione di conferma per invio di moduli*/

var sendform = confirm("Siete sicuri di voler inviare il modulo?");

if (sendform == true) return true;

return false; 

}



function writeaddr(s1,s2,s3)

{

/*funzione di scrittura indirizzo posta elettronici per non essere presi da spider*/

	s = s1 + '@' + s2;

  document.write('<a href="mailto:' + s + '">' + s3 + '</a>');

}





function emailCheck (emailStr) {

	var checkTLD=1;

	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

	var emailPat=/^(.+)@(.+)$/;

	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

	var validChars="\[^\\s" + specialChars + "\]";

	var quotedUser="(\"[^\"]*\")";

	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

	var atom=validChars + '+';

	var word="(" + atom + "|" + quotedUser + ")";

	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

	var matchArray=emailStr.match(emailPat);

	

	if (matchArray==null) {

				alert("Indirizzo mail non corretto (controllare caratere @ e .'s)");

				return false;

				}

	var user=matchArray[1];

	var domain=matchArray[2];

	

	for (i=0; i<user.length; i++) {

		if (user.charCodeAt(i)>127) {

			alert("indirizzo mail con caratteri non validi.");

			return false;

					}

		}

	

	for (i=0; i<domain.length; i++) {

		if (domain.charCodeAt(i)>127) {

			alert("il nome di dominio inserito nell'indirizzo mail contiene caratteri non validi.");

			return false;

					}

		}

	

	

	if (user.match(userPat)==null) {

		alert("indirizzo mail non valido.");

		return false;

					}

	

	var IPArray=domain.match(ipDomainPat);

	

	if (IPArray!=null) {

			for (var i=1;i<=4;i++) {

			if (IPArray[i]>255) {

			alert("indirizzo IP non valido");

			return false;

			   }

		}

		return true;

	}

	

	

	var atomPat=new RegExp("^" + atom + "$");

	var domArr=domain.split(".");

	var len=domArr.length;

	for (i=0;i<len;i++) {

	if (domArr[i].search(atomPat)==-1) {

	alert("nome del dominio dell'indirizzo mail non valido.");

	return false;

	   }

	}

	

	

	if (checkTLD && domArr[domArr.length-1].length!=2 && 

		domArr[domArr.length-1].search(knownDomsPat)==-1) {

		alert("indirizzo mail non risolto in modo corretto");

		return false;

		}

	

	

	if (len<2) {

		alert("indirizzo mail non corretto");

		return false;

		}	

		return true;

	}





function conferma()

{

var agree=confirm("Confermi eliminazione?");

if (agree)

	return true ;

else

	return false ;

}





	

	

function cambiaImmagine(selezione,immagine)

{

	//selezione immagine nella pagina a_news

	box = document.forms[0][selezione];

	destination = box.options[box.selectedIndex].value;

	document.forms[0][immagine].src="uploads/"+destination;

}	





function OpenPopup(the_link)

{

    window.open(the_link,'','dependent=yes,resizable=yes,scrollbars=yes,width=350,height=200');

    return true;

}





















var IE = document.all?true:false;

function getMouseXY(e,immagine,id_user) { 



	

  if (IE) { // grab the x-y pos.s if browser is IE 

    tempX = event.clientX+document.documentElement.scrollLeft;
 	tempX = 10;
    tempY = event.clientY+document.documentElement.scrollTop;



  } else {  // grab the x-y pos.s if browser is NS 

    tempX = e.pageX; //layerx
    tempX = 10;

    tempY = e.pageY;

  }       

  //alert("coordinate del mouse, X="+tempX+" e Y="+tempY);

  target = document.getElementById("finestra");		   

    

  tempY = tempY-210;

  tempX = tempX+10;  

  

  	if (tempX < 0){tempX = 0;}

	if (tempY < 0){tempY = 0;} 

  	

	

  target.style.top=tempY+"px";

  target.style.left=tempX+"px";

  

 
  

  //il contenuto lo recupero tramite AJAX

  myRequest = CreateXmlHttpReq(Quiz_1);

  myRequest.open("GET","recupera_descrizione.php?id_user="+id_user);

  myRequest.send(null);  



  

  

  mostra_finestra(immagine,target);

  

  return true 

} 



function mostra_finestra(immagine,target)

{

if (document.getElementById) 

		{	

			/*recupera il valore completo del testo*/

			

					

			/*target = document.getElementById("finestra");*/									

					target.style.display = "";	

					sfondo = "#FFFADE";

					target.style.background = sfondo;					

					target.style.border = "2px solid #000";				

		}



}



function nascondi_finestra(immagine)

{

if (document.getElementById) 

		{			
			target = document.getElementById("finestra");									
			target.style.display = "none";	

		}

}





/***************** AJAX **********************/

var myRequest = null;





function CreateXmlHttpReq(handler) {

  var agt = navigator.userAgent.toLowerCase();

  var is_ie5 = (agt.indexOf('msie 5') != -1);

  var xmlhttp = null;

  try {

    xmlhttp = new XMLHttpRequest();

    try {

        // Fix for some version of Mozilla browser.

        http_request.overrideMimeType('text/xml');

    } catch(e) { }

    xmlhttp.onload = handler;

    xmlhttp.onerror = handler;

  } catch(e) {

    var control = (is_ie5) ? "Microsoft.XMLHTTP" : "Msxml2.XMLHTTP";

    xmlhttp = new ActiveXObject(control);

    xmlhttp.onreadystatechange = handler;

  }

  return xmlhttp;

}





function Quiz_1() {

    if (myRequest.readyState == 4 && myRequest.status == 200) 

    {	

   // Detect Browser

    var IE = (document.all) ? 1 : 0;

    var DOM = 0; 

    if (parseInt(navigator.appVersion) >=5) {DOM=1};    

    if (DOM) {

        var viewer = document.getElementById("finestra")                

        viewer.innerHTML=myRequest.responseText;

    }

    else if(IE) {    	

        document.all["finestra"].innerHTML= myRequest.responseText;

    	}    		 

	}

}















