var AR_PAGETYPE_ID = new Array();
var AR_PAGETYPE_LINKID = new Array();
/*AR_PAGETYPE_ID['42'] = 'summary';
AR_PAGETYPE_ID['43'] = 'daily';
AR_PAGETYPE_ID['44'] = 'monthlyhits';
AR_PAGETYPE_ID['45'] = 'last60_hits';
AR_PAGETYPE_ID['46'] = 'refsite';
AR_PAGETYPE_ID['47'] = 'refengine';
AR_PAGETYPE_ID['48'] = 'referer_trend';
AR_PAGETYPE_ID['49'] = 'infovis';
AR_PAGETYPE_ID['50'] = 'geoloc';
AR_PAGETYPE_ID['51'] = 'last20k';
AR_PAGETYPE_ID['52'] = 'pag_tr';
AR_PAGETYPE_ID['53'] = 'path_tr';
AR_PAGETYPE_ID['54'] = 'clickc';
AR_PAGETYPE_ID['55'] = 'search_eng_trend';*/

var GLOBAL_AR_DAYW = new Array();
GLOBAL_AR_DAYW[0] = GL.R('weekday_short_sun');
GLOBAL_AR_DAYW[1] = GL.R('weekday_short_mon');
GLOBAL_AR_DAYW[2] = GL.R('weekday_short_tue');
GLOBAL_AR_DAYW[3] = GL.R('weekday_short_wed');
GLOBAL_AR_DAYW[4] = GL.R('weekday_short_thu');
GLOBAL_AR_DAYW[5] = GL.R('weekday_short_fri');
GLOBAL_AR_DAYW[6] = GL.R('weekday_short_sat');


AR_PAGETYPE_ID['42'] = GL.R('sommario');
AR_PAGETYPE_ID['43'] = GL.R('dhtml_stats_giornaliere');
AR_PAGETYPE_ID['44'] = GL.R('dhtml_stats_mensili');
AR_PAGETYPE_ID['45'] = GL.R('dhtml_ultimi_60_gg');
AR_PAGETYPE_ID['46'] = GL.R('dhtml_provenienza')+' '+GL.R('dhtml_da_siti');
AR_PAGETYPE_ID['47'] = GL.R('dhtml_provenienza')+' '+GL.R('dhtml_da_motori');
AR_PAGETYPE_ID['48'] = GL.R('referer_trend');
AR_PAGETYPE_ID['49'] = GL.R('dhtml_configurazione_sistema');
AR_PAGETYPE_ID['50'] = GL.R('dhtml_geolocation');
AR_PAGETYPE_ID['51'] = GL.R('log_analyzer_title');
AR_PAGETYPE_ID['52'] = GL.R('dhtml_pagine_tracking');
AR_PAGETYPE_ID['53'] = GL.R('path_tracking');
AR_PAGETYPE_ID['54'] = GL.R('dhtml_click_count');
AR_PAGETYPE_ID['56'] = GL.R('tit_traffic_url');
AR_PAGETYPE_ID['57'] = GL.R('tit_traffic_title');
AR_PAGETYPE_ID['58'] = GL.R('tit_traffic_vars');
AR_PAGETYPE_ID['59'] = GL.R('LIVE_visitors');
//AR_PAGETYPE_ID['60'] = GL.R('exclusionIP');

// -- action 
AR_PAGETYPE_LINKID['42'] = 2;
AR_PAGETYPE_LINKID['43'] = 3;
AR_PAGETYPE_LINKID['44'] = 4;
AR_PAGETYPE_LINKID['45'] = 5;
AR_PAGETYPE_LINKID['46'] = 6;
AR_PAGETYPE_LINKID['47'] = 4;
AR_PAGETYPE_LINKID['48'] = 8;
AR_PAGETYPE_LINKID['49'] = 9;
AR_PAGETYPE_LINKID['50'] = 10;
AR_PAGETYPE_LINKID['51'] = 11;
AR_PAGETYPE_LINKID['52'] = 12;
AR_PAGETYPE_LINKID['53'] = 13;
AR_PAGETYPE_LINKID['54'] = 14;
AR_PAGETYPE_LINKID['55'] = 0;
AR_PAGETYPE_LINKID['56'] = 15;
AR_PAGETYPE_LINKID['57'] = 16;
AR_PAGETYPE_LINKID['58'] = 17;
AR_PAGETYPE_LINKID['59'] = 18;
AR_PAGETYPE_LINKID['60'] = 19;

function f_setTabbing(nTab){
    return;
    var arTab = new Array();

    arTab[1] = 1;
    arTab[2] = 1;
    arTab[3] = 1;
    arTab[4] = 1;


    for(var chiave in arTab){
        document.getElementById('tab_'+chiave).className = 'tab_content_off';
    }
    if(nTab<5){
        document.getElementById('tab_'+nTab).className = 'tab_content_on';
    }
}

function f_setTabbing_new(nTab){
    return;
    var arTab = new Array();

    arTab[1] = 1;
    arTab[2] = 1;
    arTab[3] = 1;
    arTab[4] = 1;
    arTab[5] = 1;

    for(var chiave in arTab){
        if(chiave==3){
            document.getElementById('tab_'+chiave).className = 'tab_content_off';
        }else{
            document.getElementById('tab_'+chiave).className = 'tab_content_off_150';
        }
    }
    if(nTab==3){
        document.getElementById('tab_'+nTab).className = 'tab_content_on_150';
    }else{
        document.getElementById('tab_'+nTab).className = 'tab_content_on';
    }
}

function count_array_elements(arr){
    var tmp_conteggio = 0;
    if(isArray_v2(arr)){
        for(chiave in arr){
            tmp_conteggio++;
        }
    }
    return tmp_conteggio;
}

function f_trova_numerico(chiave){
    var indice_numerico_NODENAME = chiave;
    var indice_numerico_NODENAME_POS = indice_numerico_NODENAME.search(/ndice_numerico_/); // mi da l'inizio della posizione ovvero 1
    if(indice_numerico_NODENAME_POS  == 1 ){
        indice_numerico_NODENAME  = indice_numerico_NODENAME.substr(16);

        indice_numerico_NODENAME = parseInt(indice_numerico_NODENAME);
        return indice_numerico_NODENAME;
    }else{
        return 1000;
    }

    return 1000;
}

function f_verifica_doppiachiave_numerico(arr,chiave_corrente){

    /*
    f_verifica_doppiachiave_numerico(arr,'du_count')
    'du_count' ...
    '0' ...
    'du_count' => "13"
    '1' ...
    'du_count' => "0"

    */
    try{
        var ritorno = 0;
        var conteggio_chiavi;
        if(isArray_v2(arr)){
            if(count_array_elements(arr) >= 1){

                for(chiave2 in arr){ // 0,1,2,3
                    conteggio_chiavi = 1;
                    for(chiave3 in arr[chiave2]){ //chiave_corrente,chiave_corrente,chiave_corrente
                        if(chiave2.match(/^\d+$/) && !chiave3.match(/^\d+$/) && chiave3==chiave_corrente){
                            conteggio_chiavi++;
                        }
                    }
                    if(conteggio_chiavi!=2) {
                        /*
                        if(chiave_corrente=='pag_count' ){
                        alert(chiave2.match(/^\d+$/) + "," + !chiave3.match(/^\d+$/) + " , " + chiave3)    ;
                        }
                        */
                        //alert ('ritorno 1 chiave NON numerica!!!' + chiave_corrente);
                        return 0;
                    }
                }


            }
        }
        //  alert ('ritorno 1 chiave numerica!!!' + chiave_corrente);
        return 1;

    }catch(e){
        alert("ERRORE:f_verifica_doppiachiave () \n error: " + e.message + "\n key: " + chiave   );
        return 0;
    }// end try
}

function f_verifica_doppiachiave(arr,chiave){

    try{
        var ritorno = 0;

        if(isArray_v2(arr)){
            if(count_array_elements(arr) == 1){
                for(chiave2 in arr){
                    if (!(chiave2==chiave)){
                        return 0;
                    }
                }
                if(!(isArray_v2(arr[chiave]))){

                    ritorno = 1;
                }
            }

        }
        return ritorno;

    }catch(e){
        alert("ERRORE:f_verifica_doppiachiave () \n error: " + e.message + "\n key: " + chiave   );
        return 0;
    }// end try
}

function fix_array_sequential(arr,newarr){
    try{
        var _is_sequential = 0;
        var first_el = 0;
        var chiave_copia = '';

        if(!(newarr)) return;
        if(isArray_v2(arr)){

            for (var chiave in arr){
                chiave_copia = chiave;
                if((f_trova_numerico(chiave)<1000) ){
                    chiave_copia = f_trova_numerico(chiave);
                }
                //alert('entro ' + chiave ) ;
                if(chiave.match(/^\d+$/) && (isArray_v2(arr[chiave]) && (count_array_elements(arr[chiave]) < 1))){ // se la chiave ï¿½ un indice numerico (array non  singolo value) e non ha niente al suo interno neanche un elemento
                //  newarr[(chiave + '_seq')] = new Array();
                //    fix_array_sequential(arr[chiave],newarr[(chiave + '_seq')]);
                }else
                {
                    if(isArray_v2(arr[chiave])){
                        if(f_verifica_doppiachiave(arr[chiave],chiave) == 1){
                            // se ï¿½ un count devo comunque mettere lo 0 come sottoarray
                            if(chiave.indexOf('_count')>-1){
                                newarr[chiave_copia] = new Array();
                                newarr[chiave_copia][0] = arr[chiave][chiave];
                            }else{
                                newarr[chiave_copia] = arr[chiave][chiave];
                            }

                        }else // se non ï¿½ una doppiachiave
                        {
                            // faccio ancora controllo per vedere se non ï¿½ una doppia chiavei nun array sequenziale
                            if(isArray_v2(arr[chiave]) && f_verifica_doppiachiave_numerico(arr[chiave],chiave) == 1){ // se ï¿½ un numerico la chiave doppia ï¿½ all'interno del numero ARkey->0->ARKEYDOPPIA=valore invece di   ARkey->0=valore
                                //alert('ï¿½ una chiave numerica ! '  + chiave);
                                newarr[chiave_copia] = new Array(); //chiave ad esempio 'pag_count' , con dentro 0 e poi ancora 'pag_count'
                                for (chiave3 in arr[chiave]){
                                    // if(arr[chiave][chiave3][chiave]){
                                    //   newarr[chiave_copia][chiave3] = '';
                                    //   alert(chiave + "," + chiave3 + "," + chiave_copia  );
                                    if(isArray_v2(arr[chiave][chiave3][chiave])){
                                        fix_array_sequential(arr[chiave][chiave3][chiave],newarr[chiave_copia][chiave3]);
                                    }else{
                                        newarr[chiave_copia][chiave3]=arr[chiave][chiave3][chiave];
                                    }
                                // alert('fatto!' + arr[chiave][chiave3][chiave] + " -> " + newarr[chiave_copia][chiave3]);
                                //  }
                                }

                            }else // altrimenti copio l'array normalmente..
                            {
                                newarr[chiave_copia] = new Array();
                                fix_array_sequential(arr[chiave],newarr[chiave_copia]);
                            }

                        }
                    }else{
                        newarr[chiave_copia] = arr[chiave];
                    }

                }
            } // fine for key

        }else{
            //alert(arr);
            //document.getElementById("divb").innerHTML =  document.getElementById("divb").innerHTML+ '<pre>' + dump(newarr) + '</pre>------- <br>';
            newarr = arr;
        //alert(newarr);
        } // fine else if is not array


    }catch(e){
        alert("ERRORE:fix_array_sequential () \n error: " + e.message    );
        return 0;
    }// end try


}// fine funct

function fix_array_recursive_v2(arr,newarr){
    try
    {
        //var tmp_key ='';
        var key_number=1000;
        var dbgid = 0;
        var _is_sequential = 0;
        if(isArray_v2(arr))
        {

            for(tmp_key in arr)
            {


                if(f_verifica_doppiachiave(arr[tmp_key],tmp_key))
                { // ï¿½ un arr ma per il problema doppia chiave in realtï¿½ ï¿½ un var
                    newarr[tmp_key] = arr[tmp_key][tmp_key];
                }else
                { // ï¿½ un subarray

                    if(f_trova_numerico(tmp_key) < 1000)
                    {
                        newarr[f_trova_numerico(tmp_key)] = new Array();
                        fix_array_recursive_v2(arr[tmp_key],newarr[f_trova_numerico(tmp_key)]);

                    }else
                    {

                        newarr[tmp_key] = new Array();
                        fix_array_recursive_v2(arr[tmp_key],newarr[tmp_key]);
                    }
                }



            } // fine per ogni key
        }else
        { //fine is array
            newarr = arr;

        }

    }catch(e){
        alert("ERRORE:fix_arrIEFX_v2 () \n error: " + e.message + "\n key: "+ "\n dbgid: " + dbgid  );
    }// end try
}

function fix_array_recursive(arr,newarr){ // devo passare se ï¿½ numero e se ï¿½ numerico anche se ha 0 elementi dentro ma ï¿½ un array lo metto come elemento ...
    try{
        var tmp_key ='';
        var dbgid = 0;
        if(isArray_v2(arr)){
            for(tmp_key in arr){
                if(isArray_v2(arr[tmp_key])){ // ï¿½ una chiave
                    //vedo se contiene elementi
                    if(count_array_elements(arr[tmp_key]) > 0){


                        var indice_numerico_NODENAME = tmp_key;
                        var indice_numerico_NODENAME_POS = indice_numerico_NODENAME.search(/ndice_numerico_/); // mi da l'inizio della posizione ovvero 1
                        if(indice_numerico_NODENAME_POS  == 1 ){
                            indice_numerico_NODENAME  = indice_numerico_NODENAME.substr(16);
                            indice_numerico_NODENAME = parseInt(indice_numerico_NODENAME);
                            if(arr[tmp_key][tmp_key]){ // stranamente durante la conversione mette una doppia chiave per tutto
                                //newarr[indice_numerico_NODENAME] = new Array();
                                dbgid = 1;
                                fix_array_recursive(arr[tmp_key][tmp_key], newarr[indice_numerico_NODENAME]);
                            }else{
                                dbgid = 2;
                                newarr[indice_numerico_NODENAME] = arr[tmp_key];
                            }
                        }else{
                            if(arr[tmp_key][tmp_key]){// stranamente durante la conversione mette una doppia chiave per tutto
                                //     alert('doppia:' + tmp_key + ' len: ' + count_array_elements(arr[tmp_key])  + ' len2: ' + count_array_elements(arr[tmp_key][tmp_key]));
                                if( count_array_elements(arr[tmp_key])==1){
                                    //  alert('len 1:' + tmp_key);
                                    dbgid = 3;
                                    newarr[tmp_key] = arr[tmp_key][tmp_key];
                                }else{
                                    newarr[indice_numerico_NODENAME] = new Array();
                                    dbgid = 4;
                                    fix_array_recursive(arr[tmp_key],newarr[indice_numerico_NODENAME]);
                                }
                            }else{
                                newarr[indice_numerico_NODENAME] = new Array();
                                dbgid = 5;
                                fix_array_recursive(arr[tmp_key],newarr[indice_numerico_NODENAME]);
                            }

                        }



                    }
                }else{ // ï¿½ un valore
                    dbgid = 6;
                    newarr[tmp_key] = arr[tmp_key];
                }
            } // fine for
        }else{// se non ï¿½ un array ma una normale variabile che durante la ricorsione passo per errore come array
            dbgid = 7;
            newarr = arr;

        }

    }catch(e){
        alert("ERRORE:fix_arrIEFX () \n error: " + e.message + "\n key: " + tmp_key + "\n dbgid: " + dbgid  );
    }// end try
}

function stampa_arr_in_var_v2(AR,variabile,rientroSTR){
    try{
        var debugriga   = 0;
        for ( var chiave in AR){
            if(!(isArray_v2(AR[chiave]))){
                variabile= variabile+ rientroSTR + chiave + ' = [' + AR[chiave] +"] <br>\n";
            }else{
                variabile= variabile + rientroSTR + chiave+ "[ARRAY] <br>\n";
                rientroSTR =  (rientroSTR+"	");
                variabile= stampa_arr_in_var_v2(AR[chiave], variabile,(rientroSTR+"	"));
            }
        }
        return variabile;
    }catch(e){
        alert("ERRORE:stampa_arr_in_var_v2 () \n error: " + e.message + '\n debugriga: ' + debugriga  );
    }// end try
} // end function

function isArray_v2(obj) {
    try{
        if(!obj) return;
        var debugriga   = 0;
        if ((obj.constructor.toString().indexOf("Array") == -1) && !(typeof(obj) == 'object') )
            return false;
        else
            return true;

    }catch(e){
        alert("ERRORE:isArray_v2 () \n error: " + e.message + '\n debugriga: ' + debugriga  );
    }//end try
} // end function

function isArray_sequential(obj) {
    try{
        var tmp_ritorno = 0;
        if(isArray_v2(obj)){
            if(obj.length == count_array_elements(obj)){
                tmp_ritorno = 1;
            }else{
        //alert('non seq! :' + obj.length +',' + count_array_elements(obj) )    ;
        }
        }
        return tmp_ritorno;

    }catch(e){
        return 0;
    }//end try
}

function f_GENERAL_CHK_SETVALUE(selname,selvalue){
    var obj = undefined;
    if(!document.getElementById(selname)) return ;
    obj = document.getElementById(selname);
    if(selvalue == 1 || selvalue == 'checked' || selvalue == true){
        obj.checked = true ;
    }else{
        obj.checked = false ;
    }

}

function f_GENERAL_TEXT_CLEARVALUE(textid,textvalue){
    
    if(!document.getElementById(textid)) return ;
    
    if(document.getElementById(textid).value == textvalue){
        document.getElementById(textid).value ='';
    }

}

function f_GENERAL_optionbt_SETVALUE(selname,selvalue){
    var obj = undefined;
    if(!document.getElementById(selname)) return ;
    obj = document.getElementById(selname);
    alert(selname + ' -> ' + selvalue + ' len : ' + obj.options.length);
    for (var i=0; i<obj.options.length; i++) {
        alert( ' vs '+obj[i].value);
        if(parseInt(obj[i].value) == selvalue ){
            obj[i].selected = 'true';
           
        }
    }
}

// set value for specified ID, other ID for same NAME are autmatically set as unchecked 
function f_GENERAL_radiobt_SETVALUE(selname,selvalue){
    var obj = undefined;
    selname = selname+'_'+selvalue; // id = name_value
    if(!document.getElementById(selname)) return ;
    obj = document.getElementById(selname);
    obj.checked = true ;
}
// check if a spefied ID is set as checked 
function f_GENERAL_radiobt_READ_checked(selname,selvalue){
    var obj = undefined;
    selname = selname+'_'+selvalue; // id = name_value
    if(!document.getElementById(selname)) return false;
    obj = document.getElementById(selname);
    if(obj.checked) return true ;
    return false ;
}

function f_GENERAL_optionbt_READVALUE(selname){
    var returnvalue = -1 ;

    var obj = undefined;
    for(var i = 0 ; i< 100;i++){
        if(document.getElementById(selname+i)){ //optioname_number
            obj = document.getElementById(selname+i);
            if(obj.checked){
                returnvalue = i;
            }
        }else{
            if(i> 5){ // at least do fist 5 checks
                i = 100 ;
            }
        }
    }
    return returnvalue;

}

// works only with integer values! (there is a parseint on the match) 
function f_GENERAL_select_SETVALUE(selname,selvalue){
    var obj = undefined;
    if(!document.getElementById(selname)) return ;
    obj = document.getElementById(selname);
    for (var i=0; i<obj.options.length; i++) {
        if(parseInt(obj[i].value) == parseInt(selvalue) ){
            //alert(parseInt(obj[i].value) + ' - ' + parseInt(selvalue)  );
            obj[i].selected = true;
        }else{
            obj[i].selected = false;
        }
    }
}

// works only with integer values! (there is a parseint on the match)
function f_GENERAL_select_SETVALUEstr(selname,selvalue){
    var obj = undefined;
    if(!document.getElementById(selname)) return ;
    obj = document.getElementById(selname);
    for (var i=0; i<obj.options.length; i++) {
        if((obj[i].value) == (selvalue) ){
            //alert(parseInt(obj[i].value) + ' - ' + parseInt(selvalue)  );
            obj[i].selected = true;
        }else{
            obj[i].selected = false;
        }
    }
}

function f_GENERAL_select_READVALUE(selname){
    var returnvalue = -1 ;

    var obj = undefined;
    if(document.getElementById(selname)){
        obj = document.getElementById(selname);
        returnvalue = obj[obj.selectedIndex].value
    }else{
        returnvalue =-1;
    }
    return returnvalue;

}
/*
function f_GENERAL_div_lock_screen_show(nameDiv){
    var nomeDiv = '';
    if(!nameDiv || nameDiv.length==0) nomeDiv = 'div_lock_screen';
    document.getElementById(nomeDiv).style.display = 'block';
    document.body.style.overflow = 'hidden';
    var wscreen = document.body.clientWidth;
    var hscreen = document.body.clientHeight;
    document.getElementById(nomeDiv).style.top = window.pageYOffset;
    document.getElementById(nomeDiv).style.width = wscreen +'px';
    document.getElementById(nomeDiv).style.height = hscreen +'px';    
}

function f_GENERAL_div_lock_screen_hide(nameDiv){
    var nomeDiv = '';
    if(!nameDiv || nameDiv.length==0) nomeDiv = 'div_lock_screen';
    document.getElementById(nomeDiv).style.width = 0;
    document.getElementById(nomeDiv).style.height = 0;
    document.getElementById(nomeDiv).style.display = 'none';
    document.body.style.overflow='';
}*/
function f_GENERAL_div_lock_screen_show(nameDiv){
    try{
        var nomeDiv = '';
        if(!nameDiv || nameDiv.length==0) nomeDiv = 'div_LOCKSCREEN';
        document.getElementById(nomeDiv).style.display = 'block';
        document.body.style.overflow = 'hidden';
        var wscreen = document.body.clientWidth;
        var hscreen = document.body.clientHeight;

        //document.getElementById(nomeDiv).style.top = document.body.scrollTop;
        document.getElementById(nomeDiv).style.top = 0;
        document.getElementById(nomeDiv).style.width = wscreen +'px';
        document.getElementById(nomeDiv).style.height = hscreen +'px';
        scroll(0,0);
    }catch(e){
        alert('f_GENERAL_div_lock_screen_show  \n error: ' + e.message);
    }
}

function f_GENERAL_div_lock_screen_hide(nameDiv){
    try{
        var nomeDiv = '';
        if(!nameDiv || nameDiv.length==0) nomeDiv = 'div_LOCKSCREEN';
        document.getElementById(nomeDiv).style.width = 0;
        document.getElementById(nomeDiv).style.height = 0;
        document.getElementById(nomeDiv).style.display = 'none';
        document.body.style.overflow='';
    }catch(e){
        alert('f_GENERAL_div_lock_screen_hide  \n error: ' + e.message);
    }
}

function f_GENERAL_findPos_obj(obj) {
    var curleft = 0;
    var curtop = 0;
    if (obj.offsetParent) {
        do {
            curleft += obj.offsetLeft;
            curtop += obj.offsetTop;
        } while (obj = obj.offsetParent);
        return [curleft,curtop];
    }
}

function f_GENERAL_div_ShowHide(nameObj){
    if(document.getElementById(nameObj)){
        var oggetto = document.getElementById(nameObj);
        if(oggetto.style.display=='none') oggetto.style.display='block';
        else oggetto.style.display='none';
    }
}

function doTooltip_testo(e, msg) {
    var msg= '<table border="0" width="250" cellspacing="0" cellpadding="0"><tr><td background="'+GLOBALS['FOLDER_img']+'tip_bg_t.png" height="5"></td></tr><tr><td background="'+GLOBALS['FOLDER_img']+'tip_bg_m.png" style="padding-left: 5px; padding-right: 5px" width="245"><font class=" text11_white">'+msg+'</font></td></tr><tr><td background="'+GLOBALS['FOLDER_img']+'tip_bg_b.png" height="5"></td></tr></table>';
    if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
    Tooltip.show(e, msg);
}

function hideTip() {
    if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
    Tooltip.hide();
}

function f_hide_div_abs_service(){
    document.getElementById('div_abs_service').style.display="none";
    document.getElementById('div_abs_service').innerHTML = '';
    document.getElementById('div_abs_service').style.width = 0+'px';
    document.getElementById('div_abs_service').style.height = 0+'px';
    document.getElementById('div_abs_service').style.top = 0;
    document.getElementById('div_abs_service').style.left = 0;
}

function addslashes(str) {
    if(typeof str  === "undefined") str = "";
    str=str.replace(/\\/g,'\\\\');
    str=str.replace(/\'/g,'\\\'');
    str=str.replace(/\"/g,'\\"');
    str=str.replace(/\0/g,'\\0');
    return str;
}
function addslashes_singlequote(str) {
    if(typeof str  === "undefined") str = "";
    str = stripslashes(str);
    str=str.replace(/\"/g,'\'');
    str=str.replace(/\\/g,'\\\\');
    str=str.replace(/\'/g,'\\\'');
    return str;
}

function stripslashes(str) {
    if(typeof str  === "undefined") str = "";
    str=str.replace(/\\'/g,'\'');
    str=str.replace(/\\"/g,'"');
    str=str.replace(/\\0/g,'\0');
    str=str.replace(/\\\\/g,'\\');
    return str;
}

function f_seconds_to_minhour(valore){

    valore = parseInt(valore);
    var valore_scale = '';
    var valore_dividend = 1 ;
    var returnstring = '';
    if(valore >= 86400){
        valore_scale = 'd ';
        valore_dividend = Math.floor(valore/86400);
        valore = (valore%86400);
        returnstring= returnstring + valore_dividend + valore_scale;
    }
    if(valore >= 3600){
        valore_scale = 'h ';
        valore_dividend = Math.floor(valore/3600);
        valore = (valore%3600);
        returnstring= returnstring + valore_dividend + valore_scale;
    }
    if(valore >= 60){
        valore_scale = 'm ';
        valore_dividend = Math.floor(valore/60);
        valore = (valore%60);
        returnstring= returnstring + valore_dividend + valore_scale;
    }
    if(valore > 0){
        valore_scale = 's';
        valore_dividend = valore;
       
        returnstring= returnstring + valore_dividend + valore_scale;
    }
    return returnstring ;


}

function f_adjust_bignumber(valore){

    valore = parseFloat(valore);
    var valore_scale = '';
    var valore_dividend = 1 ;
    if(valore >= 1000){
        valore_scale = 'K';
        valore_dividend = 1000;
    }
    if(valore >= 1000000){
        valore_scale = 'M';
        valore_dividend = 1000000;
    }
    if(valore >= 1000000000){
        valore_scale = 'G';
        valore_dividend = 1000000000;
    }
    if(valore >= 1000000000000){
        valore_scale = 'T';
        valore_dividend = 1000000000000;
    }
    valore = parseInt((valore/valore_dividend)*100)/100;
    return (valore + ' ' + valore_scale);
}

function f_clear_str_domain(string_dom){

    string_dom = string_dom.toLowerCase();
    string_dom = string_dom.split("\\").join("//");
    string_dom  = string_dom.split("http://").join("");
    string_dom  = string_dom.split("http:").join("");
    string_dom  = string_dom.split("http:/").join("");
    string_dom  = string_dom.split("https://").join("");
    string_dom  = string_dom.split("https:").join("");
    string_dom  = string_dom.split("https:/").join("");
    string_dom  = string_dom.split("ftp://").join("");
    string_dom  = string_dom.split("ftp:").join("");
    string_dom  = string_dom.split("ftp:/").join("");
    return (string_dom);

}

//TIP
function doTooltip_testo(e, msg) {    
    var msg= '<table border="0" width="250" cellspacing="0" cellpadding="0" ><tr><td background="'+GLOBALS['FOLDER_img']+'tip_bg_t.png" height="5"></td></tr><tr><td background="'+GLOBALS['FOLDER_img']+'tip_bg_m.png" style="padding-left:3px; padding-right:3px;"><font class="text11_white">'+msg+'</font></td></tr><tr><td background="'+GLOBALS['FOLDER_img']+'tip_bg_b.png" height="5"></td></tr></table>';
    if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
    Tooltip.show(e, msg);
}

function hideTip() {
    if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
    Tooltip.hide();
}

function f_setBar(nTab,act){
    var stato = document.getElementById('tab1_'+nTab).className;
    if(stato!='bt_menu_on'){
        if(act==1){//over
            document.getElementById('tab1_'+nTab).className = 'bt_menu_over';
        }
        if(act==2){//out
            document.getElementById('tab1_'+nTab).className = 'bt_menu_off';
        }
    }
}


function f_activeTabSheet(act){
   
    if(act==1){//over
        document.getElementById('sheetmenu_TD').className = 'tabbing2_on';
    }else if(act==2){//out
        if(GLOBAL_SELECTED_TAB!=3) document.getElementById('sheetmenu_TD').className = 'tabbing2_off';
    }    
}

function sortNumber(a,b)
{
    return a - b;
}

function sortRNumber(a,b)
{
    return  b -a ;
}

function IsNumeric(sText)
{
    try {
        sText = ''+sText;
        var ValidChars = "0123456789.";
        var IsNumber=true;
        var Char;

        for (i = 0; i < sText.length && IsNumber == true; i++)
        {
            Char = sText.charAt(i);
            if (ValidChars.indexOf(Char) == -1)
            {
                IsNumber = false;
            }
        }
        return IsNumber;
    } catch(e){
        return false
    }
}
/*
 * r = reverse
 * key_char_mantainer = '' or 'a' -> to keep numeric index sorted in the new array 
 */
function VIGOsortAssoc(aInput,r,key_char_mantainer,bool_numeric)
{
    if(bool_numeric!=true) bool_numeric= false;
    if (typeof key_char_mantainer=="undefined"){
        key_char_mantainer = 'a';
    }

    var aK = [];
    var aV = [];
    var aV_count = 0 ;
    var aRETURN = [];

    for (var sKey in aInput){
        //document.writeln(aInput[sKey] + "<br>");
        aV[aV_count] = aInput[sKey];
        aV_count++;
        if(!aK[aInput[sKey]]){
            aK[aInput[sKey]] = Array();
            aK[aInput[sKey]][0] = Array(); // array of keys
            aK[aInput[sKey]][0][sKey] = 0;
        }else{
            aK[aInput[sKey]][0][sKey] = 0;
        }
    }
    if(bool_numeric){ // number
        if(r!=1){
            aV.sort(sortNumber);
        }else{
            aV.sort(sortRNumber);
        }
    }else{ // string
        aV.sort();
        if(r==1){
            aV.reverse();
        }
    }
    var found_k = '';

    var b_found = false;
    for(kk_V in aV){
        b_found = false ;
        //document.writeln(aV[kk_V] + "<br>");
        for(tmp_k in aK[aV[kk_V]][0]){

            if(aK[aV[kk_V]][0][tmp_k] == 0 && !b_found){
                //document.writeln("testk : " + tmp_k + "<br>");
                aK[aV[kk_V]][0][tmp_k] = 1 ;
                found_k = tmp_k;
                b_found = true ;
            }
        }
        //found_k+='';
        aRETURN[(key_char_mantainer+found_k)] = aV[kk_V];
    // str.substr(1);
    }

    return aRETURN;
}

function f_print_EXPORT(JSID,type){
    var tmpDATA = PTR_MOD.f_print_dataEXP(JSID,type);
    f_print_EXPORT_screen(tmpDATA,type);
}

function f_print_EXPORT_screen(print_strEXP,type){

    var tmp_img_src = ''+GLOBALS['FOLDER_img']+'exp_csv.png';
    if(type=='tsv'){
        tmp_img_src = ''+GLOBALS['FOLDER_img']+'exp_tsv.png';
    }

    var PRINT_html = '<table border="0" width="100%" cellspacing="0" cellpadding="0" ><tr><td align="center" style="padding-top:50px;">\
                            <table border="0" width="700" cellspacing="0" cellpadding="0" height="400">\
                                <tr><td background="'+GLOBALS['FOLDER_img']+'tab_line.png" height="25">\
                                    <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" height="365" valign="top">\
                                    <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();

//----------------------------------posiziono l'iframe per piazzare il div sopra il flash in firefox linux
/*var tmp_ws = 0;
        var tmp_hs = 0;
        tmp_ws = parseInt(document.getElementById('div_LOCKSCREEN').style.width);
        tmp_hs = parseInt(document.getElementById('div_LOCKSCREEN').style.height);


        //alert('w: '+tmp_ws);
        //alert('h: '+tmp_hs);

        document.getElementById("iframe_divOverSwf").style.top = ((tmp_hs/2)-200)+'px';
        document.getElementById("iframe_divOverSwf").style.left = ((tmp_ws/2)-350)+'px';
        document.getElementById("iframe_divOverSwf").style.width = 700+'px';
        document.getElementById("iframe_divOverSwf").style.height = 400+'px';
        document.getElementById("iframe_divOverSwf").style.display="block";

        alert(document.getElementById("iframe_divOverSwf").style.top+' - '+document.getElementById("iframe_divOverSwf").style.left);*/
}



function htmlentities(texto){
   
    var i,carac,letra,novo='';
    for(i=0;i<texto.length;i++){
        carac = texto.substr(i,1).charCodeAt(0);
        if( (carac > 46 && carac < 59) || (carac > 62 && carac < 127) || carac == 32 ){
            //se for numero ou letra normal
            novo += texto.substr(i,1);
        }else{
            novo += "&#" + carac + ";";
        }
    }
    return novo;
}


function htmlentities_decode(str) {
    try{
        var ta=document.createElement("textarea");
        ta.innerHTML=str.replace(/</g,"&lt;").replace(/>/g,"&gt;");
        return ta.value;
    } catch(e){
        return '';
    }
}

function chkNUMERICval(o){
    if(typeof o !== "undefined"){
        if(parseInt(o)=='NaN') return false;
        (parseInt(o) > 0)?(b=true):(b=false);
    }
    return b;
}


function f_sort_hitsTRAFF(vsort,ar_tosort,bool_numeric,Osort,arSORTED){
    try{
        if(bool_numeric!=true) bool_numeric =false;
        if(Osort!=true) Osort =false;
        var tmp_newk = '';
        var tmp_arSORT = new Array();
        var txttmp = '' ;
        for (k in ar_tosort){
            if(bool_numeric){
                tmp_newk = ((parseInt(ar_tosort[k][vsort])*5000) +  parseInt(k)); //+ 'zzzzzzzzz' + k
                tmp_arSORT[k] = tmp_newk;
            }else{
                tmp_newk = ((((ar_tosort[k][vsort])).substr(0,18).toLowerCase()) + ' ' + k); //+ 'zzzzzzzzz' + k
                tmp_arSORT[k] = tmp_newk;
            }
        }
        arSORTED = VIGOsortAssoc(tmp_arSORT,Osort,'a' ,bool_numeric);
    } catch(err){
    }
}

//monodimensional sorted by value, (add 'a' to key)
function f_sort_monoARR(ar_tosort,BOOL_ASC,bool_numeric){ // bool_numeric -> array value numeric
    if(BOOL_ASC!=true) BOOL_ASC =false;
    var  arSORTED = new Array();
    for (var k in ar_tosort){
        if(bool_numeric){ // number
            arSORTED['a'+k] = parseInt(ar_tosort[k]);
        }else{
            arSORTED['a'+k] = ar_tosort[k];
        }
    }
    if(bool_numeric){ // number
        if(BOOL_ASC){
            arSORTED.sort(sortNumber);
        }else{
            arSORTED.sort(sortRNumber);
        }
    }else{ // string
        if(BOOL_ASC){
            arSORTED.reverse();
        }else{
            arSORTED.sort();
        }
    }
    return arSORTED;
}

function f_FeedB_showForm(){
    f_GENERAL_div_lock_screen_show();
    var titlePg = window.location;
    var prtContentFeedB = '<table border="0" width="100%" cellspacing="0" cellpadding="0" height="100%"><tr><td align="center"><table border="0" width="350" cellspacing="0" cellpadding="0">\
	<tr>\
		<td height="25" width="315"><font class="text20"><font color="#FFFFFF">Feedback</font></font></td>\
		<td height="25" width="25"><a href="javascript:f_FeedB_closeForm();"><img border="0" src="'+GLOBALS['FOLDER_img']+'bt_close2525.png"></a></td>\
	</tr>\
	<tr><td background="'+GLOBALS['FOLDER_img']+'bg_FeedB_top.png" width="350" height="6" colspan="2"></td></tr>\
	<tr><td background="'+GLOBALS['FOLDER_img']+'bg_FeedB_mid.png" width="350" align="center" colspan="2">\
		<div id="div_FeedBcontainerfomr">\
                    <table border="0" width="330" cellspacing="0" cellpadding="0">\
			<tr><td><font class="text14_orange">Your feedback for this page</font></td></tr>\
			<tr><td align="center">\
				<table border="0" width="100%" cellspacing="0" cellpadding="0" height="5"><tr><td></td></tr></table>\
				<table border="0" width="100%" cellspacing="0" cellpadding="0">\
					<tr><td><font class="text11_Dblue">Page</font></td></tr>\
					<tr><td><input disabled="disabled" name="txt_FeedB_curPage" id="txt_FeedB_curPage" size="60" class="text_grey" value="'+titlePg+'" type="text"></td></tr>\
				</table>\
				<table border="0" width="100%" cellspacing="0" cellpadding="0" height="5"><tr><td></td></tr></table>\
				<table border="0" width="100%" cellspacing="0" cellpadding="0">\
					<tr><td><font class="text11_Dblue">E-mail</font></td></tr>\
					<tr><td><input name="txt_FeedB_mail" id="txt_FeedB_mail" size="60" class="text_grey" value="" type="text"></td></tr>\
				</table>\
				<table border="0" width="100%" cellspacing="0" cellpadding="0" height="5"><tr><td></td></tr></table>\
				<table border="0" width="100%" cellspacing="0" cellpadding="0">\
					<tr><td><font class="text11_Dblue">Text</font></td></tr>\
					<tr><td><textarea rows="3" name="txt_FeedB_text" id="txt_FeedB_text" cols="50" class="textarea_grey"></textarea></td></tr>\
				</table>\
				<table border="0" width="100%" cellspacing="0" cellpadding="0" height="5"><tr><td></td></tr></table>\
				<table border="0" width="100%" cellspacing="0" cellpadding="0" height="40"><tr><td align="center"><a href="#" onclick="f_FeedB_SEND();" class="text16_blue" >Submit</a></td></tr></table>\
				</td></tr>\
		</table>\
                </div>\
	</td></tr>\
	<tr><td background="'+GLOBALS['FOLDER_img']+'bg_FeedB_bot.png" width="350" height="6" colspan="2"></td></tr>\
</table></td></tr></table>';
    document.getElementById('div_feedB_form').innerHTML = prtContentFeedB ;
    document.getElementById('div_feedB_form').style.display = 'block';
}

function f_FeedB_closeForm(){
    document.getElementById('div_feedB_form').innerHTML = '' ;
    document.getElementById('div_feedB_form').style.display = 'none';
    f_GENERAL_div_lock_screen_hide();
}

function f_FeedB_showTip(){
    var wscreen = document.body.clientWidth;
    document.getElementById('div_btFeedB').style.left = (wscreen/2)+(960/2) +'px';
    document.getElementById('div_btFeedB').style.display = 'block';
}
function f_FeedB_SEND(){
    var FEEDBurlsend = 'u='+escape(document.getElementById('txt_FeedB_curPage').value)+'&m='+escape(document.getElementById('txt_FeedB_mail').value )+'&t='+escape(document.getElementById('txt_FeedB_text').value );
    var sc=document.createElement('script');
    sc.type='text/javascript';
    sc.id="scr__FeedB_SEND";
    sc.src= 'http://www.histats.com/viewstats/RECEIVE_FEEDBACK.php?' + FEEDBurlsend + '&math='+Math.random();
    //alert( sc.src);
    document.getElementsByTagName('head')[0].appendChild(sc);

}
function f_FeedB_SENt(){
    document.getElementById('div_FeedBcontainerfomr').innerHTML = '<font class="text16_blue">You message has been sent to histats staff,<br>  thank you , <br> Francesco Vigotti</font><br><br><a href="javascript:f_FeedB_closeForm();" class="text14_orange">CLOSE</a>';
}


function f_IPn_to_IPt(IPn){
    if(!IPn) return;
    var tmpSTRip = IPn+'';
    IPn = parseInt(tmpSTRip.substr((tmpSTRip.indexOf("_", 0)+1)));

    var d = IPn%256;
    for (var i = 3; i > 0; i--) {
        IPn = Math.floor(IPn/256);
        d = IPn%256 + '.' + d;
    }
    return d;
}

function f_IPt_to_IPn(IPt){
    if(!IPt) return;
    var d = IPt.split('.');
    return ((((((+d[0])*256)+(+d[1]))*256)+(+d[2]))*256)+(+d[3]);
}

function microtime (get_as_float) {
    var now = new Date().getTime() / 1000;
    var s = parseInt(now, 10);

    return (get_as_float) ? now : (Math.round((now - s) * 1000) / 1000) + ' ' + s;
}
//document.writeln(microtime(true) + '<br>');
//document.writeln(microtime(false) + '<br>');
function Vtimer_class() {
    this.AR =[];
    this.start = function(n){
        this.AR[n] = microtime(true);
    }
    this.stopget = function(n){
        var r=microtime(true) -this.AR[n];
        this.AR[n] = null;
        return r;
    }
    try {
    } catch(e){

    }
}
var Obj_vtimer = new Vtimer_class();

// -- > @ return 2 dimensional array with data sorted by the selected key [id original,value sorted]
function f_sort_BY_KEY(ar_tosort,key_TOSORTby,b_ASC){
    ar_key_sorted = [];
    var sortedCount = 0 ;
    for (var uniq_K in ar_tosort){
        if(ar_tosort[uniq_K][key_TOSORTby]){ // key exists
            ar_key_sorted[sortedCount] = [uniq_K,ar_tosort[uniq_K][key_TOSORTby]];

            sortedCount++;
        }
    }
    if(sortedCount > 0 ){

        if(b_ASC){
            ar_key_sorted.sort(sortMultiDimensional);
        }else{
            ar_key_sorted.sort(RsortMultiDimensional);
        }
    }
    return ar_key_sorted;
}
function sortMultiDimensional(a,b)
{
    // this sorts the array using the second element
    return ((a[1] < b[1]) ? -1 : ((a[1] > b[1]) ? 1 : 0));
}

function RsortMultiDimensional(a,b)
{
    // this sorts the array using the second element
    return ((a[1] > b[1]) ? -1 : ((a[1] < b[1]) ? 1 : 0));
}



/*-------------__LANG__*/
var CHSlang=function(){
    var t=0,z=2,s=2,a;
    //var t=0,z=1,s=1,a;
    function dd(n){
        this.n=n;
        this.h=[];
        this.c=[]
    }
    dd.prototype.init=function(p,c){
        a=c;
        var w=document.getElementById(p), s=w.getElementsByTagName('ul'), l=s.length, i=0;
        for(i;i<l;i++){
            var h=s[i].parentNode;
            this.h[i]=h;
            this.c[i]=s[i];
            h.onmouseover=new Function(this.n+'.st('+i+',true)');
            h.onmouseout=new Function(this.n+'.st('+i+')');
        }
    }
    dd.prototype.st=function(x,f){
        var c=this.c[x], h=this.h[x], p=h.getElementsByTagName('a')[0];
        clearInterval(c.t);
        c.style.overflow='hidden';
        if(f){
            p.className+=' '+a;
            if(!c.mh){
                c.style.display='block';
                c.style.height='';
                c.mh=c.offsetHeight;
                c.style.height=0
            }
            if(c.mh==c.offsetHeight){
                c.style.overflow='visible'
            }
            else{
                c.style.zIndex=z;
                z++;
                c.t=setInterval(function(){
                    sl(c,1)
                },t)
            }
        }else{
            p.className=p.className.replace(a,'');
            c.t=setInterval(function(){
                sl(c,-1)
            },t)
        }
    }
    function sl(c,f){
        var h=c.offsetHeight;
        if((h<=0&&f!=1)||(h>=c.mh&&f==1)){
            if(f==1){
                c.style.filter='';
                c.style.opacity=1;
                c.style.overflow='visible'
            }
            clearInterval(c.t);
            return
        }
        var d=(f==1)?Math.ceil((c.mh-h)/s):Math.ceil(h/s), o=h/c.mh;
        c.style.opacity=o;
        c.style.filter='alpha(opacity='+(o*100)+')';
        c.style.height=h+(d*f)+'px'
    }
    return{
        dd:dd
    }
}();

function f_PRT_lang(prtM){
    var stampaM = false;
    if(prtM) stampaM = prtM;
    if(!GL.AR_ALL_langstats ) return;
    var PRT = '';
    var ARtmp = new Array();

    if(stampaM==true){
        var conta = 0;
        var Wc = 0;
        var Wuc = 200;
        for(var t in GL.AR_ALL_langstats ){
            ARtmp [conta] = GL.AR_ALL_langstats [t]['name_lang'];
            conta++;
        }
        ARtmp.sort();

        for(var t =0;t<ARtmp.length;t++){
            for(var k in GL.AR_ALL_langstats ){
                if(GL.AR_ALL_langstats [k]['name_lang']==ARtmp[t]){
                    Wc = 0;
                    Wuc = 210;
                
                    Wc = parseInt(210/100*parseInt(GL.AR_ALL_langstats [k]['perc_completition']));
                    Wuc = 210-Wc;
                
                    PRT += '<li>\
                            <a href="javascript:f_CALL_SETlang('+GL.AR_ALL_langstats [k]['id_lang']+');" class="sub"><img src="http://usa1.ffcdn.net/images/flags/'+GL.AR_ALL_langstats [k]['2char_name']+'.gif" border="0"> '+GL.AR_ALL_langstats [k]['name_lang']+'</a>\
                            <ul >\
                                <li class="topline"><a href="javascript:f_CALL_SETlang('+GL.AR_ALL_langstats [k]['id_lang']+');" >Select this language</a></li>\
                                <li ><table border="0" width="100%" cellspacing="0" cellpadding="0"><tr><td>\
                                        <a href="http://www.histats.com/EXTERN_LOGIN_languages.php?LANGID='+GL.AR_ALL_langstats [k]['id_lang']+'&item_sorting=show_by_priority&category_id=1&item_per_page=5" style="padding-bottom:10px;">Help us to traslate,completed:'+GL.AR_ALL_langstats [k]['perc_completition']+'%\
                                        <table border="0" width="210" cellspacing="0" cellpadding="0" height="6" bgcolor="#CCCCCC"><tr>\
                                            <td width="'+Wc+'" bgcolor="#0066CC"></td>\
                                            <td width="'+Wuc+'"></td>\
                                        </tr></table></a>\
                                    </td></tr></table>\
                                </li>\
                            </ul>\
                        </li>';
                }
            }
        }
        $('#menuLang').html(PRT);
    }
    
    var PRT_setcurr = '<img src="http://usa1.ffcdn.net/images/flags/'+GL.AR_ALL_langstats[GLOB_lang_curr]['2char_name']+'.gif" border="0"> '+GL.AR_ALL_langstats[GLOB_lang_curr]['name_lang']+' <img border="0" src="http://usa1.ffcdn.net/images/ar_Dg.gif">';
    $('#langCurrSET').html(PRT_setcurr);
}

function f_CALL_SETlang(Nl){
    
    var nLang = 0;
    nLang = parseInt(Nl);

    var URLhost = '';
    var URLpath = '';
    var URLquery = '';
    var URLredir = '';
    
    URLhost = jQuery.url.attr("host");
    URLpath = jQuery.url.attr("path");
    URLquery = jQuery.url.attr("query");
    
    URLredir = 'http://'+URLhost;

    if(URLpath.length>0){
        URLredir += URLpath;
    }
    
    URLredir = URLredir.replace(/^\/([a-zA-Z]{2}\/)/g, "");
    

    URLredir += '?SETLANG='+nLang;

    if(URLquery.length>0){
        URLquery = URLquery.replace(/^(.*)([\&\?]{1}SETLANG=[0-9]*)(.*)/g, "$1$3");
        URLredir += '&'+URLquery;
    }

    window.location= URLredir;
}


if(!JSCACHE) JSCACHE = [] ;
JSCACHE.push(['f_UTILS_general.js',3]);
