
// ********************************
//   Funzioni di apertura popup.
// ********************************

function apri(url,name,options)
{
  browserVer = parseInt(navigator.appVersion);
  browserName = navigator.appName;
  if (browserName == "Netscape")
  { if (browserVer >= 3) version = "n3";
    else version = "n2";
  }
  else
  { if (browserVer > 4) version = "n3";
    else version = "n2";
  }
  finestra=window.open(url,name,options).focus();
  if (version == "n3") finestra.focus();
}

function apriADV()
{
  browserVer = parseInt(navigator.appVersion);
  browserName = navigator.appName;
  if (browserName == "Netscape")
  { if (browserVer >= 3) version = "n3";
    else version = "n2";
  }
  else
  { if (browserVer > 4) version = "n3";
    else version = "n2";
  }
  finestra=window.open('/contenuti/Doc/lancio_adv2/lancio.html','','width=660,height=410,scrollbars=no').focus();
  if (version == "n3") finestra.focus();
}


// ********************************
//   Euroconvertitore
// ********************************
	
	function LiraToEuro(lire)
	{
		var EURO_LIRE = 1936.27;
		if( isNaN(lire) || document.frmConvert.edLira.value == "")
		{
			alert("Devi inserire un importo il lire");
			document.frmConvert.edLira.value="";
			document.frmConvert.edEuro.value="";
			document.frmConvert.edLira.focus();
			return;
		}
		
		if( parseInt(lire) < 20)
		{
			alert("Attenzione l'importo minimo e' di £ 20");
			return;
		}
		
		
		var euro = parseFloat(lire/EURO_LIRE);
		var strIntero;
		var strDec_1;
		var strDec_2;
		var arrRet = (euro.toString()).split(".");
		
		//if integer there 's not the separator
		if (arrRet.length <= 1 )
		{
			strIntero = euro.toString();
			strDec_1 = "0";
			strDec_2 = "0";
		}
		else
		{
			var NumIntero = parseInt(arrRet[0],10);
			var NumDec_1 = parseInt(arrRet[1].substr(0,1),10);
			var NumDec_2 = parseInt(arrRet[1].substr(1,1),10);
			var NumArrot = parseInt(arrRet[1].substr(2,2),10);
			
			if (NumArrot > 50)
			{
				NumDec_2 += 1;
				if(NumDec_2==10)
				{
					strDec_2 = "0";
					NumDec_1 += 1;
					if(NumDec_1 == 10)
					{
						strDec_1 = "0";
						NumIntero += 1;
					}
					else
					{
						strDec_1 = NumDec_1.toString();
					}
					strIntero = NumIntero.toString();
				}
				else
				{
					strIntero = NumIntero.toString();
					strDec_1 = NumDec_1.toString();
					strDec_2 = NumDec_2.toString();
				}
			}
			else
			{
				strIntero = NumIntero.toString();
				strDec_1 = NumDec_1.toString();
				strDec_2 = NumDec_2.toString();
			}
		}
		
		//add the separator for the digits
		if(strIntero.length > 3)
		{
			var resto = strIntero.length;
			
			var result="";
			j=0;
			for (i=(strIntero.length-1); i>=0; i--)
			{	 
				j++;
				if (j==3)
				{
					result += strIntero.charAt(i) + ".";
					j=0;		
				}
				else
					result += strIntero.charAt(i);
			}
			//delete the digit separator in the last position 
			if (result.lastIndexOf(".") == result.length-1)
				result = result.substr(0,result.length-1);
		
			strIntero = "";
			//reorder the string
			for (i=(result.length-1); i>=0; i--)
				strIntero += result.charAt(i);
		}
		
		var result = strIntero + "," + strDec_1 + strDec_2;
		document.frmConvert.edEuro.value = strIntero + "," + strDec_1 + strDec_2;
	}
	
	
	
	
// ********************************
//   PopUP Fondi
// ********************************
	function windowopen(page, winname, features)
 {
	 //on win nt the function focus() generate an error
	var mywin;
	var opSystem;
	opSystem = navigator.userAgent.toLowerCase();
		
		// if system is window nt
		if (opSystem.indexOf("windows nt") >- 1)
		{
			mywin = window.open(page, winname, features);
			mywin.close();
			mywin = window.open(page, winname, features);
		}
		else
		{
			mywin = window.open(page, winname, features);
			mywin.focus();
		}
	}
	
// ********************************
//   Gestione combo Fondi
// ********************************
	function changeFondi(index)
	{
		// field value
		var option = document.frmCombo.cbFondi.options[index].value; 	
		
		switch (option)
		{
			case "1":
				windowopen("/homepagejsp/fondi/quotazioniFondi.jsp?tipoFondo=azionario", "azionario" ,"width=450,height=340,resizable=no");
				break;
			case "2":
				windowopen("/homepagejsp/fondi/quotazioniFondi.jsp?tipoFondo=obbligazionario", "obbligazionario", "width=450,height=256,resizable=no");
				break;
			case "3":
				windowopen("/homepagejsp/fondi/quotazioniFondi.jsp?tipoFondo=bilanciato", "bilanciato", "width=450,height=148,resizable=no");
				break;
			case "4":
				windowopen("/homepagejsp/fondi/quotazioniFondi.jsp?tipoFondo=flessibile", "flessibile", "width=450,height=136,resizable=no");
				break;
		    case "5":
				windowopen("/homepagejsp/fondiass/Fondiass.jsp", "assicurativo", "width=450,height=320,resizable=no");
				break;
			case "6":
				windowopen("/homepagejsp/fondi/quotazioniFondi.jsp?tipoFondo=deifondi", "deifondi", "width=450,height=175,resizable=no");
				break;
			
			case "0":
				break;
			default:
				break;
		}
	}



// ************************************************************
//   Funzioni di apertura popup e preloadImages
// ************************************************************
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_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function popupNews ( urlNews )
{
  window.open ( urlNews, "New", "width=378,height=280,scrollbars" );
}
