Event.observe(window, 'load', function(event){
	
	// Give alle inputy of type text a classname 'focus' when focused
	// and remove that classname on blur again.
    $$('input[type="text"]').each( function(element){
        Event.observe(element, 'focus', function(evt){
            element.addClassName('focus');
        });
        Event.observe(element, 'blur', function(evt){
            element.removeClassName('focus');
        });
    });
    
    
    // Colorize table row backgrounds of tables of class 'cycle'.
    // Start cycle again if a TH is in the row.
    $$('table.cycle').each( function(tableObj){
    	var colors = ['#E5E5E5', '#F2F2F2'],
    		colorIndex = 0;
    	
    	tableObj.getElementsBySelector('tr').each( function(trObj, i){
    		// check if all children are TD
    		var noOtherThanTD = true;
    		trObj.immediateDescendants().each( function(thTdObj){
    			noOtherThanTD = noOtherThanTD && (thTdObj.tagName == 'TD'); 
    		});
    		if( noOtherThanTD ){
    			trObj.style.backgroundColor = colors[colorIndex];
    			colorIndex = (colorIndex == 0) ? 1 : 0;
    		} else {
    			colorIndex = 0;
    		}
    	})
    });
    
});
