function Flash( ) {

    this.transparent = true;
    this.needFlashVerion = 8;           
    this.flashvars = "xml_source=/ixml/&menuselid=0";
    this.BrowserInfo( );

}

/* Метод определения типа Браузера */
Flash.prototype.BrowserInfo = function( ) {  
  
    var userAgent = navigator.userAgent.toLowerCase( );
       this.browserIE = ( userAgent.indexOf( 'msie' ) != -1 );

}

/* Метод для опеределения нужной версии флэша */
Flash.prototype.CheckVersionFlash = function( needVersion ) {
  
    if ( navigator.plugins[ 'Shockwave Flash' ] ) {
        /* определяем есть ли у браузера plugin флэшплеера */
        matchStr = new RegExp ( '^[A-Za-z ]*(.*) .*$' );
        this.flashVerion = parseInt( navigator.plugins[ 'Shockwave Flash' ].description.replace( matchStr, '$1' ) );
        return ( needVersion <= this.flashVerion );
    }
    else if ( this.browserIE ) {
        /* иначе будет создаваться ActiveX объект (IE) */
        for( var i = needVersion; i < needVersion + 10; i++ ) {
            try {
                    flashPlayer = new ActiveXObject( 'ShockwaveFlash.ShockwaveFlash.' + i );
                    this.flashVerion = i;
                    return true;
            }
            catch( e ) {
                continue;
            }
        }
        return false;      
    }
    else {
        this.flashVerion = 0;
        return false;
    }
  
}

/* Метод вставки в страницу HTML нужного кода */
Flash.prototype.Insert = function( ) {
  
    if ( this.CheckVersionFlash( this.needFlashVerion ) ) {
        document.write( this.GenerateHtmlFlash( ) );
    }
    else {
        document.write( this.GenerateHtmlImage( ) );
    }
      
}

/* Метод для генерирования флэш - кода */
Flash.prototype.GenerateHtmlFlash = function( ) {
 
    var flashCode = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
    flashCode += 'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version= ' + this.flashVerion + ',0,0,0"' + ' width="' + this.width + '" height="' + this.height + '" align="middle">';
    flashCode += '<param name="allowScriptAccess" value="always"/>';
    flashCode += '<param name="movie" value="' + this.srcFlash + '"/>';
    flashCode += '<param name="quality" value="high"/>';
    if ( this.base ) {
        flashCode += '<param name="base" value="' + this.base + '"/>';
    }
    if ( this.background ) {
        flashCode += '<param name="bgcolor" value="' + this.background + '"/>';
    }
    if ( this.transparent ) {
        flashCode += '<param name="wmode" value="transparent"/>';
    }
    if ( this.flashvars ) {
        flashCode += '<param name="flashvars" value="' + this.flashvars + '"/>';
    }
 
    flashCode += '<embed quality="high" allowScriptAccess="always" type="application/x-shockwave-flash"' + ' pluginspage="http://www.macromedia.com/go/getflashplayer" ';
    flashCode += 'src="' + this.srcFlash+'" ' + '" width="' + this.width + '" height="' + this.height + '" ';
    if ( this.base ){
        flashCode += ' base="' + this.base + '"';
    }
    if ( this.background ){
        flashCode += ' bgcolor="' + this.background + '"';
    }
    if ( this.transparent ){
        flashCode += ' wmode="transparent"'
    }
    if ( this.flashvars ){
        flashCode += ' flashvars="' + this.flashvars + '"';
    }
    flashCode += '></embed>';
  
    flashCode += '</object>';
    return flashCode;
  
}

/* Метод для генерирования image - кода */
Flash.prototype.GenerateHtmlImage = function( ) {
  
    var imageCode = '<img src="' + this.srcImage + '"/>';
    return imageCode;
  
}

