﻿/**
 * Funzioni di utilità 
 *
 */
 
 // La funzione valuta se passare il footer a modalita di posizionamento relative in base alla risoluzione
 // disponibile 
 function SetDivfooter() 
 {    
    if(screen.height<768){
        var el = document.getElementById("divfooter");
        el.style.position="relative";            
    }       
 }
 
 // La funzione valuta se spostare un po il menu di navigazione per risoluzioni basse
 function SettabMenuHome() 
 {
    if(screen.width<=1024){
        var el = document.getElementById("tabMenuHome");
        el.style.position="relative";            
        el.style.left ="-20px";
    }       
 }
  

 /*
 function CalcBoxWidth() {
    if( screen.height>=768 )
        return 600;
    else if( screen.height>=720 )
        return 450;
    else
        return 395;    
 }
 
 
 function CalcBoxHeight() {     
    if( screen.height>=768 )
        return 500;
    else if( screen.height>=720 )
        return 375;
    else
        return 330;        
 }
 */
 
function calcCharLeft(f,l1) //funzione per il conteggio dei caratteri rimanenti nel box del messaggio
{    
    
    var msgLen;
    var MaxLength;
    MaxLength = 255;
    msgLen = document.Componi.testo.value.length;//regupero la lunghezza del messaggio    
    if ( msgLen >= MaxLength ){
        document.getElementById("charsleft").innerText = "0"; // for IE
        document.getElementById("charsleft").textContent = "0"; // for the rest of the known world	    
	    window.alert("Il messaggio può contenere massimo " + MaxLength + " caratteri.");
	    document.Componi.testo.value=document.Componi.testo.value.substring(0,MaxLength);
    }
    else{        
        document.getElementById("charsleft").innerText = (MaxLength - msgLen)+""; // for IE
        document.getElementById("charsleft").textContent = (MaxLength - msgLen)+""; // for the rest of the known world	   	   
    }
    
}
