// JavaScript Document
var peticion = false;

if (window.XMLHttpRequest) {
      peticion = new XMLHttpRequest();
      } else if (window.ActiveXObject) {
            peticion = new ActiveXObject("Microsoft.XMLHTTP");
}


//<!--function ObtenerDatosAdqui(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 MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

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 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];
	}
    
 }

//CREADO POR MIGUEL 29-11-2008
function enlazar(valor)
{
	
	if(document.getElementById('form').value!=0)
	{
		if(document.getElementById('form').value==1)
		{
			if (valor==1)
			{
				load_pestana(1);
			}
			
			if(document.getElementById('form').value==2)
			{
				if (valor==1)
				{
					load_pestana(2);
				}
				
				if(document.getElementById('form').value==3)
				{
					if (valor==1)
					{
						load_pestana(3);
					}
			
					if(document.getElementById('form').value==4)
					{
						if (valor==1)
						{
							load_pestana(4);
						}
						else
						{
								alert ("2009");
								document.getElementById('adquisiciones').style.visibility='hidden';
						}
					}
				}
			}
		}
	}
}

function ImageMax(chemin){
	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();
}

//function cargar_adquisiciones()
//  {
//   ObtenerDatosAdqui('modAdquisiciones/adquisiciones_anios2.php?c_anio='+document.getElementById("anios").value,'ContTabul');
//  }

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_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];
	}
  }
}