document.write('<script language="JavaScript" src="http://images.ig.com.br/novoscanais/js/generico.js"></script>');
var errorMessages='';
/*-----------OPEC-------------*/
function OAS_VARS(OAS_page, OAS_pos) {
OAS_site = 'www.olimpiadas2008.com.br';
OAS_sitepage = OAS_site + OAS_page;
OAS_listpos = OAS_pos;}
OAS_url = 'http://adserver.ig.com.br/RealMedia/ads/';
OAS_query = '';
OAS_target = '_blank';
OAS_version = 10;
OAS_rn = '001234567890'; OAS_rns = '1234567890';
OAS_rn = new String(Math.random()); OAS_rns = OAS_rn.substring(2, 11);
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_START() {
OAS_version = 11;
if (navigator.userAgent.indexOf('Mozilla/3') != -1 || navigator.userAgent.indexOf('Mozilla/4.0 WebTV') != -1)
 OAS_version = 10;
if (OAS_version >= 11)
 document.write('<SCRIP' + 'T LANGUAGE=JavaScript1.1 SRC="' + OAS_url + 'adstream_mjx.ads/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + '?' + OAS_query + '"><\/SCRIP' + 'T>');}
document.write('');
function OAS_AD(pos){
 if (OAS_version >= 11)
  OAS_RICH(pos);
 else
  OAS_NORMAL(pos);}

function opecStart(){
  OAS_VARS('/'+OAS_page,'x15,Top2,x07,x09,Frame1,Right,Right1,Middle,x05,x06'); 
  OAS_START();
  document.write("<div id='window'><!--//--></div>");//para funcionar os pops
}
/*-----------OPEC-------------*/

//Tag Clouds
function tagCloudsPrint() {
	/*
	tags = document.getElementById("tagClouds1").getElementsByTagName("span");
	arrayPalavras = [];
	for(i=0; i<tags.length; i++) {
		arrayPalavras[i] = tags[i].innerHTML + "|" + (i+1);
	}
	arrayPalavras.sort(ordenaPalavras);
	document.getElementById("tagClouds1").innerHTML = "";
	for(j=0; j<arrayPalavras.length; j++) {
		valor = arrayPalavras[j].split("|");
		relevancia = Math.ceil(parseInt(valor[1]) / 2);
		document.getElementById("tagClouds1").innerHTML+= "<a href='http://busca.igbusca.com.br/app/search?q=" + escape(valor[0]) + "&o=TAGCLOUDULTIMOSEGUNDO'><span class='tm" + relevancia + ((j%2==1) ? " fwb" : "") + "'> " + valor[0] + "<\/span><\/a>";
	}*/
	return;
}

function ordenaPalavras(a, b) {
	a = a.toString();
	b = b.toString();
	if(a.toLowerCase() < b.toLowerCase()) {
		return -1;
	}
	else if (a.toLowerCase() == b.toLowerCase()) {
		return 0;
	}
	else if(a.toLowerCase() > b.toLowerCase()) {
		return 1;
	}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


// ---------------------------------- Home area 2 noticias horizontais ----------------------------------
hNoticeVis = -1;
var arrNotices = new Array();

function hNoticesPositions() {
	notices = document.getElementById("h_notice");
	for (i=0; i<notices.childNodes.length; i++){
		if (notices.childNodes[i].nodeName=='SPAN') {
			arrNotices[arrNotices.length] = i;
		}
	}
	h_notice('+');
}

function h_notice(mov){
	notices = document.getElementById("h_notice");
	for (i=0; i<arrNotices.length; i++){
		notices.childNodes[arrNotices[i]].style.display = "none";
	}
	hNoticeVis = (mov == '+'? hNoticeVis+1 : hNoticeVis-1 );
	if (hNoticeVis>=arrNotices.length) hNoticeVis = 0;
	if (hNoticeVis<0) hNoticeVis = arrNotices.length - 1;
	notices.childNodes[arrNotices[hNoticeVis]].style.display = "block";
  if (mov == '+') {
    if ((hNoticeVis+1)>=arrNotices.length) {
      h_notice('+');
    } else {
      notices.childNodes[arrNotices[hNoticeVis+1]].style.display = "block";
    } 
  } else {
    if (hNoticeVis-1<0) {
      h_notice('-');
    } else {
      notices.childNodes[arrNotices[hNoticeVis-1]].style.display = "block";
    }
  }
}

function trocaAba(aba) {
  switch (aba) {
  	case "horoscopo":
  		document.getElementById("abaHoroscopo").style.display = "block"
  		document.getElementById("abaJogue").style.display = "none"
  		document.getElementById("abaSuadica").style.display = "none"
  		break
  	case "jogue":
  		document.getElementById("abaHoroscopo").style.display = "none"
  		document.getElementById("abaJogue").style.display = "block"
  		document.getElementById("abaSuadica").style.display = "none"
  		break
  	case "sua_dica":
  		document.getElementById("abaHoroscopo").style.display = "none"
  		document.getElementById("abaJogue").style.display = "none"
  		document.getElementById("abaSuadica").style.display = "block"
  		break
  	default:
  		document.getElementById("abaHoroscopo").style.display = "block"
  		document.getElementById("abaJogue").style.display = "none"
  		document.getElementById("abaSuadica").style.display = "none"
  }
}

//Validação Enquete
var clicado = false;

function votarEnquete() {

for (i = 0; i < document.formEnquete.id_alternativa.length; i++) {
	if (document.formEnquete.id_alternativa[i].checked) {
		clicado = true;
		document.formEnquete.id_alternativa[i].value=document.formEnquete.id_alternativa[i].id;
		break;
	}
}

if (clicado) {
	janelaEnquete = window.open('','janelaEnquete','toolbar=0, location=0, directories=0, menubar=0, scrollbars=YES, resizable=0 , width=400, height=455, top=100, left=100, status=no');
	window.document.formEnquete.submit();
} else {
	alert('Escolha uma opção antes de votar');
}
}
function resultadoEnquete(){
	var lkn = "http://enquete.ig.com.br/resultados.php?id_enquete=" + document.formEnquete.id_enquete.value;
	janelaEnquete = window.open(lkn,'janelaEnquete','toolbar=0, location=0, directories=0, menubar=0, scrollbars=YES, resizable=0 , width=400, height=455, top=100, left=100, status=no');
}

/*---------------------------------------------------- Player ----------------------------------------------------------*/
// var largura   = 295;

// if(document.all) {
	// var altura    = 185;
// } else {
	// var altura    = 247;
// }

// var tempoDuracao = "";
// var tempoStart;
// var objPlayer;
// var objPlayPause;

// function montaVideo(url) {
	// var objVideo  = document.getElementById("conteudoVideo");
	
	// var player = "<object id='player' classid='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6' width='" + largura + "' height='" + altura + "'>";
 	// player+= "	<param name='url' value='" + url + "'/>";
	// player+= "	<param name='AutoStart' value='true'/>";
	// player+= "	<param name='TransparentAtStart' value='0'/>";
	// player+= "	<param name='ShowStatusBar' value='0'/>";
	// player+= "	<param name='ShowDisplay' value='0'/>";
	// player+= "	<param name='AutoSize' value='0'/>";
	// player+= "	<param name='UImode' value='none'/>";
	// player+= "	<param name='AnimationAtStart' value='True'/>";
	// player+= "	<param name='StretchToFit' value='False'/>";
	// player+= "	<embed width='" + largura + "' height='" + altura + "' src='" + url + "' autostart='True'></embed>";
	// player+= "</object>";
	
	// document.getElementById("videoControlesFake").style.display = "none";
	
	// objVideo.innerHTML = player;

	// if(document.all) {
		// tempoStart = setTimeout(
			// funcao = function () { document.getElementById("player").controls.play(); }, 1000
		// );
		
		// if(document.all) {
			// document.getElementById("videoControlesPlayer").style.display = "";
		// }		
		
		// tempoDuracao = setTimeout("montaDecorrer()", 1000);
		
		// objPlayer    = document.getElementById("player");
		// objPlayPause = document.getElementById("playPause");				
	// }
// }

// function playPause() {
	// if(isPlaying()) {
		// objPlayPause.src = "http://images.ig.com.br/atitude/versao2007/tv_play.gif";
		// objPlayer.controls.pause();
	// } else {
		// objPlayPause.src = "http://image.ig.com.br/ultimosegundo/versao_2006/useg_player_pause.gif";
		// objPlayer.controls.play();
	// }
// }

// function isPlaying() {
	// if(document.all) {
		// if(objPlayer.readyState == 4 && objPlayer.PlayState == 3) {
			// return true;
		// } else {
			// return false;
		// }
	// } else {
		// return objPlayer.isplaying();
	// }
// }		

// function montaDecorrer() {
	// if(typeof objPlayer != 'undefined') {
		// posicaoAtual = objPlayer.controls.CurrentPosition;
			// duracao = objPlayer.controls.currentItem.duration;
		// fator = 1.18; // (Largura do track / 100) - 0.02
		// tamanhoPx = ((100 * fator) * posicaoAtual) / duracao;
		// document.getElementById("cursorVideo").style.width = ((Math.ceil(tamanhoPx) > 0) ? Math.ceil(tamanhoPx) : 1);
		// document.getElementById("cursorVideo").style.height = 15;
		// if(objPlayer.playState == 10) {
			// objPlayPause.src = "http://images.ig.com.br/atitude/versao2007/tv_play.gif";
			// document.getElementById("cursorVideo").style.width = 1;
			// document.getElementById("cursorVideo").style.height = 15;
			// clearTimeout(tempoDuracao);
			// clearTimeout(tempoStart);
		// } else {
			// tempoDuracao = setTimeout("montaDecorrer()", 1000);
		// }
	// }
// }

// function controlaVolume(statusVolume) {
	// volumeAtual = objPlayer.settings.volume;

	// if(statusVolume == '+') {
		// if(volumeAtual <= 100) {
			// objPlayer.settings.volume = volumeAtual + 10;
		// }
	// } else if(statusVolume == '-') {
		// if(volumeAtual >= 0) {
			// objPlayer.settings.volume = volumeAtual - 10;
		// }
	// }
// }

function compare_precos(){
    var form_compare='<form name="FormBusca" action="http://igshopping.ig.com.br/template.aspx" method="get" target="_blank" class="compareprecos">'+
      '<fieldset>'+
      '<input id="acao" type="hidden" value="busca" name="acao" />'+
      '<input id="menu" type="hidden" value="compareprecos" name="menu" />'+
      '<input id="origem" type="hidden" value="VERAO2008" name="origem" />'+
      '<label>Compare os preços</label>'+
      '<br clear="all" />'+
      '<input type="text" title="COMPARE PREÇOS" name="palavra" alt="COMPARE PREÇOS" class="busca_shop" />'+
      '<input type="image" src="http://images.ig.com.br/olimpiadas2008/images/bt_ok.gif" title="OK" alt="OK" class="bt_ok" />'+
      '</fieldset>'+
      '</form>';
   document.write(form_compare);	
}

//iG Busca
function iGBusca(){
	var html;
	html =  '<form id="busca_google" action="http://busca.igbusca.com.br/app/search">\n';
	html +=  '<fieldset>\n';
	html +=  '<input type="hidden" name="o" value="IGOLIMPIADAS" />\n';
	html +=  '<label>iG BUSCA</label>\n';
	html +=  '<p class="bygoogle">ENHANCED BY GOOGLE</p><br />\n';
	html +=  '<input type="text" title="BUSCA" alt="BUSCA" class="busca" name="q" id="google_focus" />\n';
	html +=  '<input type="image" src="http://images.ig.com.br/olimpiadas2008/images/bt_buscar.gif" title="BUSCAR" alt="BUSCAR" class="bt_buscar" />\n';
	html +=  '</fieldset>\n';
	html +=  '</form>\n';
	document.write(html); 
}

function validaMandaEmail() {
//NOME = document.NEWS.NOME.value;
EMAIL = document.NEWS.EMAIL.value;
//OPERACAO = document.NEWS.OPERACAO.value;

/**if ( NOME == "" ) {
  alert( "Entre com a NOME!" );
  document.NEWS.NOME.focus();
  return;
} else */
  if ( EMAIL == "" ) {
    alert( "Entre com o seu E-MAIL!" );
    document.NEWS.EMAIL.focus();
    return;
  } else if ( ( EMAIL.indexOf( "@", 0 ) == -1 || EMAIL.indexOf( ".", 0 ) == -1 ) || ( EMAIL.length < 5 ) ) {
    alert( "O E-MAIL informado é inválido!" );
    document.NEWS.EMAIL.focus();
    return;
  }else{
    document.NEWS.submit();
  }
}


function sub_menu(){
	var objFut = document.getElementById("sub_menu");
	if( objFut.style.display != "block" ){
		objFut.style.display = "block";
	}else{
		objFut.style.display = "none";
	}
}

if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;

//window.onload=preparaAFC;


/* Função que recebe como parâmetro os ids dos elementos que devem aparecer ou sumir, sendo que o último parâmetro é o id do elemento que se deseja trocar o fundo */
function abreFechaElemento(){
	var tam = arguments.length - 1;
	for(i=0; i < tam; i++){
		var obj = document.getElementById(arguments[i]);
		if( obj.style.display != "block" ){
			obj.style.display = "block";
		}else{
			obj.style.display = "none";
		}
	}
	trocaFundo(arguments[tam])
}

function trocaFundo(id){
	var obj = document.getElementById(id);
	if(id == id){
		if(obj.style.backgroundImage == "url(setacima.gif)"){
			obj.style.backgroundImage = "url(setabaixo.gif)";
		}else{
			obj.style.backgroundImage = "url(setacima.gif)";
		}
	}
}

function sub_menu(){
	var objFut = document.getElementById("sub_menu");
	if( objFut.style.display != "block" ){
		objFut.style.display = "block";
	}else{
		objFut.style.display = "none";
	}
}

function hideshow(objLink, id1, id2, id3){
	if(document.getElementById(id1).style.display=="none"){	
		if(document.getElementById(id1)) document.getElementById(id1).style.display="block";	
		if(document.getElementById(id2)) document.getElementById(id2).style.display="none";
		if(document.getElementById(id3)) document.getElementById(id3).style.display="none";
	}
	var links = objLink.parentNode.parentNode.getElementsByTagName("a");

	for(i=0; i< links.length; i++){
		links[i].className = "";	
	}
	objLink.className = "ativo";
}

/*-----------BASICOS-------------*/
function $(id){return document.getElementById(id)}
String.prototype.trim = function(){return this.replace(/^\s+|\s+$/, '');}

function $request( name ){
	var regexS = "[\?&]"+name+"=([^&#]*)";
	var regex = new RegExp ( regexS );
	var tmpURL = window.location.href;
	var results = regex.exec( tmpURL );
	if( results == null ){
		return "";
	}else{
		return results[1];
	}
}

var urlSite=location.href.toString();
var pathPadrao = location.protocol+"//"+location.host;
var secaoComplemento = "/olimpiada/complementohome/";


function _xStart(){
	if(secaoComplemento!=null)
	_xCopy(pathPadrao+secaoComplemento);//CARREGA OS COMPLEMENTOS;
}

/*-----------BASICOS-------------*/

/*-------------AJAX------------*/

function getHTTPObject(){if(window.XMLHttpRequest){return new XMLHttpRequest();} else if(window.ActiveXObject){var prefs = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];for(var i = 0; i < prefs.length; i++){try{return new ActiveXObject(prefs[i] + ".XMLHTTP");} catch(e){}}}}

var txt;//armazena a pagina de complemento

function rx($u){return new RegExp("<"+$u+">(.*)</"+$u+">")}

function _xCopy($path) {
    _objg = new getHTTPObject();
    _n = parseInt(Math.random()*1000000);
    _objg.open('GET', $path+"?" + _n, true);
    _objg.onreadystatechange = function() {
        if(_objg.readyState == 4) {
            if(_objg.status == '200') txt= _objg.responseText.replace(/\r\n/g, "");
        }
    };
    _objg.setRequestHeader('Content-type', 'text/html; charset=ISO-8859-1');
    _objg.send(null);
}

var area={//areas que vem por ajax;
  enquete:"enqueteHome"
}

function EnqueteHome(){
  var $u=area.enquete;
  $("x_"+$u).innerHTML=rx($u).exec(txt)[1];
}

_xStart();

/*---------------AJAX---------------*/

/*---------------Quantidade de Atletas---------------*/
//Retorna elementos com determinada classe
function $$(param){
	if(param.parent) var arrayTmp = param.parent.getElementsByTagName(param.elem);
	else var arrayTmp = document.getElementsByTagName(param.elem);
	var arrayRet = new Array();
	for(i=0; arrayTmp.length>i ;i++){
		if (arrayTmp[i].className.indexOf(param.className) != -1)
			arrayRet.push(arrayTmp[i]);
	}
	return arrayRet;
}
//Cálculo de chamadas para quantidade de atletas
function initQtaChamadas(){
	var elemsDiv = $$({elem:"div",className:"delegacao"});
	var elemsEsp = $$({elem:"p",className:"esporte"});
	
	for(j=0; elemsDiv.length>j ;j++){
		
		var divParent = $$({elem:"div",className:"atleta", parent:elemsDiv[j]});
		if (divParent.length > 0) {
			var qta = divParent[0].getElementsByTagName("ul")[0].getElementsByTagName("li");
			
			elemsEsp[j].getElementsByTagName("a")[0].getElementsByTagName("span")[0].innerHTML = qta.length;
		}
		else {
			elemsEsp[j].getElementsByTagName("a")[0].getElementsByTagName("span")[0].innerHTML = 0;
		}
	}
}

function outrosCanais(){document.write(getOptCnsHTML());}

/*-------- INICIO - FUNÇÂO PARA RODAR SCRIPTS APÓS O CARREGAMENTO DA PÁGINA --------*/
window.onload = function(){
	// sai da função se ela já foi chamada
	if (arguments.callee.done) return;

	// sinaliza a função para não ser chamada mais de uma vez
	arguments.callee.done = true;

	// executa os scrips abaixo após o carregamento da página
	document.getElementById("linkLogo").href = "http://ultimosegundo.com.br/olimpiada/";
	try{
		multiVideos();	
	}
	catch (e){
		errorMessages+="Essa página não possui player de vídeo";
	}
	
}

/*------------------ MAPEAMENTO SEÇÕES e BREADCUMBS ----------------------*/
var cnl="";//Necessário para o player

while(urlSite.indexOf("//")!=-1){
urlSite=urlSite.replace("//","/")
}
urlSite=urlSite.replace("http:/","http://")

var pathPadraoCnl="http://images.ig.com.br/olimpiadas2008/";
var secaoNome="";

var OAS_page="homepage";

var secao={
url:[
"/modalidades/",
"/modalidades/atletismo/",
"/modalidades/badminton/",
"/modalidades/basquete/",
"/modalidades/halterofilismo/",
"/modalidades/handebol/",
"/modalidades/hipismo/",
"/modalidades/polo_aquatico/",
"/modalidades/saltos_ornamentais/",
"/modalidades/softbol/",
"/modalidades/beisebol/",
"/modalidades/boxe/",
"/modalidades/canoagem/",
"/modalidades/hoquei/",
"/modalidades/iatismo/",
"/modalidades/judo/",
"/modalidades/taekwondo/",
"/modalidades/tenis/",
"/modalidades/tenis_de_mesa/",
"/modalidades/ciclismo/",
"/modalidades/esgrima/",
"/modalidades/futebol/",
"/modalidades/luta_livre/",
"/modalidades/nado_sincronizado/",
"/modalidades/natacao/",
"/modalidades/tiro/",
"/modalidades/tiro_com_arco/",
"/modalidades/triatlo/",
"/modalidades/ginastica/",
"/modalidades/pentatlo_moderno/",
"/modalidades/volei/",
"/calendario/",
"/tempo_real/",
"/videos/veja_mais/",
"/videos_modalidades/",
"/audios/",
"/agenda/",
"/calendario_resultados/",
"/calendario/",
"/quadro_de_medalhas",
"/quadro_de_medalhas/geral/",
"/medalhas_do_brasil/"
],

nome:[
"Modalidades",
"<a id='breadcumbs_ig' href='http://ultimosegundo.ig.com.br/olimpiada/modalidades/' title='Modalidades'>Modalidades</a> › Atletismo",
"<a id='breadcumbs_ig' href='http://ultimosegundo.ig.com.br/olimpiada/modalidades/' title='Modalidades'>Modalidades</a> › Badminton",
"<a id='breadcumbs_ig' href='http://ultimosegundo.ig.com.br/olimpiada/modalidades/' title='Modalidades'>Modalidades</a> › Basquete",
"<a id='breadcumbs_ig' href='http://ultimosegundo.ig.com.br/olimpiada/modalidades/' title='Modalidades'>Modalidades</a> › Halterofilismo",
"<a id='breadcumbs_ig' href='http://ultimosegundo.ig.com.br/olimpiada/modalidades/' title='Modalidades'>Modalidades</a> › Handebol",
"<a id='breadcumbs_ig' href='http://ultimosegundo.ig.com.br/olimpiada/modalidades/' title='Modalidades'>Modalidades</a> › Hipismo",
"<a id='breadcumbs_ig' href='http://ultimosegundo.ig.com.br/olimpiada/modalidades/' title='Modalidades'>Modalidades</a> › Pólo Aquático",
"<a id='breadcumbs_ig' href='http://ultimosegundo.ig.com.br/olimpiada/modalidades/' title='Modalidades'>Modalidades</a> › Saltos Ornamentais",
"<a id='breadcumbs_ig' href='http://ultimosegundo.ig.com.br/olimpiada/modalidades/' title='Modalidades'>Modalidades</a> › Softbol",
"<a id='breadcumbs_ig' href='http://ultimosegundo.ig.com.br/olimpiada/modalidades/' title='Modalidades'>Modalidades</a> › Beisebol",
"<a id='breadcumbs_ig' href='http://ultimosegundo.ig.com.br/olimpiada/modalidades/' title='Modalidades'>Modalidades</a> › Boxe",
"<a id='breadcumbs_ig' href='http://ultimosegundo.ig.com.br/olimpiada/modalidades/' title='Modalidades'>Modalidades</a> › Canoagem",
"<a id='breadcumbs_ig' href='http://ultimosegundo.ig.com.br/olimpiada/modalidades/' title='Modalidades'>Modalidades</a> › Hóquei",
"<a id='breadcumbs_ig' href='http://ultimosegundo.ig.com.br/olimpiada/modalidades/' title='Modalidades'>Modalidades</a> › Iatismo",
"<a id='breadcumbs_ig' href='http://ultimosegundo.ig.com.br/olimpiada/modalidades/' title='Modalidades'>Modalidades</a> › Judô",
"<a id='breadcumbs_ig' href='http://ultimosegundo.ig.com.br/olimpiada/modalidades/' title='Modalidades'>Modalidades</a> › Taekwondo",
"<a id='breadcumbs_ig' href='http://ultimosegundo.ig.com.br/olimpiada/modalidades/' title='Modalidades'>Modalidades</a> › Tênis",
"<a id='breadcumbs_ig' href='http://ultimosegundo.ig.com.br/olimpiada/modalidades/' title='Modalidades'>Modalidades</a> › Tênis de Mesa",
"<a id='breadcumbs_ig' href='http://ultimosegundo.ig.com.br/olimpiada/modalidades/' title='Modalidades'>Modalidades</a> › Ciclismo",
"<a id='breadcumbs_ig' href='http://ultimosegundo.ig.com.br/olimpiada/modalidades/' title='Modalidades'>Modalidades</a> › Esgrima",
"<a id='breadcumbs_ig' href='http://ultimosegundo.ig.com.br/olimpiada/modalidades/' title='Modalidades'>Modalidades</a> › Futebol",
"<a id='breadcumbs_ig' href='http://ultimosegundo.ig.com.br/olimpiada/modalidades/' title='Modalidades'>Modalidades</a> › Luta-livre",
"<a id='breadcumbs_ig' href='http://ultimosegundo.ig.com.br/olimpiada/modalidades/' title='Modalidades'>Modalidades</a> › Nado Sincronizado",
"<a id='breadcumbs_ig' href='http://ultimosegundo.ig.com.br/olimpiada/modalidades/' title='Modalidades'>Modalidades</a> › Natação",
"<a id='breadcumbs_ig' href='http://ultimosegundo.ig.com.br/olimpiada/modalidades/' title='Modalidades'>Modalidades</a> › Tiro",
"<a id='breadcumbs_ig' href='http://ultimosegundo.ig.com.br/olimpiada/modalidades/' title='Modalidades'>Modalidades</a> › Tiro com Arco",
"<a id='breadcumbs_ig' href='http://ultimosegundo.ig.com.br/olimpiada/modalidades/' title='Modalidades'>Modalidades</a> › Triatlo",
"<a id='breadcumbs_ig' href='http://ultimosegundo.ig.com.br/olimpiada/modalidades/' title='Modalidades'>Modalidades</a> › Ginástica",
"<a id='breadcumbs_ig' href='http://ultimosegundo.ig.com.br/olimpiada/modalidades/' title='Modalidades'>Modalidades</a> › Pentatlo Moderno",
"<a id='breadcumbs_ig' href='http://ultimosegundo.ig.com.br/olimpiada/modalidades/' title='Modalidades'>Modalidades</a> › Vôlei",
"Calendário",
"Pequim 2008",
"Últimos Vídeos",
"Últimos Vídeos",
"Últimos Áudios",
"Agenda",
"Calendário",
"Calendário",
"Quadro de Medalhas",
"<a id='breadcumbs_ig' href='http://ultimosegundo.ig.com.br/olimpiada/quadro_de_medalhas/' title='Quadro de Medalhas'>Quadro de Medalhas</a> › Pequim 2008",
"<a id='breadcumbs_ig' href='http://ultimosegundo.ig.com.br/olimpiada/quadro_de_medalhas/' title='Quadro de Medalhas'>Quadro de Medalhas</a> › Brasil"
],

complemento:[
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null
]
};

for(xy=0;xy<secao.url.length;xy++){
	if(urlSite.indexOf(secao.url[xy])>-1){
	  secaoNome=secao.nome[xy];
	  secaoComplemento=secao.complemento[xy];
	}
}

function breadcumbs(){
	var bc='<a id="breadcumbs_ig" href="http://www.ig.com.br/" title="HOME IG" style="font-size:11px !important; font-weight: normal !important; color: #FF8000 !important;">Home iG</a> › <a id="breadcumbs_site" href="http://ultimosegundo.ig.com.br/olimpiada" title="Pequim 2008" style="font-size:11px !important; font-weight: normal !important; color: #FF8000 !important;">Pequim 2008</a> › <span>'+secaoNome+'</span>';
	document.write(bc);
}
/*------------------ MAPEAMENTO SEÇÕES e BREADCUMBS ----------------------*/

function openContato(){window.open(pathPadrao+'/olimpiada/fale_conosco/', 'FaleConosco', 'toolbar=0,location=0,directories=0,status=yes,menubar=0,scrollbars=no,resizable=0,width=417,height=432,top=100,left=150')}

/*AFC*/
function AFC160x600(){
        google_ad_client = 'ca-btihome_js';
		google_ad_channel = 'ig_olimpiadas';
		google_ad_width = 160;
		google_ad_height = 600;
		google_ad_format = '160x600_pas_sl';
		google_ad_type = 'text_image_flash';
		google_language = 'pt';
		google_color_bg = 'FFFFFF';
		google_color_text = '333333';
		google_color_link = '298CE1';
		google_color_line = 'FFFFFF';
		google_color_url = 'FC8D3C';
		google_color_border = 'FFFFFF';
		google_encoding = 'utf8';
		google_safe = 'medium';
		google_skip = '2';
		vAFC='<script type="text/javascript" language="JavaScript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js" xml:space="preserve"><!--//--> </script>';
		document.write(vAFC);		
}

/* Função que insere o ID do jogo no Placar SWF correspondente */
function jogonoPlacar(divName, swfId, tagTitulo, swfName)
{
	var idJogo = $(divName).getElementsByTagName(tagTitulo)[0].innerHTML;
	var caminho = 'http://images.ig.com.br/olimpiadas2008/swf/';
	$(swfId).innerHTML = getFlashObject(caminho,swfName,idJogo);   
}

function getFlashObject(caminho,swfName,idJogo){
  var rnd=9999;
  out = '<div>';
	out += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="302" height="190" align="middle">';
	out += '<param name="movie" value="'+ caminho + swfName +'" />';
	out += '<param name="allowScriptAccess" value="always" />';
	out += '<param name="wmode" value="transparent" />';
	out += '<param name="FlashVars" value="j='+ idJogo +'" />';
	out += '<param name="bgcolor" value="#ffffff" />';
	out += '<embed src="'+ caminho + swfName +'?j='+ idJogo +'" bgcolor="#ffffff" wmode="Transparent" allowScriptAccess="always" quality="high" width="302" height="190" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>';
	out += '</object>';
	out += '</div>';
	
	return out;
}


//TV DHTML
var htmlObj, moveMenos, moveMais, time;
function rx(u){return new RegExp("<"+u+">(.*)</"+u+">")}

var navTvClick = true;

var controlTv={
	init:function(){
		_lgTv=$("legTV");
		_tvY=_lgTv.style.top.replace("px","");
	},
	On:function(){
		clearTimeout(moveMenos);
		moveMais=setTimeout("fmoveMais()", 10);
	},
	Off:function(){
		clearTimeout(moveMais);
		moveMenos=setTimeout("fmoveMenos()",10);
	}
}
function fmoveMenos(){
	if(_tvY<158){
		_tvY=(Math.ceil(_tvY/0.96)>158)?158:Math.ceil(_tvY/0.96);
		_lgTv.style.top=_tvY+"px";
		$("CPTvMn").style.top = _tvY+47+"px";
		moveMenos=setTimeout("fmoveMenos()",10);
	}else{
		clearTimeout(moveMenos);
	}
}
function fmoveMais(){
	if (_tvY > 127) {
		_tvY = (Math.ceil(_tvY * 0.96)<127)?127:Math.ceil(_tvY * 0.96);
		_lgTv.style.top = _tvY + "px";
		$("CPTvMn").style.top = _tvY + 47 + "px";
		moveMais=setTimeout("fmoveMais()", 10);
	}
	else {
		clearTimeout(moveMais);
	}
}
function changeTvResponse(){
	tvThCp[prx] = $("CPTv").innerHTML;
	$("legTV").style.top = ($("CPTvMn").style.top.replace("px","")-47)+"px";
	capasPub();
	controlTv.init();
	if(navTvClick){
		clearTimeout(time);
		time=setTimeout("chngTv('>')",7000);
	}
}

function chngTv(d){
	mn = $("CPTvMn").getElementsByTagName("a");
	for (i=0; i<mn.length; i++) if(mn[i].className.indexOf("activated")>=0) atual = i;
	mn[atual].className = "";
	prx = (d=="<")?parseInt(mn[atual].innerHTML,10)-1:parseInt(mn[atual].innerHTML,10)+1;
	prx = (prx==0)?5:prx;
	prx = (prx==6)?1:prx;
	mn[prx].className = "activated";
	mn[0].className = "previous";
	mn[5].className = "nobd " + mn[5].className;
	mn[6].className = "next";
	if (tvThCp[prx] == null)
		_x(new Array("tvTempo0" + prx), new Array("CPTv"), "changeTvResponse");
	else {
		$("CPTv").innerHTML = tvThCp[prx];
		changeTvResponse();
	}
}

//caso o conteúdo tenha que vir por ajax, a lógica deve ser implementada aqui
function _x(t, d, call) {
		if (t == null) $(d).innerHTML = $('tvTempos');
		else for (i = 0; i < t.length; i++) {
			$(d[i]).innerHTML = $('tvTempos').getElementsByTagName('div')[t].innerHTML;
			}			
		if(call) eval(call+"()");
}

function swpMnCp(o) {
	$("tabs").className = "tabs "+o.className.split(" ")[0];
	links = $("CpMn").getElementsByTagName("a");
	for (i=0; i<links.length; i++) {
		links[i].className= links[i].className.split(" ")[0];
		if (i==links.length-1) 
			links[i].className= links[i].className.split(" ")[0]+" nomg";
	}
	o.className=o.className+" activated";
}

function tvResponse(){
	tvThCp[parseInt(oTv.innerHTML,10)] = $("CPTv").innerHTML;
	$("legTV").style.top= ($("CPTvMn").style.top.replace("px","")-47)+"px";
	capasPub();
	controlTv.init();
}

var oTv;
var tvThCp = new Array()

function swapTvDhtml(o){
	oTv = o;
	mn = $("CPTvMn").getElementsByTagName("a");
	for (i = 0; i < mn.length; i++) 
		mn[i].className = "";
	oTv.className = "activated";
	mn[0].className = "previous";
	mn[5].className = "nobd " + mn[5].className;
	mn[6].className = "next";
	if (tvThCp[parseInt(oTv.innerHTML,10)] == null) {
		_x(new Array("tvTempo" + oTv.innerHTML), new Array("CPTv"), "tvResponse");
	}
	else {
		$("CPTv").innerHTML = tvThCp[parseInt(oTv.innerHTML,10)];
		tvResponse();
	}
}

function initTv(){
	$("TVPrv").onclick=function(){navTvClick=false;chngTv('<')}
	$("TVPos").onclick=function(){navTvClick=false;chngTv('>')}
	for(i=1; i<6; i++) $("TVP"+i).onclick=function(){swapTvDhtml(this);}
	capasPub();
	tvThCp[1] = $("CPTv").innerHTML;
	$("TVP1").className = "activated";
	$("legTV").style.top="158px";
	$("CPTvMn").style.top= "205px";	
	controlTv.init();
	clearTimeout(time);
	time=setTimeout("chngTv('>')",7000);
	for (i=1; i<6; i++) tvThCp[i] = null;
	$("tvdhtml").onmouseover=function(){clearTimeout(time);controlTv.On()}
	$("tvdhtml").onmouseout=function(){time=setTimeout("chngTv('>')",7000);controlTv.Off()}
}

function capasPub(){
	try {
		$("lnkTvPub").href=urllnkptv[hstPub];
		str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" align="middle" width="300" height="205">';
		str += '<param name="movie" value="'+urlimgptv[hstPub]+'" />';
		str += '<param name="allowScriptAccess" value="sameDomain" />';
		str += '<param name="wmode" value="transparent" />';
		str += '<embed src="'+urlimgptv[hstPub]+'" wmode="transparent" quality="high" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" width="300" height="205" />';
		str += '</object>';
		$("imgTvPub").innerHTML=str;
	}catch(err){}
}
//TV DHTML// JavaScript Document

