<!--

/**
 * Admin Functions
 */

jQuery(document).ready(function() {

    // Delete Record

    jQuery('a.delete').click(function() {
        if (confirm('Delete this record?')) {
            jQuery('#list').attr('action', jQuery(this).attr('href'));
            jQuery('#list').submit();
        }
        return false;
    });

});


/**
 * Legacy Admin Functions
 */

function sortResults(str_sort)
{
    var obj_form = document.forms['list'];
    var obj_sort = obj_form.elements['sort'];
    var obj_sdir = obj_form.elements['sdir'];

    if (obj_sort.value == str_sort) {
        obj_sdir.value = (obj_sdir.value.toUpperCase() == 'ASC') ? 'DESC' :  'ASC';
    } else {
        obj_sort.value = str_sort;
        obj_sdir.value = 'ASC';
    }

    obj_form.submit();
}


function deleteChecked(strDeleteAction)
{
    if (!strDeleteAction) {
        strDeleteAction = '/delete';
    }

    if (confirm('Delete all checked rows?')) {
        document.forms['list'].action = document.forms['list'].action + strDeleteAction;
        document.forms['list'].submit();
    }
}


function testLink(str_url)
{
    if (str_url) {
        if (str_url.indexOf('http') != 0) str_url = 'http://' + window.location.hostname + '/' + str_url;
        day = new Date();
        id  = day.getTime();
        eval("page" + id + " = window.open(str_url, '" + id + "', 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=640,height=480,left=0,top=0');");
    } else {
        alert("No link to test.");
    }
}


function printPage()
{
    if (window.print) {
        setTimeout('window.print();', 50);
    } else if (navigator.platform.indexOf('Win') != -1) {
        alert("Press 'Ctrl+P' on your keyboard to print.");
    } else {
        alert("Press 'Cmd+P' on your keyboard to print.");
    }
}

// -->
