function placeHolder(obj){

     var valore = obj.value;
     var placeH = obj.getAttribute("placeholder");
	var RO = obj.getAttribute("readonly");

	if (RO != "readonly"){
     if ( valore == placeH) 
    {
     obj.value = "";
     obj.style.color = "#000";
	  obj.style.weight = "normal";
     //obj.style.textAlign = "left";
     }
	 }
    }
    
function restorePlaceholder(obj){
	var valore = obj.value;
	if (valore == "") {
		var placeH = obj.getAttribute("placeholder");
		obj.value = placeH;
		obj.style.color = "#999";
		//obj.style.textAlign = "center";
	}
} 

function controlla(theForm){
var nomeFr = theForm.name

var fine = theForm.elements.length 
var x = 0
    do{
        if (theForm.elements[x].getAttribute("required") == "required"){
            
            switch (theForm.elements[x].getAttribute("type")){
            case "text":
                if ((theForm.elements[x].value=="") || (theForm.elements[x].value == theForm.elements[x].getAttribute('placeholder'))){ 
                    alert("Attenzione devi compilare il campo " + theForm.elements[x].getAttribute("placeholder"));
                    hightlight(theForm.elements[x])
                    return false;
                }
            break;
            case "checkbox":
                if (!theForm.elements[x].checked){
                    alert(theForm.elements[x].getAttribute("msg"))
                    theForm.elements[x].focus();
                    return false
                }
            break;
             
            case "select":
           
               if(theForm.elements[x].selectedIndex == 0){
                              alert(theForm.elements[x].getAttribute("msg"))
                        theForm.elements[x].focus();
                    return false
                             
                             } 
            break;
            
            
        }
    }
    if (theForm.elements[x].getAttribute("ismail") == "ismail"){
        if(!emailCheck(theForm.elements[x].value)){
            alert("indirizzo e-mail non corretto")
            hightlight(theForm.elements[x])
            return false;
        }
    }
x++;
}
while(x < fine)

if (nomeFr == "forex"){
  cambia()
  }
 
    for (counter = 0; counter < document.inviaInfo.interesse.length; counter++){ 
       if (document.inviaInfo.interesse[counter].checked){ 
        myvar = document.inviaInfo.interesse[counter].value; 
       } 
    } 
	
	document.inviaInfo.id_pagina.value="JUMP_" + myvar;
	document.risult = setTimeout("risultato(1)", 1000);
	document.getElementById("formOn").style.display = "none";
	
	//document.getElementById("info1").style.height = "150px"
	document.getElementById("formOff").style.display = getDisplayForObj("DIV") 
  	return true
}


function risultato(n){
switch(n){
case 1:

document.getElementById("formOff").style.height = "260px"
document.getElementById("formOff").innerHTML = '<div class="Stile6"><b>Benvenuto!</b></div><div class="Stile6" style="padding-top:20px;font-size:13px;font-family:Verdana"><b>Grazie per esserti registrato.</b><br />Ti terremo aggiornato su tutte le novità del mondo Fineco.</div>'  + document.getElementById("download").innerHTML

break;
case 2:

document.getElementById("formOff").style.height = "260px"
document.getElementById("formOff").innerHTML = '<div class="Stile6" style="width:450px;padding-top:50px"><b>Benvenuto!</b></div><div class="Stile6" style="width:450px;padding-top:20px;font-size:13px;font-family:Verdana"><b>Grazie per esserti registrato.</b><br />Ti terremo aggiornato su tutte le novità del mondo Fineco.</div>'
break;
default:

document.getElementById("formOff").style.height = "26px"
document.getElementById("formOff").innerHTML = '<div class="Stile6" style="width:450px;padding-top:50px"><b>Benvenuto!</b></div><div class="Stile6" style="width:450px;padding-top:20px;font-size:13px;font-family:Verdana"><b>Grazie per esserti registrato.</b><br />Ti terremo aggiornato su tutte le novità del mondo Fineco.</div>'
break;
 
}
sendtrack('infoJumpStaiDavantiOK')
}



  function hightlight(obj){

//obj.style.border = "1px solid red";
obj.focus();
}
    
	
	
	function controllaInvito(theForm){
var fine = theForm.elements.length 
var x = 0
    do{
        if (theForm.elements[x].getAttribute("required") == "required"){
            switch (theForm.elements[x].getAttribute("type")){
            case "text":
                if ((theForm.elements[x].value=="") || (theForm.elements[x].value == theForm.elements[x].getAttribute('placeholder'))){ 
                    alert("Attenzione devi compilare il campo " + theForm.elements[x].getAttribute("placeholder"));
                    hightlight(theForm.elements[x])
                    return false;
                }
            break;
            case "checkbox":
                if (!theForm.elements[x].checked){
                    alert("Attenzione l'autorizzazione al trattamento dei dati personali è obbligatoria")
                    theForm.elements[x].focus();
                    return false
                }
            break;
        }
    }
    if (theForm.elements[x].getAttribute("ismail") == "ismail"){
        if(!emailCheck(theForm.elements[x].value)){
            alert("indirizzo e-mail non corretto")
            hightlight(theForm.elements[x])
            return false;
        }
    }
x++;
}
while(x < fine)
    cambiaInvito(theForm.name,0,theForm)
    return true
}

function cambiaInvito(nome,flag,obj){
	document.getElementById("amicoSp").innerHTML = obj.emailAmico.value
    document.getElementById("viralOff").style.display = getDisplayForObj("TABLE")
    document.getElementById("viralOn").style.display = "none"
}
	
function nuovoInvito(){
	var objname= document.getElementById("nomeAmico");
	//objname.setAttribute("value", "");
	objname.value = "";
	var objmail= document.getElementById("emailAmico");
	//objmail.setAttribute("value", "");
	objmail.value = "";
	
	showDivision('dettagli');
	
	document.getElementById("viralOff").style.display = "none";
    document.getElementById("viralOn").style.display = getDisplayForObj("TABLE");

	restorePlaceholder(objname);
	restorePlaceholder(objmail);
}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
 function emailCheck (emailStr) {
    
    emailStr = emailStr.toLowerCase();
    /* The following variable tells the rest of the function whether or not
    to verify that the address ends in a two-letter country or well-known
    TLD.  1 means check it, 0 means don't. */
    
    var checkTLD=1;
    
    /* The following is the list of known TLDs that an e-mail address must end with. */
    
    var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum|mobi)$/;
    
    /* The following pattern is used to check if the entered e-mail address
    fits the user@domain format.  It also is used to separate the username
    from the domain. */
    
    var emailPat=/^(.+)@(.+)$/;
    
    /* The following string represents the pattern for matching all special
    characters.  We don't want to allow special characters in the address. 
    These characters include ( ) < > @ , ; : \ " . [ ] */
    
    var specialChars="\\(\\)><@,;:\\\\\\\"\\[\\]";          //modifica
    //var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]"; //originale
    
    /* The following string represents the range of characters allowed in a 
    username or domainname.  It really states which chars aren't allowed.*/
    
    var validChars="\[^\\s" + specialChars + "\]";
    
    /* The following pattern applies if the "user" is a quoted string (in
    which case, there are no rules about which characters are allowed
    and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
    is a legal e-mail address. */
    
    var quotedUser="(\"[^\"]*\")";
    
    /* The following pattern applies for domains that are IP addresses,
    rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
    e-mail address. NOTE: The square brackets are required. */
    
    var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
    
    /* The following string represents an atom (basically a series of non-special characters.) */
    
    var atom=validChars + '+';
    
    /* The following string represents one word in the typical username.
    For example, in john.doe@somewhere.com, john and doe are words.
    Basically, a word is either an atom or quoted string. */
    
    var word="(" + atom + "|" + quotedUser + ")";
    
    // The following pattern describes the structure of the user
    var userPat=new RegExp("^" + word + "(\\." + word + ")*$");         //originale
    //var userPat=new RegExp("^" + word + "(\\." + word + ")*\.$"); //modifica
    
    /* The following pattern describes the structure of a normal symbolic
    domain, as opposed to ipDomainPat, shown above. */
    
    var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
    
    /* Finally, let's start trying to figure out if the supplied address is valid. */
    
    /* Begin with the coarse pattern to simply break up user@domain into
    different pieces that are easy to analyze. */
    
    var matchArray=emailStr.match(emailPat);
    
    if (matchArray==null) 
    {
        /* Too many/few @'s or something; basically, this address doesn't
        even fit the general mould of a valid e-mail address. */
        
        //alert("Indirizzo Email non corretto (controllare i caratteri @ and .)");
        return false;
    }
    var user=matchArray[1];
    var domain=matchArray[2];
    
    // Start by checking that only basic ASCII characters are in the strings (0-127).
    
    for (i=0; i<user.length; i++) 
    {
        if (user.charCodeAt(i)>127) 
        {
            //alert("Email non valido");
            return false;
        }
    }
    for (i=0; i<domain.length; i++) 
    {
        if (domain.charCodeAt(i)>127) 
        {
            //alert("Email non valido - L'indirizzo contiene caratteri non validi.");
            return false;
        }
    }
    
    // See if "user" is valid 
    
    if (user.match(userPat)==null) 
    {
        // user is not valid
        //alert("Email non valido - L'indirizzo contiene caratteri non validi.");
        return false;
    }
    
    /* if the e-mail address is at an IP address (as opposed to a symbolic
    host name) make sure the IP address is valid. */
    
    var IPArray=domain.match(ipDomainPat);
    if (IPArray!=null) 
    {
        // this is an IP address
        for (var i=1;i<=4;i++) 
        {
            if (IPArray[i]>255) 
            {
                //alert("Indirizzo IP non valido.");
                return false;
            }
        }
        return true;
    }
    
    // Domain is symbolic name.  Check if it's valid.
     
    var atomPat=new RegExp("^" + atom + "$");
    var domArr=domain.split(".");
    var len=domArr.length;
    for (i=0;i<len;i++) 
    {
        if (domArr[i].search(atomPat)==-1) 
        {
            //alert("Email non valido - L'indirizzo contiene caratteri non validi.");
            return false;
        }
    }
    
    /* domain name seems valid, but now make sure that it ends in a
    known top-level domain (like com, edu, gov) or a two-letter word,
    representing country (uk, nl), and that there's a hostname preceding 
    the domain or country. */
    
    if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) 
    {
        //alert("Email non valido - L'indirizzo contiene caratteri non validi.");
        return false;
    }
    
    // Make sure there's a host name preceding the domain.
    
    if (len<2) 
    {
        //alert("This address is missing a hostname!");
        return false;
    }
    
    // If we've gotten this far, everything's valid!
    return true;
    
}


function cambia(){
//setTimeout("this.document.location.href='https://ib.fineco.it/ActiveTrading/jsp/forex.jsp?frm=ok'" , 1000)

  document.getElementById("tab02").style.display = getDisplayForObj("TABLE")
  document.getElementById("tab01").style.display = "none"

}


 function getDisplayForObj(tag) {
if (document.all) {
     disp = "";
}
else {
switch (tag){
case "TABLE":
     var disp = "table";
break;
case "TR":
     var disp = "table-row";
break;
case "A":
     var disp = "inline";
break;
default :
     var disp = "block";
break;
}
}
return disp
}

function feedback(titolo,messaggio){
var txt = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" style=\"border:1px solid #999; border-width:1px 0px\"><tr bgcolor=\"#eef8ef\"> <td colspan=\"5\"><img src=\"https://images.fineco.it/areapubblica/pix.gif\" border=\"0\" height=\"4\" width=\"1\"></td></tr><tr bgcolor=\"#eef8ef\"> <td class=\"gsno11\" colspan=\"3\" style=\"padding:3px 9px;line-height: 14px\"><div  style=\"margin-bottom:5px\">"
txt += titolo + "</div>" +messaggio + "</td></tr></table>"
	return txt
	
}