function PageChanger(page) { document.location.href="default.cfm?docs="+page+".htm"; }

function isEmpty(data) {
for (var i=0; i < data.value.length; i++)  {
          if (data.value.substring(i, i+1) != " ")
	  	return false;
      }
	  return true;
}


function checkForm() {
  var f=document.forms["cerca"];
	if (!isEmpty(f.q))
 	    {
 	     f.action= "default.cfm";
		   f.method="GET";
		   f.submit();
  	    }
  	      else { alert("Devi inserire almeno un carattere per la ricerca!");}
  	    }

//function checkFormHome() {
//  var f=document.forms["cercaHome"];
//	if (!isEmpty(f.q))
// 	    {
// 	     f.action= "default.cfm?channel=search";
//		   f.method="GET";
//		   f.submit();
//  	    }
//  	      else { alert("Devi inserire almeno un carattere per la ricerca!");}
//  	    }

function checkFormHome() {
	if (!isEmpty(document.getElementById("q")))
 	    {
 	     document.location.href = "default.cfm?channel=search&q=" + document.getElementById("q").value + "&area=" + document.getElementById("aree").value;
		  
  	    }
  	      else { alert("Devi inserire almeno un carattere per la ricerca!");}
  	    }
  	    
function checkFormSearch() {
	if (!isEmpty(document.getElementById("q")))
 	    {
 	     document.location.href = "default.cfm?channel=search&q=" + document.getElementById("q").value + "&area=" + document.getElementById("aree").value + "&xpag=" + document.getElementById("xpag").value + "&mode=" + document.getElementById("mode").value; 
	    }
	else { alert("Devi inserire almeno un carattere per la ricerca!");}
	    }  	      

function emailchk(mailField) {
  mailValue = mailField.value;

  var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
  if (filter.test(mailValue)){
  return true;
  } else {
  return false;  
  }
}

function newsletter(action) {
  var f = document.forms["newsletter"];
	if  (emailchk(f.email))
 	    {
 	      f.action="default.cfm?channel=newsletter";
 	      f.whattodo.value= action;
		  	f.method="POST";
		  	f.submit();
  	   } else { alert("Indirizzo email non valido!");}
}


function pop(str) {
        popwin = window.open(str,'popwin','scrollbars=yes,resizable=yes,width=500,height=400,status=no,location=no,toolbar=no');
        popwin.focus();
}

function popwin(str,str2,dimx,dimy) {
         popWin = window.open(str,str2,'scrollbars=yes,resizable=yes,width='+ dimx +',height='+ dimy +',status=no,location=no,toolbar=no');
         popWin.focus();
}

function popimg(str,str2,dimx,dimy) {
         popWin = window.open(str,str2,'top=100,left=100,scrollbars=no,resizable=yes,width='+ dimx +',height='+ dimy +',status=no,location=no,toolbar=no');
         popWin.focus();
}

function cart(ID)
  {
    winx=784;
    winy=900;
    win1=window.open("/cart/cart.cfm?ID="+ID,"opencart","toolbar=no,directories=no,status=yes,menubar=no,scrollbars=no,width="+winx+",height="+winy);
  }

function newsFocus(){
  var f = document.forms["newsletter"];
  if (f.email.value == 'e-mail'){
  f.email.value = '';
  }
}