// JScript File
// GESTIONE AJAX SCRIPTMANAGER


Sys.Application.add_load( ApplicationLoadHandler );

function prm () {
    return Sys.WebForms.PageRequestManager.getInstance();
};


function ApplicationLoadHandler( sender, args ) {

    prm().add_endRequest( _EndAjaxRequst );
    prm().add_initializeRequest( _SetUpdateProgress );
    prm().add_endRequest( _StopUpdateProgress );
    prm().add_initializeRequest( _RemoveEndRequest );
	

};


function _RemoveEndRequest() {

    prm().remove_endRequest( _EndAjaxRequst );
    prm().remove_endRequest( _StopUpdateProgress );
    

};



function setMyForm() {
};




function _EndAjaxRequst( sender, args ) {
    var asyncPB_Function = args.get_dataItems() [ "___asyncPB_Function" ];

    if ( typeof( asyncPB_Function ) == "string" ) {
            eval( asyncPB_Function ) ( name );
        };

    prm().remove_endRequest( _EndAjaxRequst );
};


// FUNZIONI AJAX ASPNET : LATO SERVER
function Catalogo_CambioPagina() {
    FixThisPng( ".pngFix" );
    scrollTop();
    MyMooCart.prova();
	Preferiti_SetDialog();
	 Preferiti_SetDialog();
 NoLogged_SetDialog();
};

function Preferiti_Change() {
    FixThisPng( ".pngFix" );
    MyMooCart.prova();
	Preferiti_SetDialog();
		 Preferiti_SetDialog();
 NoLogged_SetDialog();
};



function MyModal_PageToRecPass() {

    MyModal.newPage( "div_RecPass" );

};

function MyModal_PageToCreaAcc() {

    MyModal.newPage( "div_CreaAcc" );

};

function Login_CloseLogBox() {

    MyModal.removeElements();

};




//FUNZIONI AJAX MOOTOOLS : ASPNET
function _StopUpdateProgress( sender, args ) {

    if ( MNAX_CustomPreloader ) {
            if ( MyModal.moodAling )MyModal.progress();

        }

    else {
            standard_Preloader( false );
        }

    prm().remove_endRequest( _StopUpdateProgress );
};


function _SetUpdateProgress( sender, args ) {

    if ( MNAX_CustomPreloader ) {
            if ( MyModal.moodAling ) MyModal.progress();
        }

    else {
            standard_Preloader( true );
        }

    prm().remove_initializeRequest( _SetUpdateProgress );
};



function standard_Preloader( start ) {


    if ( start ) {
            isUpdating = true;
            var winSize = window.getSize();
var MaskUpdate = new Element( 'div', {'id': "boxUpdate"} ).injectInside( document.body );
MaskUpdate.setStyles( {'height': document.body.scrollHeight, 'width': document.body.scrollWidth, 'opacity': 0.01} );
            uP = function() {
                     if ( isUpdating ) {
     var ProgressUpdate = new Element( 'div', {'id': "ProgressUpdate"} ).injectInside( document.body );//.setText( "in caricamento" );
     ProgressUpdate.setStyles( {'left': ( window.getSize().x.toInt() - ProgressUpdate.getSize().x.toInt() ) / 2, 'top': ( window.getSize().y.toInt() - ProgressUpdate.getSize().y.toInt() ) / 2 + window.getScroll().y.toInt() } );
                         }

                     ;
                 }

                 .delay( 500 );

        }

    else {
            isUpdating = false;

            if ( $( "boxUpdate" ) ) {
                    $( "boxUpdate" ).remove();

                };

            if ( $( "ProgressUpdate" ) ) {
                    $( "ProgressUpdate" ).remove();

                };
        };








};




