if( document.getElementById == undefined ) {
  alert( "Your browser doesn't seem to support DOM at all ..." );
}

a = document.getElementById( "div1" );
a = applyEmulation( a );
a.addEventListener( 'click', function () { alert( "Alert 1" ); }, false );
a.addEventListener( 'click', function () { alert( "Alert 2" ); }, false );

a = document.getElementById( "div2" );
a = applyEmulation( a );
a.addEventListener( 'click', function () { alert( "one" ); }, true );
a.addEventListener( 'click', function () { alert( "four" ); }, false );

a = document.getElementById( "div3" );
a = applyEmulation( a );
a.addEventListener( 'click', function () { alert( "two" ); }, true );
a.addEventListener( 'click', function () { alert( "three" ); }, false );

function setBGColor( obj, string ) {
        if( true ) {
        //if( obj.id == "fancyDemoDiv1" ) {
                j = 0;
                var str = "";
                for( i in obj ) {
                        if( j > 15 ) {
                                alert( str );
                                str = "";
                                j = 0;
                        }
                        str += i + "\n";
                        j++;
                }
                alert( str );
        }
        if( obj.style == undefined ) {
                obj.style = new Object();
        }
        obj.style.backgroundColor = string;
        obj.bgColor = string;
}





// note: document.getElementsByName only works for form
//       elements in IE for windows. so, I must do this:

function fancyCapture( e ) {
        if( !e.emulationOn ) {
                e.cur = this;
        }
        e.cur.className = "fancyDemoCapture";
        alert( "Capturing ... " );
        e.cur.className = "fancyDemo";
}

function fancyBubble( e ) {
        if( !e.emulationOn ) {
                e.cur = this;
        }
        e.cur.className = "fancyDemoBubble";
        alert( "Bubbling ... " );
        e.cur.className = "fancyDemo";
}

a = document.getElementById( "fancyDemoDiv1" );
a = applyEmulation( a );
a.addEventListener( 'click', fancyCapture, true );
a.addEventListener( 'click', fancyBubble, false );

a = document.getElementById( "fancyDemoDiv2" );
a = applyEmulation( a );
a.addEventListener( 'click', fancyCapture, true );
a.addEventListener( 'click', fancyBubble, false );

a = document.getElementById( "fancyDemoDiv3" );
a = applyEmulation( a );
a.addEventListener( 'click', fancyCapture, true );
a.addEventListener( 'click', fancyBubble, false );

a = document.getElementById( "fancyDemoDiv4" );
a = applyEmulation( a );
a.addEventListener( 'click', fancyCapture, true );
a.addEventListener( 'click', fancyBubble, false );
