// JavaScript Document

function OpenFoto(imageName,imageWidth,imageHeight) {

	LeftPosition = (screen.width) ? (screen.width-imageWidth)/2 : 10;
	TopPosition = (screen.height) ? (screen.height-imageHeight)/2 : 10;
	opt = "width=" + imageWidth + ",height=" + imageHeight + ",left=" + LeftPosition + ",top=" + TopPosition + ",maxbutton=0,scrollbar=0";
	alt = "Pulse sobre la foto para cerrar esta ventana";

 	newWindow = window.open("","newWindow",opt);
	newWindow.document.open();
	newWindow.document.write('<html><head><title>'+alt+'</title></head><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">'); 
	newWindow.document.write('<a href="javascript:window.close()"><img src='+imageName +' alt="'+alt+'" border="0"></a>'); 
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}

function AbrirEmpresaAsociada(keyvalue){
	
	pag = 'asociadas_unesid_detalle.asp?id=' + keyvalue;
	ok = openWindow(pag,640,300,1,1);
}

function AbrirEmpresasProducto(keyvalue,nombre){
	
	pag = 'empresas_productos.asp?id=' + keyvalue + '&nombre=' + nombre;
	ok = openWindow(pag,640,300,1,1);
}

function openWindow(pag,w,h,sc,resiz){
	l = (screen.width) ? (screen.width-w)/2 : 0;
	t = (screen.height) ? (screen.height-h)/2 : 0;
	hwnd = window.open(pag,'asociadas','scrollbars='+sc+',resizable='+resiz+',width='+w+',height='+h+',top='+t+',left='+l+',status=true')
}

function MM_jumpMenu(targ,selObj,restore){ 
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function VisualizarCapa(nombre)
{
	elementos = document.body.getElementsByTagName("div");
	for (var i = 0, total = elementos.length; i < total; i ++){
		if (elementos[i].id != nombre){
			if (elementos[i].id.indexOf('ficha')!=-1){
				elementos[i].style.visibility = 'hidden';
			}
		}
	}
	
	capa = document.getElementById(nombre);
	capa.style.visibility = "visible";
	capa.style.zindex=10;
				     
}

function OcultarCapa(nombre)
{
	capa = document.getElementById(nombre);
	capa.style.visibility = "hidden";
	capa.style.zindex=2;
					     
}

function ValidarBuscador(nombre){
	formulario = document.getElementById(nombre);
	if (formulario.parametro.value==""){
		alert("Debe seleccionar algún parámetro de búsqueda");
		formulario.parametro.focus();
	}else{
		formulario.submit();
	}
}

function ValidarBuscadorLocal(nombre){
	formulario = document.getElementById(nombre);
	if (formulario.parametrolocal.value==""){
		alert("Debe seleccionar algún parámetro de búsqueda");
		formulario.parametrolocal.focus();
	}else{
		formulario.submit();
	}
}

function ValidarAreaPrivada(nombre){
	formulario = document.getElementById(nombre);
	if (formulario.Usuario.value == "" || formulario.Clave.value == ""){
		alert("Debes rellenar todos los campos para poder continuar");
		formulario.Usuario.focus();
	}else{
		formulario.submit();
	}
}

function openWindow(pag,w,h,sc,resiz){
	l = (screen.width) ? (screen.width-w)/2 : 0;
	t = (screen.height) ? (screen.height-h)/2 : 0;
	hwnd = window.open(pag,'puu','scrollbars='+sc+',resizable='+resiz+',width='+w+',height='+h+',top='+t+',left='+l);
}
function opengaleria(imageName,imageWidth,imageHeight) {
	OpenWindowGallery(imageName)
}
function OpenWindowGallery(foto){
	w=680;
	h=455;
	LeftPosition = (screen.width) ? (screen.width-w)/2:0;
	TopPosition = (screen.width) ? (screen.height-h)/2:0;
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars=1';
	hwnd = window.open("galeria_list.asp","AV",settings);
}
