function getById( id ) {
    var ret = new Object();

    if ( document.getElementById ) {
	ret.obj   = document.getElementById(id);
	if ( ret.obj && ret.obj.style ) {
	    ret.style = document.getElementById(id).style;
	}
    }
    else if ( document.all ) {
	ret.obj   = document.all[id];
	ret.style = document.all[id].style;
    }
    else if ( document.layers ) {
	ret.obj   = document.layers[id];
	ret.style = document.layers[id];
    }

    if ( ret.obj ) {
	return ret;
    }
    else {
	return false;
    }
}

/**
 * Given object will have the magic powers to
 * modify it's classes in a nice way.
 * 
 *
 * Usage: 
 *
 * obj = getElementById( 'someHtmlId');
 * makeClassHandler( obj );
 * // now the obj has the following functions:
 * 
 * if ( obj.hasClass( 'someClass' ) ) {
 *     // do something
 * }
 *
 * obj.addClass( 'anotherClass' );
 *
 * obj.dropClass( 'anotherClass' );
 */

function makeClassHandler( obj )
{

    if ( obj.className.length > 0 ) {
	obj.classes = obj.className.split( ' ' );
    }
    else {
	obj.classes = new Array();
    }

    obj.addClass = function( c ) {
	for ( var i = 0 ; i < this.classes.length; i++ ) {
	    if ( this.classes[i] == c ) {
		return true;
	    }
	}
	this.classes.push( c );
	this.updateClassName();
	return true;
    }

    obj.dropClass = function( c ) {
	for ( var i = 0 ; i < this.classes.length; i++ ) {
	    if ( this.classes[i] == c ) {
//		this.classes[i] = null;
		this.classes.splice( i, 1 );
		this.updateClassName();
		return true;
	    }
	}
	return false;
    }

    obj.hasClass = function( c ) {
	for ( var i = 0 ; i < this.classes.length; i++ ) {
	    if ( this.classes[i] == c ) {
		return true;
	    }
	}
	return false;
    }
    
    obj.updateClassName = function(){
	this.className = this.classes.join( ' ' );
    }

}