﻿/*
  filename: page_list.js
*/

$(document).ready(main);

function main() {
    // inicia la pagina normal
    if (page_pgGoogleSearch != 1) {
        list_RowCount = true;
        page_link = 'cms_load_list(pgRowPageIndex);';
        pgRowsPerPage = page_pgRowsPerPage;
        pagination_init2(0, page_pgTotalRows);
    }
}

function cms_load_list(row) {
    
    document.location.href = page_href + '#top';

    $.ajax({ async:true,
        type: "POST",
        url: "page_list.aspx",
        data: "ajax_cmd=get_list&type=" + page_pType + "&row=" + row + "&row_count=" + list_RowCount + "&cache_id=" + pTitleHash + "&title=" + pTitle,
        success: function(response) {cms_load_list_success(response);},
        error: cms_load_list_error,
        timeout:40000
    });    

    $('#main_articulos').fadeTo(100, 0.5);
}

function cms_load_list_success(response) {
/*
    var lines = response.split('|');
    
    alert(lines.length);
    for (var a=0; a<lines.length; a++){
        alert(a);
        eval(lines[a]);
    }
    
    //eval(response);

    for (var i=0; i<oresult.html.lenght; i++) {
    alert(i);
    $('#article_wrap').html(oresult.html[i]);
    }
*/    

    eval(response);
    $('#article_wrap').html(oresult.html);

    pagination_button_active();
    
    if (pgRowsCount > pgRowsPerPage) $('#pagination').show();

    $('#loader').hide();
    $('#main_articulos').fadeTo(1000, 1);
}

function cms_load_list_error(XMLHttpRequest, textStatus, errorThrown) {
    $('#loader').hide();
    document.location.href = '#top';
}

function go_filter(url) {
    document.getElementById('form1').action = url;
    document.getElementById('form1').submit();
}
    
