function makevisible(cur,which)
{ if (which==0)
cur.filters.alpha.opacity=170
else
cur.filters.alpha.opacity=65
}

function WindowOpenCentrado(url, name, param,w, h, perc) 
{	var winX = (screen.availWidth - w)*perc*.01;
	var winY = (screen.availHeight - h)*perc*.01;
	popupWin = window.open(url, name, 'width=' + w + ',height=' + h +',left=' + winX + ',top=' + winY + ','+param);
}

var left_corner_x = 106; // x-coordinate of top left corner of dropdown menu 
var left_corner_y = 40; // y-coordinate of top left corner of dropdown menu 
var back_color = '#FFCC99'; // the background color of dropdown menu 
var border_color = '#FF6500'; // the color of dropdown menu border
var border_size = '1'; // the width of dropdown menu border
var menu_width = '105'; // the width of dropdown menu 
//// Don't change these parameters
var delay = 500; /////
var active_layer_id = -1;
var on_layer_id = -1;
var buff_id = -1; 

menu_content = new Array ('<a href=Producto.asp?F=1&SF1=1 class=subMenu><BR>GRAPADORAS POLY-CLIP SYSTEM</a> | <a href=maquinasvacio.asp class=subMenu><BR>MAQUINAS DE VACIO</a>','<a href=consumibles.htm class=subMenu><BR>CONSUMIBLES</a> | <a href=altabarrera.htm class=subMenu><BR>ALTA BARRERA</a>');

// funcio afegida per calcular el ample(Jordi)
function calculaAncho(){
if (document.layers){
ancho = window.innerWidth;
} else {
ancho = document.body.clientWidth;
}
return ancho;
}
function calculaAlto(){
if (document.layers){
alto = window.innerHeight;
} else {
alto = document.body.clientHeight;
}
return alto;
}
//function recoloca(id)
//{ setTimeout ('hide('+ id +')', 0) }

function hide(id)
{ document.getElementById('OpcionesBuscador').style.visibility="hidden";
}

function coloca(id,ll,ii)
{	quitall ();
	
	var ancho = calculaAncho();
	//alert (ancho);
		
	if(calculaAncho()<=800)
	{	var DesfaseX= (calculaAncho()/2.0-ll);
		window.status=DesfaseX;
	}
	else
	{	if(calculaAncho()<=1024)
		{	var DesfaseX= (calculaAncho()/4.0-209);
			window.status=DesfaseX;
		}
		else
		{	if(calculaAncho()<=1152)
			{	var DesfaseX= (calculaAncho()/4.0-241);
				window.status=DesfaseX;
			}
			else
			{	if(calculaAncho()<=1280)
				{	var DesfaseX= (calculaAncho()/6.0-169);
					window.status=DesfaseX;
				}
				else
				{	var DesfaseX= (calculaAncho()/6.0-169);
					window.status=DesfaseX;
				}
			}
		}
	}

	var DesfaseY= (214-ii);
	/*}*/
	document.getElementById('OpcionesBuscador').style.left=DesfaseX;
	document.getElementById('OpcionesBuscador').style.top=DesfaseY;
	document.getElementById('OpcionesBuscador').style.visibility="visible"; 
}

function quitall()
{ document.getElementById('OpcionesBuscador').style.visibility="hidden"; }


function EnviarAnadirComentario()
{	if ((FormularioAnadirComentario.puntuacion[0].checked==false) && (FormularioAnadirComentario.puntuacion[1].checked==false) && (FormularioAnadirComentario.puntuacion[2].checked==false) && (FormularioAnadirComentario.puntuacion[3].checked==false) && (FormularioAnadirComentario.puntuacion[4].checked==false))
	{	alert("Informe la puntuación.")
		return false;
	}
	document.FormularioAnadirComentario.submit();	}


function EnviarDesconectar()
{	document.getElementById("Desconectar").value="Si";
	document.FormularioDesconectar.submit();	}

function EnviarContrasena()
{	document.FormularioContrasena.submit();	}

function EnviarRecomendar()
{	if (document.getElementById('TuNombre').value=="")
	{	alert("Informe su nombre.");
		document.getElementById('TuNombre').focus();
		return false;
	}
	if (document.getElementById('Nombre').value=="")
	{	alert("Informe el nombre de tu amigo.");
		document.getElementById('Nombre').focus();
		return false;
	}
	if (document.getElementById('Email').value=="")
	{	alert("Informe el email de tu amigo.");
		document.getElementById('Email').focus();
		return false;
	}
	else
	{	arroba=document.getElementById('Email').value.indexOf("@");
		punto=document.getElementById('Email').value.indexOf(".",arroba);
		if (arroba<1 || (punto-arroba)<2 || punto==(document.getElementById('Email').value.length-1))
		{	alert("Introducir una dirección de correo electrónico correcta.")
			document.getElementById('Email').focus();
			return (false);
		}

	}
	
	document.FormularioRecomendar.submit();	
}

function EnviarListado()
{	if (document.getElementById('Nombre').value=="")
	{	alert("Informe el nombre del destinatario.");
		document.getElementById('Nombre').focus();
		return false;
	}
	if (document.getElementById('Email').value=="")
	{	alert("Informe el email del destinatario.");
		document.getElementById('Email').focus();
		return false;
	}
	else
	{	arroba=document.getElementById('Email').value.indexOf("@");
		punto=document.getElementById('Email').value.indexOf(".",arroba);
		if (arroba<1 || (punto-arroba)<2 || punto==(document.getElementById('Email').value.length-1))
		{	alert("Introducir una dirección de correo electrónico correcta.")
			document.getElementById('Email').focus();
			return (false);
		}

	}
	
	document.FormularioListado.submit();
}

function EnviarBusquedaLibro()
{	if (document.getElementById('Nombre').value=="")
	{	alert("Informe el nombre.");
		document.getElementById('Nombre').focus();
		return false;
	}
	if (document.getElementById('Email').value=="")
	{	alert("Informe el email del destinatario.");
		document.getElementById('Email').focus();
		return false;
	}
	else
	{	arroba=document.getElementById('Email').value.indexOf("@");
		punto=document.getElementById('Email').value.indexOf(".",arroba);
		if (arroba<1 || (punto-arroba)<2 || punto==(document.getElementById('Email').value.length-1))
		{	alert("Introducir una dirección de correo electrónico correcta.")
			document.getElementById('Email').focus();
			return (false);
		}

	}
	
	/*if (document.getElementById('Titulo').value=="")
	{	alert("Informe el títlo del libro.");
		document.getElementById('Titulo').focus();
		return false;
	}
	if (document.getElementById('Autor').value=="")
	{	alert("Informe el autor del libro.");
		document.getElementById('Autor').focus();
		return false;
	}*/
	
	document.FormularioBuscarLibro.submit();	

}


function EnviarMiPedido2()
{	if ((FormularioMiPedido2.pago[0].checked == false) && (FormularioMiPedido2.pago[1].checked == false) && (FormularioMiPedido2.pago[2].checked == false))
	{	alert("Debe informar la forma de pago.");
		FormularioMiPedido2.pago[0].focus();	
		return false; 
	}
	if (document.getElementById('nif').value=="")
	{	alert("Informe su NIF.");
		document.getElementById('nif').focus();
		return false;
	}
	if (document.getElementById('nombre').value=="")
	{	alert("Informe su nombre.");
		document.getElementById('nombre').focus();
		return false;
	}
	if (document.getElementById('apellidos').value=="")
	{	alert("Informe sus apellidos.");
		document.getElementById('apellidos').focus();
		return false;
	}
	if (document.getElementById('direccion').value=="")
	{	alert("Informe su dirección.");
		document.getElementById('direccion').focus();
		return false;
	}
	if (document.getElementById('codigopostal').value=="")
	{	alert("Informe su codigo postal.");
		document.getElementById('codigopostal').focus();
		return false;
	}
	if (document.getElementById('poblacion').value=="")
	{	alert("Informe su población.");
		document.getElementById('poblacion').focus();
		return false;
	}
	if (document.getElementById('provincia').value=="")
	{	alert("Informe su provincia.");
		document.getElementById('provincia').focus();
		return false;
	}
	if (document.getElementById('telefono').value=="")
	{	alert("Informe su telefono y/o fax.");
		document.getElementById('telefono').focus();
		return false;
	}
	if (document.getElementById('email').value=="")
	{	alert("Informe su email.");
		document.getElementById('email').focus();
		return false;
	}
	else
	{	arroba=document.getElementById('email').value.indexOf("@");
		punto=document.getElementById('email').value.indexOf(".",arroba);
		if (arroba<1 || (punto-arroba)<2 || punto==(document.getElementById('email').value.length-1))
		{	alert("Introducir una dirección de correo electrónico correcta.")
			document.getElementById('email').focus();
			return (false);
		}
	}	
	
	if (document.getElementById('Casilla').checked == false)
	{	if (document.getElementById('nombre2').value=="")
		{	alert("Informe a la atención de quien van los datos de entrega.");
			document.getElementById('nombre2').focus();
			return false;
		}		
		if (document.getElementById('direccion2').value=="")
		{	alert("Informe la dirección completa para los datos de entrega.");
			document.getElementById('direccion2').focus();
			return false;
		}
		if (document.getElementById('codigopostal2').value=="")
		{	alert("Informe su codigo postal para los datos de entrega.");
			document.getElementById('codigopostal2').focus();
			return false;
		}
		if (document.getElementById('poblacion2').value=="")
		{	alert("Informe la población para los datos de entrega.");
			document.getElementById('poblacion2').focus();
			return false;
		}
		if (document.getElementById('provincia2').value=="")
		{	alert("Informe la provincia para los datos de entrega.");
			document.getElementById('provincia2').focus();
			return false;
		}
		if (document.getElementById('telefono2').value=="")
		{	alert("Informe su telefono y/o fax para los datos de entrega.");
			document.getElementById('telefono2').focus();
			return false;
		}
	}
	
	document.FormularioMiPedido2.submit();
}


function OrdenarLibros3(Orden)
{	Ruta = self.location.href; //parent.frames[0]
	pos=Ruta.indexOf("Orden");
	if (pos!=-1)
	{	Ruta2 = Ruta.substr(0,pos-1);
		self.location.href=Ruta2+'&Orden='+Orden;		
	}
	else
	{	self.location.href=self.location.href+'&Orden='+Orden;	}	
}

function EnviarFormularioLibros2()
{	if (document.getElementById('Descripcion2Articulo').value!="")
	{	document.getElementById('Descripcion2Articulo').value = document.getElementById('Descripcion2Articulo').value.replace("'","·");	}
	
	if (document.getElementById('DescripcionArticulo').value!="")
	{	document.getElementById('DescripcionArticulo').value = document.getElementById('DescripcionArticulo').value.replace("'","·");	}
	
	if (document.getElementById('PalabraClave').value!="")
	{	document.getElementById('PalabraClave').value = document.getElementById('PalabraClave').value.replace("'","·");	}
		
	document.FormularioLibros2.submit();
}


function EnviarFormularioLibros2()
{	if (document.getElementById('Descripcion2Articulo').value!="")
	{	document.getElementById('Descripcion2Articulo').value = document.getElementById('Descripcion2Articulo').value.replace("'","·");	}
	
	if (document.getElementById('PalabraClave').value!="")
	{	document.getElementById('PalabraClave').value = document.getElementById('PalabraClave').value.replace("'","·");	}
		
	document.FormularioLibros2.submit();
}

function CambiarPag(Pagina,x,PagAnt)
{	Parametros = self.location.search.substr(1,self.location.search.length);	//parent.frames[0].
	//alert(Parametros); pag=2&
	self.location.replace(Pagina+'?pag='+x+'&'+Parametros.replace('pag='+PagAnt+'&',''));
}

function EnviarFormularioBusqueda()
{	
	if (document.getElementById('Descripcion2Articulo').value!="")
	{	document.getElementById('Descripcion2Articulo').value = document.getElementById('Descripcion2Articulo').value.replace("'","·");	}
	
	if (document.getElementById('DescripcionArticulo').value!="")
	{	document.getElementById('DescripcionArticulo').value = document.getElementById('DescripcionArticulo').value.replace("'","·");	}
	
	
	if (document.getElementById("EdicionAnyo").value!='')
	{	var number0 = parseFloat(document.getElementById("EdicionAnyo").value);
		if (isNaN(number0)==true)
		{	alert("El campo Año no es numérico");	
			document.getElementById("EdicionAnyo").select();
			document.getElementById("EdicionAnyo").focus();
			return false;
		}		
	}		
	document.FormularioBusqueda.submit();
}

function EnviarFormularioBusqueda_()
{	
	if (document.getElementById('Descripcion2Articulo').value!="")
	{	document.getElementById('Descripcion2Articulo').value = document.getElementById('Descripcion2Articulo').value.replace("'","·");	}
	
	if (document.getElementById('PalabraClave').value!="")
	{	document.getElementById('PalabraClave').value = document.getElementById('PalabraClave').value.replace("'","·");	}
	
	
	document.FormularioBusqueda.submit();
}

function Reemplazo(obj)
{	if (obj.value!='') 
	{	obj.value = obj.value.replace("'","·");	}
}

function EnviarBusqueda1(Campo,Tipo)
{	var PC;
	
	if (document.getElementById('PalabraClaveBuscador1').value=="")
	{	alert("Informar la palabra clave");	
		document.getElementById('PalabraClaveBuscador1').focus();
		return false;
	}
	else
	{	
		PC = document.getElementById('PalabraClaveBuscador1').value.replace("'","·")
		//alert(PC);
		if (Tipo=="Numerico")
		{	var number = parseFloat(document.getElementById('PalabraClaveBuscador1').value);
			if (isNaN(number)==true)
			{	alert("La palabra clave debe ser un valor numérico");	}
			else
			{	self.parent.frames[0].location.href='Libros3.asp?BuscarEn='+Campo+'&Tipo='+Tipo+'&PC='+PC;	}
		}
		else
		{	self.parent.frames[0].location.href='Libros3.asp?BuscarEn='+Campo+'&Tipo='+Tipo+'&PC='+PC;	}
	}
}

function Tecla(e){		
	
 val = (document.all) ? e.keyCode : e.which; // 2
 
 text = (document.all) ? self.event.srcElement.name : e.target.name;
		
		if (val == 13 ){	

			if (document.getElementById('PalabraClaveBuscador1').value==""){	
				alert("Informar la palabra clave");	
				document.getElementById('PalabraClaveBuscador1').focus();
				return false;
			}
			else	
			{	val = 9;
				if (text == "PalabraClaveBuscador1")
					self.parent.frames[0].location.href='Libros3.asp?BuscarEn=Todos&PC='+document.getElementById('PalabraClaveBuscador1').value.replace("'","·");
			}
		}
}

function EnviarFormularioClienteProfesional()
{	document.getElementById("Zona").value=document.getElementById("Zonap").value;
	document.getElementById("usuario").value=document.getElementById("usuariop").value;
	document.getElementById("contrasena").value=document.getElementById("contrasenap").value;
	
	EnviarFormularioCliente();
}

function EnviarFormularioCliente(){	

	if (self.parent.frames[0].location.href=="http://www.espaxs.com/MiPedido2.asp")	{	
		document.getElementById("Pagina").value="MiPedido2.asp";
		document.FormularioCliente.submit();

	}else{	
	
		document.FormularioCliente.submit();
	}
}	

function Valida()
{	if ( document.getElementById("usuario").value == "" || document.getElementById("contrasena").value == "")
	{	alert("Debe informar el usuario y la contraseña");
		document.getElementById("usuario").focus();
		return false;
	}
	else	
	{	//document.FormularioCliente.submit();
		EnviarFormularioCliente();
	}
}

function MPValida()
{	if ( document.getElementById("MPusuario").value == "" || document.getElementById("MPcontrasena").value == "")
	{	alert("Debe informar el usuario y la contraseña");
		document.getElementById("MPusuario").focus();
		return false;
	}
	else	
	{	document.getElementById("usuario").value = document.getElementById("MPusuario").value;
		document.getElementById("contrasena").value = document.getElementById("MPcontrasena").value;
		EnviarFormularioCliente();
	}
}


function ClicaEnDatosEnvio()
{	
	if (document.getElementById('Casilla').checked)
	{	document.getElementById('TR1').style.visibility='hidden';
		document.getElementById('TR2').style.visibility='hidden';
		document.getElementById('TR3').style.visibility='hidden';
		document.getElementById('TR4').style.visibility='hidden';
		
		document.getElementById('empresa2').value="";
		document.getElementById('nombre2').value="";
		document.getElementById('direccion2').value="";
		document.getElementById('codigopostal2').value="";
		document.getElementById('poblacion2').value="";
		document.getElementById('provincia2').value="";
		document.getElementById('pais2').value="";
		document.getElementById('telefono2').value="";
		document.getElementById('observaciones').value="";
	}	
	else
	{	document.getElementById('TR1').style.visibility='visible';	
		document.getElementById('TR2').style.visibility='visible';
		document.getElementById('TR3').style.visibility='visible';
		document.getElementById('TR4').style.visibility='visible';
	}			
	
}

function EnviarMiPedido3(Obligatorio)
{	var DatosEnvioDiferentes
	DatosEnvioDiferentes = false;
	
	if ((Obligatorio=='S') && (document.getElementById('SuPedido').value==''))
	{	alert("Informe el número de pedido.");
		document.getElementById('SuPedido').focus();
		return false;		
	}
	
	if (document.getElementById('RecogerPedido').value=="true")
	{	if (document.getElementById('TelefonoRecoger').value=="")
		{	alert("Informe el teléfono de contacto, en el apartado recoger en librería.");
			document.getElementById('TelefonoRecoger').focus();
			return false;
		}	
		else
		{	if (!(document.getElementById('TelefonoCorrecto').checked))
			{	alert("Revise y confirme, clicando en el check, que el teléfono de contacto, en el apartado recoger en librería, es el correcto.");
				document.getElementById('TelefonoRecoger').focus();
				return false;
			}	
		}	
	}
	
	
	if (document.getElementById('FacturarOtraEmpresaDelGrupo').checked)
	{	if (document.getElementById('EmpresaGrupo').value=="")
		{	alert("Informe la empresa o entidad del grupo a facturar.");
			document.getElementById('EmpresaGrupo').focus();
			return false;
		}		
		if (document.getElementById('DireccionGrupo').value=="")
		{	alert("Informe la dirección completa del grupo a facturar.");
			document.getElementById('DireccionGrupo').focus();
			return false;
		}
		if (document.getElementById('CPGrupo').value=="")
		{	alert("Informe su codigo postal del grupo a facturar.");
			document.getElementById('CPGrupo').focus();
			return false;
		}
		if (document.getElementById('PoblacionGrupo').value=="")
		{	alert("Informe la población del grupo a facturar.");
			document.getElementById('PoblacionGrupo').focus();
			return false;
		}
		if (document.getElementById('ProvinciaGrupo').value=="")
		{	alert("Informe la provincia del grupo a facturar.");
			document.getElementById('ProvinciaGrupo').focus();
			return false;
		}
		if (document.getElementById('CifDniGrupo').value=="")
		{	alert("Informe su Cif/Dni del grupo a facturar.");
			document.getElementById('CifDniGrupo').focus();
			return false;
		}
	}
	
	
	if (document.getElementById('ModificaEnvio').checked)
	{	if (document.getElementById('PersonaEnvio').value=="")
		{	alert("Informe a la atención de quien van los datos de envío.");
			document.getElementById('PersonaEnvio').focus();
			return false;
		}		
		if (document.getElementById('DireccionEnvio').value=="")
		{	alert("Informe la dirección completa para los datos de envío.");
			document.getElementById('DireccionEnvio').focus();
			return false;
		}
		if (document.getElementById('CPEnvio').value=="")
		{	alert("Informe su codigo postal para los datos de envío.");
			document.getElementById('CPEnvio').focus();
			return false;
		}
		if (document.getElementById('PoblacionEnvio').value=="")
		{	alert("Informe la población para los datos de envío.");
			document.getElementById('PoblacionEnvio').focus();
			return false;
		}
		if (document.getElementById('ProvinciaEnvio').value=="")
		{	alert("Informe la provincia para los datos de envío.");
			document.getElementById('ProvinciaEnvio').focus();
			return false;
		}
		if (document.getElementById('TelefonoEnvio').value=="")
		{	alert("Informe su telefono y/o fax para los datos de envío.");
			document.getElementById('TelefonoEnvio').focus();
			return false;
		}
	}
	
	if (document.getElementById('RecogerPedido').value!="true")
	{
		if ((document.getElementById('PersonaEnvio').value!="") || (document.getElementById('DireccionEnvio').value!="") || (document.getElementById('CPEnvio').value!="") || (document.getElementById('PoblacionEnvio').value!="") || (document.getElementById('ProvinciaEnvio').value!="") || (document.getElementById('TelefonoEnvio').value!=""))
		{	if (!(document.getElementById('ModificaEnvio').checked))
			{	alert("Si informa unos datos de envío diferentes debe marcar la casilla anterior.");
				document.getElementById('PersonaEnvio').focus();
				return false;
			}		
		}
	}	
	
	/*if ((!(document.getElementById('FormaPago')[0].checked)) && (!(document.getElementById('FormaPago')[1].checked)) && (!(document.getElementById('FormaPago')[2].checked)) && (!(document.getElementById('FormaPago')[3].checked)) && (!(document.getElementById('FormaPago')[4].checked)))
	{	alert("Debe informar la forma de pago.");
		document.getElementById('FormaPago')[0].focus();	
		return false; 
	}*/
	
	/*if (!(document.getElementById('Condiciones').checked))
	{	document.getElementById('Condiciones').focus();
		alert("Debe leer y aceptar la condiciones generales de pago.");
		return false;
	}*/
	if (document.getElementById('RecogerPedido').value!="true")
	{
		if (document.getElementById('ModificaEnvio').checked)
		{	document.FormularioMiPedido3.action='MiPedido4Previo.asp'; }
		else
		{}
	}
	document.FormularioMiPedido3.submit();
}

function ComprobarCampos()
	{
			
			if (document.getElementById("SuPedidoDesplegable").value != "")
			{
				if (document.getElementById("SuPedido").value != "")
				{
					document.FormularioMiPedido3.submit(); 
				}
				else
				{
					//EnviarMiPedido3('<%=Session("Obligatorio")%>'); 
					alert("Debe informar el campo Asignar a:");
				}
			}
			else
			{
				//EnviarMiPedido3('<%=Session("Obligatorio")%>'); 
				alert("Debe informar el campo Asignar a:");
			}
	}
	
function Tecla_(Campo,funcion)
{	if (self.event.keyCode == 13 )
	{	//Casos especiales. En el buscador cuando de return q se vaya ya al buscar no al siguiente campo.
		if (funcion=='FormularioBusqueda') 
		{	EnviarFormularioBusqueda();	}
		else
		{	if (funcion=='FormularioLibros2')
			{	EnviarFormularioLibros2();	}			
			else
			{	if (funcion=='FormularioBusqueda_')
				{	EnviarFormularioBusqueda_();	}
				else
				{	self.event.keyCode = 9;
					if (self.event.srcElement.name == Campo)
					{	
						if (funcion=='DatosCliente')					
						{	Valida();	}	
						
						if (funcion=='MPDatosCliente')
						{	MPValida();	}			
						
						if (funcion=='EnviarFormularioClienteProfesional')
						{	EnviarFormularioClienteProfesional();	}								
					}					
				}	
			}	
		}	
	}
}


