/** 
 * Scripts for adding extra functionality and usability
 * to the (X)HTML best practice table
 * 
 * @todo: headers/id for every cell
 * @todo: Add title information on cells depending on content
 * @todo: Filter which columns and rows one chooses to see
 */

/**
 * Set alternating row background color if browser has no CSS 3 support
 *
 */
(function() {
	
	if ( !document.getElementsByTagName) {
		return;
		// No DOM support
	}
	
	// Check for CSS and more advanced DOM capabilities
	if ( document.defaultView && document.defaultView.getComputedStyle ) {
		var testRow = document.getElementsByTagName("tbody")[0].getElementsByTagName("tr")[0];
		if ( document.defaultView.getComputedStyle(testRow, null).getPropertyValue("background-color") != "transparent" ) {
			// Some background value has been set through CSS 3 selectors
			return;
		}
	}
    // Find alternate rows in table
    var tablebodies = document.getElementsByTagName("tbody");
    var tblength = tablebodies.length;
    for ( var i = 0; i < tblength; i++ ) {
        var rows = tablebodies[i].getElementsByTagName("tr");
        var trlength = rows.length;
        // Apply classname to odd rows
        for ( var j = 0; j < trlength; j++ ) {
            if ( j % 2  == 0 ) {
                rows[j].className = "odd";
            }
        }
    }
})();
// Ugly global code...
if (browser_supports_moz_transform) {
	var experimental = document.createElement("p");
	experimental.className ="noprint";
	experimental.innerHTML = "You are probably using Firefox 3.5 or another browser based on Gecko 1.9.1 or newer. " +
		"<em>Experimental features</em> have been turned on. <a href=\"http://keryx.se/contact.php\">Please contact " +
		"Lars Gunther</a> to report any issues.";
	var intropara = document.getElementsByTagName("p")[0];
    document.getElementsByTagName("body")[0].insertBefore(experimental, intropara);
}
