//Versao 1.3
//GMCEmbedCreator -------------------
function GMCEmbedCreator(config)
{
this.id = null;
this.config = config;
this.jaDeuPlay = false;
}
GMCEmbedCreator.prototype.getBanda = function()
{
return this.config.banda;
}
GMCEmbedCreator.prototype.incrementaCookiePropaganda = function()
{
if( !gmcEmbedDetecter.isWmpEmbed() )
{
var i = gmcEmbedUtil.getCookie("Propaganda");
var contador;
try
{
contador = eval(i);
}
catch(e)
{
}
if(!contador) contador=0;
//alert(contador);
contador++;
gmcEmbedUtil.setCookie("Propaganda",contador,2);
}
}
GMCEmbedCreator.prototype.zeraCookiePropaganda = function()
{
gmcEmbedUtil.setCookie("Propaganda","0",2);
}
GMCEmbedCreator.prototype.play = function()
{
if( !this.jaDeuPlay )
{
this.config.autoStart = true;
var url = gmcEmbedUtil.getUrlPlay(this.config);
location.href = url;
}
}
GMCEmbedCreator.prototype.reloadImagem = function()
{
this.config.autoStart = false;
var url = gmcEmbedUtil.getUrlPlay(this.config);
location.href = url;
}
GMCEmbedCreator.prototype.showWmp = function()
{
this.putWmpTag();
this.jaDeuPlay = true;
}
GMCEmbedCreator.prototype.showFimDeVideo = function()
{
if( this.config.mostraFimVideo=="true" && !this.config.escondeFimVideo )
{
this.config.autoStart = true;
var url = gmcEmbedUtil.getUrlFim(this.config);
location.href = url;
}
else
{
this.config.autoStart = false;
var url = gmcEmbedUtil.getUrlPlay(this.config);
location.href = url;
}
}
GMCEmbedCreator.prototype.showImagem = function()
{
try
{
document.getElementById(this.config.div).innerHTML = "";
document.getElementById(this.config.div).style.display = "none";
document.getElementById(this.config.divTitulo).style.display = "block";
document.getElementById(this.config.divImagem).style.display = "block";
document.getElementById(this.config.divFormEnviar).className = "off";
document.getElementById(this.config.divParabens).className = "off";
}
catch(e) {}
this.jaDeuPlay = false;
}
GMCEmbedCreator.prototype.putWmpTag = function()
{
document.getElementById(this.config.divTitulo).style.display = "none";
document.getElementById(this.config.divImagem).style.display = "none";
document.getElementById(this.config.div).style.display = "block";
var p;
var largura = gmcEmbedUtil.getLargura(this.config.banda);
var altura = gmcEmbedUtil.getAltura(this.config.banda);
if( gmcEmbedDetecter.isWmpEmbed() )
{
p = new GMCEmbedTag(largura, altura + this.config.barra_embed,this.config.url);
document.getElementById(this.config.div).innerHTML = p.toString();
}
else
{
p = new GMCObjectTag(largura, altura + this.config.barra_wmp,this);
document.getElementById(this.config.div).innerHTML = p.toString();
document.getElementById(p.id).URL = config.url;
p.monitora();
}
this.id = p.id;
}
GMCEmbedCreator.prototype.adaptaBanda = function()
{
//this.setaCookieBanda();
gmcEmbedUtil.adaptaBanda( this.config.banda );
}
GMCEmbedCreator.prototype.telaCheia = function()
{
if( !gmcEmbedDetecter.isWmpEmbed() )
{
var m = document.getElementById(this.id);
if( m && m.playState == 3 )
{
var t = gmcEmbedUtil.getCookie("GMCEmbedTelaCheia");
if( !t || t.length==0 )
{
var m = "Para voltar ao modo de visualizaĆ§Ć£o normal aperte a tecla ESC";
alert(m);
}
try
{
document.getElementById(this.id).fullScreen = true;
gmcEmbedUtil.setCookie("GMCEmbedTelaCheia","true",30);
}
catch(e)
{
}
}
}
}
//Tags -------------------
function GMCEmbedTag(width,height,url)
{
this.id = "gmcPlayer_" + (new Date().getTime()) + (Math.random()+"").replace(".","_");
this.width = width;
this.height = height;
this.url = url;
}
GMCEmbedTag.prototype.toString = function()
{
var tag = '';
var src = '';
if(this.url) src = 'src="' + this.url + '"';
tag += '';
return tag;
}
function GMCObjectTag(width,height,creator)
{
this.id = "gmcPlayer_" + (new Date().getTime()) + (Math.random()+"").replace(".","_");
this.width = width;
this.height = height;
this.creator = creator;
this.ultimaMidia = null;
}
GMCObjectTag.prototype.toString = function()
{
var tag = '';
tag += '';
return tag;
}
GMCObjectTag.prototype.monitora = function()
{
try
{
mediaIndex = mediaArray.length;
mediaArray.push(this);
}
catch(e)
{
mediaArray = [];
mediaIndex = mediaArray.length;
mediaArray.push(this);
}
var script = 'mediaArray[' + mediaIndex + '].onPlayStateChange(s);';
var event = 'playStateChange(s)';
createScript(this.id,script,event);
var script = 'mediaArray[' + mediaIndex + '].onMediaChange(m);';
var event = 'MediaChange(m)';
createScript(this.id,script,event);
var script = 'mediaArray[' + mediaIndex + '].onOpenStateChange(s);';
var event = 'OpenStateChange(s)';
createScript(this.id,script,event);
}
GMCObjectTag.prototype.telaCheia = function()
{
mediaArray[mediaArray.length-1].fullScreen()
}
GMCObjectTag.prototype.getInfo = function(s)
{
try
{
return document.getElementById( this.id ).currentMedia.getItemInfo(s);
}
catch(e)
{
return false;
}
}
GMCObjectTag.prototype.isPropaganda = function()
{
var p = this.getInfo("propaganda");
return ( p && p=='true' );
}
GMCObjectTag.prototype.getIdMidia = function()
{
return this.getInfo("idMidia");
}
GMCObjectTag.prototype.isUltimo = function()
{
var p = this.getInfo("ultimo");
return ( p && p=='true' );
}
GMCObjectTag.prototype.getLargura = function()
{
return document.getElementById( this.id ).width;
}
GMCObjectTag.prototype.onOpenStateChange = function(s)
{
if( s == 16 ) this.drm = true;
}
GMCObjectTag.prototype.onPlayStateChange = function(s)
{
if( s==8 && this.isUltimo() )
{
try{ document.getElementById("telaCheia").style.display = "none"; }catch(e){}
if( this.getLargura() >= 320 )
{
this.finalizou = true;
this.creator.showFimDeVideo();
}
}
else if( s==10 || s==1 )
{
if( !this.drm )
{
try{ document.getElementById("telaCheia").style.display = "none"; }catch(e){}
if( !this.finalizou )
{
this.finalizou = true;
this.creator.reloadImagem();
}
}
}
else
{
if( s==3 || s==6 ) this.drm = false;
try{ document.getElementById("telaCheia").style.display = "inline"; }catch(e){}
}
}
GMCObjectTag.prototype.onMediaChange = function(s)
{
if( this.isPropaganda() )
{
this.creator.zeraCookiePropaganda();
}
var id = this.getIdMidia();
if( id && id!=this.ultimaMidia )
{
this.creator.incrementaCookiePropaganda();
this.ultimaMidia = id;
}
}