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

function int_virgula(e , nome)
{
	
	
	tecla		= new Number(0);
	
	if (!e) var e = window.event;
	if (!nome) nome = this;
	
	if (e.keyCode) tecla = e.keyCode;  	
	else if (e.which) tecla = e.which; // Netscape 4.?
	else if (e.charCode) tecla = e.charCode; // Mozilla

	var virgula = nome.value.indexOf(",");
	
	// numeros de 0 a 9 e a vírgula
	if ( tecla < 20 || (tecla > 47 && tecla < 58 ) || (tecla > 95 && tecla < 106 ) || ( ( tecla == 188 || tecla == 110 ) && virgula == -1 && nome.value.length > 0 ) )
		return true;
	else
	{
		return false;
	}
}

function numeros(e)
{

	if (document.all) // Internet Explorer
		var tecla = e.keyCode;
	else if(document.layers) // Nestcape
		var tecla = e.which;
	// numeros de 0 a 9
	if ( ( tecla > 47 && tecla < 58 ) )
		return true;
	else
	{
		if (tecla != 8) // backspace
			if (document.all)
				e.keyCode	= 0;
			else if(document.layers) // Nestcape
				e.which		= 0;
			//return false;
		else
			return true;
	}
}

function numeros_virgula(e , nome)
{

	tecla		= new Number(0);
	
	if (!e) var e = window.event;
	if (!nome) nome = this;
	
	if (e.keyCode) tecla = e.keyCode;  	
	else if (e.which) tecla = e.which; // Netscape 4.?
	else if (e.charCode) tecla = e.charCode; // Mozilla

	var virgula = nome.value.indexOf(",");
	
	// numeros de 0 a 9 e a vírgula
	if ( tecla < 20 ||  (tecla > 47 && tecla < 58 ) || (tecla > 95 && tecla < 106 ) || ( ( tecla == 188 || tecla == 110 ) && virgula == -1 && nome.value.length > 0 ) )
		return true;
	else
	{
		if (tecla != 8) // backspace
			return false;
		else
			return true;
	}
}

function abre( x , largura , altura ){

	var foto = window.open("","foto","width="+largura+", height="+altura);
	foto.document.write("<body leftmargin='0' topmargin='0'>");
	foto.document.write("<img src='"+x+"' width='"+largura+"' height='"+altura+"' />");
	foto.document.write("</body></html>");
	
}

//Validar data
function validaData(strData)
{
    var bissexto 	= 0;
    var data 		= strData;
    var tam 		= data.length;
    if (tam == 10)
    {
        var dia = data.substr(0,2)
        var mes = data.substr(3,2)
        var ano = data.substr(6,4)
        if ((ano > 1900)||(ano < 2100))
        {
            switch (mes)
            {
                case '01':
                case '03':
                case '05':
                case '07':
                case '08':
                case '10':
                case '12':
                    if  (dia <= 31)
                    {
                        return true;
                    }
                    break
                
                case '04':        
                case '06':
                case '09':
                case '11':
                    if  (dia <= 30)
                    {
                        return true;
                    }
                    break
                case '02':
                    /* Validando ano Bissexto / fevereiro / dia */
                    if ((ano % 4 == 0) || (ano % 100 == 0) || (ano % 400 == 0))
                    {
                        bissexto = 1;
                    }
                    if ((bissexto == 1) && (dia <= 29))
                    {
                        return true;                
                    }
                    if ((bissexto != 1) && (dia <= 28))
                    {
                        return true;
                    }            
                    break                        
            }
        }
    }    
    return false;
}
function checkMail(mail){
    var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
    if( typeof(mail) == "string" ){
        if(er.test(mail)){ return true; }
    } else if( typeof(mail) == "object" ){
        if(er.test(mail.value)){
            return true;
        }
    }else{
    	return false;
    }
}


/*
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*/
