

function getEl(elementId){
	if (document.getElementById(elementId)){
		return document.getElementById(elementId);
	}
}


function Flash(nombre,width,height){
	document.write('<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="'+width+'" height="'+height+'">'); 
	document.write('<param name="movie" value="'+nombre+'" />'); 
    document.write('<param name="quality" value="high" />'); 
    document.write('<param name="wmode" value="transparent" />');
    document.write('<embed src="'+nombre+'" width="'+width+'" height="'+height+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed>'); 
    document.write('</object>');
}



function ampliarVideo(){
	video1=getEl('cont-1');
	video2=getEl('cont-2');
	video1.style.display="none";
	video2.style.display="block";
}
function ocultarVideo(){
	video1=getEl('cont-1');
	video2=getEl('cont-2');
	video2.style.display="none";
	video1.style.display="block";
}

function startList() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}


//variables globales para muestra lista
var yaInit = new Array()
var indexInit = 0;
var text = new Array(); 
var cant = new Array();
var currPos = new Array();
var init=true;
var currIndex;
function muestraLista(id ,numero){
	
	//numeros
	if (document.getElementById(numero)){
			var num = document.getElementById(numero);
			var nums = num.getElementsByTagName('a');
	}
	
	//traigo el elemento
	var cont = document.getElementById(id);
	
	
	//traigo los tags
	lista = cont.getElementsByTagName('ul');
	//traigo  las flechas 
	flechas = lista[1].getElementsByTagName('li');
	var prev = flechas[0];
	var next = flechas[1];
	//Armo un array con los ya inicializados y me fijo si hay alguno inicizlizado
	indexa(id);
	if(init){
		currIndex=indexInit;
		yaInit[currIndex]=id;
		currPos[currIndex]=0;
		indexInit++;
	}
	//tags a mostrar
	//text[currIndex] = lista[1].getElementsByTagName('li');
	text[currIndex] = traeElem(lista[0],'LI');
	//cant de tags y ultimo elem
	cant[currIndex] = text[currIndex].length;
	//inicializo
	if (init){
		//if (cant!=0){
			text[currIndex][currPos[currIndex]].style.display = "block";
			//prev.style.display = "none";
			//if (cant==1){
				//next.style.display = "none";
			//}
		//}
		init=true;
	}
	//hizo click en flecha derecha
	prev.onmousedown = function() {
		indexa(id);
		ultPos=cant[currIndex]-1;
		if (currPos[currIndex]!=0){
			text[currIndex][currPos[currIndex]].style.display = "none";
			currPos[currIndex]--;
			text[currIndex][currPos[currIndex]].style.display = "block";
			/*if (currPos[currIndex]==0){
				prev.style.display = "none";
				next.style.display = "block";
			}
			else{
				prev.style.display = "block";
				next.style.display = "block";
			}*/
		}
		else{
			text[currIndex][currPos[currIndex]].style.display = "none";
			currPos[currIndex]=ultPos;
			text[currIndex][currPos[currIndex]].style.display = "block";
			//next.style.display = "none";
		}
	}
	//hizo click en flecha izquierda
	next.onmousedown = function() {
		indexa(id);
		ultPos=cant[currIndex]-1;
		if (currPos[currIndex]!=ultPos){
			text[currIndex][currPos[currIndex]].style.display = "none";
			currPos[currIndex]++;
			text[currIndex][currPos[currIndex]].style.display = "block";
			/*if (currPos[currIndex]==ultPos){
				next.style.display = "none";
				prev.style.display = "block";
			}
			else{
				next.style.display = "block";
				prev.style.display = "block";
			}*/
		}
		else{
			text[currIndex][currPos[currIndex]].style.display = "none";
			currPos[currIndex]=0;
			text[currIndex][currPos[currIndex]].style.display = "block";
			//next.style.display = "none";
		}
	}
	//hizo click en un numero
	if (document.getElementById(numero)){
		for (j=0;j<nums.length;j++){
			thisNum=nums[j];
			thisNum.onmousedown = function() {
				indexa(id);
				var numPos;
				for(k=0;k<nums.length;k++){
					if(nums[k]==this){
						numPos=k;
					}
				}
				text[currIndex][currPos[currIndex]].style.display = "none";
				currPos[currIndex]=numPos;
				text[currIndex][currPos[currIndex]].style.display = "block";
			}
		}
	}
}

function indexa(id){
	num=yaInit.length;
	i=0;
	while (i<=num){
		if (id==yaInit[i]){
			init=false;
			currIndex=i;
		}
		i++;
	}
}

function traeElem(id,elem){
		var elemNP = new Array();
		contened = id;
		j=0;
		for (i=0; i<contened.childNodes.length; i++) {
			node = contened.childNodes[i];
			if (node.nodeName==elem) {
				elemNP[j]=node;
				j++;
			}
		}
		return elemNP;
}


//Abrir Ventana con imagen por Tunait
var ventana
var cont=0
var titulopordefecto = "Tu Titulo de la ventana"
function afoto(cual,titulo)
{
if(cont==1){ventana.close();ventana=null}
if(titulo==null){titulo=titulopordefecto}
ventana=window.open('','ventana','resizable=no,sc rollbars=no,width=100,height=100')
ventana.document.write('<html><head><title>' + titulo + '</title></head><body style="overflow:hidden" marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" scroll="no"  onUnload="opener.cont=0"><div align="center"><a href="javascript:this.close()"><img src="' + cual + '" onLoad="opener.redimensionar(this.width, this.height)" style="border:none"></a></div>')
ventana.document.close()
cont++
}
function redimensionar(ancho, alto)
{
if (document.all){
	ventana.resizeTo(ancho+5,alto+30)
}
else{
	ventana.resizeTo(ancho+5,alto+80)

}
ventana.moveTo((screen.width-ancho)/2,(screen.height-alto)/2) //centra la ventana. Eliminar si no se quiere centrar el popup
}


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];}
}

// Cambia la class del elem id por clase, y anula las class de los posibles span
function rollover(id,clase) {
	// Agrego la class
	id.className+=" "+clase;
	// Saco las class de los posibles span
	subCLass=id.getElementsByTagName('span');
	for (i=0; i<subCLass.length; i++) {
			subCLass[i].className+="q";
	}
}
// Restaura la funcion rollover
function rollout(id,clase) {
	// Compruebo si es o no class unica
	if (id.className==" "+clase){
		classAnt=" "+clase;
	}
	else{
		classAnt=clase;
	}
	// Saco la class que agregue
	id.className=id.className.replace(classAnt, "");
	// Restauro las clss de los span
	subCLass=id.getElementsByTagName('span');
	for (i=0; i<subCLass.length; i++) {
			subCLass[i].className=subCLass[i].className.replace("q", "");
	}
}

