function popup(name,url,width,height) {
	newwindow=window.open(url,name,'width='+width+',height='+height+',scrollbars=0,resizable=0,left=0,top=0,statusbar=0');
	if (window.focus) {newwindow.focus()}
//	return false;
}

function popUpRes(name,URL,width,height) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open('" + URL + "', '" + name + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width="+width+",height="+height+"');");
	if (window.focus) {eval("page" + id +".focus()")}
}


// opens a custom window (full parameters)
function customPopUp(url,x,y,name,param,focusOnPopUp,focusOnWindow)		{

	// dimensioni
	var winSize="";
	if (x>0)	winSize+="width="+x+",";
	if (y>0)	winSize+="height="+y+",";
	
	// new windows
	var siteWindowVar=open(url,name,winSize+"directories=no,"+param);
	
	if (siteWindowVar&&focusOnPopUp)	siteWindowVar.focus();	// popup in primo piano
	if (siteWindowVar&&focusOnWindow)	self.focus();			// finestra corrente in primo piano
	
	// il return serve per controllare eventuali popup bloccati o javascript non abilitato
	return (siteWindowVar==null);

	if (window.focus) {siteWindowVar.focus()}

}

//controlla il searchbox
function CheckSearch() {
if (document.searchbox.Key1.value=='') {
	alert('Enter at least one word');
	return false;
	}
if (document.searchbox.Key1.value=='Keyword or Style') {
	alert('Enter Keyword or Style');
	return false;
	}
return true;
}

//controlla l'indirizzo email
function isValidEmail(strEmail) {
//			 var msg = '<%= DecidiLingua("Check E-mail Address","Controlla l\'indirizzo email")%>';
			 var msg = 'Check E-mail Address';
			 var at="@";
             var dot=".";
              var lat=strEmail.indexOf(at);
              var lstr=strEmail.length; 
			  var ldot=strEmail.indexOf(dot);
             if (strEmail.indexOf(at)==-1)
             {
                       alert(msg);
                        return false;
                }
              if (strEmail.indexOf(at)==-1 || strEmail.indexOf(at)==0 || strEmail.indexOf(at)==lstr)
             {
                       alert(msg);
                return false;
                } 
             if (strEmail.indexOf(dot)==-1 || strEmail.indexOf(dot)==0 || strEmail.indexOf(dot)==lstr)
              {
                       alert(msg);
                          return false;
                  } 
                if (strEmail.indexOf(at,(lat+1))!=-1)
              {
                       alert(msg);
                        return false;
                  } 
             if (strEmail.substring(lat-1,lat)==dot || strEmail.substring(lat+1,lat+2)==dot)
            { 
                       alert(msg);
                   return false;
               } 
          if (strEmail.indexOf(dot,(lat+2))==-1)
                    { 
                       alert(msg);
                             return false;
                    }
                if (strEmail.indexOf(" ")!=-1)
         { 
                       alert(msg);
                   return false;
              }
//        return true;

// Secondo Controllo

	// Recupero il campo Email
	// var email = new String(Request.Form("email"));

   // Imposto l'espressione regolare per un indirizzo email
   var controlla = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;

   // Effettuo il controllo vero e proprio
//   alert("Secondo Controllo...");
   if (!controlla.test(strEmail)) {
                       alert(msg);
                   return false;
   } else {
   
   return true;
   }


} 

//Mostra/Nascondi elementi (tabelle o form)
function MostraNascondi (nr,checkboxname) {
// nr = ID dell'elemento
// checkboxname = ID del checkbox utilizzato
		if (document.layers)	{
			if (document.getElementById(checkboxname).checked) {
				document.layers[nr].display = 'block'; }
				else {
				document.layers[nr].display = 'none';
				}
		}
	else if (document.all)	{
			if (document.getElementById(checkboxname).checked) {
				document.all[nr].style.display = 'block'; }
				else {
				document.all[nr].style.display = 'none';
				}
		}
	else if (document.getElementById)	{
			if (document.getElementById(checkboxname).checked) {
				document.getElementById(nr).style.display = 'block'; }
				else {
				document.getElementById(nr).style.display = 'none';
				}

		}
}

