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