/*---------------------------------------------------------------------------------
    CORE DEFINITION
---------------------------------------------------------------------------------*/

/*
var task_number = 0;
function alertDebug(){
    alert("Ci sono in memoria "+task_number+" task.");
}
setTimeout("alertDebug()",10000);

*/

var core = function(){
    
    this.hash = location.hash;
    this.hashParams = false;    
    
    /*-------------------------------------------------------------------------------------------
    ---------------------------------------------------------------------------------------------
    ----------------------------------------------------------------------------- CONSTRUCTOR */
       
    this.start = function(){
        
        this.system = new system();
        //this.system_history = new system_history();
        this.css = new css();
        this.user = new user();
        this.autocomplete = new autocomplete();
        this.upload = new upload();
		this.show = new show();
        this.action = new action();
        this.form = new form();
        this.list = new list();
        this.hash = new hash();
              
    }  
    
    this.goToLanguage = function (language){
        location.href = HOST+'/'+language+'/';
    }
    
    /*-------------------------------------------------------------------------------------------
    ---------------------------------------------------------------------------------------------
    ----------------------------------------------------------------------------- EVAL JSP */
    
    this.evalOnclick = function(selector){
        $(selector).attr("jsp",$(selector).attr("onclick"));
    }
    
    this.evalJsp = function(jsp){
        if(jsp){
            if (window.execScript){
                window.execScript(jsp);
            } else {
                eval(jsp);
            }
        }
    }
    
    // ------------------------------------------------------------- BARRA MOVIBILE 
    
    /*    
    this.fixPosUFrame = function(){
    
        var heightWindow = $(window).height();
        var heightBody = $(document).height();
        var heightFrame = $('.userIFrame').height();
        var heightScroll = $(window).scrollTop();
        var positionTopAbsolute = heightWindow-heightFrame;

        // DEBUG POSITION

        var debug = 'Altezza della finestra '+heightWindow;
        debug += '\r\n Offset Top '+heightScroll; 
        debug += '\r\n Altezza del body '+heightBody; 
        debug += '\r\n Altezza Frame '+heightFrame; 
        debug += '\r\n Top Frame Assoluto'+positionTopAbsolute;

        //alert(debug);

        // INIZIO RICERCA POSIZIONE DEL FRAME

        $('.userIFrame').css('top',(positionTopAbsolute+heightScroll)+'px');
    
    }
    */
	
    
    this.start();
        
}

/*---------------------------------------------------------------------------------
    CORE START
---------------------------------------------------------------------------------*/


$(document).ready(function(){
    
    $.ajaxSetup({"error":function(XMLHttpRequest,textStatus, errorThrown) {   
      // alert(textStatus);
      // alert(errorThrown);
      // alert(XMLHttpRequest.responseText);
    }});
    
    $('img').live("click",function(){
        if($(this).attr('href')){
            location.href = $(this).attr('href');
        }
    });
    
    core = new core();
    
}
);

    
    
    

/*---------------------------------------------------------------------------------
    CALL ON SCROLL
---------------------------------------------------------------------------------*/

/*

$(document).ready(
    function(){
       
       core.fixPosUFrame();
       
       $(window).scroll(
           function(){
               core.fixPosUFrame();
           }
       );
       
       $(window).resize(
           function(){
               core.fixPosUFrame();
           }
       );
        
    }
);

*/
