//** Tab Content script- Š Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
//** Last updated: Nov 8th, 06

var enabletabpersistence=0 //enable tab persistence via session only cookies, so selected tab is remembered?
var globalselect="minutos1"
var globalselect2="recomendados1"
var globalselect3="multitab1"
var primerglobal3=false
var primerglobal1=false
var primerglobal=false
var globalselect4="semana1"
var primerglobal4=false
var globalselect5="partitab1"
var primerglobal5=false
var globalselect6="busqueda1"
var primerglobal6=false
var globalselect7="tcontent1"
var primerglobal7=false
////NO NEED TO EDIT BELOW////////////////////////
var tabcontentIDs=new Object()
//Agregado Por Adriana y Claudia
var tabcontentIDs2=new Object()

var sBrowser; 

   function setBrowserType(){ 
    var aBrowFull = new Array("opera", "msie", "netscape", "gecko", "mozilla"); 
    var aBrowVers = new Array("opera", "msie", "netscape", "rv",    "mozilla"   ); 
    var aBrowAbrv = new Array("op",    "ie",   "ns",       "mo",    "ns"   ); 
    var sInfo = navigator.userAgent.toLowerCase();; 

    sBrowser = ""; 
    for (var i = 0; i < aBrowFull.length; i++){ 
     if ((sBrowser == "") && (sInfo.indexOf(aBrowFull[i]) != -1)){ 
      sBrowser = aBrowAbrv[i]; 
      sVersion = String(parseFloat(sInfo.substr(sInfo.indexOf(aBrowVers[i]) + aBrowVers[i].length + 1))); 
     } 
    } 
	return sBrowser;
   } 

function equis(nombres, activo){


	for (var i=0; i<nombres.length; i++){
		if(nombres[i]!=activo){
			var pestania = nombres[i]
			var ulobj = document.getElementById(pestania)
				
			
			var ul_list= ulobj.getElementsByTagName("li")
	for (var x=0; x<ul_list.length; x++){ //loop through each LI element
var ulistlink=ul_list[x].getElementsByTagName("a")[0]
if (ulistlink.getAttribute("rel")){
savetabcontentids2(pestania, ulistlink.getAttribute("rel"))}}
			//alert(ul_list) //get list of LIs corresponding to the tab contents
		
	
		for (var j=0; j<ul_list.length; j++){

			ul_list[j].className=""//deselect all tabs
			
			if (typeof tabcontentIDs2[pestania][j]!="undefined") //if tab content within this array index exists (exception: More tabs than there are tab contents)
				
				document.getElementById(tabcontentIDs2[pestania][j]).style.display="none" //hide all tab contents
					
			}
		}

	}
}
function expandcontent(linkobj,nombres){
var ulid=linkobj.parentNode.parentNode.id //id of UL element
var ullist=document.getElementById(ulid).getElementsByTagName("li") //get list of LIs corresponding to the tab contents

//Agregado Por Adriana y Claudia
equis(nombres,ulid)

for (var i=0; i<ullist.length; i++){
ullist[i].className=""  //deselect all tabs

if (typeof tabcontentIDs[ulid][i]!="undefined"){ //if tab content within this array index exists (exception: More tabs than there are tab contents)

document.getElementById(tabcontentIDs[ulid][i]).style.display="none" //hide all tab contents
}
}


linkobj.parentNode.className="selected"  //highlight currently clicked on tab
document.getElementById(linkobj.getAttribute("rel")).style.display="block" //expand corresponding tab content
saveselectedtabcontentid(ulid, linkobj.getAttribute("rel"))

}

function expandtab(tabcontentid, tabnumber){ //interface for selecting a tab (plus expand corresponding content)
var thetab=document.getElementById(tabcontentid).getElementsByTagName("a")[tabnumber]
if (thetab.getAttribute("rel"))
expandcontent(thetab)
}

function savetabcontentids(ulid, relattribute){// save ids of tab content divs
if (typeof tabcontentIDs[ulid]=="undefined") //if this array doesn't exist yet
tabcontentIDs[ulid]=new Array()
tabcontentIDs[ulid][tabcontentIDs[ulid].length]=relattribute
}
//Agregado Por Adriana y Claudia
function savetabcontentids2(ulid, relattribute){// save ids of tab content divs
if (typeof tabcontentIDs2[ulid]=="undefined") //if this array doesn't exist yet
tabcontentIDs2[ulid]=new Array()
tabcontentIDs2[ulid][tabcontentIDs2[ulid].length]=relattribute
}

function saveselectedtabcontentid(ulid, selectedtabid){ //set id of clicked on tab as selected tab id & enter into cookie
if (enabletabpersistence==1) //if persistence feature turned on
setCookie(ulid, selectedtabid)
}

function getullistlinkbyId(ulid, tabcontentid){ //returns a tab link based on the ID of the associated tab content
var ullist=document.getElementById(ulid).getElementsByTagName("li")
for (var i=0; i<ullist.length; i++){
if (ullist[i].getElementsByTagName("a")[0].getAttribute("rel")==tabcontentid){
return ullist[i].getElementsByTagName("a")[0]
break
}
}
}

function initializetabcontent(){
		var nombres = arguments
for (var i=0; i<arguments.length; i++){ //loop through passed UL ids

if (enabletabpersistence==0 && getCookie(arguments[i])!="") 
//clean up cookie if persist=off
setCookie(arguments[i], "")
var clickedontab=getCookie(arguments[i]) //retrieve ID of last clicked on tab from cookie, if any
var ulobj=document.getElementById(arguments[i])
var ulist=ulobj.getElementsByTagName("li") //array containing the LI elements within UL
for (var x=0; x<ulist.length; x++){ //loop through each LI element
var ulistlink=ulist[x].getElementsByTagName("a")[0]
if (ulistlink.getAttribute("rel")){
savetabcontentids(arguments[i], ulistlink.getAttribute("rel")) //save id of each tab content as loop runs
ulistlink.onclick=function(){

expandcontent(this, nombres)
return false
}
if (ulist[x].className=="selected" && clickedontab=="") //if a tab is set to be selected by default

expandcontent(ulistlink, nombres) //auto load currenly selected tab content

}
} //end inner for loop
if (clickedontab!=""){ //if a tab has been previously clicked on per the cookie value
var culistlink=getullistlinkbyId(arguments[i], clickedontab)
if (typeof culistlink!="undefined") //if match found between tabcontent id and rel attribute value
expandcontent(culistlink, nombres) //auto load currenly selected tab content
else //else if no match found between tabcontent id and rel attribute value (cookie mis-association)
expandcontent(ulist[0].getElementsByTagName("a")[0], nombres) //just auto load first tab instead
}
} //end outer for loop

}


function getCookie(Name){ 
var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
if (document.cookie.match(re)) //if cookie found
return document.cookie.match(re)[0].split("=")[1] //return its value
return ""
}

function setCookie(name, value){
document.cookie = name+"="+value //cookie value is domain wide (path=/)
}

function initializetabcontent2(){
		var nombres = arguments
for (var i=0; i<arguments.length; i++){ //loop through passed UL ids

if (enabletabpersistence==0 && getCookie(arguments[i])!="") 
//clean up cookie if persist=off
setCookie(arguments[i], "")
var clickedontab=getCookie(arguments[i]) //retrieve ID of last clicked on tab from cookie, if any
var ulobj=document.getElementById(arguments[i])
var ulist=ulobj.getElementsByTagName("li") //array containing the LI elements within UL
for (var x=0; x<ulist.length; x++){ //loop through each LI element
var ulistlink=ulist[x].getElementsByTagName("a")[0]
if (ulistlink.getAttribute("rel")){
savetabcontentids(arguments[i], ulistlink.getAttribute("rel")) //save id of each tab content as loop runs
ulistlink.onclick=function(){

expandcontent2(this, nombres)
return false
}
if (ulist[x].className=="selected" && clickedontab=="") //if a tab is set to be selected by default

expandcontent2(ulistlink, nombres) //auto load currenly selected tab content

}
} //end inner for loop
if (clickedontab!=""){ //if a tab has been previously clicked on per the cookie value
var culistlink=getullistlinkbyId(arguments[i], clickedontab)
if (typeof culistlink!="undefined") //if match found between tabcontent id and rel attribute value
expandcontent2(culistlink, nombres) //auto load currenly selected tab content
else //else if no match found between tabcontent id and rel attribute value (cookie mis-association)
expandcontent2(ulist[0].getElementsByTagName("a")[0], nombres) //just auto load first tab instead
}
} //end outer for loop

}
function expandcontent2(linkobj,nombres){
var ulid=linkobj.parentNode.parentNode.id //id of UL element
var ullist=document.getElementById(ulid).getElementsByTagName("li") //get list of LIs corresponding to the tab contents

//Agregado Por Adriana
equis(nombres,ulid)

for (var i=0; i<ullist.length; i++){
ullist[i].className=""  //deselect all tabs

if (typeof tabcontentIDs[ulid][i]!="undefined"){ //if tab content within this array index exists (exception: More tabs than there are tab contents)

document.getElementById(tabcontentIDs[ulid][i]).style.display="none" //hide all tab contents
	
}
}


linkobj.parentNode.className="selected"  //highlight currently clicked on tab
document.getElementById(linkobj.getAttribute("rel")).style.display="block" //expand corresponding tab content
saveselectedtabcontentid(ulid, linkobj.getAttribute("rel"))

var tipocaja = linkobj.getAttribute("rel").substring(0,6)

if (tipocaja=="minuto")
{
	var spaniz=linkobj.getAttribute("rel")+"_iz"
	var spande=linkobj.getAttribute("rel")+"_de"
	document.getElementById(spande).style.visibility="visible"
	document.getElementById(spaniz).style.visibility="visible"

	if(linkobj.getAttribute("rel")!="minutos1" || primerglobal==true){
		primerglobal=true
		if (linkobj.getAttribute("rel")!=globalselect){
		document.getElementById(globalselect+"_de").style.visibility="hidden"
		document.getElementById(globalselect+"_iz").style.visibility="hidden"
		}
	}
	globalselect=linkobj.getAttribute("rel");
	

}

if(tipocaja=="recome"){
	var spaniz1=linkobj.getAttribute("rel")+"_izq"
	var spande1=linkobj.getAttribute("rel")+"_der"

	document.getElementById(spande1).style.visibility="visible"
	document.getElementById(spaniz1).style.visibility="visible"

	if(linkobj.getAttribute("rel")!="recomendados1" || primerglobal1==true){
		primerglobal1=true
		if (linkobj.getAttribute("rel")!=globalselect2){
		document.getElementById(globalselect2+"_der").style.visibility="hidden"
		document.getElementById(globalselect2+"_izq").style.visibility="hidden"
		}
	}

	globalselect2=linkobj.getAttribute("rel");
}

if(tipocaja=="multit"){
	var spaniz3=linkobj.getAttribute("rel")+"_izq"
	var spande3=linkobj.getAttribute("rel")+"_der"

	document.getElementById(spande3).style.visibility="visible"
	document.getElementById(spaniz3).style.visibility="visible"

	if(linkobj.getAttribute("rel")!="multitab1" || primerglobal3==true){
		primerglobal3=true
		if (linkobj.getAttribute("rel")!=globalselect3){
		document.getElementById(globalselect3+"_der").style.visibility="hidden"
		document.getElementById(globalselect3+"_izq").style.visibility="hidden"
		}
	}

	globalselect3=linkobj.getAttribute("rel");

}
if(tipocaja=="partit"){
	var spaniz5=linkobj.getAttribute("rel")+"_izq"
	var spande5=linkobj.getAttribute("rel")+"_der"

	document.getElementById(spande5).style.visibility="visible"
	document.getElementById(spaniz5).style.visibility="visible"

	if(linkobj.getAttribute("rel")!="partitab1" || primerglobal5==true){
		primerglobal5=true
		if (linkobj.getAttribute("rel")!=globalselect5){
		document.getElementById(globalselect5+"_der").style.visibility="hidden"
		document.getElementById(globalselect5+"_izq").style.visibility="hidden"
		}
	}

	globalselect5=linkobj.getAttribute("rel");

}
//para agregar la pestaņita debes colocar otra condicion desde 1* hasta 2* 
//estar pendiente de cambia todas las variables
//1*
if(tipocaja=="semana"){
	var spaniz4=linkobj.getAttribute("rel")+"_izq"
	var spande4=linkobj.getAttribute("rel")+"_der"

	document.getElementById(spande4).style.visibility="visible"
	document.getElementById(spaniz4).style.visibility="visible"

	if(linkobj.getAttribute("rel")!="semana1" || primerglobal4==true){
		primerglobal4=true
		if (linkobj.getAttribute("rel")!=globalselect4){
		document.getElementById(globalselect4+"_der").style.visibility="hidden"
		document.getElementById(globalselect4+"_izq").style.visibility="hidden"
		}
	}

	globalselect4=linkobj.getAttribute("rel");

}
//2*
if(tipocaja=="busque"){
	var spaniz6=linkobj.getAttribute("rel")+"_izq"
	var spande6=linkobj.getAttribute("rel")+"_der"

	document.getElementById(spande6).style.visibility="visible"
	document.getElementById(spaniz6).style.visibility="visible"

	if(linkobj.getAttribute("rel")!="busqueda1" || primerglobal6==true){
		primerglobal6=true
		if (linkobj.getAttribute("rel")!=globalselect6){
		document.getElementById(globalselect6+"_der").style.visibility="hidden"
		document.getElementById(globalselect6+"_izq").style.visibility="hidden"
		}
	}
		
	globalselect6=linkobj.getAttribute("rel");

}

if(tipocaja=="tconte"){
	var spaniz7=linkobj.getAttribute("rel")+"_izq"
	var spande7=linkobj.getAttribute("rel")+"_der"

	document.getElementById(spande7).style.visibility="visible"
	document.getElementById(spaniz7).style.visibility="visible"

	if(linkobj.getAttribute("rel")!="tcontent1" || primerglobal7==true){
		primerglobal7=true
		if (linkobj.getAttribute("rel")!=globalselect7){
		document.getElementById(globalselect7+"_der").style.visibility="hidden"
		document.getElementById(globalselect7+"_izq").style.visibility="hidden"
		}
	}
		
	globalselect7=linkobj.getAttribute("rel");

}
}

