/**
 * Function stripe
 *
 * Verändert die Hintergrundfarbe von DIV class="box" in einem mit ID übergebenen DIV
 *
 * @author	Philipp Heine (LLH) <p.heine@llh-online.de>
 */

  // this function is needed to work around 
  // a bug in IE related to element attributes
  
function hasClassBox(obj) {
    var result = false;
    if (obj.getAttributeNode) {
        if (obj.getAttributeNode("class") != null) {
            if (obj.getAttributeNode("class").value == arguments[1]) {
                result = true;
            }
        }
        return result;
    }
} 

 function stripe(id) {
 
	// the flag we'll use to keep track of
	// whether the current row is odd or even
	var even = false;

	var boxclass = arguments[3] ? arguments[3] : "box";;

	// if arguments are provided to specify the colours
	// of the even & odd rows, then use the them;
	// otherwise use the following defaults:
	var evenColor = arguments[1] ? arguments[1] : "#f2f2f2";
	var oddColor = arguments[2] ? arguments[2] : "#eee";

	// obtain a reference to the desired table
	// if no such table exists, abort
	var div = document.getElementById(id);
	if (! div) { return; }
	
	// find all Divs
	var divs = div.getElementsByTagName("div");
	
	// ... and iterate through them
	for (var j = 0; j < divs.length; j++) {
		//alert('OK:' + j);
		var mydiv = divs[j];
	
		if (hasClassBox(mydiv, boxclass)) {
			mydiv.style.backgroundColor = even ? evenColor : oddColor;
			// flip from odd to even, or vice-versa
			even =  ! even;
			}
		}
}
 

