var eleccion=-1;
var peticion = false; 

var index1="";
var index2="";
var index3="";

var src1="";
var src2="";
var src3="";

var seleccion=-1;

imagenes=new Array();

if (window.XMLHttpRequest) {	
      peticion = new XMLHttpRequest();
      } else if (window.ActiveXObject) {
            peticion = new ActiveXObject("Microsoft.XMLHTTP");
}


function ObtenerDatosAsist(datos,divID) { 
if(peticion) {
     var obj = document.getElementById(divID); 
     peticion.open('GET',datos); 
     peticion.onreadystatechange = function()  { 
          if (peticion.readyState == 4) { 
               obj.innerHTML = peticion.responseText; 
          } 
     } 
peticion.send(null); 
}
}

function CambiarEstilo(id) {
	var elementosMenu = getElementsByClassName(document, "li", "activo");
	for (k = 0; k< elementosMenu.length; k++) {
	elementosMenu[k].className = "inactivo";
	}
	var identity=document.getElementById(id);
	identity.className="activo";
}
function getElementsByClassName(oElm, strTagName, strClassName){
    var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for(var i=0; i<arrElements.length; i++){
        oElement = arrElements[i];      
        if(oRegExp.test(oElement.className)){
            arrReturnElements.push(oElement);
        }   
    }
    return (arrReturnElements)
}


function load_pestana(param){ 
  if(document.getElementById('form').value!='0')
   {
	document.getElementById('asistencia').style.visibility='visible';
    ObtenerDatosAsist('modAsistenciatecnica/at'+param+'.php?idInst='+document.getElementById('form').value,'ContTabul');
//    CambiarEstilo('bt'+param);	
	}
	else
	{		
		document.getElementById('asistencia').style.visibility='hidden';
	}
 }



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];}
  
}
function buscar_indices()
{
	for(i=0; i<document.images.length;i++)
	{
		if( document.images[i].name == 'Image2' || document.images[i].name == 'Image3' || document.images[i].name == 'Image4' )
		{
			
			switch(document.images[i].name)
			{
				case "Image2":
					index1=i;
				break;
				case "Image3":
					index2=i;
				break;
				case "Image4":
					index3=i;
				break;
				default:
			}
		}
	}
  // cargar_img();
}

function cargar_img()
{
	imagenes[0] = document.images[index1].src;
	imagenes[1] = document.images[index2].src;
	imagenes[2] = document.images[index3].src;
}

function volver_img(ruta,id)
{if(seleccion!=id){
 switch(id)
  {case 0:document.images[index1].src=ruta;break;
   case 1:document.images[index2].src=ruta;break;
   case 2:document.images[index3].src=ruta;break;
   default:       
  }
}
}

function cambiar_img(ruta,id)
{if(seleccion!=id || seleccion==0){
  switch(id)
  {case 0:document.images[index1].src=ruta;
  		document.images[index2].src=imagenes[1] ;
		document.images[index3].src=imagenes[2] ;
  		break;
   case 1:document.images[index2].src=ruta;
   		document.images[index1].src=imagenes[0] ;
		document.images[index3].src=imagenes[2] ;
   		break;
   case 2:document.images[index3].src=ruta;
   		document.images[index1].src=imagenes[0] ;
		document.images[index2].src=imagenes[1] ;
   		break;
   default:
   		//alert(ruta);
   		
  } 
 } 
}

function seleccionar(param)
{   aux=seleccion;
    seleccion=param;
    if(aux!=param){
    if(aux==0)document.images[index1].src=imagenes[0];
    if(aux==1)document.images[index2].src=imagenes[1];
    if(aux==2)document.images[index3].src=imagenes[2];
	}
    
 }

function enlazar(valor)
{
	
	if(document.getElementById('form').value!=0)
	{
		if(document.getElementById('form').value==1)
		{
			if (valor==1)
			{
				load_pestana(1);
			}
			if (valor==2)
			{
				load_pestana(2);
			}
			if (valor==3)
			{
				load_pestana(3);
			}
		}
	//	if(document.getElementById('form').value==2)
//		{
//			if (valor==1)
//			{
//				load_pestana(4);
//			}
//			if (valor==2)
//			{
//				load_pestana(5);
//			}
//			if (valor==3)
//			{
//				load_pestana(21);
//			}		
//		}
		if(document.getElementById('form').value==3)
		{
			if (valor==1)
			{
				load_pestana(6);
			}
			if (valor==2)
			{
				load_pestana(7);
			}
			if (valor==3)
			{
				load_pestana(8);
			}		
		}
		if(document.getElementById('form').value==4)
		{
			if (valor==1)
			{
				load_pestana(9);
			}
			if (valor==2)
			{
				load_pestana(10);
			}
			if (valor==3)
			{
				load_pestana(11);
			}		
		}
		if(document.getElementById('form').value==5)
		{
			if (valor==1)
			{
				load_pestana(12);
			}
			if (valor==2)
			{
				load_pestana(13);
			}
			if (valor==3)
			{
				load_pestana(14);
			}		
		}
		if(document.getElementById('form').value==6)
		{
			if (valor==1)
			{
				load_pestana(15);
			}
			if (valor==2)
			{
				load_pestana(16);
			}
			if (valor==3)
			{
				load_pestana(17);
			}		
		}
		if(document.getElementById('form').value==7)
		{
			if (valor==1)
			{
				load_pestana(18);
			}
			if (valor==2)
			{
				load_pestana(19);
			}
			if (valor==3)
			{
				load_pestana(20);
			}		
		}
	}
	else
	{
			alert ("Seleccione Institución u Organización");
			document.getElementById('asistencia').style.visibility='hidden';
	}		
}


function ImageMax(chemin){
	html = '<html><head><title>carátula</title></head>'+
			'<body topmargin=\"0\" leftmargin=\"0\" onload=\"window.focus()\">'+
				'<div align="center"><table><tr><td></td></tr></table>'+
					'<img src="' + chemin + '" align="center" width="260" BORDER="0" NAME="ImageMax" ID="ImageMax" '+
						' onLoad="window.resizeTo(document.ImageMax.width+20, document.ImageMax.height+50);"'+
					' >'+
				'</div>'+
			'</body></html>';
//onLoad="window.resizeTo(document.ImageMax.width+20, document.ImageMax.height+50);"
	/*html = "<html><head><title>carátula</title></head>"+
			"<body topmargin=\"0\" leftmargin=\"0\" onload=\"window.focus()\">
				<img src=\"" + chemin + "\" BORDER=\"0\" NAME=\"ImageMax\" ID=\"ImageMax\" onLoad=\"window.resizeTo(document.ImageMax.width+20, document.ImageMax.height+50);\">"+
			"</body></html>";*/
	popupImage =  window.open('','popup','resizable=1','width=800,height=900','top=200, left=300');
	popupImage.document.open();
	popupImage.document.write(html);
	popupImage.document.close();
}
//////////////////////////////

//-->
