var arr_descripcion_producto = new Array();
var i=0;
var top = 0;
var left = 0;			
function checkwhere(e) {
        if (document.layers){
        xCoord = e.x;
        yCoord = e.y;
	}
        else if (document.all){
	xCoord=event.x+document.body.scrollLeft; 
	yCoord=event.y;
	}
        else if (document.getElementById){
        xCoord = e.clientX;
        yCoord = e.clientY;
	}
        left= xCoord;
      	top=yCoord;
}
document.onmousemove = checkwhere;
function alternar_img(nombre,fuente) {
	   imagen = new Object();
	   imagen = nombre;
	   imagen.src = fuente;
	}

function mostrar_descripcion(num) {
	if(arr_descripcion_producto[num]!='&nbsp;'){
	   document.all["descripcion_producto"].innerHTML = "<font class='txt_producto'>"+arr_descripcion_producto[num]+"</font>";
	   document.all["div_producto"].style.visibility = 'visible';
	   document.all["div_producto"].style.top = top+150;
	   if(window.screen.availWidth == 800){
	   	document.all["div_producto"].style.left= 200;
	   }
	   else{
	   	document.all["div_producto"].style.left= 320;
	   }
	   }
	}
function ocultar_descripcion() {
   document.all["div_producto"].style.visibility = 'hidden';
	}
function alternar_texto(obj, clase, texto) {
   document.all[obj].innerHTML = "<font class='" + clase + "'>"+texto+"</font>";
	}
function cambiaIMG(obj, img){
	document.all[obj].src = img;
}
function cambiaFondo(obj, color){
	obj.style.backgroundColor=color;
}
function cambia(){
	document.location.reload();
	}
function init(){
	window.onresize=cambia;
}
function abreVentanaProveedor(id){
	window.open('proveedor.asp?id_proveedor='+id,'proveedor','top='+window.screen.availHeight/4+', left='+window.screen.availWidth/4+',toolbar=no, scrollbars=yes, width=374, height=300, status=no, location=no, resizable=no');
}
function abreVentanaContacte(){
	window.open('contacte.asp','contacte','top='+window.screen.availHeight/4+', left='+window.screen.availWidth/4+',toolbar=no, scrollbars=yes, width=374, height=450, status=no, location=no, resizable=no');
}
function abreVentanaTexto(){
	window.open('texto.htm','texto','top=75, left='+window.screen.availWidth/4+',toolbar=no, scrollbars=yes, width=500, height=500, status=no, location=no, resizable=no');
}
function cargaProductos(){
	document.location='default.asp?b_id_area='+document.f.slc_areas[document.f.slc_areas.selectedIndex].value;
}
function cargaProveedores(){
	document.location='default.asp?b_id_area='+document.f.slc_areas[document.f.slc_areas.selectedIndex].value+'&b_id_producto='+document.f.slc_producto[document.f.slc_producto.selectedIndex].value;
	}
function validarContacte(){
	if(document.f.nombre.value==""){
			alert("Ha de rellenar el campo NOMBRE");
			document.f.nombre.focus();
			return;
		}
	if(document.f.direccion.value==""){
			alert("Ha de rellenar el campo DIRECCIÓN");
			document.f.direccion.focus()
			return;
		}
	if(document.f.telefono.value==""){
			alert("Ha de rellenar el campo TELÉFONO");
			document.f.telefono.focus()
			return;
		}
	document.f.submit();
}
function validarBuscar(){
	if(document.f.slc_producto.selectedIndex==0 && document.f.bus_generica.value==""){
			alert("Debe establecer un criterio de búsqueda");
			return;
		}
	document.f.submit();
}
// Funciones para controlar el movimiento del scroll por capas
var valor = new Array(0,0,0);
var movimiento = 0;
var altura = 15000;
var enciende = 0;
var pausa = 0;
var idTimer = 0;
  
function activar_arriba(capa,num){
   movimiento = 1;
   mover_parriba(capa,num);
}

function activar_abajo(capa,num){
   movimiento = 1;   
   mover_pabajo(capa,num);
}

function mover_parriba(capa,num) {
   if(movimiento && valor[num]>(-altura)) {
   document.all[capa].style.top = valor[num]--;
   idTimer=setTimeout('mover_parriba(\"'+capa+'\",'+num+')',40);
   }
}

function mover_pabajo(capa,num) {
   if(movimiento && valor[num]<0) {
   document.all[capa].style.top = valor[num]++;
   idTimer=setTimeout('mover_pabajo(\"'+capa+'\",'+num+')',40);
   }
}

function parar() {
   movimiento = 0;
   clearTimeout(idTimer);
}

