/*JAVASCRIPT*/
/*menu*/
function loadMenu(){
	var menu	= document.getElementById("menu");
	var itens	= menu.getElementsByTagName("li");
	for ( var i = 0; i < itens.length; ++i ){
		var item	= itens[i];
		item.onmouseover	= function(){$("#coluna-meio").find("object").css("visibility", "hidden");}
		item.onmouseout		= function(){$("#coluna-meio").find("object").css("visibility", "");}
		var submenu	= item.className.split(" ")[0];
		submenu		= submenu.replace("item-", "menu-");
		submenu		= document.getElementById( submenu );
		if ( submenu ){
			submenu.pai			= item.getAttribute('pai');
			item.submenu		= submenu;
			item.onmouseover	= function(){
				this.submenu.style.display	= 'block';
				$("#coluna-meio").find("object").css("visibility", "hidden");
			}
			item.onmouseout		= function(){ 
				this.submenu.style.display	= '';
				$("#coluna-meio").find("object").css("visibility", "");
			}
			submenu.onmouseover	= function(){
				this.style.display	= 'block';
				if ( this.pai ){ document.getElementById( this.pai ).style.display	= 'block'; }
			}
			submenu.onmouseout	= function(){
				this.style.display	= '';
				if ( this.pai ){ document.getElementById( this.pai ).style.display	= ''; }
			}
		}
		
	}
}
/*fim menu*/
/*TRIM*/
function Trim(TRIM_VALUE){
	if(TRIM_VALUE.length < 1){
		return"";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE==""){
		return "";
	}
	else{
		return TRIM_VALUE;
	}
} //End Function

function RTrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0){
		return"";
	}
	var iTemp = v_length -1;

	while(iTemp > -1){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;

	} //End While
	return strTemp;

} //End Function

function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	} //End While
	return strTemp;
} //End Function
/*fim TRIM*/
/*
url-loading object and a request queue built on top of it
*/

/* namespacing object */
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;


/*--- content loader object for cross-browser requests ---*/
net.ContentLoader=function(url,onload,onerror,method,params,contentType){
	this.url	= url;
  this.req=null;
  this.onload=onload;
  this.onerror=(onerror) ? onerror : this.defaultError;
  this.loadXMLDoc(url,method,params,contentType);
}

net.ContentLoader.prototype.loadXMLDoc=function(url,method,params,contentType){
  if (!method){
    method="GET";
  }
  if (!contentType && method=="POST"){
    contentType='application/x-www-form-urlencoded';
  }
  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(){
        net.ContentLoader.onReadyState.call(loader);
      }
      this.req.open(method,url,true);
      if (contentType){
        this.req.setRequestHeader('Content-Type', contentType);
      }
      this.req.send(params);
    }catch (err){
      this.onerror.call(this);
    }
  }
}


net.ContentLoader.onReadyState=function(){
	var req=this.req;
	var ready=req.readyState;
	var httpStatus;
	try { httpStatus = this.transport.status; } catch(e) { httpStatus = 0; }
	if (ready==net.READY_STATE_COMPLETE){
		if (httpStatus==200 || httpStatus==0){
			this.onload.call(this);
		}else{
			this.onerror.call(this);
		}
	}
}

net.ContentLoader.prototype.defaultError=function(){
  alert("error fetching data!"
    +"\n\nreadyState:"+this.req.readyState
    +"\nstatus: "+this.req.status
    +"\nheaders: "+this.req.getAllResponseHeaders());
}

/* OAS SETUP */
//configuration 7
			
OAS_version = 11;
OAS_url = 'http://ads.globo.com/RealMedia/ads/';
OAS_listpos = 'Top,Right1,Right2,Frame1';
// Varifica se lista foi setada no layout
if (typeof OAS_listposLayout != 'undefined') {
	OAS_listpos = OAS_listposLayout;
}
OAS_query = '';
OAS_target = '_blank';
OAS_rn = '001234567890'; OAS_rns = '1234567890';
OAS_rn = new String (Math.random()); OAS_rns = OAS_rn.substring (2, 11);
		
//end of configuration	


	function OAS_NORMAL(pos) {
		document.write('<A HREF="' + OAS_url + 'click_nx.ads/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + '!' + pos + '?' + OAS_query + '" TARGET=' + OAS_target + '>');
	  	document.write('<IMG SRC="' + OAS_url + 'adstream_nx.ads/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + '!' + pos + '?' + OAS_query + '" BORDER=0></A>');
	}

	function OAS_AD(pos) {
		if (OAS_listpos.search(pos) == -1) {
			return;
		}
		if (OAS_version >= 11) {
			OAS_RICH(pos); 
		} else { 
			OAS_NORMAL(pos); 
		}
	}

	var oas_print_flag = 0;
	function OAS_PrintGLB() {
		if (oas_print_flag == 0) {
			oas_print_flag = 1;
			if (OAS_version >= 11)
			  document.write('<script type="text/javascript" language="Javascript1.1" SRC="' + OAS_url + 'adstream_mjx.ads/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + '?' + OAS_query + '"><\/script>');
		}	 
	}
/* /OAS SETUP end */

/* globo esporte news */
function loadNoticiasGloboEsporte(){
	var conteudo	= document.getElementById( "futnews_quadro" );
	
	//cria imagem de carregando
	var img	= document.createElement( "img" );
	img.id	= "loadingNoticia";
	img.alt	= "carregando notícias";
	img.title	= img.alt;
	img.src		= "img/loading.verde.gif";
	conteudo.appendChild( img );
	
	document.getElementById( "futnews_quadro_noticias" ).style.display	= "none";
	
	var loader		= new net.ContentLoader(
		'noticias.php',
		loadNoticiasGloboEsporteRetorno
	)
}
function loadNoticiasGloboEsporteRetorno(){
	var xml	=  this.req.responseXML;
	if ( xml ){
		var noticias	= xml.getElementsByTagName( "noticia" );
		var conteudo	= document.getElementById( "futnews_quadro_noticias" );
		for ( var i = 0; i < noticias.length; i++ ){
			var noticia	= noticias.item(i);
			
			//div exterior
			var div	= document.createElement("div");
			div.link	= noticia.getElementsByTagName( "link" ).item(0).firstChild.nodeValue
			div.onclick	= function(){ window.open( this.link ); }
			
			//titulo
			var spanTitulo	= document.createElement("span");
			spanTitulo.className	= "titulo";
			div.appendChild( spanTitulo );
			
			//texto do título
			var textTitulo	= document.createTextNode( noticia.getElementsByTagName( "titulo" ).item(0).firstChild.nodeValue );
			spanTitulo.appendChild( textTitulo );
			
			//notícia
			var pNoticia	= document.createElement( "p" );
			div.appendChild( pNoticia );
			
			//texto da notícia
			if ( noticia.getElementsByTagName( "texto" ) && noticia.getElementsByTagName( "texto" ).item(0) && noticia.getElementsByTagName( "texto" ).item(0).firstChild ){
				var textNoticia	= document.createTextNode( noticia.getElementsByTagName( "texto" ).item(0).firstChild.nodeValue );
				pNoticia.appendChild( textNoticia );
			}
			
			conteudo.appendChild( div );
		}
		conteudo.style.display	= "block";
		document.getElementById( "marquee_noticias" ).scrollAmount	= 2;
		document.getElementById( "futnews_quadro" ).removeChild( document.getElementById( "loadingNoticia" ) );
	}
}
/* globo esporte news */
/*coluna direita noticiário*/
function ManipulaMarquee(op) {
	var id = document.getElementById('marquee_noticias');
	switch (op) {
		case 1:
			id.scrollAmount = 0;
		break;
		case 2:
			id.scrollAmount = 2;
		break;
	}			
}
/*fim coluna direita noticiário*/
