function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
function MM_reloadPage(init) {  //Updated by PVII. Reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) history.go(0);
}
function YY_checkform() { //v4.71
//copyright (c)1998,2002 Yaromat.com
  var a=YY_checkform.arguments,oo=true,v='',s='',err=false,r,o,at,o1,t,i,j,ma,rx,cd,cm,cy,dte,at;
  for (i=1; i<a.length;i=i+4){
    if (a[i+1].charAt(0)=='#'){r=true; a[i+1]=a[i+1].substring(1);}else{r=false}
    o=MM_findObj(a[i].replace(/\[\d+\]/ig,""));
    o1=MM_findObj(a[i+1].replace(/\[\d+\]/ig,""));
    v=o.value;t=a[i+2];
    if (o.type=='text'||o.type=='password'||o.type=='hidden'){
      if (r&&v.length==0){err=true}
      if (v.length>0)
      if (t==1){ //fromto
        ma=a[i+1].split('_');if(isNaN(v)||v<ma[0]/1||v > ma[1]/1){err=true}
      } else if (t==2){
        rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-zA-Z]{2,4}$");if(!rx.test(v))err=true;
      } else if (t==3){ // date
        ma=a[i+1].split("#");at=v.match(ma[0]);
        if(at){
          cd=(at[ma[1]])?at[ma[1]]:1;cm=at[ma[2]]-1;cy=at[ma[3]];
          dte=new Date(cy,cm,cd);
          if(dte.getFullYear()!=cy||dte.getDate()!=cd||dte.getMonth()!=cm){err=true};
        }else{err=true}
      } else if (t==4){ // time
        ma=a[i+1].split("#");at=v.match(ma[0]);if(!at){err=true}
      } else if (t==5){ // check this 2
            if(o1.length)o1=o1[a[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!o1.checked){err=true}
      } else if (t==6){ // the same
            if(v!=MM_findObj(a[i+1]).value){err=true}
      }
    } else
    if (!o.type&&o.length>0&&o[0].type=='radio'){
          at = a[i].match(/(.*)\[(\d+)\].*/i);
          o2=(o.length>1)?o[at[2]]:o;
      if (t==1&&o2&&o2.checked&&o1&&o1.value.length/1==0){err=true}
      if (t==2){
        oo=false;
        for(j=0;j<o.length;j++){oo=oo||o[j].checked}
        if(!oo){s+='* '+a[i+3]+'\n'}
      }
    } else if (o.type=='checkbox'){
      if((t==1&&o.checked==false)||(t==2&&o.checked&&o1&&o1.value.length/1==0)){err=true}
    } else if (o.type=='select-one'||o.type=='select-multiple'){
      if(t==1&&o.selectedIndex/1==0){err=true}
    }else if (o.type=='textarea'){
      if(v.length<a[i+1]){err=true}
    }
    if (err){s+='* '+a[i+3]+'\n'; err=false}
  }
  if (s!=''){alert(' === ERRORE ===\t\n\n'+s)}
  document.MM_returnValue = (s=='');
}
function KW_getVal(o){ //v1.2
	var retVal="0";if (o.type=="select-one")
	{retVal=(o.selectedIndex==-1)?0:o.options[o.selectedIndex].value;}
	else if (o.length>1){for (var i=0;i<o.length;i++) if (o[i].checked) retVal=o[i].value;
	} else if (o.type=="checkbox") {retVal=(o.checked)?o.value:0;} else {
	retVal=Number(o.value)}return parseFloat(retVal);
}

function KW_calcForm() { //v1.2
	var str="",a=KW_calcForm.arguments; for (var i=3;i<a.length;i++)
	str+=(a[i].indexOf("#")==-1)?a[i]:KW_getVal(MM_findObj(a[i].substring(1)));
	t=Math.round(a[1]*eval(str))/a[1];tS=t.toString();if(a[2]>0){tSp=tS.indexOf(".");
	if(tSp==-1)	tS+=".";tSp=tS.indexOf(".");while(tSp!=(tS.length-1-a[2])){tS+="0";
	tSp=tS.indexOf(".");}} MM_findObj(a[0]).value=tS;
}
function tmt_compareField(f1,f2,rule,errorMsg){
	var myErr = "";
	if(eval("MM_findObj('"+f1+"').value"+rule+"MM_findObj('"+f2+"').value")){
		alert(unescape(errorMsg));myErr += 'errorMsg';}
	document.MM_returnValue = (myErr == "");
}
function tmt_winControl(id,c){ 
	var d=eval(id)==null||eval(id+".closed");
	if(!d){eval(id+"."+c);}
}

function tmt_winLoad(id,u){
	var d=eval(id)==null||eval(id+".closed");
	if(!d){eval(id+".location.href='"+u+"'")}
}

function tmt_checkImgObj(){//v2.0
	var errorMsg="";
	if(this.maxS!=""&&this.fileSize/1000>this.maxS){
		errorMsg+="Peso Massimo Consentito: "+this.maxS+" KB \n";}
	if(this.minS!=""&&this.fileSize/1000<this.minS){
		errorMsg+="Minimum size for images is: "+this.minS+" kilobytes \n";}
	if(this.maxW!=""&&this.width>this.maxW){
		errorMsg+="Maximum width allowed for images is: "+this.maxW+" pixels \n";}
	if(this.minW!=""&&this.width<this.minW){
		errorMsg+="Minimum width allowed for images is: "+this.minW+" pixels \n";}
	if(this.maxH!=""&&this.height>this.maxH){
		errorMsg+="Maximum height allowed for images is: "+this.maxH+" pixels \n";}	
	if(this.minH!=""&&this.height<this.minH){
		errorMsg+="Minimum height allowed for images is: "+this.minH+" pixels \n";}	
	if(errorMsg==""){
		if(this.fW){var fW=MM_findObj(this.fW);if(fW){fW.value=this.width;}}
		if(this.fH){var fH=MM_findObj(this.fH);if(fH){fH.value=this.height;}}}
		else{alert(errorMsg);}document.MM_returnValue=(errorMsg=="");
}

function tmt_createImgObj(imgURL,loadHandler,minW,maxW,minH,maxH,minS,maxS,fW,fH){//v2.0
	document.MM_returnValue=false; var img=new Image();img.minW=minW;img.maxW=maxW;img.minH=minH;img.maxH=maxH;
	img.fW=fW;img.fH=fH;img.minS=minS;img.maxS=maxS;img.onload=loadHandler;img.src=imgURL;
}

function tmt_CheckImg(formElement,minW,maxW,minH,maxH,minS,maxS,mime,fW,fH){//v2.1
	document.MM_returnValue=true;if(document.getElementById){var obj=MM_findObj(formElement);
	var f=obj.form.name;if(obj&&f){var exRex=new RegExp("\\.("+mime+")$","i");
	var noWhiteRex=/\\[\w_]*\.(\w{3})$/i;if(exRex.test(obj.value)&&noWhiteRex.test(obj.value)){	
	var imgURL="file:///"+obj.value;tmt_createImgObj(imgURL,tmt_checkImgObj,minW,maxW,minH,maxH,minS,maxS,fW,fH);
	eval("setTimeout(\"if(document.MM_returnValue){document."+f+".submit()}\",300)");}
	else{document.MM_returnValue=false;alert("Sono consentiti solo file "+mime+",\nniente spazi bianchi, parentesi, \ne commerciali, trattini etc.!");
	obj.focus();obj.select();}}}
}

function P7_swapClass(){ //v1.4 by PVII
 var i,x,tB,j=0,tA=new Array(),arg=P7_swapClass.arguments;
 if(document.getElementsByTagName){for(i=4;i<arg.length;i++){tB=document.getElementsByTagName(arg[i]);
  for(x=0;x<tB.length;x++){tA[j]=tB[x];j++;}}for(i=0;i<tA.length;i++){
  if(tA[i].className){if(tA[i].id==arg[1]){if(arg[0]==1){
  tA[i].className=(tA[i].className==arg[3])?arg[2]:arg[3];}else{tA[i].className=arg[2];}
  }else if(arg[0]==1 && arg[1]=='none'){if(tA[i].className==arg[2] || tA[i].className==arg[3]){
  tA[i].className=(tA[i].className==arg[3])?arg[2]:arg[3];}
  }else if(tA[i].className==arg[2]){tA[i].className=arg[3];}}}}
}
function pviiW3Cbg(obj, pviiColor) { //v1.1 by Project VII
	obj.style.backgroundColor=pviiColor
}
function P7_MultiClass2() { //v1.0 by PVII
 var args=P7_MultiClass2.arguments;if(document.getElementById){
  for(var i=0;i<args.length;i+=2){if(document.getElementById(args[i])!=null){
  if(document.p7setdown){for(var k=0;k<p7dco.length-1;k+=2){
  if(args[i]==p7dco[k]){args[i+1]=p7dco[k+1];break;}}}
  document.getElementById(args[i]).className=args[i+1];}}}
}

//Highlight form element- © Dynamic Drive (www.dynamicdrive.com)
//For full source code, 100's more DHTML scripts, and TOS,
//visit http://www.dynamicdrive.com

var highlightcolor="#B1CBE4"

var ns6=document.getElementById&&!document.all
var previous=''
var eventobj

//Regular expression to highlight only form elements
var intended=/INPUT|TEXTAREA|SELECT|OPTION/

//Function to check whether element clicked is form element
function checkel(which){
if (which.style&&intended.test(which.tagName)){
if (ns6&&eventobj.nodeType==3)
eventobj=eventobj.parentNode.parentNode
return true
}
else
return false
}

//Function to highlight form element
function highlight(e){
eventobj=ns6? e.target : event.srcElement
if (previous!=''){
if (checkel(previous))
previous.style.backgroundColor=''
previous=eventobj
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
}
else{
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
previous=eventobj
}
}

/*
Submit Once form validation- 
© Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/

function submitonce(theform){
//if IE 4+ or NS 6+
if (document.all||document.getElementById){
//screen thru every element in the form, and hunt down "submit" and "reset"
for (i=0;i<theform.length;i++){
var tempobj=theform.elements[i]
if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
//disable em
tempobj.disabled=true
}
}
}
function selectAll(){
var tutti=false;

	if(document.forms[0].selprod.checked)
	tutti=true;

	for (var i=0;i<document.forms[0].elements.length;i++){
	var e = document.forms[0].elements[i];
	if(tutti)
	e.checked=true;
	else
	e.checked=false;
	}
}

function mostra_nascondi(lyr){
  document.getElementById(lyr).style.display=(document.getElementById(lyr).style.display=='none')?'block':'none';
}
function askinfo() {
			if (document.contact.nome.value == '') {
				alert('Il nome è obbligatorio');
				document.contact.nome.focus();
				return;
			}
			if (document.contact.cognome.value == '') {
				alert('Il cognome è obbligatorio');
				document.contact.cognome.focus();
				return;
			}
			if (document.contact.mail.value == '') {
				alert('L\'\indirizzo email è obbligatorio');
				document.contact.mail.focus();
				return;
			}
			if (document.contact.Messaggio.value == '') {
				alert('Scrivere un Messaggio');
				document.contact.Messaggio.focus();
				return;
			}
			document.contact.submit();
		}

function signsoc() {
			if (document.sign.nome.value == '') {
				alert('Il nome è obbligatorio');
				document.sign.nome.focus();
				return;
			}
			if (document.sign.cognome.value == '') {
				alert('Il cognome è obbligatorio');
				document.sign.cognome.focus();
				return;
			}
			if (document.sign.societa.value == '') {
				alert('Il nome della società è obbligatorio');
				document.sign.societa.focus();
				return;
			}
			if (document.sign.piva.value == '') {
				alert('Il numero della partita IVA è obbligatorio');
				document.sign.piva.focus();
				return;
			}
			if (document.sign.via.value == '') {
				alert('L\'\indirizzo è obbligatorio');
				document.sign.via.focus();
				return;
			}
			if (document.sign.civico.value == '') {
				alert('Il numero civico è obbligatorio');
				document.sign.civico.focus();
				return;
			}
			if (document.sign.cap.value == '') {
				alert('Il CAP è obbligatorio');
				document.sign.cap.focus();
				return;
			}
			if (document.sign.citta.value == '') {
				alert('La città è obbligatoria');
				document.sign.citta.focus();
				return;
			}
			if (document.sign.prov.value == '') {
				alert('La provincia è obbligatoria');
				document.sign.prov.focus();
				return;
			}
			if (document.sign.tel.value == '') {
				alert('Il numero di telefono è obbligatorio');
				document.sign.tel.focus();
				return;
			}
			
			if (document.sign.mail.value == '') {
				alert('L\'\indirizzo email è obbligatorio');
				document.sign.mail.focus();
				return;
			}
			if (document.sign.nick.value == '') {
				alert('Scegliere il Nome Utente');
				document.sign.nick.focus();
				return;
			}
			if (document.sign.pw.value == '') {
				alert('Scegliere una password');
				document.sign.pw.focus();
				return;
			}
			document.sign.submit();
		}
		
function signpriv() {
			if (document.sign.nome.value == '') {
				alert('Il nome è obbligatorio');
				document.sign.nome.focus();
				return;
			}
			if (document.sign.cognome.value == '') {
				alert('Il cognome è obbligatorio');
				document.sign.cognome.focus();
				return;
			}
			if (document.sign.via.value == '') {
				alert('L\'\indirizzo è obbligatorio');
				document.sign.via.focus();
				return;
			}
			if (document.sign.civico.value == '') {
				alert('Il numero civico è obbligatorio');
				document.sign.civico.focus();
				return;
			}
			if (document.sign.cap.value == '') {
				alert('Il CAP è obbligatorio');
				document.sign.cap.focus();
				return;
			}
			if (document.sign.citta.value == '') {
				alert('La città è obbligatoria');
				document.sign.citta.focus();
				return;
			}
			if (document.sign.prov.value == '') {
				alert('La provincia è obbligatoria');
				document.sign.prov.focus();
				return;
			}
			if (document.sign.tel.value == '') {
				alert('Il numero di telefono è obbligatorio');
				document.sign.tel.focus();
				return;
			}
			
			if (document.sign.mail.value == '') {
				alert('L\'\indirizzo email è obbligatorio');
				document.sign.mail.focus();
				return;
			}
			if (document.sign.nick.value == '') {
				alert('Scegliere il Nome Utente');
				document.sign.nick.focus();
				return;
			}
			if (document.sign.pw.value == '') {
				alert('Scegliere una password');
				document.sign.pw.focus();
				return;
			}
			document.sign.submit();
		}		
		
		function brand() {
			if (document.newbrand.brandnome.value == '') {
				alert('Il nome del Marchio è obbligatorio');
				document.newbrand.brandnome.focus();
				return;
			}
			document.newbrand.submit();
		}

