function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  obj.style.filter = "alpha(opacity:"+opacity+")";	// IE/Win
  obj.style.KHTMLOpacity = opacity/100;			// Safari<1.2, Konqueror
  obj.style.MozOpacity = opacity/100;			// Older Mozilla and Firefox
  obj.style.opacity = opacity/100;				// Safari 1.2, newer Firefox and Mozilla, CSS3
}


function fadeIn(id_objeto,opacity) {
    obj = document.getElementById(id_objeto);
    if (opacity <= 100) {
      setOpacity(obj, opacity);
      opacity += 3;
      window.setTimeout("fadeIn('"+id_objeto+"',"+opacity+")", 10);
    }
}

function imgOpacityInit(id_objeto) {
  objeto = document.getElementById(id_objeto);
  setOpacity(objeto, 0);
  objeto.style.visibility = 'visible';
  fadeIn(id_objeto,0);
}



function rOver(object){ 
	//fondo_old = object.style.background; 	// Esto parece que no va
	object.style.background = '#f0f0f0'; 
}
function rOut(object) { 
	object.style.background = '#FFFFFF'; 
}



function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  obj.style.filter = "alpha(opacity:"+opacity+")";	// IE/Win
  obj.style.KHTMLOpacity = opacity/100;			// Safari<1.2, Konqueror
  obj.style.MozOpacity = opacity/100;			// Older Mozilla and Firefox
  obj.style.opacity = opacity/100;				// Safari 1.2, newer Firefox and Mozilla, CSS3
}


function fadeIn(id_objeto,opacity) {
    obj = document.getElementById(id_objeto);
    if (opacity <= 100) {
      setOpacity(obj, opacity);
      opacity += 3;
      window.setTimeout("fadeIn('"+id_objeto+"',"+opacity+")", 10);
    }
}

function imgOpacityInit(id_objeto) {
  objeto = document.getElementById(id_objeto);
  setOpacity(objeto, 0);
  objeto.style.visibility = 'visible';
  fadeIn(id_objeto,0);
}



// --- TR mouseOver/mouseOut	multi/color
rrbgbackup = '';
function rrOver(obj){ rrbgbackup = obj.style.backgroundColor; obj.style.backgroundColor = '#f0f0f0'; }
function rrOut(obj){ obj.style.backgroundColor = rrbgbackup; }


// --- _WOPEN
function _wopen(direccion, w_name, ancho, alto, w_cfg){
	// --- Centrando ventana
	coordx= screen.width ? (screen.width-ancho)/2 : 0;	
	coordy= screen.height ? (screen.height-alto)/2 : 0;
	w_config = 'width='+ancho+',height='+alto+',top='+coordy+',left='+coordx;
	
	// --- Configuracion de la ventana
	if(w_cfg !=''){
		w_config += ', '+w_cfg;
	}else{w_config += ', scrollbars=yes,resizable=yes'; }	// --- Por defecto
	
	// --- Trae al frente la ventana
	var newwindow;
	newwindow = window.open(direccion, w_name, w_config);
	if (window.focus) {newwindow.focus() }
}


// ------------------------------------------------------------------------------------------
// --- DIV EMERJENTES AL LADO DE UN OBJETO PULSADO
// ------------------------------------------------------------------------------------------

	function div_menu(obj_boton,div_id,direccion){
		// --- Muestra un DIV con respecto al objeto pulsado
		pos_boton = findPos(obj_boton);	// --- Array con x,y,width,height
		
		//alert(pos_boton[0]+' - '+pos_boton[1]+' | '+pos_boton[2]+'x'+pos_boton[3]);
		obj_div = document.getElementById(div_id);
		obj_div.style.position = 'absolute';
		obj_div.style.display =  'block';		
		
		pos_div = findPos(obj_div);
		//alert(pos_div[0]+' - '+pos_div[1]+' | '+pos_div[2]+'x'+pos_div[3]);


		if(direccion == 1){	// -- arriba, derecha
			obj_div.style.left = pos_boton[0];
			obj_div.style.top = pos_boton[1]-pos_div[3];
		}else if(direccion == 2){	// -- arriba, izquierda
			obj_div.style.left = pos_boton[0]+pos_boton[2]-pos_div[2];
			obj_div.style.top = pos_boton[1]-pos_div[3];
		}else if(direccion == 3){	// -- derecha, abajo
			obj_div.style.left = (pos_boton[0]+pos_boton[2]);
			obj_div.style.top = pos_boton[1];			
		}else if(direccion == 4){	// -- derecha, arriba
			obj_div.style.left = (pos_boton[0]+pos_boton[2]);
			obj_div.style.top = pos_boton[1]+pos_boton[3]-pos_div[3];
		}else if(direccion == 5){	// -- abajo, derecha
			obj_div.style.left = pos_boton[0];
			obj_div.style.top = pos_boton[1]+pos_boton[3];			
		}else if(direccion == 6){	// -- abajo, izquierda
			obj_div.style.left = (pos_boton[0]+pos_boton[2]-pos_div[2]);
			obj_div.style.top = pos_boton[1]+pos_boton[3];
		}else if(direccion == 7){	// -- izquierda, abajo
			obj_div.style.left = (pos_boton[0]-pos_div[2]);
			obj_div.style.top = pos_boton[1];
		}else if(direccion == 8){	// -- izquierda, arriba
			obj_div.style.left = (pos_boton[0]-pos_div[2]);
			obj_div.style.top = pos_boton[1]+pos_boton[3]-pos_div[3];
		}else{
			// --- Por defecto es el 3
			obj_div.style.left = (pos_boton[0]+pos_boton[2]);
			obj_div.style.top = pos_boton[1];	
		}
	}
	
	function div_menu_close(div_id){
		obj_div = document.getElementById(div_id);
		obj_div.style.display =  'none';
	}


	function findPos(obj){
		// --- Devuelve un array con la posicion y tamaņo de un objeto en el navegador
		// --- x,y,width,height
		var curleft = curtop = obj_width = obj_height = 0;
		obj_width = obj.offsetWidth;
		obj_height = obj.offsetHeight;
		
		if (document.getElementById || document.all){
			while (obj.offsetParent){
				curtop += obj.offsetTop
				curleft += obj.offsetLeft
				obj = obj.offsetParent;
			}
		}else if(document.layers){
			curleft += obj.x;
			curtop += obj.y;
			
		}
	 	return [curleft,curtop,obj_width,obj_height];
	}

