

function histats_registration_class() {
    try {

        

    } catch(e){
        alert("err loading javascript ,    try refreshing browser cache \n "  + e.message + "\n ");
    }
	
} // end
//
// build online average values based on vis
var G_reg = new histats_registration_class();

// return single sid row 
histats_registration_class.prototype.f_return_CP_singleSID  = function(sid){
    if(!G_AR_SITES[sid]) return '';
    var PTR = G_AR_SITES[sid];
    var tmpHTML = ' <br> row site: ' + sid+" -> " + PTR['iu'];
    return tmpHTML;
}

histats_registration_class.prototype.f_return_LIST_SITES  = function(){
    var tmpHTML = 'head tabella sites<br>';

    if(f_array_size(G_AR_SITES) > 0 ){
        for(sid in G_AR_SITES){
            tmpHTML+=  this.f_return_CP_singleSID(sid);
        }
      
    }
    tmpHTML+= '<br> fine tabella sites';


    
    return tmpHTML;
}


histats_registration_class.prototype._show_step1  = function(){

    // hide string step1/2
    document.getElementById('div_ACCOUNT_string_step1').style.display = 'none';
    document.getElementById('div_ACCOUNT_string_step2').style.display = 'none';
    document.getElementById('div_ACCOUNT_string_continuereg_BTN').style.display = 'block';


    document.getElementById('div_ACCOUNT_reg_step1').style.display = 'block';
    document.getElementById('div_ACCOUNT_reg_step2').style.display = 'none';
    document.getElementById('B5').value = 'Continue' ;
}



histats_registration_class.prototype._show_step2  = function(){

    // hide string step1/2
    document.getElementById('div_ACCOUNT_string_step1').style.display = 'none';
    document.getElementById('div_ACCOUNT_string_step2').style.display = 'none';
    document.getElementById('div_ACCOUNT_string_continuereg_BTN').style.display = 'none';

    
    document.getElementById('div_ACCOUNT_reg_step1').style.display = 'none';
    document.getElementById('div_ACCOUNT_reg_step2').style.display = 'block';
    document.getElementById('B5').value = GL.R('save') ;
}

// show both steps
histats_registration_class.prototype._show_edit  = function(){

    // hide string step1/2
    document.getElementById('div_ACCOUNT_string_step1').style.display = 'none';
    document.getElementById('div_ACCOUNT_string_step2').style.display = 'none';
    document.getElementById('div_ACCOUNT_string_continuereg_BTN').style.display = 'none';


    document.getElementById('div_ACCOUNT_reg_step1').style.display = 'block';
    document.getElementById('div_ACCOUNT_reg_step2').style.display = 'block';
    document.getElementById('B5').value = 'UPDATE' ;
}

histats_registration_class.prototype.PRINT_MAIN  = function(){

    this._show_step1();
    this.FILL_DATA();
    return;

    var tmpHTML = this.f_return_LIST_SITES();

    document.getElementById('HISTATS_CONTROL_PANEL').innerHTML = tmpHTML;
   
    if(G_AR_SUBu) print_r(G_AR_SUBu);
}

histats_registration_class.prototype.FILL_DATA  = function(){
    if(!ARjs_DATA_ACCOUNT){
        alert('you cannot edit account , error has occurred, please contact histats staff!');
        return ;
    }

    if(!ARjs_DATA_ACCOUNT['idu']) return ;
    if(ARjs_DATA_ACCOUNT['idu'] < 1 ) return ;
    //print_r(ARjs_DATA_ACCOUNT);




    document.getElementById('hid_ACCOUNT_edit_id').value=ARjs_DATA_ACCOUNT['idu'];
    document.getElementById('txt_ACCOUNT_edit_mail').value=ARjs_DATA_ACCOUNT['email'];
    document.getElementById('txt_ACCOUNT_edit_mailC').value=ARjs_DATA_ACCOUNT['email'];

    document.getElementById('txt_ACCOUNT_edit_pass').value=ARjs_DATA_ACCOUNT['pass'];
    document.getElementById('txt_ACCOUNT_edit_passC').value=ARjs_DATA_ACCOUNT['pass'];


    document.getElementById('txt_ACCOUNT_edit_name').value=ARjs_DATA_ACCOUNT['name'];
    document.getElementById('txt_ACCOUNT_edit_Sname').value=ARjs_DATA_ACCOUNT['sname'];
    document.getElementById('txt_ACCOUNT_edit_address').value=ARjs_DATA_ACCOUNT['address'];
    document.getElementById('txt_ACCOUNT_edit_city').value=ARjs_DATA_ACCOUNT['city'];
    document.getElementById('txt_ACCOUNT_edit_country').value=ARjs_DATA_ACCOUNT['country'];
    document.getElementById('txt_ACCOUNT_edit_phone').value=ARjs_DATA_ACCOUNT['phone'];
    document.getElementById('txt_ACCOUNT_edit_mobile').value=ARjs_DATA_ACCOUNT['mobile'];
    document.getElementById('chk_ACCOUNT_edit_terms').checked = true ;
    document.getElementById('TXT_HIDDEN_TIMEZONE').value=ARjs_DATA_ACCOUNT['txzone']  ;
    //alert('select timezone : ' + ARjs_DATA_ACCOUNT['txzone'] );
    G_TZ_form.ACTION_selected_AllTZ(G_TZ_form.get_id_BY_ZONENAME(ARjs_DATA_ACCOUNT['txzone']));
    G_TZ_form.BOOL_BLOCK_AUTOSET_TIMEZONE = true; // block the autoset
    this._show_edit();
/*
 * [idu] => 2
    [email] => histats.support1@gmail.com
    [pass] => EDIT-TO-CHANGE
    [name] =>
    [sname] =>
    [address] =>
    [city] =>
    [country] =>
    [phone] =>
    [mobile] =>
    [idtz] => 440
    [txzone] => Pacific/Niue

 */
}



histats_registration_class.prototype.CHECK_REGISTRATION_DATA  = function(nSTEP){
    var txt_alert = '';
    document.getElementById('TXT_HIDDEN_TIMEZONE').value=G_TZ_form.TXT_SELECTED_ZONEname  ;
    
    if(nSTEP==2){
        if(document.getElementById('txt_ACCOUNT_edit_mail').value=='') txt_alert += 'MAIL field is required\n\n';
        if(document.getElementById('txt_ACCOUNT_edit_mailC').value=='') txt_alert += 'MAIL CONFIRMATION field is required\n\n';
        if(document.getElementById('txt_ACCOUNT_edit_pass').value=='') txt_alert += 'PASSWORD field is required\n\n';
        if(document.getElementById('txt_ACCOUNT_edit_passC').value=='') txt_alert += 'PASSWORD CONFIRMATION field is required\n\n';
        if((document.getElementById('txt_ACCOUNT_edit_mailC').value != document.getElementById('txt_ACCOUNT_edit_mail').value) && document.getElementById('txt_ACCOUNT_edit_mail').value!='') txt_alert += 'email CONFIRMATION didn\'t match\n';
        if((document.getElementById('txt_ACCOUNT_edit_passC').value != document.getElementById('txt_ACCOUNT_edit_pass').value) && document.getElementById('txt_ACCOUNT_edit_pass').value!='') txt_alert += 'password CONFIRMATION didn\'t match \n';
        if(txt_alert.length>0){
            alert(txt_alert);
            return 999;
        }
    }else{
        if(document.getElementById('chk_ACCOUNT_edit_terms').checked==false) txt_alert += 'you must AGREE "Agreement Terms"\n\n';
        if(txt_alert.length>0){
            alert(txt_alert);
            return false ;
        }else{
            return true ;
        }
    }   
}

histats_registration_class.prototype.f_accountEDIT_check_retypeF  = function(nSTEP){
    var boolReturn = true;
    if(nSTEP==1){
        var Fmail = document.getElementById('txt_ACCOUNT_edit_mail').value;
        var FmailC = document.getElementById('txt_ACCOUNT_edit_mailC').value;
        var Fpass = document.getElementById('txt_ACCOUNT_edit_pass').value;
        var FpassC = document.getElementById('txt_ACCOUNT_edit_passC').value;

        if((Fmail.length>0 || FmailC.length>0) &&(Fmail!=FmailC)){
            alert('Incorrect retype mail');
            boolReturn = false;
        }
        if((Fpass.length>0 || FpassC.length>0) &&(Fpass!=FpassC)){
            alert('Incorrect retype password');
            boolReturn = false;
        }
    }else if(nSTEP==2){
        if(document.getElementById('chk_ACCOUNT_edit_terms').checked==false){
            alert('you must AGREE "Agreement Terms"');
            boolReturn = false ;
        }else{
            boolReturn = true ;
        }
    }
    return boolReturn;
}


if(!JSCACHE) JSCACHE = [] ;
JSCACHE.push(['registration.class.js',1]);
