function exibe_flash(swf,width,height,id)
{
    var flash = "";
    flash += '<object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+width+'" height="'+height+'" id="'+id+'">';
    flash += '<param name="movie" value="'+swf+'" />';
    flash += '<param name="bgcolor" value="#fff" />';
    flash += '<param name="menu" value="false" />';
    flash += '<param name="quality" value="high" />';
    flash += '<embed src="'+swf+'" swliveconnect="true" name="'+id+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'"></embed>';
    flash += '</object>';
    document.write(flash);
}

function exibe_dcr(dcr,width,height,id)
{
    var flash = "";
    flash += '<object id="'+id+'" codebase="http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,0,0,0" border="0" width="'+width+'" height="'+height+'" classid="clsid:166B1BCA-3F9C-11CF-8075-444553540000">';
    flash += '<param name="src" value="'+dcr+'" />';
    flash += '<param name="swStretchStyle" value="fill" />';
    flash += '<embed src="'+dcr+'" name="'+id+'" pluginspage="http://www.macromedia.com/shockwave/download/" class="FlashGame" width="'+width+'" height="'+height+'"></object>';
    document.write(flash);
}

var tamanho_jogo = 0;

function getFlashMovieObject(movieName)
{
    if ( window.document[movieName] ) {
        return window.document[movieName];
    }
    if ( navigator.appName.indexOf("Microsoft Internet") == -1 ) {
        if ( document.embeds && document.embeds[movieName] ) {
            return document.embeds[movieName];
        }
    }
    else {
    	return document.getElementById(movieName);
    }
}

function retornaWidth( height )
{
    var width;
    width = new Number( ( height * 585 ) / 424 );
    return width.toFixed(0);
}

function resizeDiv(width, height)
{
    var movie = getFlashMovieObject("jogo");
    movie.width = width;
    movie.height = height;
}

function resizeDiv2(width, height)
{
    var movie = getFlashMovieObject("jogo");
    movie.width = width;
    movie.height = height;
}

function aumenta_jogo()
{

    if (tamanho_jogo == 0) {
        var movie = getFlashMovieObject("jogo");
        tamanho_jogo = movie.height * 1;
    }

    var h = tamanho_jogo + 60;

    if ( !( h > ( screen.height - 20 ) ) ) {
        tamanho_jogo = h;
        var w = retornaWidth( h );
        if ( screen.width > 600 ) {
           var posDiv =  ( ( screen.width - w ) / 2 ) - 130;
        } else {
           var posDiv =  ( ( screen.width - w ) / 2 );
        }
        var top = h + 12;
        resizeDiv2(w, h);
        altera_propriedades_pagina(posDiv, top, w);
    } 
}

function diminui_jogo()
{
    if (tamanho_jogo == 0) {
        var movie = getFlashMovieObject("jogo");
        tamanho_jogo = movie.height * 1;
    }

    var h = tamanho_jogo - 60;
    if ( !( h <  420 ) ) {
        tamanho_jogo = h;
        var w = retornaWidth( h );
        if ( screen.width > 600 ) {
           var posDiv =  ( ( screen.width - w ) / 2 ) - 130;
        } else {
           var posDiv =  ( ( screen.width - w ) / 2 );
        }
        var top = h + 12;
        resizeDiv2(w, h);
        altera_propriedades_pagina(posDiv, top, w);
    } 
}

function altera_propriedades_pagina(posDiv, top, w)
{
    document.getElementById("addir").style.visibility = "hidden";

    tamanho = w - 10;
    top = top + 71;
}

function progress(type){
    var movie=getFlashMovieObject('jogo');
    var cw=parseInt(document.getElementById('progressContainer').style.width);
    var bw=parseInt(document.getElementById('progressBar').style.width);
    /*try {
    	bw = Math.ceil(cw * movie.PercentLoaded() / 100);
        if(movie.PercentLoaded() == 100) {
            progressHide();
        }
        document.getElementById('progressBar').style.width=bw+'px';
    } catch (err) {
    */
    	var i=Math.ceil(cw/10);
        bw=bw+i;
        if(bw>=cw){
            bw=cw;
            progressHide();
        }
        document.getElementById('progressBar').style.width=bw+'px';
        if(movie.PercentLoaded() == 100) {
            document.getElementById('progressStatus').innerHTML = '<a href="javascript:progressHide();">Jogo carregado. Clica aqui para jogares.</a>';
        }
    //}
}
function progressHide() {
    clearInterval(interval);
    document.getElementById('gameAdsContainer').style.display='none';
    document.getElementById('gameContainer').style.visibility='visible';
}
