//
// visualizzare il contattore
//

var abilitato=0;
var stringa="";     
function test(){
	//analizza se il browser e' compatibile con Javascript
	browserName=navigator.appName.charAt(0);
	browserVer=parseInt(navigator.appVersion);
	if (browserName=="M" && browserVer >= 3) abilitato=1;
	if (browserName=="N" && browserVer >= 3) abilitato=2;
	if (browserName=="N" && browserVer >= 4) abilitato=3;
	if (browserName=="M" && browserVer >= 4) abilitato=4;
	}
function keyDown(e) {
        	if (abilitato==3) {
		//var ns4=1;
		var nKey=e.which; var ieKey=0;
		// tasto L
		if (nKey==113){
				var realkey = String.fromCharCode(e.which);
				stringa="Codice tasto in Netscape: "+nKey+". Premuto tasto "+realkey
				
				window.open('http://s1.shinystat.com/cgi-bin/shinystatv.cgi?L=0&USER=algherodream&NH=1');
    			return(true);
				} 
			
				};
		};
        	if (abilitato==4) {
		//var ns4=0;
		var ieKey=event.keyCode; var nKey=0;
		if (ieKey==113){
			var realkey = String.fromCharCode(event.keyCode);
			stringa="Codice tasto in Explorer: " + ieKey+". Premuto tasto "+realkey

			window.open('http://s1.shinystat.com/cgi-bin/shinystatv.cgi?L=0&USER=algherodream&NH=1');			
			};

	}
document.onkeydown = keyDown
//if (ns4) document.captureEvents(Event.KEYDOWN)



// aprire i popup

function popup(url, name, width, height)
	{
	settings=
		"toolbar=no,location=no,directories=no,"+
		"status=no,menubar=no,scrollbars=no,"+
		"resizable=no,channelmode=no,left=550,top=100,width="+width+",height="+height;

	MyNewWindow=window.open(url,name,settings);
	}
	
// popup grandi

function popupG(url, name, width, height)
	{
	settings=
		"toolbar=no,location=no,directories=no,"+
		"status=no,menubar=no,scrollbars=no,"+
		"resizable=no,left=450,top=20,width="+width+",height="+height;

	MyNewWindow=window.open(url,name,settings);
	}

// pop senza settings

function new_Finestra(url, name)
	{

	MyNewWindow=window.open(url,name,'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
	}

// controllo form contatti

		function MM_findObj(n, d) { 
		  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_validateForm() {
      var myForm = document.formcontatti; 
		  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;

		  for (i=0; i<(args.length-2); i+=3) { 
          test=args[i+2]; val=MM_findObj(args[i]);		  
			    if (val) { 
              nm=val.title; 
              if ((val=val.value)!="") {
			           if (((myForm.email.value != "")) && (test.indexOf('isEmail')!=-1)) {                  
                    p=val.indexOf('@');
				            if (p<1 || p==(val.length-1)) errors+='- '+nm+' deve contenere un indirizzo e-mail valido.\n';
                  } else if (test!='R') { 
                    num = parseFloat(val);
				            if (isNaN(val)) errors+='- '+nm+' deve contenere un numero.\n';
				            if (test.indexOf('inRange') != -1) { 
                        p=test.indexOf(':');
				                min=test.substring(8,p); max=test.substring(p+1);
				                if (num<min || max<num) errors+='- '+nm+' deve contenere un numero compreso tra '+min+' e '+max+'.\n';
			               } 
                  }
              } else if (test.charAt(0) == 'R') errors += '- '+nm+' è obbligatorio.\n'; 
          }
      }
      if ((myForm.telefono.value == "") && (myForm.email.value == "")) errors+=' è obbligatorio inserire telefono o e-mail.\n';
      if (errors) alert('Compila i seguenti campi:\n'+errors);
		  document.MM_returnValue = (errors == '');
		}

//risoluzione bug

	function changeDiv(){
		if( document.getElementById ){
			if ((BrowserDetect.browser == 'Firefox') | (BrowserDetect.browser == 'Opera')) {
				document.getElementById("Layer3").style.left ='-90px';
				document.getElementById("tableCentro").width = '1000';
				document.getElementById("Layer4").style.left ='-100px';
			} else {
				document.getElementById("Layer3").style.left ='5px';
				document.getElementById("tableCentro").width = '1';
				document.getElementById("Layer4").style.left ='1px';
			}
		}
	}



//Per richiamare codice javascript

function MM_callJS(jsStr) {
  return eval(jsStr)
}

