/*
 *
 * Copyright 2005 Maxxor Business Solutions (Pty) Ltd. All Rights Reserved.
 *
 * http://www.maxxor.com/
 *
 * This software is the intellectual property of Maxxor Business Solutions (Pty) Ltd.
 * Unauthorised use is strictly forbidden.
 *
 */
 

// Developed by Mustapha Baboo
// Create the onmouse events for a list table's rows

var rowColour;

function genRowColours(tableName) {
    var allTRs
    allTRs = document.getElementById(tableName).getElementsByTagName("tr")
    for (var i = 0; i < allTRs.length; i++) {
        
        // Alternate row background colours
        if (i%2==1) {
        	allTRs[i].className = "RowA"
	} else {
        	allTRs[i].className = "RowB"
	}
    }
}

function genMouseOver(tableName) {
    var allTRs
    allTRs = document.getElementById(tableName).getElementsByTagName("tr")
    for (var i = 0; i < allTRs.length; i++) {
        allTRs[i].onmouseover = function() {
            hilite(this)
        }
        allTRs[i].onmouseout = function() {
            unhilite(this)
        }
    }
}


// Change style to highlight a row 

function hilite(row) {
    row.className = 'list-hilite'
}

// Change style to un-highlight a row 

function unhilite(row) { 
    row.className = "gray12"
}


// Check and set a multi-row action for a list table 

function setMultiAction(form,action,field) {

    // Check that at least one item has been selected. 
    checked = false;
    for (i = 0; i < field.length; i++)
        checked = checked || field[i].checked; 

    // At least one item selected from a list 
    // OR there is only one item & it is selected
    
    if (checked || field.checked) {
        if (action == "delete") {
            if (confirm('Confirm deletion')) { 
                form.action.value=action;
                form.submit();
            }
        }
    } else { 
        alert("Please select at least one item!");
    } 
}


// Switch all the selections for a multi-row action for a list table 

function toggleAll(field) {
    for (i = 0; i < field.length; i++)
        field[i].checked = !(field[i].checked);
        
    if (!field.length > 0)
        field.checked = !field.checked;
}
