function limit(obj,maxChar){
    while(obj.value.length>maxChar){
        obj.value=obj.value.substring(0, maxChar);
    }
    document.getElementById("charrem").innerHTML = maxChar - obj.value.length;
}

function setDays(form){
    year = parseInt(form.year.options[form.year.selectedIndex].value);
    month = form.month.selectedIndex;
    day = form.day.selectedIndex;
    form.day.options.length = 0;
    var days = new Array(31, ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0 ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
    for(i = 0; i < days[month]; i++) {
        form.day.options.length = form.day.options.length + 1;
        form.day.options[i].value = i + 1;
        form.day.options[i].text = i + 1;
    }
    form.day.selectedIndex = (day < form.day.options.length) ? day : form.day.options.length - 1;
}

function ControllaPIVA(pi) {
    if( pi == '' ) {
        //document.getElementById("xpiva").innerHTML='<font color=\"red\"><small>Scrive la partita IVA</small></font>';
        return;
        //alert('Scrive la partita IVA');
    }
    if( pi.length != 11 ) {
        //alert (pi + '\nLa lunghezza della partita IVA non e\ncorretta: la partita IVA dovrebbe essere lunga\nesattamente 11 caratteri.\n');
        document.getElementById("xpiva").innerHTML='<font color=\"red\"><small>La lunghezza della partita IVA non e corretta: la partita IVA dovrebbe essere lunga esattamente 11 caratteri!</small></font>';
        return;
    }
    validi = "0123456789";
    for( i = 0; i < 11; i++ ){
        if( validi.indexOf( pi.charAt(i) ) == -1 ) {
            //alert ('La partita IVA contiene un carattere non valido `' + pi.charAt(i) + '`.\nI caratteri validi sono le cifre.\n');
            document.getElementById("xpiva").innerHTML='<font color=\"red\"><small>La partita IVA contiene un carattere non valido. I caratteri validi sono le cifre.</small></font>';
        return;
        }
    }
    s = 0;
    for( i = 0; i <= 9; i += 2 )
        s += pi.charCodeAt(i) - '0'.charCodeAt(0);
    for( i = 1; i <= 9; i += 2 ){
        c = 2*( pi.charCodeAt(i) - '0'.charCodeAt(0) );
        if( c > 9 )  c = c - 9;
        s += c;
    }
    if( ( 10 - s%10 )%10 != pi.charCodeAt(10) - '0'.charCodeAt(0) ) {
        //alert ('La partita IVA non e valida!');
        document.getElementById("xpiva").innerHTML='<font color=\"red\"><small>La partita IVA e non valida!</small></font>';
        return;
    }
}

function shmail(maiusr,maihos) {
    document.getElementById("mailbt").innerHTML='<a href="mailto:'+maiusr+'@'+maihos+'">'+maiusr+'@'+maihos+'</a>';
}
function hdmail(newtext) {
    document.getElementById("mailbt").innerHTML=newtext;
}
function messagioweb(web) {
    if( web.length > 5 ) {
        document.getElementById("xweb").innerHTML='<font color=\"red\"><small>Ecco i nostri codici html da inserire sul vostro sito.<br><strong>&lt;a href=&quot;http://www.italiaguide.info&quot; target=&quot;_blank&quot; title=&quot;Guida d\' Italia&quot;&gt;Guida d\' Italia&lt;/a&gt;</strong></small></font>';
        return;
    }
}

function esempio1() {
    document.getElementById("pex1").value = 'Cammera ingola';
    document.getElementById("pex2").value = '';
    document.getElementById("pex3").value = '';
    document.getElementById("pex4").value = '';
    document.getElementById("pex5").value = '';
    document.getElementById("pex6").value = '80';
    document.getElementById("pex7").value = '';
    document.getElementById("pex8").value = '';
    document.getElementById("pex9").value = '';
}
function esempio2() {
    document.getElementById("pex1").value = 'HP VECTRA VL 420MT';
    document.getElementById("pex2").value = 'PC, Hardware';
    document.getElementById("pex3").value = 'PC PIV 1.6 GHZ; 256 MB RAM; 40 GB HDD; FLOPPY; CD; LAN; AUDIO; USB';
    document.getElementById("pex4").value = '159';
    document.getElementById("pex5").value = '';
    document.getElementById("pex6").value = '130';
    document.getElementById("pex7").value = '';
    document.getElementById("pex8").value = '';
    document.getElementById("pex9").value = '';
}
function esempio3() {
    document.getElementById("pex1").value = 'Paulaner';
    document.getElementById("pex2").value = 'birra, bevanda';
    document.getElementById("pex3").value = '';
    document.getElementById("pex4").value = '';
    document.getElementById("pex5").value = '';
    document.getElementById("pex6").value = '2.35';
    document.getElementById("pex7").value = 'bicchiere';
    document.getElementById("pex8").value = '4.15';
    document.getElementById("pex9").value = 'bottiglia';
}
function esempio4() {
    document.getElementById("pex1").value = 'Pateuri';
    document.getElementById("pex2").value = 'cibo';
    document.getElementById("pex3").value = '';
    document.getElementById("pex4").value = '1.25';
    document.getElementById("pex5").value = '';
    document.getElementById("pex6").value = '1.00';
    document.getElementById("pex7").value = '1 porzione';
    document.getElementById("pex8").value = '3.00';
    document.getElementById("pex9").value = '5 porzioni';
}
function showvot1(){
    var obj1 = document.getElementById('valuta1');
    var obj2 = document.getElementById('valuta2');
    if(obj1) obj1.style.display = obj1.style.display != 'none' ? 'none' : 'block';
    if(obj2) obj2.style.display = 'none';
    return void(0);
}
function showvot2(){
    var obj1 = document.getElementById('valuta1');
    var obj2 = document.getElementById('valuta2');
    if(obj1) obj1.style.display = 'none';
    if(obj2) obj2.style.display = obj2.style.display != 'none' ? 'none' : 'block';
    return void(0);
}
function showadpano(){
    var obj1 = document.getElementById('adpano');
    if(obj1) obj1.style.display = obj1.style.display != 'none' ? 'none' : 'block';
    return void(0);
}
function shownews(nwdivo){
    var obj1 = document.getElementById(nwdivo);
    if(obj1) obj1.style.display = obj1.style.display != 'none' ? 'none' : 'block';
    return void(0);
}