var flashTitle = new Object();

flashTitle = {

	flashes: new Array(),

    //Fejléc tagok kigyüjtése
    findTags: function( tag, cn ) {

        var returnArray = [];
        var els = document.getElementsByTagName( tag );

        var pattern = new RegExp('(^|\\s)'+cn+'(\\s|$)');
        for (var FSi = 0; FSi < els.length; FSi++) {
            if ( ((cn !== null || cn !== '') && pattern.test(els[FSi].className)) && (cn !== null || cn !== '') )
                returnArray.push(els[FSi]);
         }

        return returnArray;
    },	

    addFlash: function( num, cn, flash, w, h, wmode, bgcolor ) {
        var data = new Array();
        data['num'] = num;
        data['className'] = cn;
        data['flash'] = flash;

        if ( w !== null )
            data['width'] = w;

        if ( h !== null )
            data['height'] = h;

        if ( wmode !== null )
            data['wmode'] = wmode;

        if ( bgcolor !== null )
            data['bgcolor'] = bgcolor;

        this.flashes.push( data );
    },


    replaceHeaders: function() {
        for ( var i=0; i<this.flashes.length ; i++ ) {
            var headers = this.findTags( this.flashes[i]['num'], this.flashes[i]['className'] );
    
            for ( var j=0; j<headers.length; j++ )	{
                if ( headers[j].id == null || headers[j].id == '' )
                    headers[j].id = 'flashTitle_' + i + '_' + j;

                if ( this.flashes[i]['width'] !== null ) {
                    var width = this.flashes[i]['width'];
                } else {
                    var width = headers[j].offsetWidth;
                }

                if ( this.flashes[i]['height'] !== null ) {
                    var height = this.flashes[i]['height'];
                } else {
                    var height = headers[j].offsetHeight;
                }

                var so = new FlashObject('top', this.flashes[i]['flash'], width, height);

                if ( this.flashes[i]['wmode'] !== null ) {
                    so.setAttribute('wmode', this.flashes[i]['wmode']);
                }

                if ( this.flashes[i]['bgcolor'] !== null ) {
                    so.setAttribute('bgcolor', this.flashes[i]['bgcolor']);
                }

                so.addVariable('Title', headers[j].innerHTML);
                so.write( headers[j].id );
            }
        }
    }

};
Event.register( 'load', function() { flashTitle.replaceHeaders(); }, window );

/* SET ME  (tagName, className, flashURI, width, height) */
flashTitle.addFlash('h1','','gfx/title.swf', 492, 40, 'transparent', '');

