var info_on=new Image(); 
var descargar_on=new Image(); 
var streaming_on=new Image(); 
var camara_on=new Image(); 

var info_off=new Image(); 
var descargar_off=new Image(); 
var streaming_off=new Image(); 
var camara_off=new Image(); 

info_on.src="../img/info3.png"; 
descargar_on.src="../img/descargar3.png"; 
streaming_on.src="../img/streaming3.png"; 
camara_on.src="../img/camara3.png"; 

info_off.src="../img/info4.png"; 
descargar_off.src="../img/descargar4.png"; 
streaming_off.src="../img/streaming4.png"; 
camara_off.src="../img/camara4.png"; 

function sacarDescripcion(idcarrera,anyo,numetapa)
{

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp2=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp2.onreadystatechange=function()
  {
  
  if (xmlhttp2.readyState==1 || document.getElementById("campotamanyo").innerHTML=="<img src='http://"+ location.hostname + "/img/cargando.gif'>")
  {
	document.getElementById("campodescripcion").innerHTML="<img src='./img/cargando.gif'>";
  }
  if (xmlhttp2.readyState==4 && xmlhttp2.status==200)
    {
    document.getElementById("campodescripcion").innerHTML=xmlhttp2.responseText;
    }
  }
xmlhttp2.open("GET","descripcioncarrera.php?idcarrera="+idcarrera+"&anyo="+anyo+"&numetapa="+numetapa,true);
xmlhttp2.send();
}

function sacarVencedor(idcarrera,anyo,numetapa)
{

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp1=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp1.onreadystatechange=function()
  {
  
  if (xmlhttp1.readyState==1 || document.getElementById("campotamanyo").innerHTML=="<img src='http://"+ location.hostname + "/img/cargando.gif'>")
  {
	document.getElementById("divvencedor").innerHTML="<img src='./img/cargando.gif'>";
  }
  if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
    {
    document.getElementById("divvencedor").innerHTML=xmlhttp1.responseText;
    }
  }
xmlhttp1.open("GET","vencedor.php?idcarrera="+idcarrera+"&anyo="+anyo+"&numetapa="+numetapa,true);
xmlhttp1.send();
}

function sacarVideoStreaming(url,i,total)
{
var j=0;


if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp1=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp1.onreadystatechange=function()
  {
  
  if (xmlhttp1.readyState==1)
  {
	document.getElementById("divvideo").innerHTML="<img src='./img/cargando.gif'>";
	
	for (j=0;j<total;j++)
	{
		document.getElementById(j).style.backgroundColor="ffffff";
		document.getElementById("streaming"+j).src = "./img/streaming4.png";
	}

	document.getElementById(i).style.backgroundColor="C5FFC5";
	document.getElementById("streaming"+i).src = "./img/play.png";
	
  }
  if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
    {
    document.getElementById("divvideo").innerHTML=xmlhttp1.responseText;
	
    }
  }
xmlhttp1.open("GET","videostreaming.php?url="+url,true);
xmlhttp1.send();
}


function sacarDescripcion_copia(idcarrera,anyo,numetapa)
{

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp1=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp1.onreadystatechange=function()
  {
  
  if (xmlhttp1.readyState==1 || document.getElementById("campotamanyo").innerHTML=="<img src='http://"+ location.hostname + "/img/cargando.gif'>")
  {
	document.getElementById("campodescripcion").innerHTML="<img src='./img/cargando.gif'>";
  }
  if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
    {
    document.getElementById("campodescripcion").innerHTML=xmlhttp1.responseText;
    }
  }
xmlhttp1.open("GET","descripcioncarrera.php?idcarrera="+idcarrera+"&anyo="+anyo+"&numetapa="+numetapa,true);
xmlhttp1.send();
}

function sacarTamanyo(link)
{

	
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==1 || xmlhttp.readyState==2)
  {
	document.getElementById("campotamanyo").innerHTML="<img src='http://"+ location.hostname + "/img/cargando.gif'>";
  }
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("campotamanyo").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","tamanyocarrera.php?link="+link,true);
xmlhttp.send();
}

function showUser(str)
{

}

function MostrarOcultarFila(id)
{
 fila = document.getElementById(id);
 
 if (fila.style.display == "none")
 {
	fila.style.display = "";
	document.getElementById("img-"+id).src = "./img/minus.png";
 }
 else
 {
	fila.style.display = "none";
	document.getElementById("img-"+id).src = "./img/plus.png";
 }
 

}

function tratarLink(link)
{

 capturas = document.getElementById('capturas');
 duracion = document.getElementById('duracion');
 tamanyo = document.getElementById('tamanyo');

 if (link.indexOf('youtube') > -1)
 {
	capturas.style.display = "none";
	duracion.style.display = "none";
	tamanyo.style.display = "none";
 }
 else if (link.indexOf('pando') > -1)
 { 
	tamanyo.style.display = "none";
 }
 else if (link.indexOf('megaupload') > -1)
 { 
	tamanyo.style.display = "none";
 }
 else
 {
	capturas.style.display = "";
	duracion.style.display = "";
	tamanyo.style.display = "";
 }
 

}

function ChangeImg(on,nombre){ 
document.images[nombre].src=on.src; 
} 


function overTD(td,color){td.bgColor=color;}
function outTD(td,color){td.style.cursor='default';td.bgColor=color;}
function clickTD(td){td.children.tags('A')[0].click();}


function Filas(id) {


	if  (document.getElementById(id+"-img").src == "http://"+ location.hostname + "/img/plus.png")
	{
		var elementos = document.getElementsByName(id);
	
		for (i = 0; i < elementos.length; i++)
			elementos[i].style.display ='';
	
		document.getElementById(id+"-img").src = "./img/minus.png";
		
		newImage = "url(./img/ramaminus.png)";
		document.getElementById(id+"-td").style.backgroundImage = newImage;

	}
	else
	{
		var elementos = document.getElementsByName(id);

		for (k = 0; k < elementos.length; k++)
			elementos[k].style.display = "none";
	
		document.getElementById(id+"-img").src = "./img/plus.png";
		
		document.getElementById(id+"-td").style.backgroundImage = "";
	}
	
	
}

function mostrarsubmenu() {
			if ( ((document.getElementById("submenu").innerHTML.length)==0) || (document.getElementById("submenu").style.display=="none")) {			 						
				document.getElementById("submenu").style.display="";
			}
			else 
				document.getElementById("submenu").style.display="none";							
		}

function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
    if(document.layers)	   //NN4+
    {
       document.layers[szDivID].visibility = iState ? "show" : "hide";
    }
    else if(document.getElementById)	  //gecko(NN6) + IE 5+
    {
        var obj = document.getElementById(szDivID);
        obj.style.visibility = iState ? "visible" : "hidden";
    }
    else if(document.all)	// IE 4
    {
        document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
    }
}

	
		var xmlhttp;

function poner_texto(texto) {
     document.getElementById('vencedor').value = texto;
	 document.getElementById('livesearch').style.display = 'none';
}

function showResult(str)
{

document.getElementById('livesearch').style.display = 'block';

if (str.length==0)
  {
  document.getElementById("livesearch").innerHTML="";
  document.getElementById("livesearch").style.border="0px";
  return;
  }
xmlhttp=GetXmlHttpObject()
if (xmlhttp==null)
  {
  alert ("Your browser does not support XML HTTP Request");
  return;
  }
var url="livesearch.php";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged ;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChanged()
{
if (xmlhttp.readyState==4)
  {
  document.getElementById("livesearch").innerHTML=xmlhttp.responseText;
  document.getElementById("livesearch").style.border="1px solid #A5ACB2";
  }
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}


function getData(dia,idcarrera)
{
var XMLHttpRequestObject = false;
var layer=dia+"-"+idcarrera;

if (window.XMLHttpRequest) {
XMLHttpRequestObject = new XMLHttpRequest();
} else if (window.ActiveXObject) {
XMLHttpRequestObject = new
ActiveXObject("Microsoft.XMLHTTP");
}

if(XMLHttpRequestObject) {
var url="detallecal.php";
url=url+"?id="+idcarrera;

XMLHttpRequestObject.open("GET",url,true);

XMLHttpRequestObject.onreadystatechange = function()
{
if (XMLHttpRequestObject.readyState == 4 &&
XMLHttpRequestObject.status == 200) {
document.getElementById(layer).innerHTML = XMLHttpRequestObject.responseText;
delete XMLHttpRequestObject;
XMLHttpRequestObject = null;
}
}

XMLHttpRequestObject.send(null);
}
}


function mostrardiv(capa) {
diviconos = document.getElementById("iconos"+capa);
diviconos.style.display = '';

}

function cerrar(capa) {

diviconos = document.getElementById("iconos"+capa);
diviconos.style.display = "none";

}

