class source: Toolbar Example 2


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:wairole="http://www.w3.org/2005/01/wai-rdf/GUIRoleTaxonomy#"
      xmlns:aaa="http://www.w3.org/2005/07/aaa">

<head>
  <title>class: Toolbar Example 2</title>


<style type="text/css">
#container ul[role="toolbar"]{
  float: left;
  text-align: center;
  padding-bottom: .25em;
  padding-top: .25em;
  padding-left: .25em;
  list-style: none;
  border-top: black 1px solid;
  border-left: black 1px solid;
  border-bottom: black 1px solid;
  border-right:  black 1px solid;
  
}

#container li[role="button"]{
  float: left;
  text-align: center;
  padding-right: .25em;
  height: 100%;
  list-style: none;
}

#container ul div.italic{

font-style: italic;

}

textarea.example1 {
  clear: both;
  padding: .25em;
  width: 50%;
  height: 200px;
  
}
textarea.example2 {
  clear: both;
  padding: .25em;
  width: 50%;
  height: 200px;
  font-style:italic;
}

.hide {
position: absolute;
top: -20em;
left: -200em;
}

</style>

<script type="text/javascript">

//toolbar2_class.js


/**
*
* The Toolbar object is used to maintain information about a group of button widgets
*
* @constructor
*/

function Toolbar( id ) {

  this.id = id;
  this.buttons = new Array();
  this.button_selected = -1;
  this.button_focus = -1;

}  //end Toolbar

/**
* init is a subclass of Toolbar and is used to initialize the event handlers
*
* @member Toolbar
*
* @return none
*/

Toolbar.prototype.init = function() {
  
  var obj = this;
  this.node = document.getElementById(this.id);

  
  // Initialize Buttons
  for(var i = 0; i < this.buttons.length; i++ ) {
  this.buttons[i].init();
  } // end for
  
  // Check to see if any buttons are selected in the toolbar from markup
  for(var i = 0; i < this.buttons.length; i++ ) {

    
    if( this.buttons[i].node.getAttribute("aria-pressed") =="true") {
    selectButton( this, i, false );
    }
    
  } // endfor  
  
  // Add event handlers for first and last buttons to emulate IE button behavior for TAB navigation
  browser.addEvent(this.buttons[0].node, "focus", function(event) {handleButtonFirstFocus(event, obj);}, false);
  browser.addEvent(this.buttons[0].node, "blur", function(event) {handleButtonFirstBlur(event, obj);}, false);
  browser.addEvent(this.buttons[this.buttons.length-1].node, "focus", function(event) {handleButtonLastFocus(event, obj);}, false);
  browser.addEvent(this.buttons[this.buttons.length-1].node, "blur", function(event) {handleButtonLastBlur(event, obj);}, false);
    
  // Add event handlers for selecting a button
  browser.addEvent(this.node, "keydown", function(event) {handleToolbarKeyDownEvent(event, obj);}, false);

} // end Toolbar.prototype.init

/**
* add is a subclass of Toolbar and adds a Button object to the Toolbar list
*
* @member Toolbar
*
* @param ( Button object ) obj button to be added to button list
*
* @return none
*/

Toolbar.prototype.add = function( obj ) {

  this.buttons[this.buttons.length] = obj;

} // end Toolbar.prototype.add

/**
* selectButton is called by event handlers to select one of the buttons in a toolbar
*
* @param ( Toolbar object ) toolbar  Toolbar to change selected button
* @param ( integer ) index Index of button to be selected
* @param ( integer ) focus_flag If value is set to 1 then keyboard focus will be moved to the selected button
*
* @return none
*/

function selectButton( toolbar, index, focus_flag) {

  // Check to see if index is larger than the number of buttons, if so wrap to first button
  
  if( index >= toolbar.buttons.length )
    index = 0;

  // Check to see if index is less than zero, if so wrap to last button
  
  if( index < 0)
    index = toolbar.buttons.length - 1;

  // Check to make sure the index value is valid before changin states

  if( (index >= 0 ) && (index < toolbar.buttons.length) ) {

    // Set all buttons to not selected
    // CSS selectors based on the "pressed" attribute value change the visual rendering
    // The pressed attribute is used communicate button state information to assitive technologies
    // Tabindex is set to -1 so the control can still receive focus, but is removed from tab order

    for(var i = 0; i < toolbar.buttons.length; i++ ) {
        toolbar.buttons[i].node.tabIndex = -1;
    }  // endfor

    // Set radio button based on the index value
    // CSS selectors based on the "pressed" attribute change the visual rendering
    // The pressed attribute is used communicate radio button state information to assitive technologies
    // Tabindex is set to 0 so the control is added to tab order
  
    
    toolbar.buttons[index].node.tabIndex = 0;
  toolbar.buttons[index].image_node.src= toolbar.buttons[index].pressed;
  
  // Check focus flag to see if keyboard focus should be moved to selected control
  if( focus_flag ) {
      toolbar.buttons[index].node.focus();
  }  // endif
  
  toolbar.button_focus = index;

    // Keep track of the last button selected
    
    toolbar.button_selected = index;

  } // endif
  
} // end selectButton

/**
* Button Object
*
* @param ( id ) id of text to style
*
* @return none
*/

function Button( id, pressed, unpressed, focus_pressed, focus_unpressed ) {

   this.id = id;
   this.pressed = pressed;
   this.unpressed = unpressed;
   this.focus_pressed = focus_pressed;
   this.focus_unpressed = focus_unpressed;
  
} // end Button

/**
* Button Object
*
* @param ( id ) id of text to style
*
* @return none
*/

Button.prototype.init = function() {

  this.node = document.getElementById(this.id);
  this.image_node = this.node.getElementsByTagName("img")[0];
  
  var obj = this;
  
  // Add event handlers for pressing a button
  browser.addEvent(this.node, "keydown", function(event) {handleButtonKeyDownEvent(event, obj);}, false);
  browser.addEvent(this.node, "keyup",   function(event) {handleButtonKeyUpEvent(event, obj); },  false);
  
  browser.addEvent(this.node, "mousedown", function(event) {handleButtonMouseDownEvent(event, obj);}, false);
  browser.addEvent(this.node, "mouseup",   function(event) {handleButtonMouseUpEvent(event, obj); },  false);

  // Add event handlers for a button geeting and losing focus
  browser.addEvent(this.node, "focus", function(event) {handleButtonFocusEvent(event, obj);}, false);
  browser.addEvent(this.node, "blur",  function(event) {handleButtonBlurEvent(event, obj); }, false);
  

} // end Button.prototype.init



/**
* handleButtonFocusEvent processes keys associated with a button
*
* @param ( event ) event is the event handler for the event
* @param ( Button object ) button is the Button object that is the target of the keyboard event
*
* @return false if keyboard event was used by button, else true
*/

handleButtonFocusEvent = function(event, button) {
  if( button.node.getAttribute("aria-pressed") == "true" ) {
    //use the focus highlighting for a pressed button
    button.image_node.src= button.focus_pressed;
    }
  else{
    //use the focus highlighting for an unpressed button
    button.image_node.src= button.focus_unpressed;
    }
  return true;

} // end handleButtonFocusEvent

/**
* handleButtonBlurEvent processes keys associated with a button
*
* @param ( event ) event is the event handler for the event
* @param ( Button object ) button is the Button object that is the target of the keyboard event
*
* @return false if keyboard event was used by button, else true
*/

handleButtonBlurEvent = function(event, button) {

   if( button.node.getAttribute("aria-pressed") == "true" ) {
    //use the focus highlighting for a pressed button
    button.image_node.src= button.pressed;
  } else {
    //use the focus highlighting for an unpressed button
    button.image_node.src= button.unpressed;
  } // endif

  return true;

} // end handleButtonBlurEvent

/**
* handleButtonFirstFocus processes onFocus event when TAB has been pressed  
*
* @param ( event ) event is the event handler for the event
* @param ( Toolbar object ) toolbar is the Toolbar object that is the target of the keyboard event
*
* @return false if keyboard event was used by toolbar, else true
*/


function handleButtonFirstFocus( event, toolbar, button ) {

  // check to see if any buttons are selected
  if( toolbar.button_selected < 0 ) {
    
  // if a button is not selected, remove the last button to tab order  
    toolbar.buttons[toolbar.buttons.length-1].node.tabIndex = -1;

  // keep track of the last button with focus
  toolbar.button_focus = 0;
  
  //focus on first by adding the highlight
  if(toolbar.buttons[0].node.getAttribute("aria-pressed") == "true"){
    toolbar.buttons[0].image_node.src= toolbar.buttons[0].focus_pressed;
  }else{
    toolbar.buttons[0].image_node.src= toolbar.buttons[0].focus_unpressed;
  }//endif
      
  } // end if
  return true;

} // end handleButtonFirstFocus

/**
* handleButtonFirstBlur processes onBlur event when TAB has been pressed  
*
* @param ( event ) event is the event handler for the event
* @param ( Toolbar object ) toolbar is the Toolbar object that is the target of the keyboard event
*
* @return false if keyboard event was used by toolbar, else true
*/


function handleButtonFirstBlur( event, toolbar, button ) {

  // check to see if any buttons are selected
  if( toolbar.button_selected < 0 ) {
    
  // if a button is not selected, add the last button to tab order  
    toolbar.buttons[toolbar.buttons.length-1].node.tabIndex = 0;
  
  //blur button
  if(toolbar.buttons[0].node.getAttribute("aria-pressed") == "true"){
    toolbar.buttons[0].image_node.src= toolbar.buttons[0].pressed;
  }else{
    toolbar.buttons[0].image_node.src= toolbar.buttons[0].unpressed;
  }//endif
  
  } // end if
  
  return true;

} // end handleButtonFirstBlur

/**
* handleButtonLastFocus processes onFocus event when SHIFT+TAB has been pressed  
*
* @param ( event ) event is the event handler for the event
* @param ( Toolbar object ) toolbar is the Toolbar object that is the target of the keyboard event
*
* @return false if keyboard event was used by toolbar, else true
*/


function handleButtonLastFocus( event, toolbar, button ) {

  // check to see if any buttons are selected
  if( toolbar.button_selected < 0 ) {
    
  // if a button is not selected, remove the first button to tab order  
    toolbar.buttons[0].node.tabIndex = -1;
      
  // keep track of the last button with focus
  toolbar.button_focus = toolbar.buttons.length-1;
  
  //highlight the button that is in focus
  if(toolbar.buttons[toolbar.buttons.length-1].node.getAttribute("aria-pressed") == "true"){
  toolbar.buttons[toolbar.buttons.length-1].image_node.src= toolbar.buttons[toolbar.buttons.length-1].focus_pressed;
  }else{
  toolbar.buttons[toolbar.buttons.length-1].image_node.src= toolbar.buttons[toolbar.buttons.length-1].focus_unpressed;
  }//endif
      
  } // end if
  
  return true;

} // end handleButtonLastFocus

/**
* handleButtonLastBlur processes onBlur event when SHIFT+TAB has been pressed  
*
* @param ( event ) event is the event handler for the event
* @param ( Toolbar object ) toolbar is the Toolbar object that is the target of the keyboard event
*
* @return false if keyboard event was used by toolbar, else true
*/


function handleButtonLastBlur( event, toolbar, button ) {

  // check to see if any buttons are selected
  if( toolbar.button_selected < 0 ) {
    
  // if a button is not selected, then add the first button to tab order  
    toolbar.buttons[0].node.tabIndex = 0;
  
  //blur button
  if(toolbar.buttons[toolbar.buttons.length-1].node.getAttribute("aria-pressed") == "true"){
  toolbar.buttons[toolbar.buttons.length-1].image_node.src= toolbar.buttons[toolbar.buttons.length-1].pressed;
  }else{
  toolbar.buttons[toolbar.buttons.length-1].image_node.src= toolbar.buttons[toolbar.buttons.length-1].unpressed;
  }//endif
      
  } // end if
  
  return true;

} // end handleButtonLastBlur

/**
* handleToolbarKeyDownEvent processes keys associated with a toolbar
*
* @param ( event ) event is the event handler for the event
* @param ( Toolbar object ) toolbar is the Toolbar object that is the target of the keyboard event
*
* @return false if keyboard event was used by toolbar, else true
*/

function handleToolbarKeyDownEvent( event, toolbar, button ) {
  // If IE get the IE event object
  var e = event || window.event;
  
  // If any modifier keys are pressed do not process this event
  if( e.altKey || e.ctrlKey || e.shiftKey )
    return true;

  switch( e.keyCode ) {
  
    case KEY_RIGHT:
       // Hitting right will switch the focus and selected to the next item in the toolbar
         if( (toolbar.button_selected < 0 )  &&   (toolbar.button_focus >= 0 ) ){
       selectButton( toolbar, (toolbar.button_focus + 1), true);
     }
      
         else  {
      
           selectButton( toolbar, (toolbar.button_selected + 1), true);
     }
     // Tell browser we handled this event and not to process any other actions  
     return browser.stopPropagation( e );
       break;
  
  case KEY_LEFT:
       // Hitting left will switch the focus and selected to the previous item in the toolbar
         if( (toolbar.button_selected < 0 )  &&   (toolbar.button_focus >= 0 ) )
       selectButton( toolbar, (toolbar.button_focus - 1), true);
      
         else  
           selectButton( toolbar, (toolbar.button_selected - 1), true);
     if(toolbar.buttons[toolbar.button_focus].node.getAttribute("aria-pressed") == "true"){
      
      toolbar.buttons[toolbar.button_focus].node.setAttribute("aria-pressed", "true")      
     }
     else
     {
      toolbar.buttons[toolbar.button_focus].node.setAttribute("aria-pressed", "false")      
     }
     // Tell browser we handled this event and not to process any other actions    
     return browser.stopPropagation( e );
       break;
    
  case KEY_SPACE:
       // Hitting space will select the current item in the toolbar
         if( (toolbar.button_selected < 0 )  &&   (toolbar.button_focus >= 0 ) ){
       selectButton( toolbar, toolbar.button_focus, true);
     }
    
     // Tell browser we handled this event and not to process any other actions    
     return browser.stopPropagation( e );
       break;  
  
  } // end switch
} //end handleToolbarKeyDownEvent

/**
* handleButtonKeyDownEvent processes keys associated with a button
*
* @param ( event ) event is the event handler for the event
* @param ( Button object ) button is the Button object that is the target of the keyboard event
*
* @return false if keyboard event was used by button, else true
*/

handleButtonKeyDownEvent = function(event, button) {
  // If IE get the IE event object
  var e = event || window.event;

  switch( browser.keyCode(e) ) {

    case KEY_SPACE:
       // Tell assistive technologies that the button is currently pressed
       button.node.setAttribute("aria-pressed", "true");
     // Change the styling of the button to indicate it is pressed
         button.image_node.src = button.focus_pressed;
     // Tell browser we handled this event and not to process any other actions
         return browser.stopPropagation(e);
         break;

  }  // end switch

  return true;

} // end handleButtonKeyDownEvent

/**
* handleButtonKeyUpEvent processes keys associated with a button
*
* @param ( event ) event is the event handler for the event
* @param ( Button object ) button is the button object that is the target of the keyboard event
*
* @return false if keyboard event was used by button, else true
*/

handleButtonKeyUpEvent = function(event, button) {
  // If IE get the IE event object
  var e = event || window.event;

  switch( browser.keyCode(e) ) {

    case KEY_SPACE:
       // Tell assistive technologies that the button is not currently pressed
       button.node.setAttribute("aria-pressed", "false");
         button.image_node.src = button.focus_unpressed;
         browser.simulateOnClickEvent( button.node );
     // Tell browser we handled this event and not to process any other actions
         return browser.stopPropagation(e);
         break;

  }  // end switch

  return true;

} // end handleButtonKeyUpEvent

/**
* handleButtonMouseDownEvent processes keys associated with a button
*
* @param ( event ) event is the event handler for the event
* @param ( Button object ) button is the Button object that is the target of the keyboard event
*
* @return false if keyboard event was used by button, else true
*/

handleButtonMouseDownEvent = function(event, button) {
  // If IE get the IE event object
  var e = event || window.event;

  if( browser.target(e) == button.node || browser.target(e) == button.image_node) {
   // Tell assistive technologies that the button is currently pressed
     button.node.setAttribute("aria-pressed", "true");
   // Change the styling of the button to indicate it is pressed
     button.image_node.src = button.focus_pressed;
   //set focus
   button.node.focus();
   // Tell browser we handled this event and not to process any other actions
    return browser.stopPropagation(e);

  }  // end if

  return true;

} // end handleButtonMouseDownEvent

/**
* handleButtonMouseUpEvent processes keys associated with a button
*
* @param ( event ) event is the event handler for the event
* @param ( Button object ) button is the button object that is the target of the keyboard event
*
* @return false if keyboard event was used by button, else true
*/

handleButtonMouseUpEvent = function(event, button) {
  // If IE get the IE event object
  var e = event || window.event;
  // Tell assistive technologies that the button is not currently pressed
  button.node.setAttribute("aria-pressed", "false");
  button.image_node.src = button.focus_unpressed;

  if( browser.target(e) == button.node ) {
    
     browser.simulateOnClickEvent( button.node );
   // Tell browser we handled this event and not to process any other actions
     return browser.stopPropagation(e);
    
   }  // end if

  return true;

} // end handleButtonMouseUpEvent


/**
* ButtonToggle Object
*
* @param ( id ) id of text to style
*
* @return none
*/

function ButtonToggle( id, pressed, unpressed, focus_pressed, focus_unpressed ) {

   this.id = id;
   this.pressed = pressed;
   this.unpressed = unpressed;
   this.focus_pressed = focus_pressed;
   this.focus_unpressed = focus_unpressed;
  
} // end ButtonToggle

/**
* ButtonToggle Object
*
* @param ( id ) id of text to style
*
* @return none
*/

ButtonToggle.prototype.init = function() {

  this.node = document.getElementById(this.id);
  this.image_node = this.node.getElementsByTagName("img")[0];
  
  
  var obj = this;
  
  // Add event handlers for toggling a button
  browser.addEvent(this.node, "keydown",   function(event) {handleButtonToggleKeyDownEvent(event, obj);},   false);
  browser.addEvent(this.node, "mousedown", function(event) {handleButtonToggleMouseDownEvent(event, obj);}, false);
  
  // Add event handlers for a button getting and losing focus
  browser.addEvent(this.node, "focus", function(event) {handleButtonFocusEvent(event, obj);}, false);
  browser.addEvent(this.node, "blur",  function(event) {handleButtonBlurEvent(event, obj); }, false);
  
} // end ButtonToggle.prototype.init

/**
* toggleButton is called by event handlers to toggle the state of the button
*
* @param ( Button object ) button  Button to toggle state
*
* @return none
*/

toggleButton = function( button ) {

  if( button.node.getAttribute("aria-pressed") == "true" ) {

    // If the button is currently pressed set the state to not pressed  

    button.node.setAttribute("aria-pressed", "false");
    button.image_node.src = button.focus_unpressed;

  } else {

    // If the button is not currently pressed set the state to pressed  

    button.node.setAttribute("aria-pressed", "true");
    button.image_node.src = button.focus_pressed;

  }  // endif
  
  
} // end toggleButton

/**
* handleButtonToggleKeyDownEvent processes keys associated with a button
*
* @param ( event ) event is the event handler for the event
* @param ( Button object ) button is the Button object that is the target of the keyboard event
*
* @return false if keyboard event was used by radio group, else true
*/

handleButtonToggleKeyDownEvent = function(event, button) {
  // If IE get the IE event object
  var e = event || window.event;

  switch( browser.keyCode(e) ) {

    case KEY_SPACE:
       // Toggle the button
         toggleButton( button );
         browser.simulateOnClickEvent( button.node );
       // Tell browser we handled this event and not to process any other actions
         return browser.stopPropagation(e);
         break;

  }  // end switch

  return true;

} // end handleButtonToggleKeyDownEvent

/**
* handleButtonToggleMouseDownEvent processes keys associated with a button
*
* @param ( event ) event is the event handler for the event
* @param ( Button object ) button is the button object that is the target of the keyboard event
*
* @return false if keyboard event was used by button, else true
*/

handleButtonToggleMouseDownEvent = function(event, button) {
  // If IE get the IE event object
  var e = event || window.event;

  if( browser.target(e) == button.node || browser.target(e) == button.image_node) {
  // Toggle button
    toggleButton( button );
    browser.simulateOnClickEvent( button.node );
  //set focus on mouse press
  button.node.focus();
  // Tell browser we handled this event and not to process any other actions
    return browser.stopPropagation(e);
  }  // end if

  return true;

} // end handleButtonToggleMouseDownEvent


/**
* StateButton Object
*
* @param ( id ) id of text to style
*
* @return none
*/

function ButtonState( id, pressed, unpressed, focus_pressed, focus_unpressed ) {

   this.id = id;
   this.pressed = pressed;
   this.unpressed = unpressed;
   this.focus_pressed = focus_pressed;
   this.focus_unpressed = focus_unpressed;
  
} // end ButtonState

/**
* ButtonState Object
*
* @param ( id ) id of text to style
*
* @return none
*/

ButtonState.prototype.init = function() {

  this.node = document.getElementById(this.id);
  this.image_node = this.node.getElementsByTagName("img")[0];
  
  var obj = this;

  // Add event handlers for toggling a button state
  browser.addEvent(this.node, "keydown",   function(event) {handleButtonStateKeyDownEvent(event, obj); },   false);
  browser.addEvent(this.node, "mousedown", function(event) {handleButtonStateMouseDownEvent(event, obj); }, false);
  
  // Add event handlers for a ButtonState getting and losing focus
  browser.addEvent(this.node, "focus", function(event) {handleStateFocusEvent(event, obj);}, false);
  browser.addEvent(this.node, "blur", function(event) {handleStateBlurEvent(event, obj);}, false);
  


  
} // end ButtonState.prototype.init


/**
* handleStateFocusEvent processes keys associated with a buttonstate
*
* @param ( event ) event is the event handler for the event
* @param ( ButtonState object ) button_state is the ButtonState object that is the target of the keyboard event
*
* @return false if keyboard event was used by button, else true
*/

handleStateFocusEvent = function(event, button) {
  if( button.node.getAttribute("aria-pressed") == "true" ) {
  //use the focus highlighting for a pressed button

      button.image_node.src= button.focus_pressed;
  } else {
  //use the focus highlighting for an unpressed button  

      button.image_node.src= button.focus_unpressed;
  } // endif

  return true;

} // end handleStateFocusEvent

/**
* handleStateBlurEvent processes keys associated with a button_state
*
* @param ( event ) event is the event handler for the event
* @param ( ButtonState object ) button_state is the ButtonState object that is the target of the keyboard event
*
* @return false if keyboard event was used by button_state, else true
*/

handleStateBlurEvent = function(event, button) {

   if( button.node.getAttribute("aria-pressed") == "true" ) {
  //use the focus highlighting for a pressed button
    button.image_node.src = button.pressed;
  } else {
  //use the focus highlighting for an unpressed button  
    button.image_node.src = button.unpressed;

  } // endif

  return true;

} // end handleStateBlurEvent

/**
* handleButtonStateKeyDownEvent processes keys associated with a button
*
* @param ( event ) event is the event handler for the event
* @param ( Button object ) button is the Button object that is the target of the keyboard event
*
* @return false if keyboard event was used by radio group, else true
*/

handleButtonStateKeyDownEvent = function(event, button) {
  // If IE get the IE event object
  var e = event || window.event;

    switch( browser.keyCode(e)  ) {

    case KEY_SPACE:

     // press the button
     button.node.setAttribute("aria-pressed","true");
     button.image_node.src = button.focus_pressed;
  
   browser.simulateOnClickEvent( button.node );
       // Tell browser we handled this event and not to process any other actions
         return browser.stopPropagation(e);
         break;

  }  // end switch

  return true;

} // end handleButtonStateKeyDownEvent

/**
* handleButtonStateMouseDownEvent processes keys associated with a button
*
* @param ( event ) event is the event handler for the event
* @param ( Button object ) button is the button object that is the target of the keyboard event
*
* @return false if keyboard event was used by button, else true
*/

handleButtonStateMouseDownEvent = function(event, button) {
  // If IE get the IE event object
  var e = event || window.event;

  if( browser.target(e) == button.node || browswe.target(e) == button.image_node) {

      //press the button
      button.node.setAttribute("aria-pressed","true");
      button.image_node.src = button.focus_pressed;
  
   //set focus on mouse press
   button.node.focus();
   // Tell browser we handled this event and not to process any other actions
     return browser.stopPropagation(e);
    
  }  // end if

  return true;

} // end handleButtonStateMouseDownEvent



/**
* StyledText Object
*
* @param ( id ) id of text to style
*
* @return none
*/

function StyledText( id ) {

   this.id = id;
  
   this.fontSize = 3;
   this.fontSizes = ['85%', '90%', '95%', '100%', '105%', '110%', '120%', '140%', '180%'];
  
} // end StyledText

/**
* init is a subclass of StyledText
* tabs in a menu bar.
*
* @member StyleText
*
* @return none
*/

StyledText.prototype.init = function() {

  this.node = document.getElementById(this.id);

  
} // end StyledText.prototype.init

/**
* handleStyledTextFontSize
*
* @param ( StyledText object) styled text to have its font changed
* @param ( integer ) size index of font desired size
*
* @return none
*/

function handleStyledTextFontSize( stext, size ) {

  // Make sure that size is no less than 0
  if( size < 0 )
     size = 0;
  // Make sure we access a valid element  
  if( size >= stext.fontSizes.length )
    size = stext.fontSizes.length -1;
  // Set our fontSize to size
  stext.fontSize = size;
  // Use the corresponding fontSize among the fontSizes
  stext.node.style.fontSize = stext.fontSizes[stext.fontSize];

} // end handleStyledTextFontSize

/**
* handleStyledTextFontSizeLarger
* handlers changing
*
* @param ( StyledText object) styled text to have its font changed
*
* @return none
*/

function handleStyledTextFontSizeLarger( stext ) {
  // Increment fontSize
  stext.fontSize++;
  // Make sure we access valid elements
  if( stext.fontSize >= stext.fontSizes.length )
    stext.fontSize = stext.fontSizes.length - 1;
  // Use the corresponding fontSize among the fontSizes
  stext.node.style.fontSize = stext.fontSizes[stext.fontSize];
  
} // end handleStyledTextFontSizeLarger

/**
* handleStyledTextFontSizeSmaller
*
* @param ( StyledText object) styled text to have its font changed
*
* @return none
*/

function handleStyledTextFontSizeSmaller( stext ) {
  // Decrement fontSize
  stext.fontSize--;
  // Make sure that it doesn't go below 0
  if( stext.fontSize < 0 )
    stext.fontSize = 0;
  // Use the corresponding fontSize among the fontSizes
  stext.node.style.fontSize = stext.fontSizes[stext.fontSize];
  
} // end handleStyledTextFontSizeSmaller

function handleTextAlignLeft(stext, toolbar, button){
  
  stext.node.style.textAlign = "left";
  
  //unpress all of the other state buttons
  for(var i = 0; i < toolbar.buttons.length; i++ ) {
    toolbar.buttons[i].node.setAttribute("aria-pressed", "false");
    toolbar.buttons[i].image_node.src= toolbar.buttons[i].unpressed;
  }
    
   //press the button
      button.node.setAttribute("aria-pressed","true");
      button.image_node.src= button.focus_pressed;
}

function handleTextAlignCenter(stext, toolbar, button){
    
  stext.node.style.textAlign = "center";

  //unpress all of the other state buttons
  for(var i = 0; i < toolbar.buttons.length; i++ ) {
    toolbar.buttons[i].node.setAttribute("aria-pressed", "false");
    toolbar.buttons[i].image_node.src= toolbar.buttons[i].unpressed;
  }
  
   //press the button
      button.node.setAttribute("aria-pressed","true");
      button.image_node.src= button.focus_pressed;
}

function handleTextAlignRight(stext, toolbar, button){
    
  stext.node.style.textAlign = "right";

  //unpress all of the other state buttons
  for(var i = 0; i < toolbar.buttons.length; i++ ) {
    toolbar.buttons[i].node.setAttribute("aria-pressed", "false");
    toolbar.buttons[i].image_node.src= toolbar.buttons[i].unpressed;
    }
  
   //press the button
      button.node.setAttribute("aria-pressed","true");
      button.image_node.src= button.focus_pressed;
}

function handleTextAlignJustify(stext, toolbar, button){
    
  stext.node.style.textAlign = "justify";
  
  //unpress all of the other state buttons
  for(var i = 0; i < toolbar.buttons.length; i++ ) {
    toolbar.buttons[i].node.setAttribute("aria-pressed", "false");
    toolbar.buttons[i].image_node.src= toolbar.buttons[i].unpressed;
  }  
  
   //press the button
      button.node.setAttribute("aria-pressed","true");
      button.image_node.src= button.focus_pressed;
}

/**
* handleStyledTextToggleBold
* handlers changing
*
* @param ( MenuBar object) styled text to have its font changed
* @param ( StyledText object) styled text to have its font changed
*
* @return none
*/

function handleStyledTextToggleBold( button, stext ) {
  
  if( button.node.getAttribute("aria-pressed") == "true" ) {
  // If button is pressed set text to bold
    stext.node.style.fontWeight = "bold";
  } else {
    // If button is not pressed set text to normal
    stext.node.style.fontWeight = "normal";
  } // endif
  
} // end handleStyledTextToggleBold

/**
* handleStyledTextToggleItalic
* handlers changing
*
* @param ( MenuBar object) styled text to hav its font changed
* @param ( StyledText object) styled text to have its font changed
*
* @return none
*/

function handleStyledTextToggleItalic( button, stext ) {
  
  if( button.node.getAttribute("aria-pressed") == "true" ) {
  // If button is pressed set text to italic
    stext.node.style.fontStyle = "italic";
  } else {
  // If button is not pressed set text to normal
    stext.node.style.fontStyle = "normal";
  } // endif
  
} // end handleStyledTextToggleItalic



//widgets_class.js

// JavaScript Document


if (!window.Node) {
  var Node = {            // If there is no Node object, define one
    ELEMENT_NODE: 1,    // with the following properties and values.
    ATTRIBUTE_NODE: 2,  // Note that these are HTML node types only.
    TEXT_NODE: 3,       // For XML-specific nodes, you need to add
    COMMENT_NODE: 8,    // other constants here.
    DOCUMENT_NODE: 9,
    DOCUMENT_FRAGMENT_NODE: 11
  }
}

var ARIA_STATE = "aria-";

/**
* Widgets Object is used to initialize a set of controls
* and provide a conveinence fuction to cancel event propagration
* @construtor
*/

function Widgets() {
  this.widgets = new Array();
}

/**
* add is member of the Widgets Object
* and used add a widget ot the list of widgets to be intitialized
* as part of the onload event
* The controls array is the list of controls to initialize
* @member Enable
* @return none
*/

Widgets.prototype.add = function(obj) {
  this.widgets[this.widgets.length] = obj;
}

/**
* init is member of the Widgets Object
* and is called by the onload event to initialize widgets in the web resource
* The controls array is the list of controls to initialize
* @member Enable
* @return none
*/

Widgets.prototype.init = function() {
     
   for(var i = 0; i < this.widgets.length; i++ )
     this.widgets[i].init();
}

//
// convience function for getting the node based on id

function _$( id ) {
  return document.getElementById( id );  
}


//
// WebBrowser object to abstract accessibility API differences between web standards supporting browsers and Internet Explorer 7.0
//
// The state variable keeps track of current state of checkbox
function WebBrowser() {

}

/**
* Mouse capture
*
* @param ( node ) DOM node object
* @return nothing
*/

if ( document.addEventListener ) {

  // If a web standards based browser implement this function

  WebBrowser.prototype.setMouseCapture = function( node, clickHandler, downHandler, moveHandler, upHandler ) {

    if( clickHandler )
      document.addEventListener( "click",     clickHandler, true );
    
    if( downHandler )
      document.addEventListener( "mousedown", downHandler,  true );

    if( moveHandler )
      document.addEventListener( "mousemove", moveHandler,  true );
    
    if( upHandler)
      document.addEventListener( "mouseup",   upHandler,    true );

  }

  WebBrowser.prototype.releaseMouseCapture = function( node, clickHandler, downHandler, moveHandler, upHandler ) {

  if( upHandler)
      document.removeEventListener( "mouseup",   upHandler,    true );
      
    if( moveHandler )
      document.removeEventListener( "mousemove", moveHandler,  true );
    
    if( downHandler )
      document.removeEventListener( "mousedown", downHandler,  true );
      
    if( clickHandler )
      document.removeEventListener( "click",     clickHandler, true );

  }

} else {

  // If a Microsoft IE based browser implement this function

  WebBrowser.prototype.setMouseCapture = function( node, clickHandler, downHandler, moveHandler, upHandler ) {

   node.setCapture();
   if( clickHandler)
     node.attachEvent( "onclick", clickHandler );
    
   if( downHandler)
     node.attachEvent( "onmousedown", downHandler );
    
   if( moveHandler )
     node.attachEvent( "onmousemove", moveHandler );
    
   if( upHandler )
     node.attachEvent( "onmouseup", upHandler );

  } // endif

  WebBrowser.prototype.releaseMouseCapture = function( node, clickHandler, downHandler, moveHandler, upHandler ) {

   if( upHandler )
     node.detachEvent( "onmouseup", upHandler );
    
   if( moveHandler )
     node.detachEvent( "onmousemove", moveHandler );
    
   if( downHandler)
     node.detachEvent( "onmousedown", downHandler );
    
   if( clickHandler)
     node.detachEvent( "onclick", clickHandler );
    
     node.releaseCapture();

  } // endif


}

/**
* OnClick Event Simulator
*
* @param ( node ) DOM node object
* @return nothing
*/

if( document.createEvent ) {

  // If a web standards based browser implement this function

  WebBrowser.prototype.simulateOnClickEvent = function( node ) {
    // W3C DOM Events way to trigger a "click" event
    var e = document.createEvent('MouseEvents');
    e.initEvent( 'click', true, true );

    node.dispatchEvent( e );

  }

} else {

  // If a Microsoft IE based browser implement this function

  WebBrowser.prototype.simulateOnClickEvent = function( node ) {

    var e = document.createEventObject();
    node.fireEvent( "onclick", e );

  } // endif

}

//
// keyCode is a function to get the keycode from a keypress event
//
// @param ( event object) event is an event object
//
// @return ( keycode )

WebBrowser.prototype.keyCode = function( event ) {
  var e = event || window.event;
  
  return e.keyCode;
  
}  

if (typeof document.documentElement.setAttributeNS != 'undefined') {

  WebBrowser.prototype.stopPropagation = function( event ) {
    event.stopPropagation();
    event.preventDefault();
    return false;
  }

  WebBrowser.prototype.target = function( event ) {
  return event.target;
  }
  
  WebBrowser.prototype.charCode = function(event) {
     return event.charCode;
  }

  WebBrowser.prototype.calculateOffsetLeft = function( node ) {
  return node.offsetLeft;    
  }
  
  WebBrowser.prototype.calculateOffsetTop = function( node ) {
  return node.offsetTop;    
  }
  
  WebBrowser.prototype.pageX = function( e ) {
    return e.pageX;    
  }
  
  WebBrowser.prototype.pageY = function( e ) {
    return e.pageY;    
  }

  WebBrowser.prototype.setNodePosition = function(node,left,top) {
    node.style.left = left+"px";
    node.style.top = top+"px";
  }
  
} else {

  WebBrowser.prototype.stopPropagation = function( event ) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
    return false;
  }

  WebBrowser.prototype.charCode = function(event) {
    return window.browser.keyCode( event );
  }

  WebBrowser.prototype.target = function( event ) {
    return window.event.srcElement;
  }

  WebBrowser.prototype.calculateOffsetLeft = function(node) {
  var offset = 0;
  
  while( node ) {
    offset += node.offsetLeft;
    node = node.offsetParent;
  }
  
  return offset;    
  }
  
  WebBrowser.prototype.calculateOffsetTop = function(node) {
  var offset = 0;
  
  while( node ) {
    offset = offset + node.offsetTop;
    node = node.offsetParent;
  }
  
  return offset;    
  }

  WebBrowser.prototype.pageX = function( e ) {
    return e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft);    
  }
  
  WebBrowser.prototype.pageY = function( e ) {
    return e.clientY + (document.documentElement.scrollTop || document.body.scrollTop);    
  }
  
  WebBrowser.prototype.setNodePosition = function(node,left,top) {
    var offsetx = 0;
    var offsety = 0;
    var nnode = node.offsetParent
    while( nnode ) {
      offsetx = offsetx + nnode.offsetLeft;
      offsety = offsety + nnode.offsetTop;
      nnode = nnode.offsetParent;
    }
    node.style.left = left-offsetx+"px";
    node.style.top = top-offsety+"px";
  }


};


if (document.addEventListener) {

     // Functions for W3C Standards compliant implementation of adding event handlers

     WebBrowser.prototype.addEvent = function(elmTarget, sEventName, fCallback) {
       elmTarget.addEventListener(sEventName, fCallback, false);
       returnValue = true;
     };

     WebBrowser.prototype.removeEvent = function(elmTarget, sEventName, fCallback) {
       elmTarget.removeEventListener(sEventName, fCallback, false);
       returnValue = true;
     };

     WebBrowser.prototype.addChangeEvent =  function(elmTarget, fCallback) {
      elmTarget.addEventListener("DOMAttrModified", fCallback, false);
      returnValue = true;
    };

} else {

  if(document.attachEvent) {

     // IE Specific Event handler functions
     WebBrowser.prototype.addEvent = function(elmTarget, sEventName, fCallback) {
       returnValue = elmTarget.attachEvent('on' + sEventName, fCallback);
     };

     WebBrowser.prototype.removeEvent = function(elmTarget, sEventName, fCallback) {
       returnValue = elmTarget.detachEvent('on' + sEventName, fCallback);
     };

    WebBrowser.prototype.addChangeEvent =  function(elmTarget, fCallback) {
      returnValue = elmTarget.attachEvent("onpropertychange", fCallback);
    };

  } else {

     // For browsers that do not support W3C or IE event functions
     WebBrowser.prototype.addEvent = function(elmTarget, sEventName, fCallback) {
       return false;
     };

     WebBrowser.prototype.removeEvent = function(elmTarget, sEventName, fCallback) {
       return false;
     };

     WebBrowser.prototype.addChangeEvent =  function(elmTarget, fCallback) {
       return false;
     };

  }

}



//
// ARIA functions to absract the setting and reading of ARIA features
// This is important since the ARIA specification is not completely defined
// This makes it easier to make syntactic changes to examples
//

function ARIA() {

}

ARIA.prototype.setAriaState = function(elmTarget, sStateName, sStateValue) {
  elmTarget.setAttribute(ARIA_STATE + sStateName, sStateValue);
}

ARIA.prototype.setRole = function(elmTarget, sStateValue) {
  elmTarget.setAttribute("role", sStateValue);
}
  
ARIA.prototype.getAriaState = function(elmTarget, sStateName) {
  return elmTarget.getAttribute(ARIA_STATE + sStateName);
}

ARIA.prototype.removeAriaState = function(elmTarget, sStateName) {
  return elmTarget.removeAttribute(ARIA_STATE + sStateName);
}

ARIA.prototype.hasAriaState = function(elmTarget, sStateName) {
  return elmTarget.hasAttribute(ARIA_STATE + sStateName);
}


ARIA.prototype.setRolesAndStates = function(elmAccessible)
{
  var STATE_MACHINE_BEGIN = 0;
  var STATE_MACHINE_IN_ACCESSIBLE = 1;
  var STATE_MACHINE_ROLE_IS_SET = 2;

  var sClass = elmAccessible.className;
  var arClassNames = sClass.split(' ');
  var machineState = STATE_MACHINE_BEGIN;
  var role = "";

  for (j = 0; j < arClassNames.length; j++) {

    // Delete spaces in CNAMEs
    var sClass = arClassNames[j].replace(/ /g, '');

    // alert(sClass + " " + machineState);
    // Test to see if there are any CNAMEs to process, if not exit
    if (!sClass) { continue; }
  
    // Look for CNAMEs assocaited with ARIA markup
    if ( sClass == 'axs' ) {

      /* found "axs" accessible keyword, rest of class will be treated as ARIA roles and states */
      machineState = STATE_MACHINE_IN_ACCESSIBLE;

    } else if (machineState == STATE_MACHINE_IN_ACCESSIBLE) {

//       alert(elmAccessible.id + " " + sClass);

      /* found role, set it and move on */
    if( sClass != 'norole')
        this.setRole(elmAccessible, sClass);

      machineState = STATE_MACHINE_ROLE_IS_SET;
      role = sClass;

    } else if (machineState == STATE_MACHINE_ROLE_IS_SET) {

      /* found state, set it and look for more */
      if (sClass.indexOf('-') != -1) {

        /* state has specific value, parse it out and set it */
        var arValue = sClass.split(/-/);

        // arValue[0] is state name, arValue[1] is value
  //
  // test for tabindex value
  if( arValue[0] != "tabindex" )
    //
    // If not tabindex set the aria property and value
          this.setAriaState(elmAccessible, arValue[0], arValue[1]);
  else {
    //
    // If tabindex use Microsoft IE property to set tabindex value
    if( arValue[1] != "" ) {
      // alert("Tabindex=" + arvalue[1]);
            elmAccessible.tabIndex = arValue[1];      
          } else {
      // if tabindex value is undefined assume it is a negative number and set tabindex=-1
      // alert("Tabindex=-1");
            elmAccessible.tabIndex = -1;            
    }
  }
      } else {
        /* state is simply a name, value is null - make it a string to match other values as strings*/
        this.setAriaState(elmAccessible, sClass, "");
      }
    }
  }
};

initApp = function(elmRoot) {
  
  if (document.isInitialized) {
    return;  // Avoid second initialization -- we inited early because of DOMContentLoaded
  }
  
  document.isInitialized = true;
  
  // If elmRoot is undefined start with the BODY element
  
  if ((!elmRoot) || (!elmRoot.getElementsByTagName)) {
    elmRoot = document.body;
  }

  // Check elmRoot node for information in the CLASS attribute to convert to ARIA markup
  
  if (/axs /.test(elmRoot.className)) {
    aria.setRolesAndStates(elmRoot);  // First do root element
  }

  //
  // Check for W3C Standards compliant implementation of XPATH evaluation
  if (document.evaluate) {
    
  // Get ARIA Roles and States  
    var snapAccessibleElements = document.evaluate(".//*[contains(@class, 'axs ')]", elmRoot, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
    for (var i = snapAccessibleElements.snapshotLength - 1; i >= 0; i--) {
      aria.setRolesAndStates(snapAccessibleElements.snapshotItem(i), "wairole:");
    }

  //
  // Otherwise use Micrsoft IE technique for identifying nodes
  } else {
  var axsElements = new Array();
  var axsElementCount = 0;

  var arElements = (typeof elmRoot.all != 'undefined') ? elmRoot.all : elmRoot.getElementsByTagName('*');
  var iElementCount = arElements.length;

  //
  // Find elements with ARIA markup and save their IDs
    for (var i = 0; i < iElementCount; i++) {
      if (/axs /.test(arElements[i].className)) {
        aria.setRolesAndStates(arElements[i]);
      } // endif
    } // endfor
  
}  // endif

  // Initialize widgets
  
  widgets.init();

};

// Initialize global variables used to initial widgets and provide browser independence for handling events and lack of namespace support in IE DOM functions

widgets_flag = true;
var widgets = new Widgets();
var browser = new WebBrowser();
var aria = new ARIA();
//globals.js

/**
*
* The Globale Variables
*/

if (!window.Node) {
  var Node = {            // If there is no Node object, define one
    ELEMENT_NODE: 1,    // with the following properties and values.
    ATTRIBUTE_NODE: 2,  // Note that these are HTML node types only.
    TEXT_NODE: 3,       // For XML-specific nodes, you need to add
    COMMENT_NODE: 8,    // other constants here.
    DOCUMENT_NODE: 9,
    DOCUMENT_FRAGMENT_NODE: 11
  }
}


var KEY_PAGEUP   = 33;
var KEY_PAGEDOWN = 34;
var KEY_END      = 35;
var KEY_HOME     = 36;

var KEY_LEFT     = 37;
var KEY_UP       = 38;
var KEY_RIGHT    = 39;
var KEY_DOWN     = 40;

var KEY_SPACE    = 32;
var KEY_TAB      = 9;

var KEY_BACKSPACE = 8;
var KEY_DELETE    = 46;
var KEY_ENTER     = 13;
var KEY_INSERT    = 45;
var KEY_ESCAPE    = 27;

var KEY_F1        = 112;
var KEY_F2        = 113;
var KEY_F3        = 114;
var KEY_F4        = 115;
var KEY_F5        = 116;
var KEY_F6        = 117;
var KEY_F7        = 118;
var KEY_F8        = 119;
var KEY_F9        = 120;
var KEY_F10       = 121;

var KEY_M         = 77;

var NS_XHTML = "http://www.w3.org/1999/xhtml"
var NS_STATE = "http://www.w3.org/2005/07/aaa";

// **********************************************
// *
// * Commonly used helper functions
// *
// **********************************************

/**
*
* nextSiblingElement
*
* @contructor
*/

function nextSiblingElement( node ) {

  var next_node = node.nextSibling;

  while( next_node
    && (next_node.nodeType != Node.ELEMENT_NODE) ) {
    next_node = next_node.nextSibling;
  }  // endwhile

  return next_node;
  
}

/**
*
* previousSiblingElement
*
* @param ( node ) node object for which you are looking for the next sibling element node
*
* @return ( node) next sibling or "null"
*/

function previousSiblingElement( node ) {

  var next_node = node.previousSibling;

  while( next_node
    && (next_node.nodeType != Node.ELEMENT_NODE) ) {
    next_node = next_node.previousSibling;
  }  // endwhile

  return next_node;
  
}

/**
*
* firstChildElement
*
* @param ( node ) node object for which you are looking for the first child element node
*
* @return ( node) next sibling or "null"
*/

function firstChildElement( node ) {

  var next_node = node.firstChild;

  while( next_node
    && (next_node.nodeType != Node.ELEMENT_NODE) ) {
    next_node = next_node.nextSibling;
  }  // endwhile


  return next_node;
  
}

/**
*
* getTextContentOfNode
*
* @contructor
*/

function getTextContentOfNode( node ) {

  var next_node = node.firstChild;
  var str = "";

  while( next_node ) {
    
    if( (next_node.nodeType == Node.TEXT_NODE ) &&
      (next_node.length > 0 )
     )
      str += next_node.data;
    
    
    next_node = next_node.nextSibling;
    
  }  // endwhile

  return str;
  
}

/**
*
* setTextContentOfNode
*
* @contructor
*/

function setTextContentOfNode( node, text ) {

   // Generate a new text node with the text value
    var text_node = document.createTextNode(text);
  
    // Remove child nodes to remove text
    while (node.firstChild) {
      node.removeChild(node.firstChild);
    } // while

    // Append new text to the container element
    node.appendChild( text_node );

}
</script>
</head>
<body onload="widgets.init()">
<div role="application">
<script type="text/javascript">

  var toolbar1 = new Toolbar("toolbar1");
  widgets.add(toolbar1);

  var larger1 = new Button("larger1",
                           "buttonimages/big/bigpressed.png",
               "buttonimages/big/big.png",
               "buttonimages/big/bigpressed-focus.png",
               "buttonimages/big/bigfocus.png");
  toolbar1.add(larger1);
  
  var smaller1 = new Button("smaller1",
                            "buttonimages/small/smallpressed.png",
                "buttonimages/small/small.png",
                "buttonimages/small/smallpressed-focus.png",
                "buttonimages/small/small-focus.png");
  toolbar1.add(smaller1);
  
  var italic1 = new ButtonToggle("italic1",
                           "buttonimages/italic/italicpressed.png",
               "buttonimages/italic/italic.png",
               "buttonimages/italic/italicpressed-focus.png",
               "buttonimages/italic/italic-focus.png");
  toolbar1.add(italic1);
  
  var bold1 = new ButtonToggle("bold1",  
                           "buttonimages/bold/boldpressed.png",
               "buttonimages/bold/bold.png",
               "buttonimages/bold/boldpressed-focus.png",
               "buttonimages/bold/bold-focus.png");
  toolbar1.add(bold1);
  
  var stext1 = new StyledText("text1");
  widgets.add(stext1);


  var toolbar2 = new Toolbar("toolbar2");
  widgets.add(toolbar2);

  var larger2 = new Button("larger2",
                           "buttonimages/big/bigpressed.png",
               "buttonimages/big/big.png",
               "buttonimages/big/bigpressed-focus.png",
               "buttonimages/big/bigfocus.png");
  toolbar2.add(larger2);
  
  var smaller2 = new Button("smaller2",
                            "buttonimages/small/smallpressed.png",
                "buttonimages/small/small.png",
                "buttonimages/small/smallpressed-focus.png",
                "buttonimages/small/small-focus.png");
  toolbar2.add(smaller2);
  
  var italic2 = new ButtonToggle("italic2",  
                           "buttonimages/italic/italicpressed.png",
               "buttonimages/italic/italic.png",
               "buttonimages/italic/italicpressed-focus.png",
               "buttonimages/italic/italic-focus.png");
  toolbar2.add(italic2);
  
  var bold2 = new ButtonToggle("bold2",  
                           "buttonimages/bold/boldpressed.png",
               "buttonimages/bold/bold.png",
               "buttonimages/bold/boldpressed-focus.png",
               "buttonimages/bold/bold-focus.png");
  toolbar2.add(bold2);
  
  var stext2 = new StyledText("text2");
  widgets.add(stext2);
  
  
  var toolbar3 = new Toolbar("toolbar3");
  widgets.add(toolbar3);

  var left1 = new ButtonState("left1",  
                           "buttonimages/left/leftpressed.png",
               "buttonimages/left/left.png",
               "buttonimages/left/leftpressed-focus.png",
               "buttonimages/left/left-focus.png");
  toolbar3.add(left1);
  
  var center1 = new ButtonState("center1",  
                           "buttonimages/center/centerpressed.png",
               "buttonimages/center/center.png",
               "buttonimages/center/centerpressed-focus.png",
               "buttonimages/center/center-focus.png");
  toolbar3.add(center1);
  
  var right1 = new ButtonState("right1",  
                           "buttonimages/right/rightpressed.png",
               "buttonimages/right/right.png",
               "buttonimages/right/rightpressed-focus.png",
               "buttonimages/right/right-focus.png");
  toolbar3.add(right1);
  
  var justify1 = new ButtonState("justify1",  
                           "buttonimages/justify/justifypressed.png",
               "buttonimages/justify/justify.png",
               "buttonimages/justify/justifypressed-focus.png",
               "buttonimages/justify/justify-focus.png");
  toolbar3.add(justify1);
  
  
  var toolbar4 = new Toolbar("toolbar4");
  widgets.add(toolbar4);

  var left2 = new ButtonState("left2",  
                           "buttonimages/left/leftpressed.png",
               "buttonimages/left/left.png",
               "buttonimages/left/leftpressed-focus.png",
               "buttonimages/left/left-focus.png");
  toolbar4.add(left2);
  
  var center2 = new ButtonState("center2",  
                           "buttonimages/center/centerpressed.png",
               "buttonimages/center/center.png",
               "buttonimages/center/centerpressed-focus.png",
               "buttonimages/center/center-focus.png");
  toolbar4.add(center2);
  
  var right2 = new ButtonState("right2",  
                           "buttonimages/right/rightpressed.png",
               "buttonimages/right/right.png",
               "buttonimages/right/rightpressed-focus.png",
               "buttonimages/right/right-focus.png");
  toolbar4.add(right2);
  
  var justify2 = new ButtonState("justify2",  
                           "buttonimages/justify/justifypressed.png",
               "buttonimages/justify/justify.png",
               "buttonimages/justify/justifypressed-focus.png",
               "buttonimages/justify/justify-focus.png");
  toolbar4.add(justify2);
  
  
</script>

<h3>Text Sample 1</h3>

<ul class="toolbar" title="Text Formating Controls 1" role="toolbar" id="toolbar1">

    <li id="larger1"  
        class="unpressed axs button tabindex-0 labelledby-larger_label"
        onclick="handleStyledTextFontSizeLarger(stext1)"
    ><img src="buttonimages/big/big.png" alt="increase font size" align="middle"></li>
            
    <li id="smaller1"  
        class="unpressed axs button tabindex--1 labelledby-smaller_label"
        onclick="handleStyledTextFontSizeSmaller(stext1)"
    ><img src="buttonimages/small/small.png" alt="decrease font size" align="middle"></li>
          
    <li id="italic1"  
        class="italic pressed axs button tabindex--1 labelledby-italic_label"
    onclick="handleStyledTextToggleItalic(italic1, stext1 )"
    ><img src="buttonimages/italic/italic.png" alt="italicize text" align="middle"></li>
        
    <li id="bold1"  
        class="unpressed axs button tabindex-0 labelledby-bold_label"
    onclick="handleStyledTextToggleBold(bold1, stext1)"
    ><img src="buttonimages/bold/bold.png" alt="bold text" align="middle"></li>
        
</ul>

<ul class="toolbar" title="Paragraph Formating Controls 1"  role="toolbar" id="toolbar3">
    
  <li id="left1"
        class="pressed axs button tabindex-0 labelledby-left_label"
    aria-pressed="true"
        onclick="handleTextAlignLeft(stext1, toolbar3, left1)"
    ><img src="buttonimages/left/leftpressed.png" alt="align text left" align="middle"></li>
            
    <li id="center1"
        class="unpressed axs button tabindex--1 labelledby-center_label"
        onclick="handleTextAlignCenter(stext1, toolbar3, center1)"
    ><img src="buttonimages/center/center.png" alt="align text center" align="middle"></li>
          
    <li id="right1"
        class="unpressed axs button tabindex--1 labelledby-right_label"
    onclick="handleTextAlignRight(stext1, toolbar3, right1)"
    ><img src="buttonimages/right/right.png" alt="align text right" align="middle"></li>
        
    <li id="justify1"
        class="unpressed axs button tabindex-0 labelledby-justify_label"
    onclick="handleTextAlignJustify(stext1, toolbar3, justify1)"
    ><img src="buttonimages/justify/justify.png" alt="justify text" align="middle"></li>
        
</ul>

<p style="clear: both; height: 1px">&nbsp;</p>

<textarea id="text1" name="text1" class="example1">
Four score and seven years ago our fathers brought forth on this continent a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.

Now we are engaged in a great civil war, testing whether that nation, or any nation, so conceived and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this.
</textarea>  
<p>&nbsp;</p>

<h3>Text Sample 2</h3>

<ul class="toolbar" title="Text Formating Controls 2"  role="toolbar" id="toolbar2">

    <li id="larger2"  
        class="unpressed axs button tabindex-0 labelledby-larger_label"
        onclick="handleStyledTextFontSizeLarger(stext2)"
    ><img src="buttonimages/big/big.png" alt="increase font size" align="middle"></li>
            
    <li id="smaller2"
    class="unpressed axs button tabindex--1 labelledby-smaller_label"
        onclick="handleStyledTextFontSizeSmaller(stext2)"
    ><img src="buttonimages/small/small.png" alt="decrease font size" align="middle"></li>
          
    <li id="italic2"  
        class="italic pressed axs button tabindex--1 labelledby-italic_label"
    aria-pressed="true"
    onclick="handleStyledTextToggleItalic(italic2, stext2 )"
    ><img src="buttonimages/italic/italicpressed.png" alt="italicize text" align="middle"></li>
        
    <li id="bold2"  
        class="unpressed axs button tabindex-0 labelledby-bold_label"
        onclick="handleStyledTextToggleBold(bold2, stext2)"
    ><img src="buttonimages/bold/bold.png" alt="bold text" align="middle"></li>
        
</ul>

<ul class="toolbar" title="Paragraph Formating Controls 2"  role="toolbar" id="toolbar4">

    <li id="left2"
        class="pressed axs button tabindex-0 labelledby-left_label"
    aria-pressed="true"
        onclick="handleTextAlignLeft(stext2, toolbar4, left2)"
    ><img src="buttonimages/left/leftpressed.png" alt="align text left" align="middle"></li>
            
    <li id="center2"
        class="unpressed axs button tabindex--1 labelledby-center_label"
        onclick="handleTextAlignCenter(stext2, toolbar4, center2)"
    ><img src="buttonimages/center/center.png" alt="align text center" align="middle"></li>
          
    <li id="right2"
        class="unpressed axs button tabindex--1 labelledby-right_label"
    onclick="handleTextAlignRight(stext2, toolbar4, right2)"
    ><img src="buttonimages/right/right.png" alt="align text right" align="middle"></li>
        
    <li id="justify2"
        class="unpressed axs button tabindex-0 labelledby-justify_label"
    onclick="handleTextAlignJustify(stext2, toolbar4, justify2)"
    ><img src="buttonimages/justify/justify.png" alt="justify text" align="middle"></li>
        
</ul>

<p style="clear: both; height: 1px">&nbsp;</p>

<textarea id="text2" name="text2" class="example2">
But, in a larger sense, we can not dedicate - we can not consecrate - we can not hallow - this ground. The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us - that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion - that we here highly resolve that these dead shall not have died in vain - that this nation, under God, shall have a new birth of freedom - and that government of the people, by the people, for the people, shall not perish from the earth.
</textarea>

<p class="hide" id="bold_label">Bold</p>

<p class="hide" id="italic_label">Italic</p>

<p class="hide" id="larger_label">Font Larger</p>

<p class="hide" id="smaller_label">Font Smaller</p>

</div></body>
</html>