
function histats_site_multimonth_class() {
    try {
        this.ids = 0 ;
        this.nmod = 0 ;

        this.ndaysback = 60;

        this.tmp_col1 ='';
        this.tmp_col2 ='';
        this.tmp_col3 ='';
        this.tmp_strx ='';
        this.tmp_strdate ='';
        this.wday1st =''; // weekday first day 0,6-99
        this.tmp_count_DAY = 0 ;
        this.tmp_count_DAY_forecast = 0 ; // in case of forecast on last day --> tmp_count_DAY-1

        

        this.swf_GRAPH_ID = 0 ;

        this.AR_DISPLAYED_MONTHCODE = new Array(); // array of months used
        this.multimonthAR = new Array(); // contain some multimonth data processed

        this.ARSWF_variables =  new Array(); // PTR


        this.TOTAL_HITS = 0 ;
        this.TOTAL_VIS = 0 ;
        this.TOTAL_nVIS = 0 ;
        this.totalPPV =0;
        this.totalnvisPERC =0;
    } catch(e){
        alert("err loading javascript ,    try refreshing browser cache \n "  + e.message + "\n ");
    }
	
}
var G_MULTIMONT = new histats_site_multimonth_class();


histats_statsmodule_class.prototype.swf_gotoday_multimonth  = function(dayvalue) {
    if(!OBJ_SITEs[this.ids]) return;
    var OBJ_SITE = OBJ_SITEs[this.ids];
    if(!OBJ_STATSsheet.ARmodules[this.nmod]) return;
    var OBJ_MOD = OBJ_STATSsheet.ARmodules[this.nmod];
    var OBJ_dateMOD = G_CAL_HANDLER.AR_CALENDAR[OBJ_MOD.ID_DATECAL];
    var OBJ_dateSID =  G_CAL_HANDLER.AR_CALENDAR[OBJ_SITE.ID_CALDATE_SITE];
    var MONTH_TO_DISPLAY = OBJ_dateSID.dateAR['monthcode'];

    var BOOL_VALID_MONTH = true ;
    var MONTH_TO_DISPLAY_back = MONTH_TO_DISPLAY;
    while(BOOL_VALID_MONTH){
        if(!OBJ_SITE.monthly_stats[MONTH_TO_DISPLAY_back]) BOOL_VALID_MONTH = false ;
        if(BOOL_VALID_MONTH){ // if  valid month
            MONTH_TO_DISPLAY = MONTH_TO_DISPLAY_back;
            MONTH_TO_DISPLAY_back = f_DATE_BACK_1_monthcode(MONTH_TO_DISPLAY);//MONTH_TO_DISPLAY--;
        }
    }
    //alert(MONTH_TO_DISPLAY+','+MONTH_TO_DISPLAY_back);
    var unixt = f_return_unixT_by_idmonth(MONTH_TO_DISPLAY);
    unixt+=((dayvalue-1)*86400);
    //alert(f_return_DAYN_by_UnxT(unixt));
    if((OBJ_SITE.site_time-(86400*30)) > unixt ) return ;
    var OBJ_gotoDATE = new histats_datecal_class();
    OBJ_gotoDATE.tNOW = unixt;
    OBJ_gotoDATE.range = 'd';
    OBJ_gotoDATE.build_dateAR();
    OBJ_gotoDATE.build_URL();
    //http://www.histats.com/viewstats/?SID=90&act=3&dt=11-2-2010-0d
    var url_GOTO = 'http://www.histats.com/viewstats/?SID='+this.ids+'&act=3&dt='+OBJ_gotoDATE.dateURL_STRING;
    location.href = url_GOTO ;

//var url_GOTO = 'http://www.histats.com/viewstats/?SID='+this.ids+'&act='+act+'&dt='+ptrDATEmodule.dateURL_STRING+'&dt1='+OBJ_COMPAREDATE.dateURL_STRING+'';
//location.href = url_GOTO ;
}


histats_site_multimonth_class.prototype.f_build_MULTImonthstats  = function() { // set nmod and change what need to get changed when nmod is changed :)
    if(!OBJ_SITEs[this.ids]) return;
    var OBJ_SITE = OBJ_SITEs[this.ids];
    if(!OBJ_STATSsheet.ARmodules[this.nmod]) return;
    var OBJ_MOD = OBJ_STATSsheet.ARmodules[this.nmod];
    var OBJ_dateMOD = G_CAL_HANDLER.AR_CALENDAR[OBJ_MOD.ID_DATECAL];
    var OBJ_dateSID =  G_CAL_HANDLER.AR_CALENDAR[OBJ_SITE.ID_CALDATE_SITE];

    var MONTH_TO_DISPLAY = OBJ_dateSID.dateAR['monthcode'];
    //alert(MONTH_TO_DISPLAY);
    ARDATE = OBJ_dateSID.dateAR;

    this.tmp_col1 = '' ;
    this.tmp_col2 = '' ;
    this.tmp_col3 = '' ;

    this.tmp_strx = '' ;
    this.tmp_strdate = '' ;

    this.tmp_count_DAY = 0 ;
    this.multimonthAR['str_nvisPERC'] = '' ;
    this.multimonthAR['str_ppv'] = '' ;
    this.multimonthAR['str_unb'] = '' ;
    this.multimonthAR['str_tun'] = '' ;
    this.multimonthAR['avg_online'] = '' ;
    this.AR_DISPLAYED_MONTHCODE = Array();
    // currentmonth ridotto e limitato
    if(!OBJ_SITE.monthly_stats[MONTH_TO_DISPLAY]) return  ;
    var OBJ_MONTH = OBJ_SITE.monthly_stats[MONTH_TO_DISPLAY];
    OBJ_MONTH.build_ARDATE();
    OBJ_MOD.f_monthlystats_build_addional_stats(MONTH_TO_DISPLAY);
    this.AR_DISPLAYED_MONTHCODE[(this.AR_DISPLAYED_MONTHCODE.length)] = MONTH_TO_DISPLAY;
    
    MONTH_TO_DISPLAY = f_DATE_BACK_1_monthcode(MONTH_TO_DISPLAY);//MONTH_TO_DISPLAY--;

    OBJ_MONTH.build_AR_exploded();
    OBJ_MOD.f_month_build_avg_online(MONTH_TO_DISPLAY,(ARDATE['day']));
    OBJ_MONTH.build_strimploded_FROMAR( (ARDATE['day'])); // cut current month
    OBJ_MONTH.build_strGRAPH_date((ARDATE['day'])); // build x line dateSTR
    this.tmp_count_DAY+= parseInt(ARDATE['day']) ;
    this.tmp_strx=  this.tmp_strx +OBJ_MONTH.str_x;

    this.tmp_strdate=  this.tmp_strdate +OBJ_MONTH.str_data;

    this.tmp_col1=  this.tmp_col1 +  OBJ_MONTH.str_nevis;
    this.tmp_col2=  this.tmp_col2 + OBJ_MONTH.str_vis;
    //this.tmp_col3=  this.tmp_col3 + OBJ_MONTH.str_hits;
    this.tmp_col3=  this.tmp_col3 + OBJ_MONTH.str_hits;
    this.multimonthAR['str_nvisPERC']=  this.multimonthAR['str_nvisPERC'] + OBJ_MONTH.str_nvisPERC;
    this.multimonthAR['str_ppv']=  this.multimonthAR['str_ppv'] + OBJ_MONTH.str_ppv;
    this.multimonthAR['str_onlineAVG']=  this.multimonthAR['str_onlineAVG'] + OBJ_MONTH.str_onlineAVG;

    

    this.multimonthAR['str_unb']=  this.multimonthAR['str_unb'] + OBJ_MONTH.str_unb;
    this.multimonthAR['str_tun']=  this.multimonthAR['str_tun'] + OBJ_MONTH.str_tun;

    

    this.TOTAL_HITS+=OBJ_MONTH.TOTAL_HITS;
    this.TOTAL_VIS+=OBJ_MONTH.TOTAL_VIS;
    this.TOTAL_nVIS+=OBJ_MONTH.TOTAL_nVIS;
    //this.totalPPV+=OBJ_MONTH.totalPPV;
    //this.totalnvisPERC+=OBJ_MONTH.totalnvisPERC;
    //alert('appendo mese ');
    var BOOL_VALID_MONTH = true ;
    while(BOOL_VALID_MONTH){
        //alert(MONTH_TO_DISPLAY);
        if(!OBJ_SITE.monthly_stats[MONTH_TO_DISPLAY]) BOOL_VALID_MONTH = false ;
        if(BOOL_VALID_MONTH){ // if valid month

            OBJ_MONTH = OBJ_SITE.monthly_stats[MONTH_TO_DISPLAY];
            OBJ_MOD.f_monthlystats_build_addional_stats(MONTH_TO_DISPLAY);
           
            this.AR_DISPLAYED_MONTHCODE[(this.AR_DISPLAYED_MONTHCODE.length)] = MONTH_TO_DISPLAY;
            OBJ_MONTH.build_ARDATE();
            OBJ_MONTH.build_AR_exploded();
            OBJ_MOD.f_month_build_avg_online(MONTH_TO_DISPLAY);
            OBJ_MONTH.build_strimploded_FROMAR(0); // cut current month
            OBJ_MONTH.build_strGRAPH_date(0); // build x line dateSTR

            this.tmp_strx=  OBJ_MONTH.str_x + "#"+ this.tmp_strx ;
            this.tmp_strdate=  OBJ_MONTH.str_data+ "#"+ this.tmp_strdate ;

            this.tmp_col1=     OBJ_MONTH.str_nevis + "#"+ this.tmp_col1 ;
            this.tmp_col2=    OBJ_MONTH.str_vis + "#"+ this.tmp_col2;
         
            this.tmp_col3=    OBJ_MONTH.str_hits + "#"+this.tmp_col3 ;

            this.multimonthAR['str_nvisPERC']=   OBJ_MONTH.str_nvisPERC + "#" + this.multimonthAR['str_nvisPERC'];
            this.multimonthAR['str_ppv']=   OBJ_MONTH.str_ppv  + "#" + this.multimonthAR['str_ppv'];
            this.multimonthAR['str_onlineAVG']=   OBJ_MONTH.str_onlineAVG  + "#" + this.multimonthAR['str_onlineAVG'];

            this.multimonthAR['str_unb']=   OBJ_MONTH.str_unb  + "#" + this.multimonthAR['str_unb'];
            this.multimonthAR['str_tun']=   OBJ_MONTH.str_tun  + "#" + this.multimonthAR['str_tun'];

            this.TOTAL_HITS+=OBJ_MONTH.TOTAL_HITS;
            this.TOTAL_VIS+=OBJ_MONTH.TOTAL_VIS;
            this.TOTAL_nVIS+=OBJ_MONTH.TOTAL_nVIS;
            //this.totalPPV+=OBJ_MONTH.totalPPV;
            //this.totalnvisPERC+=OBJ_MONTH.totalnvisPERC;

            this.tmp_count_DAY+=parseInt(OBJ_MONTH.AR_date['ndayMonth']);
        }
        //MONTH_TO_DISPLAY--; // back 1 month
        MONTH_TO_DISPLAY = f_DATE_BACK_1_monthcode(MONTH_TO_DISPLAY);
    //return ;
    }
    this.tmp_count_DAY_forecast = this.tmp_count_DAY;
    this.wday1st= OBJ_MONTH.AR_date['wday1st'];
    if(this.TOTAL_VIS > 0 ) this.totalPPV = parseInt((this.TOTAL_HITS/this.TOTAL_VIS)*100)/100;
    if(this.TOTAL_VIS > 0 ) this.totalnvisPERC = parseInt((this.TOTAL_nVIS/this.TOTAL_VIS)*10000)/100;

}

histats_site_multimonth_class.prototype.f_build_swf_Data  = function() {
  //  console.log(this.tmp_col3);
//histats_site_multimonth_class.prototype.f_build_swf_graph  = function() { // set nmod and change what need to get changed when nmod is changed :)
    this.ARSWF_variables['var_val_col1'] = this.tmp_col1;
    this.ARSWF_variables['var_val_col2'] = this.tmp_col2 ;
    this.ARSWF_variables['var_val_col3'] = this.tmp_col3;


    this.ARSWF_variables['var_val_p1'] = '';
    this.ARSWF_variables['var_val_p2'] = '';
    this.ARSWF_variables['var_val_p3'] = '';
    this.ARSWF_variables['var_number_lineDraw'] = '0';
    this.ARSWF_variables['var_tiposcala_linee'] = 3;

    this.ARSWF_variables['var_n_barre'] =  this.tmp_count_DAY;
    //if(this.tmp_count_DAY_forecast ==)
    //alert(tmp_strx + '\n' + tmp_strdate  + '\n' + tmp_col1  + '\n' + tmp_col2  + '\n' + tmp_col3  );
    this.ARSWF_variables['var_str_x'] = this.tmp_strx;
    this.ARSWF_variables['var_str_data'] = this.tmp_strdate;

  

    this.ARSWF_variables['var_gg_forecast'] = this.tmp_count_DAY_forecast;
    this.ARSWF_variables['WDAY_firstDAY'] =this.wday1st;// weekday first day 0,6-99
    this.ARSWF_variables['var_lang_vis'] = GL.Q('visitatori');
    this.ARSWF_variables['var_lang_pv'] = GL.Q('pagine_viste');
    //alert(print_r(this.ARSWF_variables,true));
    //alert(this.tmp_count_DAY);
    // init swf
    if(this.ARSWF_variables['var_for_col1']=='0' && this.ARSWF_variables['var_for_col2']=='0' && this.ARSWF_variables['var_for_col3']=='0' ){
        this.ARSWF_variables['var_for_col1'] = '0#';
        this.ARSWF_variables['var_for_col2'] = '0#';
        this.ARSWF_variables['var_for_col3'] = '0#';
    }
}




histats_site_multimonth_class.prototype.f_build_swf_graph  = function() {
    var swfid = G_SWF_HANDLER.crate_swf_obj();
    this.swf_GRAPH_ID = swfid;
    var OBJ_MOD = OBJ_STATSsheet.ARmodules[this.nmod];
    OBJ_MOD.swf_COLGRAPH_id = this.swf_GRAPH_ID;
    // load swf
    G_SWF_HANDLER.AR_SWFOBJ[swfid].nome_DIV_CONTAINER ='histats_3monthstats_divFOB';
    G_SWF_HANDLER.AR_SWFOBJ[swfid].swfclickfunct = "OBJ_STATSsheet.ARmodules["+this.nmod+"].swf_gotoday_multimonth('--value--');";

    G_SWF_HANDLER.AR_SWFOBJ[swfid].callback_type = 'data';
    G_SWF_HANDLER.AR_SWFOBJ[swfid].AR_RETURN_DATA = this.ARSWF_variables;

    G_SWF_HANDLER.AR_SWFOBJ[swfid].LOAD_FOB();
}

histats_statsmodule_class.prototype.f_print_MULTImonthstats_nocompare  = function() { // set nmod and change what need to get changed when nmod is changed :)
    G_MULTIMONT.f_build_swf_Data();
    G_MULTIMONT.ARSWF_variables['rldData'] = '1';
}

histats_statsmodule_class.prototype.f_print_MULTImonthstats_average_ppv  = function() { // set nmod and change what need to get changed when nmod is changed :)
    /*if(!OBJ_SITEs[this.ids]) return;
    OBJ_SITE = OBJ_SITEs[this.ids];
    if(!OBJ_SITE.monthly_stats) return;
    this.f_print_MULTImonthstats();*/
    G_MULTIMONT.f_build_swf_Data();
    G_MULTIMONT.ARSWF_variables['var_val_p1'] =  G_MULTIMONT.multimonthAR['str_ppv'];
    G_MULTIMONT.ARSWF_variables['var_number_lineDraw'] = '1';
    G_MULTIMONT.ARSWF_variables['var_tiposcala_linee'] =3;
    G_MULTIMONT.ARSWF_variables['var_lang_p1'] = GL.Q('ppv_desc');
    G_MULTIMONT.ARSWF_variables['rldData'] = '1';
    //this.reload_FOB();
//this.f_print_MULTImonthstats();
}


histats_statsmodule_class.prototype.f_print_MULTImonthstats_unb  = function() { // set nmod and change what need to get changed when nmod is changed :)
    G_MULTIMONT.f_build_swf_Data();

    G_MULTIMONT.ARSWF_variables['var_val_p1'] = G_MULTIMONT.multimonthAR['str_unb'];
    G_MULTIMONT.ARSWF_variables['var_val_p2'] = G_MULTIMONT.multimonthAR['str_tun'];
    G_MULTIMONT.ARSWF_variables['var_number_lineDraw'] = '2';
    G_MULTIMONT.ARSWF_variables['var_tiposcala_linee'] =3;
    G_MULTIMONT.ARSWF_variables['var_lang_p1'] = '% '+GL.Q('bounce_desc');
    G_MULTIMONT.ARSWF_variables['var_lang_p2'] = '% '+GL.Q('tbounce_desc');
    G_MULTIMONT.ARSWF_variables['rldData'] = '1';
    //this.reload_FOB();
//this.f_print_MULTImonthstats();
}



histats_statsmodule_class.prototype.f_print_MULTImonthstats_newvis_perc  = function() { // set nmod and change what need to get changed when nmod is changed :)
    /*if(!OBJ_SITEs[this.ids]) return;
    OBJ_SITE = OBJ_SITEs[this.ids];
    if(!OBJ_SITE.monthly_stats) return;
    this.f_print_MULTImonthstats();*/
    G_MULTIMONT.f_build_swf_Data();
    G_MULTIMONT.ARSWF_variables['var_val_p1'] =  G_MULTIMONT.multimonthAR['str_nvisPERC'];
    G_MULTIMONT.ARSWF_variables['var_number_lineDraw'] = '1';
    G_MULTIMONT.ARSWF_variables['var_tiposcala_linee'] =3;
    //alert(OBJ_DAY.str_ppv);
    G_MULTIMONT.ARSWF_variables['var_lang_p1'] = '% '+ GL.Q('n_visitatori');
    G_MULTIMONT.ARSWF_variables['rldData'] = '1';
    //this.reload_FOB();
//this.f_print_MULTImonthstats();
}


histats_statsmodule_class.prototype.f_print_MULTImonthstats_online  = function() { // set nmod and change what need to get changed when nmod is changed :)
    /*if(!OBJ_SITEs[this.ids]) return;
    OBJ_SITE = OBJ_SITEs[this.ids];
    if(!OBJ_SITE.monthly_stats) return;
    this.f_print_MULTImonthstats();*/
    G_MULTIMONT.f_build_swf_Data();
    G_MULTIMONT.ARSWF_variables['var_val_p1'] =  G_MULTIMONT.multimonthAR['str_onlineAVG'];
    G_MULTIMONT.ARSWF_variables['var_number_lineDraw'] = '1';
    G_MULTIMONT.ARSWF_variables['var_tiposcala_linee'] =3;
    G_MULTIMONT.ARSWF_variables['var_lang_p1'] = GL.Q('avg_online');
    G_MULTIMONT.ARSWF_variables['rldData'] = '1';
    //this.reload_FOB();
//this.f_print_MULTImonthstats();
}

histats_statsmodule_class.prototype.f_build_weekData  = function(){

    G_MULTIMONT.tmp_col1W ='';
    G_MULTIMONT.tmp_col2W ='';
    G_MULTIMONT.tmp_col3W ='';
    G_MULTIMONT.tmp_strxW ='';
    G_MULTIMONT.tmp_strdateW ='';
    G_MULTIMONT.tmp_count_DAYW = 0 ;
    G_MULTIMONT.tmp_count_DAY_forecastW = 0 ;
    G_MULTIMONT.n_barreW = 0 ;

    var ArSplit_col1 = new Array();
    var ArSplit_col2 = new Array();
    var ArSplit_col3 = new Array();
    var ArSplit_strx = new Array();
    var ArSplit_strdate = new Array();
    var ArSplit = new Array();
    ArSplit['col1'] = G_MULTIMONT.tmp_col1.split('#');
    ArSplit['col2'] = G_MULTIMONT.tmp_col2.split('#');
    ArSplit['col3'] = G_MULTIMONT.tmp_col3.split('#');
    ArSplit['strx'] = G_MULTIMONT.tmp_strx.split('#');
    ArSplit['strdate'] = G_MULTIMONT.tmp_strdate.split('#');

    var AR_cumulative = new Array();
    AR_cumulative['col1'] = 0;
    AR_cumulative['col2'] = 0;
    AR_cumulative['col3'] = 0;
    AR_cumulative['AVGcol1'] = 0;
    AR_cumulative['AVGcol2'] = 0;
    AR_cumulative['AVGcol3'] = 0;

    var tmp_contaNgW = G_MULTIMONT.wday1st;
    var tmp_contaCOL = 0;
    var conta_chk = 0;
    var new_colIntera = 0;
    var tmp_cancelletto = '';
    var tmp_cancellettoD = '';

    var tmp_MonstrxW = '';
    var tmp_strdateW = '';
    if(ArSplit['col1'].length>0){
        
        for(var k in ArSplit['col1']){
            
            if(tmp_contaNgW==1 ){
                tmp_MonstrxW = tmp_cancelletto+ArSplit['strx'][k];
                tmp_strdateW = tmp_cancelletto+ArSplit['strdate'][k];
                tmp_contaCOL++;
            }
            AR_cumulative['col1'] += parseInt(ArSplit['col1'][k]);
            AR_cumulative['col2'] += parseInt(ArSplit['col2'][k]);
            AR_cumulative['col3'] += parseInt(ArSplit['col3'][k]);

            if(tmp_contaNgW==7){
                AR_cumulative['AVGcol1'] = parseInt(AR_cumulative['col1']/tmp_contaNgW);
                AR_cumulative['AVGcol2'] = parseInt(AR_cumulative['col2']/tmp_contaNgW);
                AR_cumulative['AVGcol3'] = parseInt(AR_cumulative['col3']/tmp_contaNgW);
                tmp_contaNgW = 0;
                G_MULTIMONT.tmp_col1W += tmp_cancelletto+AR_cumulative['AVGcol1'];
                G_MULTIMONT.tmp_col2W += tmp_cancelletto+AR_cumulative['AVGcol2'];
                G_MULTIMONT.tmp_col3W += tmp_cancelletto+AR_cumulative['AVGcol3'];
                AR_cumulative['col1'] = 0;
                AR_cumulative['col2'] = 0;
                AR_cumulative['col3'] = 0;
                G_MULTIMONT.tmp_strxW += tmp_MonstrxW;
                G_MULTIMONT.tmp_strdateW += tmp_strdateW+' - '+ArSplit['strdate'][k];
                tmp_cancelletto = '#';
            }
            
            tmp_contaNgW++;

        }
        
    }
    G_MULTIMONT.n_barreW = tmp_contaCOL-1;
}
histats_statsmodule_class.prototype.f_print_MULTImonthstats_week  = function() {
    G_MULTIMONT.ARSWF_variables['var_val_col1'] = G_MULTIMONT.tmp_col1W;
    G_MULTIMONT.ARSWF_variables['var_val_col2'] = G_MULTIMONT.tmp_col2W ;
    G_MULTIMONT.ARSWF_variables['var_val_col3'] = G_MULTIMONT.tmp_col3W;
    G_MULTIMONT.ARSWF_variables['var_for_col1'] = '0#';
    G_MULTIMONT.ARSWF_variables['var_for_col2'] = '0#';
    G_MULTIMONT.ARSWF_variables['var_for_col3'] = '0#';

    G_MULTIMONT.ARSWF_variables['var_val_p1'] = '';
    G_MULTIMONT.ARSWF_variables['var_val_p2'] = '';
    G_MULTIMONT.ARSWF_variables['var_val_p3'] = '';
    G_MULTIMONT.ARSWF_variables['var_number_lineDraw'] = '0';
    G_MULTIMONT.ARSWF_variables['var_tiposcala_linee'] = 3;

    G_MULTIMONT.ARSWF_variables['var_n_barre'] =  G_MULTIMONT.n_barreW;
    G_MULTIMONT.ARSWF_variables['var_str_x'] = G_MULTIMONT.tmp_strxW;
    G_MULTIMONT.ARSWF_variables['var_str_data'] = G_MULTIMONT.tmp_strdateW;

    G_MULTIMONT.ARSWF_variables['var_gg_forecast'] = G_MULTIMONT.n_barreW;
    G_MULTIMONT.ARSWF_variables['WDAY_firstDAY'] =99;// weekday first day 0,6-99
    G_MULTIMONT.ARSWF_variables['var_lang_vis'] = GL.Q('visitatori');
    G_MULTIMONT.ARSWF_variables['var_lang_pv'] = GL.Q('pagine_viste');
    G_MULTIMONT.ARSWF_variables['rldData'] = '1';

    //alert(print_r(G_MULTIMONT.ARSWF_variables,true));
    //this.reload_FOB();
}

histats_statsmodule_class.prototype.f_print_MULTImonth_hourlytableHTML  = function() {
    //  this.AR_DISPLAYED_MONTHCODE[(this.AR_DISPLAYED_MONTHCODE.length)] = MONTH_TO_DISPLAY;
    var HTML_TABLE = '' ;
    var month_shortname = '' ;
    if(G_MULTIMONT.AR_DISPLAYED_MONTHCODE.length < 1 ) return '';
    var MONTH_TO_DISPLAY = 0 ;
    var tmpCount = 0;
    var tmp_classRow = 'tb_data_1';
    var print_perc = 0;
    var tmp_Wbar = 0;
    //for(var k_monthcode=0;k_monthcode<G_MULTIMONT.AR_DISPLAYED_MONTHCODE.length;k_monthcode++){
    for(var k_monthcode in  G_MULTIMONT.AR_DISPLAYED_MONTHCODE ){
        //for(var k_monthcode=G_MULTIMONT.AR_DISPLAYED_MONTHCODE.length; k_monthcode>0;k_monthcode--){
        MONTH_TO_DISPLAY = G_MULTIMONT.AR_DISPLAYED_MONTHCODE[k_monthcode];
        if(!OBJ_SITE.monthly_stats[MONTH_TO_DISPLAY]) return ;
        
        OBJ_MONTH = OBJ_SITE.monthly_stats[MONTH_TO_DISPLAY];
        month_shortname =  GL.R(GLOBAL_AR_MONTH[OBJ_MONTH.AR_date['month']]);
        var AR_PECENT_BAR =  f_cal_percentuali_ARRAY( OBJ_MONTH.AR_vis )  // AR_ritorno['perc_assoluta'] ,  AR_ritorno['perc_relativa']
        var tmp_monthtableHTML = '';
        
        // for(var k=0;k<OBJ_MONTH.AR_vis.length;k++){
        for(var k in OBJ_MONTH.AR_vis){
            if(parseInt(k) < OBJ_MONTH.AR_date['ndayMonth']){
                tmp_classRow = 'tb_data_1';
                if(tmpCount%2==1) tmp_classRow = 'tb_data_2';

                if(AR_PECENT_BAR['perc_assoluta'][k]) print_perc = GL.fn(parseInt(AR_PECENT_BAR['perc_assoluta'][k]*100)/100);
                else print_perc = 0;

                tmp_Wbar = 0;
                if(AR_PECENT_BAR['perc_relativa'][k]){
                    tmp_Wbar = parseInt(AR_PECENT_BAR['perc_relativa'][k]*1.7);
                }
                if(tmp_Wbar>170) tmp_Wbar = 170;

                tmp_monthtableHTML+= '<table class="'+tmp_classRow+'"  width="700"><tr>\
                                        <td width="70" align="center">'+(parseInt(k)+1)+' '+month_shortname+' </td>\
                                        <td width="230" align="left" style="padding-left: 5px"><div id="prgBAR" style="width:'+tmp_Wbar+'px"></div>&nbsp;'+print_perc+' %</td>\
                                        <td width="100" align="center"><font class="text14">'+GL.fn(OBJ_MONTH.AR_vis[k])+'</font></td>\
                                        <td width="130" align="center"><font class="text14">'+GL.fn(OBJ_MONTH.AR_hits[k])+'</font> ('+GL.fn(OBJ_MONTH.AR_ppv[k])+')</td>\
                                        <td width="100" align="center">'+GL.fn(OBJ_MONTH.AR_nevis[k])+' ('+GL.fn(OBJ_MONTH.AR_nvisPERC[k])+')</td>\
                                        <td width="70" align="center">'+GL.fn(OBJ_MONTH.AR_tun[k])+'%</td>\
                                    </tr></table>';
                tmpCount++;
            }
        }
        HTML_TABLE= tmp_monthtableHTML + HTML_TABLE;
    }

    HTML_TABLE= '<table border="0" width="100%" cellspacing="0" cellpadding="0" height="10"><tr><td></td></tr></table>\
                <table border="0" width="700" cellspacing="1" cellpadding="0"><tr>\
                    <td width="70" align="center" class="tdIntesta tdIntestaL">'+GL.R('giorno')+'</td>\
                    <td width="230" align="left" style="padding-left:3px;" class="tdIntesta">'+GL.R('grafico_visitatori')+'</td>\
                    <td width="100" align="center" class="tdIntesta"><font class="text11_white">'+GL.R('visitatori')+'</font></td>\
                    <td width="130" align="center" class="tdIntesta"><font class="text11_white">'+GL.R('pagine')+'</font></td>\
                    <td width="100" align="center" class="tdIntesta"><font class="text11_white">'+GL.R('newvis')+'(%)</font></td>\
                    <td width="70" align="center" class="tdIntesta tdIntestaR"><font class="text11_white">%'+GL.R('bounce')+'</font></td>\
                </tr></table>' + HTML_TABLE;

    return HTML_TABLE;
}



histats_statsmodule_class.prototype.reload_FOB  = function(){

  
    G_SWF_HANDLER.AR_SWFOBJ[this.swf_COLGRAPH_id].LOAD_FOB();
}

histats_statsmodule_class.prototype.f_print_MULTImonthstats  = function() {
   
    if(!OBJ_SITEs[this.ids]) return;
    OBJ_SITE = OBJ_SITEs[this.ids];
    if(!OBJ_SITE.monthly_stats) return;


    G_MULTIMONT.ids = this.ids;
    G_MULTIMONT.nmod = this.nmod;
    G_MULTIMONT.f_build_MULTImonthstats();




    var ptrDATEmodule = G_CAL_HANDLER.AR_CALENDAR[this.ID_DATECAL];
    var MONTH_TO_DISPLAY = ptrDATEmodule.dateAR['monthcode'];
    if(!OBJ_SITE.monthly_stats[MONTH_TO_DISPLAY]) return ;
    OBJ_MONTH = OBJ_SITE.monthly_stats[MONTH_TO_DISPLAY];


    var HTML_TABLE_DAY = this.f_print_MULTImonth_hourlytableHTML(MONTH_TO_DISPLAY);

    var ptr_SITEtime =  G_CAL_HANDLER.AR_CALENDAR[OBJ_SITE.ID_CALDATE_SITE];
    //alert(ptr_SITEtime.dateAR['monthcode'] + ' - ' + MONTH_TO_DISPLAY);
    var currentSITE_monthcode = ptr_SITEtime.dateAR['monthcode'];
    //alert(currentSITE_monthcode);
    //ptr_sid.monthly_stats[DAY_TO_DISPLAY]
    /*<table border="0" width="700" cellspacing="0" cellpadding="0"><tr>\
                        <td width="700"  align="left"><font class="text20">'+GL.R('last')+' '+G_MULTIMONT.ndaysback+' '+GL.R('days')+'</font></td>\
                    </tr></table>\*/
    /*<table border="0" width="700" cellspacing="0" cellpadding="0" height="50" background="'+GLOBALS['FOLDER_img']+'bgTITLE_70040.png">\
                        <tr>\
                            <td   align="left" style="padding-left: 10px"><font class="text20"><font color="#FFFFFF">'+GL.R('last')+' '+G_MULTIMONT.ndaysback+' '+GL.R('days')+'</font></font></td>\
                        </tr>\
                        <tr>\
                            <td height="10"></td>\
                        </tr>\
                    </table>\\n\*/
    var HTML_PART1 = '<table class="Dintesta" border="0" width="700" cellspacing="0" cellpadding="0"><tr><td align="left">'+GL.R('last')+' '+G_MULTIMONT.ndaysback+' '+GL.R('days')+'</td></tr></table>\
                    <table border="0" cellpadding="0" cellspacing="0" height="10" width="100%"><tr><td></td></tr></table>';




    var HTML_PART2 = '<div class="TBcompare">\
                        <table border="0" width="100%" cellspacing="0" cellpadding="0"><tr>\
                            <td width="25"><img border="0" src="'+GLOBALS['FOLDER_img']+'compareICO2.png"></td>\
                            <td ><font class="text14_blue"> '+GL.R('compare')+'</font></td>\
                            <td class="compareTD ttip" onclick="OBJ_STATSsheet.ARmodules['+this.nmod+'].f_print_MULTImonthstats_nocompare();" original-title=\''+addslashes(GL.R('no_compare'))+'\'"><img src="'+GLOBALS['FOLDER_img']+'150.png" border="0"> no</font></td>\
                            <td class="compareTD ttip" onclick="OBJ_STATSsheet.ARmodules['+this.nmod+'].f_print_MULTImonthstats_unb();" original-title=\''+addslashes(GL.R('trend_bounce'))+'\'"><img border="0" src="'+GLOBALS['FOLDER_img']+'bounce.png"> bounce</td>\
                            <td class="compareTD ttip" onclick="OBJ_STATSsheet.ARmodules['+this.nmod+'].f_print_MULTImonthstats_average_ppv();"  original-title=\''+addslashes(GL.R('trend_Ppv'))+'\'"><img border="0" src="'+GLOBALS['FOLDER_img']+'trend10.png"> '+GL.R('ppv')+'</td>\
                            <td class="compareTD ttip" onclick="OBJ_STATSsheet.ARmodules['+this.nmod+'].f_print_MULTImonthstats_newvis_perc();"  original-title=\''+addslashes(GL.R('n_visitatori'))+'\'"><img border="0" src="'+GLOBALS['FOLDER_img']+'trend10b.png"> Nvis</td>\
                            <td class="compareTD ttip" onclick="OBJ_STATSsheet.ARmodules['+this.nmod+'].f_print_MULTImonthstats_online();" original-title=\''+addslashes(GL.R('avg_online'))+'\'"><img border="0" src="'+GLOBALS['FOLDER_img']+'liveIco.png"> '+GL.R('contval_online')+'</td>\
                            <td class="compareTD ttip" onclick="OBJ_STATSsheet.ARmodules['+this.nmod+'].f_print_MULTImonthstats_week();" original-title=\''+addslashes(GL.R('avg_week'))+'\'"><img border="0" src="'+GLOBALS['FOLDER_img']+'025.png"> '+GL.R('week')+'</td>\
                        </tr></table>\
                    </div>\
' + HTML_TABLE_DAY ;
    var divname_part1 = 'histats_3monthstats_divpart1';
    var divname_part2 = 'histats_3monthstats_divpart2';

    document.getElementById(divname_part1).innerHTML = HTML_PART1;
    document.getElementById(divname_part2).innerHTML = HTML_PART2;

    G_MULTIMONT.f_build_swf_Data();
    G_MULTIMONT.f_build_swf_graph();

    this.f_build_weekData();

    $(document).ready(function(){
        $(".compareTD").bind("mouseenter mouseleave",function(event){
            $(this).toggleClass("compareTD_over");
        });
    });
    $(".tb_data_1").hover(function () {
        $(this).toggleClass('tb_data_Over')
    });
    $(".tb_data_2").hover(function () {
        $(this).toggleClass('tb_data_Over')
    });
}

histats_statsmodule_class.prototype.f_showHide_COMPARE  = function(){
    if(document.getElementById('div_contentCOMPARE_on').style.display=='none'){
        document.getElementById('div_contentCOMPARE_on').style.display='block';
        document.getElementById('div_contentCOMPARE_off').style.display='none';
    }else{
        document.getElementById('div_contentCOMPARE_on').style.display='none';
        document.getElementById('div_contentCOMPARE_off').style.display='block';
    }
}

histats_statsmodule_class.prototype.f_print_multimstats_EXPORT  = function(type) {

    var print_strEXP = '';
    var tmp_separatore = ",";
    var tmp_img_src = ''+GLOBALS['FOLDER_img']+'csv.gif';
    if(type=='tsv'){
        tmp_separatore = "\t";
        tmp_img_src = ''+GLOBALS['FOLDER_img']+'tsv.gif';
    }

    var month_shortname = '' ;

    if(G_MULTIMONT.AR_DISPLAYED_MONTHCODE.length < 1 ) return '';
    var MONTH_TO_DISPLAY = 0 ;

    

    if(G_MULTIMONT.AR_DISPLAYED_MONTHCODE.length>0){
        print_strEXP = GL.R('giorno') + tmp_separatore +  GL.R('visitatori') + tmp_separatore + GL.R('pagine') + tmp_separatore + 'ppv' + tmp_separatore + GL.R('newvis') +"\n";
        for(k_monthcode in  G_MULTIMONT.AR_DISPLAYED_MONTHCODE ){
            MONTH_TO_DISPLAY = G_MULTIMONT.AR_DISPLAYED_MONTHCODE[k_monthcode];
            if(!OBJ_SITE.monthly_stats[MONTH_TO_DISPLAY]) return ;
            OBJ_MONTH = OBJ_SITE.monthly_stats[MONTH_TO_DISPLAY];
            month_shortname =  GL.R(GLOBAL_AR_MONTH[OBJ_MONTH.AR_date['month']]);
            for(k in OBJ_MONTH.AR_vis){
                if(parseInt(k) < OBJ_MONTH.AR_date['ndayMonth']){
                    print_strEXP += (parseInt(k)+1)+' '+month_shortname + tmp_separatore + OBJ_MONTH.AR_vis[k] + tmp_separatore + OBJ_MONTH.AR_hits[k] + tmp_separatore + OBJ_MONTH.AR_ppv[k]+ tmp_separatore  + OBJ_MONTH.AR_nevis[k] +"\n";
                }
            }
        }
    }else{
        print_strEXP = GL.R('No_data');
    }


    var PRINT_html = '<table border="0" width="100%" cellspacing="0" cellpadding="0" height="100%"><tr><td align="center">\
                        <table border="0" width="700" cellspacing="0" cellpadding="0">\
                            <tr><td background="'+GLOBALS['FOLDER_img']+'tab_line.png">\
                                <table border="0" cellpadding="0" cellspacing="0" height="25" width="700"><tr>\
                                    <td background="'+GLOBALS['FOLDER_img']+'tab_L_on.png" width="15">&nbsp;</td>\
                                    <td align="center" background="'+GLOBALS['FOLDER_img']+'tab_M_on.png" width="100"><font class="text14_Dblue">Export data&nbsp;<img border="0" src="'+GLOBALS['FOLDER_img']+'189.png" width="10" height="10"></font></td>\
                                    <td background="'+GLOBALS['FOLDER_img']+'tab_R_on.png" width="15">&nbsp;</td>\
                                    <td align="right" style="padding-right:5px;width:570px;"><a href="javascript:f_GENERAL_div_lock_screen_hide(\'\');"><img border="0" src="'+GLOBALS['FOLDER_img']+'101_16.png"></a></td>\
                                </tr></table>\
                            </td></tr>\
                            <tr><td background="'+GLOBALS['FOLDER_img']+'700_mid.png" align="center">\
                                <table border="0" width="680" cellspacing="0" cellpadding="0"  height="25"><tr>\
                                    <td width="30"><img border="0" src="'+tmp_img_src+'"></td>\
                                    <td width="650"><font class="text11_Dblue">Move mouse over textarea to select exported data, and then copy it.</font></td>\
                                </tr></table>\
                                <textarea name="S1" cols="125" rows="20" class="textarea_grey" onmouseover="this.focus()" onfocus="this.select()">'+print_strEXP+'</textarea>\
                            </td></tr>\
                            <tr><td background="'+GLOBALS['FOLDER_img']+'700_bot.png" height="10"></td></tr>\
                        </table>\
                    </td></tr></table>';
    document.getElementById('div_LOCKSCREEN').innerHTML = PRINT_html;
    f_GENERAL_div_lock_screen_show();
}


histats_statsmodule_class.prototype.f_print_dataEXP  = function(JSID,type){
    var print_strEXP = '';
    var tmp_separatore = ",";
   
    if(type=='tsv'){
        tmp_separatore = "\t";
    }

    var month_shortname = '' ;

    if(G_MULTIMONT.AR_DISPLAYED_MONTHCODE.length < 1 ) return '';
    var MONTH_TO_DISPLAY = 0 ;
    var print_strEXP_M = '';
    if(G_MULTIMONT.AR_DISPLAYED_MONTHCODE.length>0){
        
        for(var k_monthcode in  G_MULTIMONT.AR_DISPLAYED_MONTHCODE ){
            MONTH_TO_DISPLAY = G_MULTIMONT.AR_DISPLAYED_MONTHCODE[k_monthcode];
            if(!OBJ_SITE.monthly_stats[MONTH_TO_DISPLAY]) return ;
            OBJ_MONTH = OBJ_SITE.monthly_stats[MONTH_TO_DISPLAY];
            month_shortname =  GL.R(GLOBAL_AR_MONTH[OBJ_MONTH.AR_date['month']]);
            print_strEXP_M = '';
            for(var k in OBJ_MONTH.AR_vis){
                if(parseInt(k) < OBJ_MONTH.AR_date['ndayMonth']){
                    print_strEXP_M += (parseInt(k)+1)+' '+month_shortname + tmp_separatore + OBJ_MONTH.AR_vis[k] + tmp_separatore + OBJ_MONTH.AR_hits[k] + tmp_separatore + OBJ_MONTH.AR_ppv[k]+ tmp_separatore  + OBJ_MONTH.AR_nevis[k] +"\n";
                }
            }
            print_strEXP= print_strEXP_M + print_strEXP;
        }

        print_strEXP = GL.R('giorno') + tmp_separatore +  GL.R('visitatori') + tmp_separatore + GL.R('pagine') + tmp_separatore + 'ppv' + tmp_separatore + GL.R('newvis') +"\n" + print_strEXP;

    }else{
        print_strEXP = GL.R('No_data');
    }

    return print_strEXP;
}

if(!JSCACHE) JSCACHE = [] ;
JSCACHE.push(['multimonthstats.class.js',2]);
