function init(){
        var obj1 = document.getElementById( "form_elements_on_page" );        
        if( obj1 != null ){
                obj1 = document.getElementById( "elements_on_pagex" );                
                if( obj1 != null ){
                        obj1.style.visibility ='visible';
                        obj1.visibility ='visible';                                 
                        obj1.style.display = "block";
                }
        }
        var obj2 = document.getElementById( "form_view_model" );
        if( obj2 != null ){
                obj2 = document.getElementById( "view_model" );
                 if( obj2 != null ){
                        obj2.style.visibility ='visible';
                        obj2.visibility ='visible';  
                        obj2.style.display = "block";
                }
        }

}
function MM_openBrWindow(theURL,features) { 
        newWindow = window.open(theURL,'chart',features);
        newWindow.focus();
}

function MM_goToURL() { 
        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 openAvailability( theURL ) {         
        return openAvailability( 'qta',theURL );
}*/

function openAvailability(p1, p2) {         
        var theURL,id;
        if( p2 ){
                id=p1;
                theURL=p2;
        }else{
                id='qta';
                theURL=p1;
        }
        var qta = document.getElementById( id ).value;
        var newWindow = window.open(theURL+"&qta="+qta,'chart','width=320,height=240,resizable=no,scrollbars=no,status=yes');        
}



/*****************************************
    Controllo della Partita I.V.A.
    Linguaggio: JavaScript
******************************************/

function controllaPIVA(pi){
        var test = false;
        alert( '0 ' );
        if( pi != '' && pi.length == 11 ){                                
                alert( '1');
                if(  /\d{11}/.test(pi) ){
                        alert( '2');
                        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) ){
                                test = false;
                                alert( '3');
                        }else{
                        
                                test = true;
                                alert( '4');
                        }
                }
                        
        }        
        alert( '5');
        return test;
}       
 function pivaTest( pi ){
                if( controllaPICA(pi) )
                        alert( '<%= TXT.getText("REGISTRATION_EMAIL_MISMATCHING")%>' );
                else
                        alert( "ok!!!!" );
        }


function spingUP( id ){
        var ele = document.getElementById( id );
        var x = parseInt( ele.value );
        ele.value = ++x;
        ele.focus();
}
function spingDOWN(id ){
        var ele = document.getElementById( id );
        var x = parseInt( ele.value );
        if( x>0 )
                ele.value = --x;
        ele.focus();    
}



function trim(stringa){    
        while (stringa.substring(0,1) == ' '){        
                stringa = stringa.substring(1, stringa.length);    
        }    
        while (stringa.substring(stringa.length-1, stringa.length) == ' '){        
                stringa = stringa.substring(0,stringa.length-1);    
        }    
        return stringa;
}