
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_reloadPage(init) {  //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) location.reload();
}
MM_reloadPage(true);

// Image Rollover & Preload

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
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_validateForm() { //v4.0
  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.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\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+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

//Open Browser Window

function OpenBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
scrolling = scroll? "yes": "no";
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
  }
  window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}

//Centered Pop Up
var newwin = null;
function popup(url, wid, hi, scroll) {
	new_spec = wid + "_" + hi + scroll;
	scrolling = scroll? "yes": "no";
	if (scroll && document.all && (navigator.userAgent.indexOf("Mac") > -1)) wid = wid+17;
	newwin=window.open(url,new_spec,"WIDTH=" + wid + ",HEIGHT=" + hi + ",scrollBars=" + scrolling + ",toolbar=0, statusbar=0, menubar=0, resizable=no,screenX=100,screenY=100,left=100,top=100");
	newwin.focus();
}

var ua = navigator.userAgent
var ps = navigator.productSub 
var dom = (document.getElementById)? 1:0
var ie4 = (document.all&&!dom)? 1:0
var ie5 = (document.all&&dom)? 1:0
var nn4 =(navigator.appName.toLowerCase() == "netscape" && parseInt(navigator.appVersion) == 4)
var nn6 = (dom&&!ie5)? 1:0
var sNav = (nn4||nn6||ie4||ie5)? 1:0
var cssFilters = ((ua.indexOf("MSIE 5.5")>=0||ua.indexOf("MSIE 6")>=0)&&ua.indexOf("Opera")<0)? 1:0
var Style=[],Text=[],Count=0,sbw=0,move=0,hs="",mx,my,scl,sct,ww,wh,obj,sl,st,ih,iw,vl,hl,sv,evlh,evlw,tbody
var HideTip = "eval(obj+sv+hl+';'+obj+sl+'=0;'+obj+st+'=-800')"
var doc_root = ((ie5&&ua.indexOf("Opera")<0||ie4)&&document.compatMode=="CSS1Compat")? "document.documentElement":"document.body"
var PX = (nn6)? "px" :"" 

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}
// -----------------------------------Apertura Popup---------------------------------
 
function ApriFin_DoFSCommand(command, args)
{ 
	if ( command == "dist" )
	{ window.open(args,'','toolbar=yes,status=yes,scrollbars=yes,width=760,height=420'); }
	if ( command == "riv" )
	{ window.open(args,'','toolbar=yes,status=yes,scrollbars=no,width=760,height=432'); }
	if ( command == "credit" )
	{ window.open(args,'','toolbar=yes,status=yes,scrollbars=yes,width=400,height=420'); }
    if ( command == "policy" )
	{ window.open(args,'','toolbar=yes,status=yes,scrollbars=yes,width=400,height=420'); }
}
//----------------------------------Fina Apertura Popup-----------------------------
//---------------sound----------------------
function MM_controlSound(x, _sndObj, sndFile) { //v3.0
  var i, method = "", sndObj = eval(_sndObj);
  if (sndObj != null) {
    if (navigator.appName == 'Netscape') method = "play";
    else {
      if (window.MM_WMP == null) {
        window.MM_WMP = false;
        for(i in sndObj) if (i == "ActiveMovie") {
          window.MM_WMP = true; break;
      } }
      if (window.MM_WMP) method = "play";
      else if (sndObj.FileName) method = "run";
  } }
  if (method) eval(_sndObj+"."+method+"()");
  else window.location = sndFile;
}

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 cambia(tipo)
{
	if (tipo=='ok')
	{
		document.form1.Submit.disabled=false
	}else{
		document.form1.Submit.disabled=true
	}
}

function billing(tipo)
{
	if (tipo=='fattura')
	{
		document.formCassa.agenzia.style.width=200
		document.formCassa.pi.style.width=200
		document.formCassa.stato.style.width=200
		document.formCassa.citta.style.width=200
		document.formCassa.indirizzo.style.width=200
		document.formCassa.cap.style.width=200
	}else{
		document.formCassa.agenzia.style.width=0
		document.formCassa.pi.style.width=0
		document.formCassa.stato.style.width=0
		document.formCassa.citta.style.width=0
		document.formCassa.indirizzo.style.width=0
		document.formCassa.cap.style.width=0
	}
}

function fatture(tipo)
{
	if (tipo=='business')
	{
		document.form1.business_name.style.width=180
		document.form1.account.style.width=180
	}else{
		document.form1.business_name.style.width=0
		document.form1.account.style.width=0
	}
}

function paga(tipo)
{
	if (tipo=='okcc'||tipo=='okbb') 
	{
		document.form1.Submit.disabled=false
	}else{
		document.form1.Submit.disabled=true
	}
}

function cambiaOfferta(tipo)
{
	if (tipo=='ok')
	{
		document.frmElettricita.Submit.disabled=false
	}else{
		document.frmElettricita.Submit.disabled=true
	}
}

function vai()
{
	//document.form1.onSubmit="MM_validateForm('cognome','','R','tel','','R','email','','NisEmail','zona','','R');return document.MM_returnValue"
	document.form1.submit();
}

function checkMemberId() {
	var userId = document.form1.user_ID.value;
	if (userId.length == 0 || userId == " ") {
		alert("Specifica la user ID prima di controllarla"); return false;
	}
	popupWindow = window.open("signUpcheckUser.asp?userId="+userId,"check", "width=300, height=119,resizable=no,status=no,titlebar=no,location=no,scrollbars=no");
	if(popupWindow)
	    popupWindow.focus();
}

function votaSonda() {
	var userId = document.form1.radiobutton.value;
	var IDsonda = document.form1.IDsondaggio.value;
	if (userId.length == 0 || userId == " ") {
		alert("Rispondi almeno ad una domanda"); return false;
	}
	popupWindow = window.open("sondaggioVota.asp?IDdomanda="+userId+"&IDsondaggio="+IDsonda,"check", "width=300, height=150,resizable=no,status=no,titlebar=no,location=no,scrollbars=no");
	if(popupWindow)
	    popupWindow.focus();
}

function checkPrevBanner() {
	var dime = document.form1.dimensione.value;
	if (dime.length == 0 || dime == " ") {
		alert("Select a valide size"); return false;
	}
	var vis = document.form1.visibilita.value;
	var dur = document.form1.durata.value;
	popupWindow = window.open("servizi_calcoloBanner.asp?dur="+dur+"&vis="+vis+"&dimensione="+dime,"check", "width=300, height=180,resizable=no,status=no,titlebar=no,location=no,scrollbars=no");
	if(popupWindow)
	    popupWindow.focus();
}
function viewText(testo) {
if (document.getElementById)
  document.getElementById('interno').innerHTML= testo;
else if (document.all)  
  document.all['interno'].innerHTML= testo;
else {
  document.layers.esterno.document.layers.interno.document.open ();
  document.layers.esterno.document.layers.interno.document.write ("<span class=font>" + testo + "</span>");
  document.layers.esterno.document.layers.interno.document.close ();
	}
}
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
// controlla la la lunghezza massima di una textarea
var maxchars=250;
function CheckLength()
  {
  with (document.form1)
    {
    chars=testo.value
    if (chars.length > maxchars)
      {
      testo.value=chars.substr(0,maxchars);
      testo.blur();
      }
    chr.value=maxchars-testo.value.length;
    }
  }
function svuota() {
document.getElementById("codicePromozione").value="";
}
