// FUNCIONES DE VENTANA

function AbrirVentana(url,nombre) {
    v = window.open(url, nombre,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=560,height=400'); 
	v.focus();
}
// nombre: nombre de la ventana (con ruta)
// w : atributo width
// h : atributo height
function openWindow(nombre,w,h) {
	
   var n = nombre.substring(nombre.lastIndexOf('/')+1,nombre.lastIndexOf('.'));
   alert(n);
   var ww = w;
   var hh = h;
   var l = (screen.availWidth-w)/2;
   var t = (screen.availHeight-h)/2;
   if (screen.availWidth <= w) {
   	ww = screen.availWidth - 5;
   	l = (screen.width-w)/2;
   }
   if (screen.availHeight <= h) {
   	hh = screen.availHeight - 27;
		t = (screen.height-h)/2;
   }
   var v1 = window.open(nombre,n,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+ww+',height='+hh+',left='+l+',top='+t);
   v1.focus();
   return false;
}
// nombre: nombre de la ventana (con ruta)
// w : atributo width
// h : atributo height
function openWindowNoScroll(nombre,w,h) {
   var n = nombre.substring(nombre.lastIndexOf('/')+1,nombre.lastIndexOf('.'));
   var ww = w;
   var hh = h;
   var l = (screen.availWidth-w)/2;
   var t = (screen.availHeight-h)/2;
   if (screen.availWidth <= w) {
   	ww = screen.availWidth - 5;
   	l = (screen.width-w)/2;
   }
   if (screen.availHeight <= h) {
   	hh = screen.availHeight - 27;
		t = (screen.height-h)/2;
   }
   var v2 = window.open(nombre,n,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+ww+',height='+hh+',left='+l+',top='+t);
   v2.focus();
   return false;
}
// Agregar a favoritos
function addBookmark() {
   if (navigator.appName=="Netscape") {
      alert('Para añadir este sitio a sus favoritos pulse Ctrl+D');
   }
   else if (parseInt(navigator.appVersion)>3) {
      window.external.AddFavorite(top.location.href, document.title);
   }
}
// Cierra ventana
function closeWindow() {
   //window.opener.focus();
   window.top.close();
   return false;
}
// Imprime 
function printWindow() {
   window.print();
   return false;
}

//FUNCIONES DE FORMULARIO

// Comprueba si un campo de texto de un formulario esta vacio. Si es asi, devuelve
//true, si no, devuelve false. El parámetro pasado corresponde al nombre de formulario
//junto con el nombre del campo (nombre_formulario.nombre_fichero)
function vacio(c) {
   eval("v = document." + c + ".value;");
   if (v != "") 
      return false;
   return true;
}

//FUNCIONES DE IMÁGENES
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_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];}
};

function MostrarTooltip(idObject) 
{ 			
	var obj = document.getElementById( idObject ); 
		
	if(obj.options[obj.selectedIndex].value !="") 
	{
		document.getElementById("tooltip").innerHTML = obj.options[obj.selectedIndex].text;
		
		//Formato Tooltip 
 		document.getElementById("tooltip").style.zIndex = 9999999; 
  		document.getElementById("tooltip").style.display = "inline"; 
  		document.getElementById("tooltip").style.position = "absolute"; 
 		document.getElementById("tooltip").style.border =  "ActiveBorder  1px	solid"; 
		document.getElementById("tooltip").style.padding =   "3px"; 
		document.getElementById("tooltip").style.fontSize =  "10px"; 
		document.getElementById("tooltip").style.fontFamily = "Verdana"; 
		document.getElementById("tooltip").style.backgroundColor = "LemonChiffon"; 
		//document.getElementById("tooltip").style.top = document.getElementById(idObject).offsetTop + document.getElementById(idObject).offsetHeight + "px";   
		//document.getElementById(idObject).offsetTop + document.getElementById(idObject).offsetHeight + "px";   
		//document.getElementById("tooltip").style.left =	5 + event.x;			    
	}     
}

function OcultarTooltip()
{ 
  document.getElementById("tooltip").style.display = "none"; 
}
