<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>{TITLE}</title>
{_META_HEAD_CONTENIDO_}
{_CSS_HEAD_CONTENIDO_}
{_JS_HEAD_CONTENIDO_}
    <script type="text/javascript" src="scripts/rowMark.js"></script>
    <script type="text/javascript" src="scripts/articleObject.js.php?contenido={_SID_}"></script>

</head>
<body style="margin:10px;">
    <!--vertical-ailgn:middle;-->
    <div style="border:1px solid #B3B3B3; background:#E2E2E2; margin:0 0 10px 0; padding:2px;line-height:20px;">{TITLE}</div>

    <table width="100%" border="0" cellspacing="0" cellpadding="2" class="bordered">
    <tr>
        <td width="1%" class="headerbordercell" nowrap="nowrap">{TH_START}</td>
        <td width="100%" class="headerbordercell sortable" id="col-title" nowrap="nowrap">{TH_TITLE}</td>
        <td width="1%" class="headerbordercell sortable" id="col-lastmodified" nowrap="nowrap">{TH_CHANGED}</td>
        <td width="1%" class="headerbordercell sortable" id="col-published" nowrap="nowrap">{TH_PUBLISHED}</td>
        <td width="1%" class="headerbordercell sortable" id="col-artsort" nowrap="nowrap">{TH_SORTORDER}</td>
        <td width="1%" class="headerbordercell" nowrap="nowrap">{TH_TEMPLATE}</td>
        <td width="1%" class="headerbordercell" nowrap="nowrap">{TH_ACTIONS}</td>
    </tr>

    <!-- BEGIN:BLOCK -->
    {ROWS}
    <!-- END:BLOCK -->

    </table>

    <div id="store_search" style="margin-top: 20px;">
        <b>{STORESEARCHINFO}</b><br><br>
        {STORESEARCHFORM}
    </div>

    <div style="margin-top: 20px">{SEARCHSTOREDMESSAGE}</div>

<script type="text/javascript">
// Function for deleting articles
function deleteArticle(idart, idcat) {
    var url = Con.UtilUrl.build('main.php', {
        area: 'con',
        action: 'con_deleteart',
        frame: 4,
        idcat: idcat,
        idart: idart
    });
    window.location.href = url;
}

// Appends the given form value to the given form as a hidden input field.
function appendFormField(form, name, value) {
    // if a hidden input field with the given name already exists, just set the value
    if ($(form).find('input[type="hidden"][name="' + name + '"]').length > 0) {
        $(form).find('input[type="hidden"][name="' + name + '"]').val(value);
    } else {
        // otherwise append a new field to the form
        $(form).append('<input type="hidden" value="' + value + '" name="' + name + '">');
    }
}

// make the article table sortable
(function(Con, $) {
    $(function() {
        $('td.sortable').css('cursor', 'pointer');
        $('td.sortable').click(function() {
            var currentSortby = '{CURRENT_SORTBY}';
            var currentSortmode = '{CURRENT_SORTMODE}';
            var id = $(this).attr('id').split('-')[1];
            var sortmode = 'asc';
            if (currentSortby == id && currentSortmode == 'asc') {
                sortmode = 'desc';
            }
            var searchForm = $('#backend_search', Con.getFrame('left_top').document);
            appendFormField(searchForm, 'sortby', id);
            appendFormField(searchForm, 'sortmode', sortmode);
            // searchForm.submit() does not work, so trigger click event on submit button
            searchForm.find('input[type="submit"]').click();
            return false;
        });
    });
})(Con, Con.$);

{SCRIPT}

var rcount = 0;

// Update frame right top for sub navigation
{SUBNAVI}

// Refresh top_left frame to show new saved searches
{REFRESH}

// Create a reference to the Article Object in frame 'right_top'
artObj = Con.getFrame('left_top').artObj;

/* Reset article object
   properties. e.g. Some article was edited and we are now back in the
   overview mask. There is now no marked article, the articleObject data
   should be reset.  */
if (artObj) {
    artObj.reset();
    artObj.enable();
    artObj.setHrefOverview(document.location.href);
}

// Timeout to call the function afer 250ms
window.setTimeout(function() {
    createReference();
}, 250);

Con.markSubmenuItem('c_0');

// Javascript-Error work-around... try to create the reference after
// 250ms again... and hope it works..
function createReference() {
    if (!artObj) {
        artObj = Con.getFrame('left_top').artObj;
        if (artObj) {
            artObj.reset();
            artObj.enable();
            artObj.setHrefOverview(document.location.href);
        }
    }
    if (!artObj) {
        return false;
    }
}

// Extract data from the article grid and send them to the articleObject Instance. The data is
// stored in the attribute 'id' of the row object.
function conArtOverviewExtractData(obj) {
    if (!artObj) {
        var rval = createReference();
        if (rval == false) {
            return false;
        }
    }

    var datastring = obj.id;
    var data = datastring.split("-");

    if (data.length === 6) {
        /* Send data to articleObject instance:
            0: idart
            1: idartlang
            2: idcat
            3: idcatlang
            5: idcatart */
        artObj.setProperties(data[0], data[1], data[2], data[3], data[4], data[5]);
    }
    return true;
}

// Function for sorting the articles
function artSort(selObj) {
    var i = selObj.selectedIndex;
    var sortkey = selObj.options[i].value;
    // @TODO Why do we have idcat 57 here?
    var url = Con.UtilUrl.build('main.php', {area: 'con', frame: '4', idcat: 57, sort: sortkey});
    window.location.href = url;
}

function initTheOne() {
   var theOne = document.getElementById("{FIRST_ROWID}");
   artRow.reset();
   artRow.over(theOne);
   artRow.click(theOne)
}

initTheOne();
</script>
</body>
</html>
