// jq-aria.js: add wai aria attributes (role)
// version 1.1, 2010-12-07
// needs jQuery 1.3.x or higher
// * adds attribute role for all elements with class role_ROLENAME
// written by Markus Breitschuh <breitschuh@informedia.de>, 
// inspired by http://www.vorsprungdurchwebstandards.de/theory/7-gruende-wai-aria-landmarks-sofort-einzusetzen/
// see also http://www.w3.org/TR/wai-aria/roles
// use freely

$(document).ready(function() {
	// Widget Roles
	// The following roles act as standalone user interface widgets or as part of larger, composite widgets.
	jqaria_setRole("alert");
    jqaria_setRole("alertdialog");
    jqaria_setRole("button");
    jqaria_setRole("checkbox");
    jqaria_setRole("dialog");
    jqaria_setRole("gridcell");
    jqaria_setRole("link");
    jqaria_setRole("log");
    jqaria_setRole("marquee");
    jqaria_setRole("menuitem");
    jqaria_setRole("menuitemcheckbox");
    jqaria_setRole("menuitemradio");
    jqaria_setRole("option");
    jqaria_setRole("progressbar");
    jqaria_setRole("radio");
    jqaria_setRole("scrollbar");
    jqaria_setRole("slider");
    jqaria_setRole("spinbutton");
    jqaria_setRole("status");
    jqaria_setRole("tab");
    jqaria_setRole("tabpanel");
    jqaria_setRole("textbox");
    jqaria_setRole("timer");
    jqaria_setRole("tooltip");
    jqaria_setRole("treeitem");
    // The following roles act as composite user interface widgets. These roles typically act as containers that manage other, contained widgets.
	jqaria_setRole("combobox");
	jqaria_setRole("grid");
	jqaria_setRole("listbox");
	jqaria_setRole("menu");
	jqaria_setRole("menubar");
	jqaria_setRole("radiogroup");
	jqaria_setRole("tablist");
	jqaria_setRole("tree");
	jqaria_setRole("treegrid");
        
    // Document Structure    
    // The following roles describe structures that organize content in a page. Document structures are not usually interactive.
	jqaria_setRole("article");
	jqaria_setRole("columnheader");
	jqaria_setRole("definition");
	jqaria_setRole("directory");
	jqaria_setRole("document");
	jqaria_setRole("group");
	jqaria_setRole("heading");
	jqaria_setRole("img");
	jqaria_setRole("list");
	jqaria_setRole("listitem");
	jqaria_setRole("math");
	jqaria_setRole("note");
	jqaria_setRole("presentation");
	jqaria_setRole("region");
	jqaria_setRole("row");
	jqaria_setRole("rowheader");
	jqaria_setRole("separator");
	jqaria_setRole("toolbar");
    
    // Landmark Roles
	// The following roles are regions of the page intended as navigational landmarks. All of these roles inherit from the landmark base type and, with the exception of application, all are imported from the Role Attribute [ROLE]. The roles are included here in order to make them clearly part of the WAI-ARIA Role taxonomy.
	jqaria_setRole("application");
	jqaria_setRole("banner");
	jqaria_setRole("complementary");
	jqaria_setRole("contentinfo");
	jqaria_setRole("form");
	jqaria_setRole("main");
	jqaria_setRole("navigation");
	jqaria_setRole("search");
});

function jqaria_setRole(role) {
	$(".role_"+role).attr("role",role).removeClass("role_"+role);
}
