// Función para abrir fotografía en ventana nueva redimensionada a tamaño de la imagen

var estilos = "/css/estilos.css"
var titulo = "Suministros Trio"

var laventana
function imagen(cual)
{
if(laventana){laventana.close()}
	laventana=window. open('','laventana','resize=no,scrollbars=no,resizable=no')
	laventana.document.writeln ('<html>')
	laventana.document.writeln ('<head>')
	laventana.document.writeln ('<link href="' + estilos + '" rel="stylesheet" type="text/css">')
	laventana.document.writeln('<title>' + titulo + '</title></head>')
	laventana.document.writeln('<body style="overflow:hidden">')
	laventana.document.writeln('<img id="imagen" alt="pulsar para cerrar" src="' + cual + '" onLoad="opener.redimensionarlaventana(this.width, this.height)" onClick="window.close();" border="0">')
	laventana.document.writeln ('</body>')
	laventana.document.writeln ('</html>')
	laventana.document.close()
}
var cont

function redimensionarlaventana(ancho, alto)
{
	laventana.resizeTo(ancho+10,alto+29)
	laventana.moveTo((screen.width - ancho)/2,(screen.height - (alto+60))/2)
}

// Función para abrir ventana sin scroll

function ventana(cual,ancho,alto,barras) {
	window.open (cual, null, "width="+ancho+",height="+alto+",status=no,toolbar=no,menubar=no,location=no,resizable=no,titlebar=no,scrollbars="+barras);
}

// Funciones personalizadas

function legal() {
	window.open ("/legal.php", "legal", "width=300,height=400,status=no,toolbar=no,menubar=no,location=no,resizable=yes,titlebar=no,scrollbars=no");
}

function creditos() {
	window.open ("/creditos.php", "creditos", "width=300,height=400,status=no,toolbar=no,menubar=no,location=no,resizable=yes,titlebar=no,scrollbars=no");
}

// Tooltip

var theObj="";
document.write("<span id='toolTipBox' width='100'></span>");

function toolTip(text,me) {
	theObj=me;
	theObj.onmousemove=updatePos; 
	document.getElementById('toolTipBox').innerHTML=text;  
	document.getElementById('toolTipBox').style.display="block";  
	window.onscroll=updatePos;
}
	
function updatePos() { 
	var ev=arguments[0]?arguments[0]:event;  
	var x=ev.clientX; 
	var y=ev.clientY;  
	diffX=-25;  
	diffY=25;  
	document.getElementById('toolTipBox').style.top  = y-2+diffY+document.body.scrollTop+ "px";  
	document.getElementById('toolTipBox').style.left = x-2+diffX+document.body.scrollLeft+"px";  
	theObj.onmouseout=hideMe;
}

function hideMe() {  
	document.getElementById('toolTipBox').style.display="none";
}

// Añadir a favoritos

function afavoritos() {
	if (window.external)
		external.AddFavorite("http://www.suministrostrio.com", "Grupo Trio")
	else
		alert("Tu navegador no soporta esta caracteristica");
}

// Validar formulario de Intranet

function validar(formulario)
{
  if (formulario.v_usuario.value=="")
  {
    formulario.v_usuario.focus()
    alert("Nombre de usuario no válido");
    return false;
  }
  else if (formulario.v_clave.value=="")
  {
    formulario.v_clave.focus()
    alert("Contraseña incorrecta");
    return false;
  }
    return true;
}
