function GmcPlay(url) {	
         window.open(url,'GMC');
}


function gmcPop() {	
         window.open('http://gmc.globo.com/GMC/0,,2465-MC30,00.html','GMC');
}/**
 * Criado por Globo.com - Tecnologia
 * Copyright 2004 TV Globo LTDA
 */

/**
 * @author Globo.com - Tecnologia
 *
 * Função utilizada para a leitura de um cookie.
 * 
 * @param name o nome do cookie
 *
 * @return o conteúdo do cookie
 */
function readCookie(name)
{   
	var nameEQ = name + "=";
         var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') 
		{
			c = c.substring(1,c.length);
		}
      		if (c.indexOf(nameEQ) == 0) 
   		{
   			return unescape(c.substring(nameEQ.length,c.length));
   		}
	}
	return null;
}

/**
 * @author Globo.com - Tecnologia
 *
 * Função utilizada para criar um cookie.
 *
 * @param name o nome do cookie
 * @param value o conteúdo do cookie
 * @param hours o número de horas pelo qual o cookie deve permanecer válido
 * @param path o path do cookie
 */
function createCookie(name,value,hours,path)
{
	if (hours)
	{
		var date = new Date();
		date.setTime(date.getTime()+(hours*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else 
	{
		var expires = "";
	}
	document.cookie = name+"="+escape(value)+expires+"; path="+path;
}

/**
 * @author Globo.com - Tecnologia
 *
 * Função utilizada para apagar um cookie.
 * Se for Mac, seta a expiração para um tempo curto, caso contrário seta a expiração imediata.
 *
 * @param name o nome do cookie a ser apagado.
 */
function eraseCookie(name,path)
{
	var mac = (navigator.appVersion.indexOf("Mac") != -1) ? true : false;
	if (mac)
	{
		createCookie(name,"",0.001,path);
 	}
	else
	{
		createCookie(name,"",-1,path);
	}
}
// Inicio Flash Generica
function AC_AddExtension(src, ext) {
 if (src.indexOf('?') != -1) return src.replace(/\?/, ext+'?'); 
 else return src + ext;
}
 
function AC_Generateobj(objAttrs, params, embedAttrs) { 
 var str = '<object ';
 for (var i in objAttrs) str += i + '="' + objAttrs[i] + '" ';
 str += '>';
 for (var i in params) str += '<param name="' + i + '" value="' + params[i] + '" /> ';
 str += '<embed ';
 for (var i in embedAttrs) str += i + '="' + embedAttrs[i] + '" ';
 str += ' ></embed></object>';
 document.write(str);
}
 
function AC_FL_RunContent(){
 var ret = AC_GetArgs ( arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000", "application/x-shockwave-flash" );
 AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}
 
function AC_SW_RunContent(){
 var ret = AC_GetArgs ( arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000", null );
 AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}
 
function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
 var ret = new Object();
 ret.embedAttrs = new Object();
 ret.params = new Object();
 ret.objAttrs = new Object();
 for (var i=0; i < args.length; i=i+2){
  var currArg = args[i].toLowerCase();    
  switch (currArg){ 
   case "classid":
    break;
   case "pluginspage":
      ret.embedAttrs[args[i]] = args[i+1];
      break;
   case "src":
   case "movie": 
      args[i+1] = AC_AddExtension(args[i+1], ext);
      ret.embedAttrs["src"] = args[i+1];
      ret.params[srcParamName] = args[i+1];
      break;
   case "onafterupdate": case "onbeforeupdate": case "onblur": case "oncellchange": case "onclick":
   case "ondblClick": case "ondrag": case "ondragend": case "ondragenter": case "ondragleave":
   case "ondragover": case "ondrop": case "onfinish": case "onfocus": case "onhelp":
    case "onmousedown": case "onmouseup": case "onmouseover": case "onmousemove":
   case "onmouseout": case "onkeypress": case "onkeydown": case "onkeyup": case "onload":
   case "onlosecapture": case "onpropertychange": case "onreadystatechange": case "onrowsdelete":
   case "onrowenter": case "onrowexit": case "onrowsinserted": case "onstart": case "onscroll":
   case "onbeforeeditfocus": case "onactivate": case "onbeforedeactivate": case "ondeactivate":
   case "type": case "codebase":
    ret.objAttrs[args[i]] = args[i+1];
    break;
   case "width": case "height": case "align": case "vspace": case "hspace": case "class": 
   case "title": case "accesskey": case "name": case "id": case "tabindex":
    ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
    break;
   default:
    ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
  }
 }
 ret.objAttrs["classid"] = classid;
 if (mimeType) ret.embedAttrs["type"] = mimeType;
 return ret;
}
 
function glbFO(params) {
 
 if(!params.flashvars) params.flashvars = '';
 if(!params.version) params.version = 7;
 if(!params.id) params.id = 'flash' + new Date().getTime();
 if(!params.quality) params.quality = 'high';
 if(!params.bgcolor) params.bgcolor = '#ffffff';
 if(!params.wmode) params.wmode = 'window';
 if(!params.allowScriptAccess) params.allowScriptAccess = 'sameDomain';
 
 if(params.src.indexOf('.swf') > -1) params.src = params.src.split('.swf').join('');
 
 AC_FL_RunContent(
  'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + params.version + ',0,0,0',
  'width', params.width,
  'height', params.height,
  'src', params.src,
  'movie', params.src,
  'quality', params.quality,
  'bgcolor', params.bgcolor,
  'wmode', params.wmode,
  'id', params.id,
  'name', params.id,
  'allowScriptAccess', params.allowScriptAccess,
  'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
  'flashvars', params.flashvars
 );
 
}

// Fim Flash Generica
var net=new Object();
net.READY_STATE_UNINITIALIZED=0;
net.READY_STATE_LOADING=1;
net.READY_STATE_LOADED=2;
net.READY_STATE_INTERACTIVE=3;
net.READY_STATE_COMPLETE=4;

// Construtor
net.ContentLoader=function(url,onload,onerror,handle)
{
	this.handle=handle;  
	this.url=url;
	this.req=null;
	this.onload=onload;
	this.onerror=(onerror) ? onerror : this.defaultError;
	this.loadContent(url);
}
// Definindo objeto
net.ContentLoader.prototype={
	// Funcao que baixa conteudo de uma url
	loadContent:function(url)
	{
		if (window.XMLHttpRequest)
		{
			this.req=new XMLHttpRequest();
		} 
		else if (window.ActiveXObject)
		{
			this.req=new ActiveXObject("Microsoft.XMLHTTP");				
		}
		if (this.req)
		{
			try{
			var loader=this;
			this.req.onreadystatechange=function()
			{
				loader.onReadyState.call(loader);
			}
                           	this.req.open('GET',url,true);
                           	this.req.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
			this.req.send(null);
			}
			catch (err)
			{
				this.onerror.call(this);
			}
		}
	},
	// Callback de recebimento do conteudo
	onReadyState:function()
	{			
		var req=this.req;
		var ready=req.readyState;
		if (ready==net.READY_STATE_COMPLETE)
		{
			var httpStatus=req.status;
			if (httpStatus==200 || httpStatus==0)
			{
				this.onload.call(this);
			}
			else
			{
				this.onerror.call(this);
			}
		}
	},
	// Handler de erro padrão caso nao seja passado no construtor
	defaultError:function()
	{
		alert('Erro de comunicação com o servidor. Tente novamente.');
	}
}

function xmlObj(args) {
	this._args = args;
	this.load( this._args.obj.opt );
}

xmlObj.prototype.load = function( param ) {
	this._request = this._getXMLHTTPRequest();
	var _this = this;
	this._request.onreadystatechange = function(){_this._onData()};
	this._request.open( "POST" , this._args.url , true ) ;
         this._request.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded");         
         this._request.send( param ) ;
}

xmlObj.prototype._onData = function() {
	if(this._request.readyState == 4) {
		if(this._request.status == "200") {
			var obj = this._args.obj;
			var func = this._args.func;
			var args = this._args.args;
			args.html = this._request.responseText;
			obj[func](args);
		} else {
			if(this.onError != undefined) {
				this.onError({status:this_request.status, 
						statusText:this._request.statusText});
			}
		}
		delete this._request;
	}
}

xmlObj.prototype._getXMLHTTPRequest = function(){
	var xmlHttp;
	try	{
		xmlHttp = new ActiveXObject("Msxml2.XMLHttp");
	} catch(e) {
		try {
			xmlHttp = new ActiveXObject("Microsoft.XMLHttp");
		} catch(e2) {}
	}
	if(xmlHttp == undefined && (typeof XMLHttpRequest != 'undefined')) {
		xmlHttp = new XMLHttpRequest();
	}
	return xmlHttp;
}

var protoglb = new Object();

protoglb.move = function(target,objMove,offx,offy){
	this.target = target;
	this.obj = objMove;
	this.offx = offx;
	this.offy = offy;
	this.obj.style.left = this.moveX(this.offx,this.target)+"px";
	this.obj.style.top = this.moveY(this.offy,this.target)+"px";
	return false;
};

protoglb.move.prototype = {
	moveX:function(x, elem) {
		if (!document.layers) {
			var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
			var mac = document.all && !onWindows && getExplorerVersion() == 4.5;
			var par = elem;
			var lastOffset = 0;
			while(par){
				if(par.leftMargin && !onWindows) x += parseInt(par.leftMargin);
				if((par.offsetLeft != lastOffset) && par.offsetLeft ) x += parseInt(par.offsetLeft);
				if(par.offsetLeft != 0) lastOffset = par.offsetLeft;
				par = mac ? par.parentElement : par.offsetParent;
			}
		} else if (elem.x) x += elem.x;
		return x;	
	},
	moveY:function(y, elem) {
		if(!document.layers) {
			var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
			var mac = document.all && !onWindows && getExplorerVersion() == 4.5;
			var par = elem;
			var lastOffset = 0;
			while(par){
				if( par.topMargin && !onWindows ) y += parseInt(par.topMargin);
				if( (par.offsetTop != lastOffset) && par.offsetTop ) y += parseInt(par.offsetTop);
				if( par.offsetTop != 0 ) lastOffset = par.offsetTop;
				par = mac ? par.parentElement : par.offsetParent;
			}		
		} else if (elem.y >= 0) y += elem.y;
		return y;
	}
}

function busca(q,i) {

	var node = q.cloneNode(true);
	var img = node.getElementsByTagName('img')[0];
	node.removeChild(img);

	this.index = i;
	this.q = node.innerHTML.trim() ;
	this.opt = "q=" + this.q ;
	this.url="/Portal/globonoticias/busca/glb_gnoticias_busca_corpo_materia";	
	var divT = document.createElement('div');
	divT.id = 'boxBusca';
	divT.innerHTML = '<a class="close" href="javascript:;" onclick="jclose(this,' +i+ ');"><img src="/Portal/globonoticias/img/boxBuscaClose.gif" width="15" height="15" alt="fechar" /></a><h3><span>Busca</span></h3>';
	
	var divC = document.createElement('div');
	divC.id = 'boxBuscaConteudo';
	divC.innerHTML = '<h4>carregando...</h4>';

	divT.appendChild(divC);
	document.body.appendChild(divT);
	
	this.container = divT;
	this.conteudo = divC;
	
	new protoglb.move(q,divT,-50,15);

	var self = this;
	this.msg = new xmlObj( { url: self.url, func: 'loadMe', obj: self, args: {} } );
	
	if(oldBusca) oldBusca.parentNode.removeChild(oldBusca);
	oldBusca = divT;
}

busca.prototype.rstMe = function() {
	this.msg = '';
         oldBusca = '';
}

busca.prototype.loadMe = function(a) {
	var div = this.conteudo;
	div.innerHTML = '';
	div.innerHTML = a.html;
}

var buscas = [];
var oldBusca = '';

function addBusca(q) {
	buscas.push(new busca(q,buscas.length));	
}

function rstBusca() {
	buscas.push(new busca(q,buscas.length));	
}

function jclose(o,i) {
	buscas[i].rstMe();
	o.parentNode.parentNode.removeChild(o.parentNode);
}
function createCookieGnoticias(nome,estado,cidade)
{
  var expiration = new Date();
  expiration.setTime(expiration.getTime() + 3000*24*60*60*1000);
  document.cookie = nome+"="+estado+"|"+cidade + "; expires="+expiration.toGMTString();
}

function getCookieGnoticias(name)
{ var cname = name + "=";               
  var dc = document.cookie;             
  if (dc.length > 0) 
  { begin = dc.indexOf(cname);       
    if (begin != -1) 
    { begin += cname.length;       
      end = dc.indexOf(";", begin);
      if (end == -1) end = dc.length;
      return unescape(dc.substring(begin, end));
    } 
  }
  return null;
}

function wGLBflash(w,h,src,bg,q,t,n) {
				var flagT = 'wmode="transparent"';
				var flgN = '';
				if(n) flgN = 'name="'+n+'" id="'+n+'"';
				if(!t) flagT = '';
				document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownloadocument.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + w + '" height="' + h + '" ' + flgN + '>');
				document.write('<param name="movie" value="' + src + '" /><param name="quality" value="high" /><param name="flashvars" value="' + q + '" /><param name="bgcolor" value="' + bg + '" />');
				if(t) document.write('<param name="wmode" value="transparent" />');
				document.write('<embed ' + flgN + ' src="' + src + '" flashvars="' + q + '" quality="high" bgcolor="' + bg + '" width="' + w + '" height="' + h + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>');
			}

function resizeEnquete()
{
  var d=document;
  if( !d.getElementById('publicidade') ) 
  {
    if( d.getElementById('enquete') )
    {
      d.getElementById('enquete').style.width='99.5%';
    }
  }
}

var tam = 12;

function mudaFonte( tipo )
{
  if( tipo == 'mais' )
  {
    if( tam < 16 ) tam += 2 ;    			 
  }
  else
  {
    if( tam > 9 ) tam -= 2 ;
  }
  if( document.getElementById( 'mudaFonte' ) )
    mudaFonteRecursiva( tipo , document.getElementById( 'mudaFonte' ) ) ;

  if( document.getElementById( 'mudaFoto' ) )
    mudaFonteRecursiva( tipo , document.getElementById( 'mudaFoto' ) ) ;  
}

function mudaFonteRecursiva( tipo , domElement )
{		
  for( var i = 0 ; i < domElement.childNodes.length ; i++ )
  {
    mudaFonteRecursiva( tipo , domElement.childNodes.item( i )  ) ;
  }
  if( domElement.style )
    domElement.style.fontSize = tam+'px';
}

function createCookie(name,value,days) {
  if (days) 
  {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  } 
  else var expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++)
  {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
      if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

var flag=0;
function mudaBg(num){
	if (flag==0){
		document.getElementById('tab'+num).style.backgroundColor='#EEEEEE';
		document.getElementById('tab'+num).style.color='#D90000';
		flag=num;
	}else{
		document.getElementById('tab'+num).style.backgroundColor='#EEEEEE';
		document.getElementById('tab'+num).style.color='#D90000';
		document.getElementById('tab'+flag).style.color='#333333';
		document.getElementById('tab'+flag).style.backgroundColor='#C8CED3';
		flag=num;
	}
}

function popupGaleria(lnk) {
			window.open(lnk,'popupGaleria','width=730,height=535,resizable=0,status=0,menubar=0,scrollbars=0');
		}

function OAS_AD(parametro){}

function abrirPopDebate()
{
  window.open( 'http://popcopa.gmc.globo.com/gmcpopcopa/PopCopa?idJogo=1' , 'janela' , 'resize=0,width=500,height=460,top=30,left=30,addressbar=0,statusbar=0,menubar=0,scrollbars=0,toolbar=0') ; 
}


function abrePopDebate(URL) 
{
	window.open(URL,'pop', 'height = 469, width = 599','scrollbars = no')	
}

function trackerPortal(obj, index)
{
 try {
  re = /https?\:\/\/[^\'\"]+/;
  array = obj.href.match(re);
  if (array != null && array.length > 0)
  {
   str = array[0].replace(/^https?\:\/\//, ""); 
   urchinTracker("/out/" + index + "/" + str);
  }
 }catch(e){}
}

function strltrim() 
{
  //Match spaces at beginning of text and replace with a null string
  return this.replace(/^\s+/,'');
}

function strrtrim() 
{
  //Match spaces at end of text and replace with a null string
  return this.replace(/\s+$/,'');
}

function strtrim() 
{
  //Match spaces at beginning and end of text and replace with null strings
  return this.replace(/^\s+/,'').replace(/\s+$/,'');
}

// Adding methods to String class
String.prototype.ltrim = strltrim;
String.prototype.rtrim = strrtrim;
String.prototype.trim = strtrim;


/* FIM JS GENERICO */
