/*
# Funções para Banners GE.Net, integração ADSphp
# Erasmo Altimeri - 12/2009
# Gazeta Esporiva - Núcleo WEB
*/
//carregamento
function adsLoadOk(){};

// Sets
function getURL_view(){return 'http://ads.gazetaesportiva.net/viewbanner.php3?bannerID=';}
function getURL_click(){return 'http://ads.gazetaesportiva.net/click.php3?bannerID=';}

//DHTML
//document.write('<style> #sec1{	position: absolute;  	top: 250px;  	left: 320px;  	width: 300px;	height: 200px;  	z-index: 999;  }.visVisible { visibility: visible;}.visHidden  { visibility: hidden ;} </style>');
function Inicializa2() {
		var sec1 = document.getElementById('sec1');
		sec1.className = 'visVisible';
		setTimeout ('hidden2()',  8000);
}  
function hidden2() {  
	var sec1 = document.getElementById('sec1');
	sec1.innerHTML = '';
	sec1.className = 'visHidden';
}


function Inicializa() {
		var sec1 = document.getElementById('sec1');
		sec1.className = 'visVisible';
		setTimeout ('hidden()',  8000);
}  
function hidden() {  
	var sec1 = document.getElementById('sec1');
	sec1.innerHTML = '';
	sec1.className = 'visHidden';
}  
function fechar() {
	var sec1 = document.getElementById('ox_banner_show');
	sec1.innerHTML = '';
	sec1.className = 'visHidden';	
}  

//CSS
function cssStart(tipo){//CSS para os itens 
	switch (tipo){
	case 'flash_x':
		document.write('<style type="text/css">#sec11{position: absolute;top: 0px;left: 0px;width: 728px;height: 90px;z-index: 9999;background: url(gif_transparente.gif);}</style>');
	break
	}
}
//contador externo
function contadorExterno(html_content){
	document.write ('<div style=" position:absolute; top:-100px; left:-100px">'+html_content+'</div>');
}
//Random Banners
function numRandom(aux){ 
	var numero = Math.floor(Math.random() * aux); 
	return numero;
}
// Get variaveis por JS;
function getUrlVars(){
	var vars = [], pedaco;
	var inteira = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
	for (var i = 0; i < inteira.length; i++){
	pedaco = inteira[i].split('=');
	pedaco[1] = unescape(pedaco[1]);
	vars.push(pedaco[0]);
	vars[pedaco[0]] = pedaco[1];
	}
return vars;
}
var getUrlVars2_ok = getUrlVars();
//contador de View (Peças fora do padrão)
function view(id){
	document.write ('<div style=" position:absolute; top:-100px; left:-100px"><img src="'+getURL_view()+id+'" width="1px" height="1px" border="0"/></div>');
}

//Div Expansivels Posicição inicial
function posiciona01(s){
	if(document.layers){return document.layers[s];
	}else if(document.all && !document.getElementById) {return document.all[s];
	}else{return document.getElementById(s);}
}
//Div Expansivels Posicição expandido
function posiciona02(s,x,y){_o = posiciona01(s);_o.style.clip = 'rect(0px '+ x +'px '+ y + 'px 0px)';}

// 250x300 expansível para cima
function a_exp_300x250(){
	document.getElementById('expansivel_dds').style.height = 500;
	document.getElementById('expansivel_dds').style.maginTop = -250;
	document.getElementById('expansivel_dds').scrollTop = 0;
}
function f_exp_300x250(){
	document.getElementById('expansivel_dds').style.height = 250;
	document.getElementById('expansivel_dds').style.maginTop =  0;
	document.getElementById('expansivel_dds').scrollTop = 250;
	document.getElementById('expansivel_dds').overflow = 'hidden';
}

//Object Flash metodo antigo (Não utilizado)
function objFlash_back(flash_tag, tamanho_w, tamanho_h){
	var URL_view = getURL_view();
	var URL_click = getURL_click();
	var retorno = '<object width="'+tamanho_w+'" height="'+tamanho_h+'">';
	retorno += '<param name="movie" value="'+URL_view+flash_tag+'&clickTag='+URL_click+flash_tag+'"/></param>';
	retorno += '<param name="allowFullScreen" value="true"/></param>';
	retorno += '<param name="wmode" value="transparent" /></param>';
	retorno += '<param name="allowscriptaccess" value="always"/></param>';
	retorno += '<embed src="'+URL_view+flash_tag+'&clickTag='+URL_click+flash_tag+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="'+tamanho_w+'" height="'+tamanho_h+'" wmode="transparent" /></embed>';
	retorno += '</object>';
	document.write (retorno);
}
//Object Flash 2
function objFlash(flash_tag, tamanho_w, tamanho_h){
	var URL_view = getURL_view();
	var URL_click = getURL_click();

	var retorno = '<embed type="application/x-shockwave-flash" ';
	retorno += 'src="'+URL_view+flash_tag+'" ';
	retorno += 'id="movie_player_'+flash_tag+'" ';
	retorno += 'name="movie_player'+flash_tag+'" ';
	retorno += 'bgcolor="#000000" ';
	retorno += 'quality="high" ';
	retorno += 'allowfullscreen="true" ';
	retorno += 'wmode="transparent" ';
	retorno += 'allowscriptaccess="always" ';
	retorno += 'flashvars="clickTag='+URL_click+flash_tag+'&clickTAG='+URL_click+flash_tag+'" ';
	retorno += 'height="'+tamanho_h+'" ';
	retorno += 'width="'+tamanho_w+'">';
	//teste
	//retorno += '<div style="position:absolute; top:-1000px; left:-1000px"><img src="http://www.gazetaadventure.com.br/testes/view.php" width="1px" height="1px" border="0"/></div>';
	document.write (retorno);
}

// Exibe variações de exibição Flash + HTML para os Banners
function viewMedia(flash_id, tipo, tamanho_w, tamanho_h){
	var URL_view = getURL_view();
	var URL_click = getURL_click();
	
	// verifica se esta utilizando GET "teste" para ver a peça;
	var urlsaux = getUrlVars(); 
	if (urlsaux['ads'] > 0){
		flash_id = urlsaux['ads'];
	}
	switch (tipo) {
		case 'flash_x'://Flash com DIV transparente na frente
			cssStart('flash_x');
			document.write ('<div style="margin: 0 auto; width:'+ tamanho_w +'; height:' + tamanho_h + ' ;" >');
			document.write ('<a href="'+URL_click+flash_id+'" target="_blank"><div ID="sec11"></div></a>');
			objFlash(flash_id, tamanho_w, tamanho_h);
			document.write ('</div>');
			
		break
		case 'flash':// Flash convencional
			document.write ('<div style="width:'+ tamanho_w +'; height:' + tamanho_h + ' ;" >');
			objFlash(flash_id, tamanho_w, tamanho_h);
			document.write ('</div>');
		break
		case 'html'://HTML convencional
			document.write ('<div align="center">');
			document.write ('<a href="'+URL_click+flash_id+'" target="_BLANK">');
			document.write ('<img src="'+URL_view+flash_id+'" width="'+tamanho_w+'"  height="'+tamanho_h+'" border="0">');
			document.write ('</a>');
			document.write ('</div>');
		break
		case 'expan_728x90'://FLASH espansível (somente 728x90 a 728x300 para baixo)
			document.write ('<DIV id="Layer01" style="Z-INDEX: 100; WIDTH: 728px; POSITION: relative; HEIGHT: 90px">');
			document.write ('<DIV id="Layer02" onmouseover="posiciona02(\'Layer02\',728,300)" style="Z-INDEX: 100; LEFT: 0px; WIDTH: 728px; CLIP: rect(0px 728px 90px 0px); POSITION: absolute; TOP: 0px; HEIGHT: 90px" onmouseout="posiciona02(\'Layer02\',728,90)">');
			objFlash(flash_id, 728, 300);
			document.write ('</div></div>');
		break
		case 'expan_300x250_c'://FLASH expansível (somente 300x250 a 300x500 para cima)
			//document.write ('<DIV id="Layer01" style="Z-INDEX: 100; WIDTH: 300px; POSITION: relative; HEIGHT: 250px">');
			document.write('<div id="expansivel_dds"style="margin-top:-250px; height:auto">');
			//document.write('<div id="expansivel_dds"onmouseover="a_exp_300x250()" onmouseout="f_exp_300x250()" style="margin-top:-250px; height:auto">');
			objFlash(flash_id, 300, 500);
			document.write ('</div>');
			
		break
		case 'DHTML_f'://FLASH DHTML com botão fechar
				document.write ('<div ID="sec1" class="visHidden" align="right">');
				document.write ('<div id="sec2" style="z-index:99999"><a style="background-color:#dd0000; padding:2px 5px; color:#FFF" href="javascript:hidden()"><b>Fechar</b></a></div>');
				objFlash(flash_id, tamanho_w, tamanho_h);
				document.write ('</div>');
				window.onload  = Inicializa;
		break
		case 'DHTML'://FLASH DHTML
				document.write ('<div ID="sec1" class="visHidden" align="right">');
				objFlash(flash_id, tamanho_w, tamanho_h);
				document.write ('</div>');
				window.onload  = Inicializa;	
		break
	}
 }

//Openx 2010 ---------------------------------------------------------------------------------------

// Integração
function idZonaOX(id_zonaX){
	//carrega após Load da pagina
	window.onLoad = idZonaOX_ok(id_zonaX);
}
function idZonaOX_ok(id_zonaX){
	/* (id_zona);
		1# Super
		2# Full
		3# Botão
		4# Texto
		5# Sky
		6# Full
		7# Botão
		8# Arroba
		9# Flutuante
	*/
	id_zona = getIdZona(id_zonaX);
	
	if(typeof(admin_banner) == 'undefined'){//verifica se não esta no admin

		switch (id_zonaX) {
			case 9: 
				//Flutuante
				var m3_r = Math.floor(Math.random()*99999999999);
				var ox_u = 'http://adserver.gazetaesportiva.net/www/delivery/al.php?zoneid='+id_zona+'&target=_blank&cb='+m3_r +'&ct0=JAVASCRIPT:hidden()&layerstyle=simple&align=center&valign=top&padding=5&closetext=%5BFECHAR%5D&closetime=8&padding=0&shifth=0&shiftv=130&nobg=t&noborder=t';
				if (document.context) ox_u += '&context=' + escape(document.context);
			   document.write("<scr"+"ipt type='text/javascript' src='" + ox_u + "'></scr"+"ipt>");
			break;
			case 10: 
				//Flutuante
				var m3_r = Math.floor(Math.random()*99999999999);
				var ox_u = 'http://adserver.gazetaesportiva.net/www/delivery/al.php?zoneid='+id_zona+'&target=_blank&cb='+m3_r +'&ct0=JAVASCRIPT:hidden()&layerstyle=simple&align=center&valign=top&padding=0&closetime=10&padding=0&shifth=0&shiftv=0&nobg=t&noborder=t';
				if (document.context) ox_u += '&context=' + escape(document.context);
			    document.write("<scr"+"ipt type='text/javascript' src='" + ox_u + "'></scr"+"ipt>");
			
			break;
			default: 
				//Banner normal
				var m3_u = (location.protocol=='https:'?'https://adserver.gazetaesportiva.net/www/delivery/ajs.php':'http://adserver.gazetaesportiva.net/www/delivery/ajs.php');
				var m3_r = Math.floor(Math.random()*99999999999);
				if (!document.MAX_used) document.MAX_used = ',';
				document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
				document.write ("?zoneid=" + id_zona);
				document.write ('&amp;cb=' + m3_r);
				if (document.MAX_used != ',') document.write ("&nobg=t&amp;exclude=" + document.MAX_used);
				document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
				document.write ("&amp;loc=" + escape(window.location));
				if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
				if (document.context) document.write ("&context=" + escape(document.context));
				if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
				document.write ("'><\/scr"+"ipt>");
				document.write ("<noscr"+"ipt><a href='http://adserver.gazetaesportiva.net/www/delivery/ck.php?n=a874312e&amp;cb="+ m3_r+"' target='_blank'><img src='http://adserver.gazetaesportiva.net/www/delivery/avw.php?zoneid="+id_zona+"&amp;cb="+ m3_r+"&amp;n=a874312e' border='0' alt='' /></a><\/noscr"+"ipt>");
		}
	}
}