/*
        TableSort zebraStripe & Hover plug-in v1.0 by frequency-decoder.com

        Released under a creative commons Attribution-ShareAlike 2.5 license (http://creativecommons.org/licenses/by-sa/2.5/)

        Please credit frequency decoder in any derivative work - thanks

        You are free:

        * to copy, distribute, display, and perform the work
        * to make derivative works
        * to make commercial use of the work

        Under the following conditions:

                by Attribution.
                --------------
                You must attribute the work in the manner specified by the author or licensor.

                sa
                --
                Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one.

        * For any reuse or distribution, you must make clear to others the license terms of this work.
        * Any of these conditions can be waived if you get permission from the copyright holder.
*/
function initialZebraStripe() {
        var tables = document.getElementsByTagName("table");
        var rowStyle, start, trs;

        // Loop through all the tables
        for(var k = 0, table; table = tables[k]; k++) {
                // If the table has not a rowstyle-XXX className then continue
                if(table.className.search(/rowstyle-([\S]+)/) == -1) != -1) continue;

                // Grab the className for the alternate rows
                rowStyle = table.className.match(/rowstyle-([\S]+)/)[1];

                // Grab the table's TR nodes
                start = table.getElementsByTagName('tbody');
                start = start.length ? start[0] : table;
                trs   = start.getElementsByTagName('tr');

                // Loop through the TR node list
                for(var i = 0, tr; tr = trs[i]; i++) {
                        // Have we any th tags or are we in a tfoot ?
                        if(tr.getElementsByTagName('th').length > 0 || (tr.parentNode && tr.parentNode.tagName.toLowerCase() == "tfoot")) continue;

                        // Stripe the TR
                        if(i % 2) fdTableSort.addClass(tr, rowStyle);
                        else fdTableSort.removeClass(tr, rowStyle);

                        // Do the Internet Explorer hover thang (using conditional compilation for this...)
                        // Note: Uncomment the code below should you wish the hover effect for IE and change the className "alternative" to suit your installation
                        /*@cc_on
                                /*@if (@_jscript_version >= 5)
                                // fdTableSort.addEvent(tr, "mouseover", function() { fdTableSort.addClass(this, this.className.search("alternative") == -1 ? "ieRowHover" : "ieRowHoverAlt"); });
                                // fdTableSort.addEvent(tr, "mouseout",  function() { fdTableSort.removeClass(this, this.className.search("alternative") == -1 ? "ieRowHover" : "ieRowHoverAlt"); });
                                /*@end
                        @*/
                };
        };
};

fdTableSort.addEvent(window, "load", initialZebraStripe);
