// CÓDIGO CARRUSEL DE IMÁGENES
var ancho = 750  // especifica la anchura a mostrar
var alto = 100 // especifica la altura a mostrar (alto de las imágenes)
var velo = 100 // velocidad 
var dis = 2 //cantidad de pixels que desplaza por movimiento

var imagenes = new Array()
imagenes[0] = new Image()
imagenes[0].src = "imagenes/carrusel/1.jpg" // ruta o nombre de imagen 
imagenes[0].a = "imagenes/carrusel/seminario_136.jpg" // link de la imagen
imagenes[0].target = "_blank" //target del link
imagenes[1] = new Image()
imagenes[1].src = "imagenes/carrusel/separador.gif"
imagenes[1].a = ""
imagenes[1].target = "_blank"
imagenes[2] = new Image()
imagenes[2].src = "imagenes/carrusel/2.jpg"
imagenes[2].a = "imagenes/carrusel/seminario_056.jpg"
imagenes[2].target = "_blank"
imagenes[3] = new Image()
imagenes[3].src = "imagenes/carrusel/separador.gif"
imagenes[3].a = ""
imagenes[3].target = "_blank"
imagenes[4] = new Image()
imagenes[4].src = "imagenes/carrusel/3.jpg"
imagenes[4].a = "imagenes/carrusel/seminario_078.jpg"
imagenes[4].target = "_blank"
imagenes[5] = new Image()
imagenes[5].src = "imagenes/carrusel/separador.gif"
imagenes[5].a = ""
imagenes[5].target = "_blank"
imagenes[6] = new Image()
imagenes[6].src = "imagenes/carrusel/4.jpg"
imagenes[6].a = "imagenes/carrusel/aeropuerto1.jpg"
imagenes[6].target = "_blank"
imagenes[7] = new Image()
imagenes[7].src = "imagenes/carrusel/separador.gif"
imagenes[7].a = ""
imagenes[7].target = "_blank"
imagenes[8] = new Image()
imagenes[8].src = "imagenes/carrusel/5.jpg"
imagenes[8].a = "imagenes/carrusel/grupovisita.jpg"
imagenes[8].target = "_blank"
imagenes[9] = new Image()
imagenes[9].src = "imagenes/carrusel/separador.gif"
imagenes[9].a = ""
imagenes[9].target = "_blank"
imagenes[10] = new Image()
imagenes[10].src = "imagenes/carrusel/6.jpg"
imagenes[10].a = "imagenes/carrusel/seminario_112.jpg"
imagenes[10].target = "_blank"
imagenes[11] = new Image()
imagenes[11].src = "imagenes/carrusel/separador.gif"
imagenes[11].a = ""
imagenes[11].target = "_blank"
imagenes[12] = new Image()
imagenes[12].src = "imagenes/carrusel/7.jpg"
imagenes[12].a = "imagenes/carrusel/seminario_064.jpg"
imagenes[12].target = "_blank"
imagenes[13] = new Image()
imagenes[13].src = "imagenes/carrusel/separador.gif"
imagenes[13].a = ""
imagenes[13].target = "_blank"
imagenes[14] = new Image()
imagenes[14].src = "imagenes/carrusel/8.jpg"
imagenes[14].a = "imagenes/carrusel/europa_juniojulio2007_264.jpg"
imagenes[14].target = "_blank"
imagenes[15] = new Image()
imagenes[15].src = "imagenes/carrusel/separador.gif"
imagenes[15].a = ""
imagenes[15].target = "_blank"
imagenes[16] = new Image()
imagenes[16].src = "imagenes/carrusel/9.jpg"
imagenes[16].a = "imagenes/carrusel/europa_juniojulio2007_272.jpg"
imagenes[16].target = "_blank"
imagenes[17] = new Image()
imagenes[17].src = "imagenes/carrusel/separador.gif"
imagenes[17].a = ""
imagenes[17].target = "_blank"
imagenes[18] = new Image()
imagenes[18].src = "imagenes/carrusel/10.jpg"
imagenes[18].a = "imagenes/carrusel/europa_juniojulio2007_274.jpg"
imagenes[18].target = "_blank"
imagenes[19] = new Image()
imagenes[19].src = "imagenes/carrusel/separador.gif"
imagenes[19].a = ""
imagenes[19].target = "_blank"
imagenes[20] = new Image()
imagenes[20].src = "imagenes/carrusel/11.jpg"
imagenes[20].a = "imagenes/carrusel/europa_juniojulio2007_306.jpg"
imagenes[20].target = "_blank"
imagenes[21] = new Image()
imagenes[21].src = "imagenes/carrusel/separador.gif"
imagenes[21].a = ""
imagenes[21].target = "_blank"
imagenes[22] = new Image()
imagenes[22].src = "imagenes/carrusel/12.jpg"
imagenes[22].a = "imagenes/carrusel/europa_juniojulio2007_317.jpg"
imagenes[22].target = "_blank"
imagenes[23] = new Image()
imagenes[23].src = "imagenes/carrusel/separador.gif"
imagenes[23].a = ""
imagenes[23].target = "_blank"
imagenes[24] = new Image()
imagenes[24].src = "imagenes/carrusel/13.jpg"
imagenes[24].a = "imagenes/carrusel/europa_juniojulio2007_342.jpg"
imagenes[24].target = "_blank"
imagenes[25] = new Image()
imagenes[25].src = "imagenes/carrusel/separador.gif"
imagenes[25].a = ""
imagenes[25].target = "_blank"
imagenes[26] = new Image()
imagenes[26].src = "imagenes/carrusel/14.jpg"
imagenes[26].a = "imagenes/carrusel/europa_juniojulio2007_347.jpg"
imagenes[26].target = "_blank"
imagenes[27] = new Image()
imagenes[27].src = "imagenes/carrusel/separador.gif"
imagenes[27].a = ""
imagenes[27].target = "_blank"
imagenes[28] = new Image()
imagenes[28].src = "imagenes/carrusel/15.jpg"
imagenes[28].a = "imagenes/carrusel/europa_juniojulio2007_354.jpg"
imagenes[28].target = "_blank"
imagenes[29] = new Image()
imagenes[29].src = "imagenes/carrusel/separador.gif"
imagenes[29].a = ""
imagenes[29].target = "_blank"
imagenes[30] = new Image()
imagenes[30].src = "imagenes/carrusel/16.jpg"
imagenes[30].a = "imagenes/carrusel/europa_juniojulio2007_358.jpg"
imagenes[30].target = "_blank"
imagenes[31] = new Image()
imagenes[31].src = "imagenes/carrusel/separador.gif"
imagenes[31].a = ""
imagenes[31].target = "_blank"
imagenes[32] = new Image()
imagenes[32].src = "imagenes/carrusel/17.jpg"
imagenes[32].a = "imagenes/carrusel/europa_juniojulio2007_363.jpg"
imagenes[32].target = "_blank"
imagenes[33] = new Image()
imagenes[33].src = "imagenes/carrusel/separador.gif"
imagenes[33].a = ""
imagenes[33].target = "_blank"
imagenes[34] = new Image()
imagenes[34].src = "imagenes/carrusel/18.jpg"
imagenes[34].a = "imagenes/carrusel/europa_juniojulio2007_364.jpg"
imagenes[34].target = "_blank"
imagenes[35] = new Image()
imagenes[35].src = "imagenes/carrusel/separador.gif"
imagenes[35].a = ""
imagenes[35].target = "_blank"

var vel = velo
pasos = 4
var tot = 0
var tam =0;
var pos,pos2,tam2 =0;
function escribe(){
document.write ('<div id ="fuera" style="position:relative; width:' + ancho + 'px; height:' + alto + 'px;overflow:hidden">');
document.write ('<span id="imas" style="position:absolute; width:' + tam + 'px;height:' + alto + 'px; left = -' + tam + 'px;"  onmouseover="if(detienee == 0){detienee = 1}" onmouseout="clearTimeout(tiempo);detienee=0;atras = false;vel=velo;mueve()">');
for (m=0;m<imagenes.length;m++){
	if(imagenes[m].a != ""){
//		document.write('<a href="' + imagenes[m].a + '" target="' + imagenes[m].target + '">')
		document.write('<a href="' + imagenes[m].a + '" target="' + imagenes[m].target + '" title="Click para ver en tamaño grande">')
		}
	document.write ('<img border="0"  src ="' + imagenes[m].src + '" id="ima' + m + '" name="ima' + m + '"  onload="tot++;">');
	if(imagenes[m].a != ""){document.write ('</a>')}
	}
document.write ('</span>');
document.write ('<span id="imas2" style="position:absolute; width:' + tam + 'px;height:' + alto + ';left=0;"  onmouseover="if(detienee == 0){detienee = 1}" onmouseout="clearTimeout(tiempo);detienee=0;atras = false;vel=velo;mueve()">');
for (m=0;m<imagenes.length;m++){
	if(imagenes[m].a != ""){
//		document.write('<a href="' + imagenes[m].a + '" target="' + imagenes[m].target + '">')
		document.write('<a href="' + imagenes[m].a + '" target="' + imagenes[m].target + '" title="Click para ver en tamaño grande">')
		}
	document.write ('<img border="0" src ="' + imagenes[m].src + '" id="imaa' + m + '" name="imaa' + m + '" onload="tot++;">');
	if(imagenes[m].a != ""){document.write ('</a>')}
	}
document.write ('</span>');
document.write ('</div>');
}
var detienee = 0,posb,pos2b;
function mueve(){
pos = document.getElementById('imas').style.left;
pos2 = document.getElementById('imas2').style.left;
pos = pos.replace(/px/,"");
pos = pos.replace(/pt/,"");
pos = new Number(pos);
pos2 = pos2.replace(/px/,"");
pos2 = pos2.replace(/pt/,"");
pos2 = new Number(pos2);
if(detienee == 1){
	posb = pos;
	pos2b = pos2;
	}
if(atras == true){
pos-=dis;
pos2 -=dis;
}
else{
pos += dis;
pos2 += dis;
}
if(pos2 > (ancho + dis)){
	if(detienee == 0){
		document.getElementById('imas2').style.left = pos  - (tam + dis);
		pos2 = document.getElementById('imas2').style.left;
		}
	else{
		document.getElementById('imas').style.left = pos 
		}
	}
else{
	document.getElementById('imas').style.left = pos 
	}

if(pos > (ancho + dis)){
	if(detienee == 0){
		document.getElementById('imas').style.left = pos2 - (tam + dis);
		pos = document.getElementById('imas').style.left;
		}
	else{
		document.getElementById('imas2').style.left = pos2;
		}
	}
else{
	document.getElementById('imas2').style.left = pos2
	}
if(detienee > 0){
	if(detienee == pasos){
		vel = velo;
		atras = true;
		detienee--;
		tiempo = setTimeout('mueve()',vel);
		}
	else{
		if(atras == true){
			if(detienee>(pasos/2))
				{detienee--}
			else{
			vel = velo;
			clearTimeout(tiempo)
			}
			}
	else{
		detienee++
		}
	if(detienee > (pasos/2) && atras == false){vel +=10}
		if(detienee < (pasos/2)){vel +=10}
		tiempo = setTimeout('mueve()',vel)
		}
	}
else{
tiempo = setTimeout('mueve()',vel)
	}
if(atras == true){
		if (pos == posb){
			clearTimeout(tiempo);
			atras = false;
			}
		}
}
var tiempo;
var atras = false, ini;
function inicio(){
if(tot == (imagenes.length * 2)){clearTimeout(ini);reDimCapas();mueve()}
else{ini=setTimeout('inicio()',500)}
}
function reDimCapas(){
for(m=0;m<imagenes.length;m++){
	tam +=document.getElementById('ima'+m).width
	document.getElementById('imas').style.left = (-tam +10);
	document.getElementById('imas').style.width = tam ;
	document.getElementById('imas2').style.width = tam;
	}
}
// FIN CÓDIGO CARRUSEL DE IMÁGENES

// CÓDIGO ZONA NOTICIAS
// PRIMERA PARTE DEL CÓDIGO ZONA NOTICIAS
/*Example message arrays for the two demo scrollers*/

var pausecontent=new Array()
pausecontent[0]='<a href="archivos/noticias/news4youIssue12008.pdf" target="_blank">News 4 you February 2008</a><br />Espectacular estrategia comercial'
pausecontent[1]='<a href="noticia1.php" target="_self">Renovación de Certificado ISO9000</a><br />Buen servicio y calidad de los productos'
pausecontent[2]='<a href="noticia2.php" target="_self">Certificado de Aseguramiento de la Calidad ISO 9001 desde el 2004</a><br />Auditoria de seguimiento sobre el Sistema de Gestión de Calidad'

var pausecontent2=new Array()
pausecontent2[0]='<a href="#">Noticia 1 scroll auxiliar</a>'
pausecontent2[1]='<a href="#">Noticia 2 scroll auxiliar</a>'

// SEGUNDA PARTE DEL CÓDIGO ZONA NOTICIAS
/***********************************************
* Pausing up-down scroller- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

function pausescroller(content, divId, divClass, delay){
this.content=content //message array content
this.tickerid=divId //ID of ticker div to display information
this.delay=delay //Delay between msg change, in miliseconds.
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
this.hiddendivpointer=1 //index of message array for hidden div
document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden" id="'+divId+'2">'+content[1]+'</div></div>')
var scrollerinstance=this
if (window.addEventListener) //run onload in DOM2 browsers
window.addEventListener("load", function(){scrollerinstance.initialize()}, false)
else if (window.attachEvent) //run onload in IE5.5+
window.attachEvent("onload", function(){scrollerinstance.initialize()})
else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
setTimeout(function(){scrollerinstance.initialize()}, 500)
}

// -------------------------------------------------------------------
// initialize()- Initialize scroller method.
// -Get div objects, set initial positions, start up down animation
// -------------------------------------------------------------------

pausescroller.prototype.initialize=function(){
this.tickerdiv=document.getElementById(this.tickerid)
this.visiblediv=document.getElementById(this.tickerid+"1")
this.hiddendiv=document.getElementById(this.tickerid+"2")
this.visibledivtop=parseInt(pausescroller.getCSSpadding(this.tickerdiv))
//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
this.getinline(this.visiblediv, this.hiddendiv)
this.hiddendiv.style.visibility="visible"
var scrollerinstance=this
document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
if (window.attachEvent) //Clean up loose references in IE
window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
setTimeout(function(){scrollerinstance.animateup()}, this.delay)
}


// -------------------------------------------------------------------
// animateup()- Move the two inner divs of the scroller up and in sync
// -------------------------------------------------------------------

pausescroller.prototype.animateup=function(){
var scrollerinstance=this
if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+5)){
this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-5+"px"
this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-5+"px"
setTimeout(function(){scrollerinstance.animateup()}, 50)
}
else{
this.getinline(this.hiddendiv, this.visiblediv)
this.swapdivs()
setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
}
}

// -------------------------------------------------------------------
// swapdivs()- Swap between which is the visible and which is the hidden div
// -------------------------------------------------------------------

pausescroller.prototype.swapdivs=function(){
var tempcontainer=this.visiblediv
this.visiblediv=this.hiddendiv
this.hiddendiv=tempcontainer
}

pausescroller.prototype.getinline=function(div1, div2){
div1.style.top=this.visibledivtop+"px"
div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"
}

// -------------------------------------------------------------------
// setmessage()- Populate the hidden div with the next message before it's visible
// -------------------------------------------------------------------

pausescroller.prototype.setmessage=function(){
var scrollerinstance=this
if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
setTimeout(function(){scrollerinstance.setmessage()}, 100)
else{
var i=this.hiddendivpointer
var ceiling=this.content.length
this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
this.hiddendiv.innerHTML=this.content[this.hiddendivpointer]
this.animateup()
}
}

pausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
if (tickerobj.currentStyle)
return tickerobj.currentStyle["paddingTop"]
else if (window.getComputedStyle) //if DOM2
return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
else
return 0
}
// FIN CÓDIGO ZONA NOTICIAS


// CÓDIGO TOOL TIP PARTNERS
/***********************************************
* Cool DHTML tooltip script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var offsetxpoint=-60 //Customize x offset of tooltip
var offsetypoint=20 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thecolor, thewidth){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
else if (curX<leftedge)
tipobj.style.left="5px"
else
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetxpoint+"px"

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight)
tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
else
tipobj.style.top=curY+offsetypoint+"px"
tipobj.style.visibility="visible"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip

// ddrivetip('TEXT TO DISPLAY', 'OPTIONAL BACKGROUND COLOR', OPTIONAL TIP WIDTH)

// onMouseover="ddrivetip('JavaScriptKit.com JavaScript tutorials','yellow', 300)";
// onMouseout="hideddrivetip()"

// <DIV onMouseover="ddrivetip('This DIV has a tip!', '#EFEFEF')";
// onMouseout="hideddrivetip()">Some text here. Some text here.</div>

// FIN CÓDIGO TOOL TIP PARTNERS



// CÓDIGO CONTROL DE FORMULARIO ZONA CONTÁCTENOS
// Validar correo electrónico
function valida_correo(email){
    regx = /^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/;
    return regx.test(email);
}

//busca caracteres que no sean espacio en blanco en una cadena
//devuelve true si encontró al menos un caracter distinto de blanco
function cblanco(cadena) {
        for ( i = 0; i < cadena.length; i++ ) {
                if ( cadena.charAt(i) != " " ) {
                        return true
                }
        }
        return false
}

function Valida(form1){

	//validar nombre
	if (document.form1.nombre.value.length==0) {
		alert("Debe indicar su nombre")
		document.form1.nombre.focus()
		return false
    }
    if (cblanco(document.form1.nombre.value) == false ) {
        alert("No puede introducir ÚNICAMENTE caracteres en blanco en los campos")
   		document.form1.nombre.focus()
        return false
    }

	//validar email
	if (document.form1.email.value.length==0){
		alert("Debe indicar su correo electrónico")
		document.form1.email.focus()
		return false
    } else {
      function valida_correo(email){
      regx = /^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/;
      return regx.test(email);
      }
      if (valida_correo(document.form1.email.value)) {
      } else {
        alert("Debe escribir un correo electrónico válido")
		document.form1.email.focus()
        return false
      }
	}

	//validar empresa
	if (document.form1.empresa.value.length==0){
		alert("Debe indicar su empresa")
		document.form1.empresa.focus()
		return false
	}
    if (cblanco(document.form1.empresa.value) == false ) {
        alert("No puede introducir ÚNICAMENTE caracteres en blanco en los campos")
   		document.form1.empresa.focus()
        return false
    }

	//validar teléfono
	if (document.form1.telefono.value.length==0){
		alert("Debe indicar su teléfono de contacto")
		document.form1.telefono.focus()
		return false
	}
    if (cblanco(document.form1.telefono.value) == false ) {
        alert("No puede introducir ÚNICAMENTE caracteres en blanco en los campos")
   		document.form1.telefono.focus()
        return false
    }

	//validar ciudad
	if (document.form1.ciudad.value.length==0){
		alert("Debe indicar su ciudad")
		document.form1.ciudad.focus()
		return false
	}
    if (cblanco(document.form1.ciudad.value) == false ) {
        alert("No puede introducir ÚNICAMENTE caracteres en blanco en los campos")
   		document.form1.ciudad.focus()
        return false
    }

	//validar comentario
	if (document.form1.comentario.value.length==0){
		alert("Debe indicar el asunto que requiere")
		document.form1.comentario.focus()
		return false
	}
    if (cblanco(document.form1.comentario.value) == false ) {
        alert("No puede introducir ÚNICAMENTE caracteres en blanco en los campos")
   		document.form1.comentario.focus()
        return false
    }

//envío de formulario permitido
document.form1.submit()
}

// FIN CÓDIGO CONTROL DE FORMULARIO ZONA CONTÁCTENOS


// CÓDIGO TABS EN JAVASCRIPT

//** Tab Content script v2.0- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
//** Updated Oct 7th, 07 to version 2.0. Contains numerous improvements:
//   -Added Auto Mode: Script auto rotates the tabs based on an interval, until a tab is explicitly selected
//   -Ability to expand/contract arbitrary DIVs on the page as the tabbed content is expanded/ contracted
//   -Ability to dynamically select a tab either based on its position within its peers, or its ID attribute (give the target tab one 1st)
//   -Ability to set where the CSS classname "selected" get assigned- either to the target tab's link ("A"), or its parent container 

////NO NEED TO EDIT BELOW////////////////////////

function ddtabcontent(tabinterfaceid){
	this.tabinterfaceid=tabinterfaceid //ID of Tab Menu main container
	this.tabs=document.getElementById(tabinterfaceid).getElementsByTagName("a") //Get all tab links within container
	this.enabletabpersistence=true
	this.hottabspositions=[] //Array to store position of tabs that have a "rel" attr defined, relative to all tab links, within container
	this.subcontentids=[] //Array to store ids of the sub contents ("rel" attr values)
	this.revcontentids=[] //Array to store ids of arbitrary contents to expand/contact as well ("rev" attr values)
	this.selectedClassTarget="link" //keyword to indicate which target element to assign "selected" CSS class ("linkparent" or "link")
}

ddtabcontent.getCookie=function(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 ""
}

ddtabcontent.setCookie=function(name, value){
	document.cookie = name+"="+value+";path=/" //cookie value is domain wide (path=/)
}

ddtabcontent.prototype={

	expandit:function(tabid_or_position){ //PUBLIC function to select a tab either by its ID or position(int) within its peers
		this.cancelautorun() //stop auto cycling of tabs (if running)
		var tabref=""
		try{
			if (typeof tabid_or_position=="string" && document.getElementById(tabid_or_position).getAttribute("rel")) //if specified tab contains "rel" attr
				tabref=document.getElementById(tabid_or_position)
			else if (parseInt(tabid_or_position)!=NaN && this.tabs[tabid_or_position].getAttribute("rel")) //if specified tab contains "rel" attr
				tabref=this.tabs[tabid_or_position]
		}
		catch(err){alert("Invalid Tab ID or position entered!")}
		if (tabref!="") //if a valid tab is found based on function parameter
			this.expandtab(tabref) //expand this tab
	},

	setpersist:function(bool){ //PUBLIC function to toggle persistence feature
			this.enabletabpersistence=bool
	},

	setselectedClassTarget:function(objstr){ //PUBLIC function to set which target element to assign "selected" CSS class ("linkparent" or "link")
		this.selectedClassTarget=objstr || "link"
	},

	getselectedClassTarget:function(tabref){ //Returns target element to assign "selected" CSS class to
		return (this.selectedClassTarget==("linkparent".toLowerCase()))? tabref.parentNode : tabref
	},

	expandtab:function(tabref){
		var subcontentid=tabref.getAttribute("rel") //Get id of subcontent to expand
		//Get "rev" attr as a string of IDs in the format ",john,george,trey,etc," to easily search through
		var associatedrevids=(tabref.getAttribute("rev"))? ","+tabref.getAttribute("rev").replace(/\s+/, "")+"," : ""
		this.expandsubcontent(subcontentid)
		this.expandrevcontent(associatedrevids)
		for (var i=0; i<this.tabs.length; i++){ //Loop through all tabs, and assign only the selected tab the CSS class "selected"
			this.getselectedClassTarget(this.tabs[i]).className=(this.tabs[i].getAttribute("rel")==subcontentid)? "selected" : ""
		}
		if (this.enabletabpersistence) //if persistence enabled, save selected tab position(int) relative to its peers
			ddtabcontent.setCookie(this.tabinterfaceid, tabref.tabposition)
	},

	expandsubcontent:function(subcontentid){
		for (var i=0; i<this.subcontentids.length; i++){
			var subcontent=document.getElementById(this.subcontentids[i]) //cache current subcontent obj (in for loop)
			subcontent.style.display=(subcontent.id==subcontentid)? "block" : "none" //"show" or hide sub content based on matching id attr value
		}
	},


	expandrevcontent:function(associatedrevids){
		var allrevids=this.revcontentids
		for (var i=0; i<allrevids.length; i++){ //Loop through rev attributes for all tabs in this tab interface
			//if any values stored within associatedrevids matches one within allrevids, expand that DIV, otherwise, contract it
			document.getElementById(allrevids[i]).style.display=(associatedrevids.indexOf(","+allrevids[i]+",")!=-1)? "block" : "none"
		}
	},

	autorun:function(){ //function to auto cycle through and select tabs based on a set interval
		var currentTabIndex=this.automode_currentTabIndex //index within this.hottabspositions to begin
		var hottabspositions=this.hottabspositions //Array containing position numbers of "hot" tabs (those with a "rel" attr)
		this.expandtab(this.tabs[hottabspositions[currentTabIndex]])
		this.automode_currentTabIndex=(currentTabIndex<hottabspositions.length-1)? currentTabIndex+1 : 0 //increment currentTabIndex
	},

	cancelautorun:function(){
		if (typeof this.autoruntimer!="undefined")
			clearInterval(this.autoruntimer)
	},

	init:function(automodeperiod){
		var persistedtab=ddtabcontent.getCookie(this.tabinterfaceid) //get position of persisted tab (applicable if persistence is enabled)
		var persisterror=true //Bool variable to check whether persisted tab position is valid (can become invalid if user has modified tab structure)
		this.automodeperiod=automodeperiod || 0
		for (var i=0; i<this.tabs.length; i++){
			this.tabs[i].tabposition=i //remember position of tab relative to its peers
			if (this.tabs[i].getAttribute("rel")){
				var tabinstance=this
				this.hottabspositions[this.hottabspositions.length]=i //store position of "hot" tab ("rel" attr defined) relative to its peers
				this.subcontentids[this.subcontentids.length]=this.tabs[i].getAttribute("rel") //store id of sub content ("rel" attr value)
				this.tabs[i].onclick=function(){
					tabinstance.expandtab(this)
					tabinstance.cancelautorun() //stop auto cycling of tabs (if running)
					return false
				}
				if (this.tabs[i].getAttribute("rev")){ //if "rev" attr defined, store each value within "rev" as an array element
					this.revcontentids=this.revcontentids.concat(this.tabs[i].getAttribute("rev").split(/\s*,\s*/))
				}
				if (this.enabletabpersistence && parseInt(persistedtab)==i || !this.enabletabpersistence && this.getselectedClassTarget(this.tabs[i]).className=="selected"){
					this.expandtab(this.tabs[i]) //expand current tab if it's the persisted tab, or if persist=off, carries the "selected" CSS class
					persisterror=false //Persisted tab (if applicable) was found, so set "persisterror" to false
					//If currently selected tab's index(i) is greater than 0, this means its not the 1st tab, so set the tab to begin in automode to 1st tab:
					this.automode_currentTabIndex=(i>0)? 0 : 1
				}
			}
		} //END for loop
		if (persisterror) //if an error has occured while trying to retrieve persisted tab (based on its position within its peers)
			this.expandtab(this.tabs[this.hottabspositions[0]]) //Just select first tab that contains a "rel" attr
		if (parseInt(this.automodeperiod)>500 && this.hottabspositions.length>1){
			this.automode_currentTabIndex=this.automode_currentTabIndex || 0
			this.autoruntimer=setInterval(function(){tabinstance.autorun()}, this.automodeperiod)
		}
	} //END int() function

} //END Prototype assignment

// FIN CÓDIGO TABS EN JAVASCRIPT
