	function CerrarFicha(articulo){
		document.getElementById('ficha_catalogo').style.display = "none";
		if(articulo!=""){ 
			document.getElementById('fila_'+articulo).style.backgroundColor = '';
		}
	}
	
	function marcarArticuloLista(articulo){
		if(document.getElementById('fila_'+articulo)!=null){
			document.getElementById('fila_'+articulo).style.backgroundColor = '#ff0044';	
		}
	}
	
	function desmarcarArticuloLista(articulo){
		if(articulo!='' && document.getElementById('fila_'+articulo)!=null){
			document.getElementById('fila_'+articulo).style.backgroundColor = '';
		}
	}
	
	function incrementarCarrito(){
		if(document.getElementById('ficha_catalogo').style.display=='block'){
			//valor = document.getElementById('carrito_unidades').innerHTML;
			//document.getElementById('carrito_unidades').innerHTML = parseInt(valor) + 1;
			valor = document.getElementById('carrito_unidades').value;
			document.getElementById('carrito_unidades').value = parseInt(valor) + 1;
			
		}
	}
	
	function decrementarCarrito(){
		if(document.getElementById('ficha_catalogo').style.display=='block'){
			//valor = document.getElementById('carrito_unidades').innerHTML;
			//if(valor < 1){valor = 1}
			//document.getElementById('carrito_unidades').innerHTML = parseInt(valor) - 1;
			
			valor = document.getElementById('carrito_unidades').value;
			if(valor < 1){valor = 1}
			document.getElementById('carrito_unidades').value = parseInt(valor) - 1;
		}
	}
	
	function mostrarProgreso(mensaje){
		//document.getElementById('estadobusqueda').style.display='block';
		//document.getElementById('estadobusqueda').innerHTML=mensaje;
		document.getElementById('ficha_catalogo').style.display='block';
		document.getElementById('ficha_catalogo').innerHTML='<br><br><br><br><br><br>'+mensaje+'<br><br><br><br><br><br><br>';
	}
	
	function siguelo(){
		if(document.getElementById('ficha_catalogo').style.display == "block"	){
			scrOfY = getScrollTop() + getOffsetLayer();
			
			document.getElementById('ficha_catalogo').style.top = scrOfY + 'px';
		}
	}
	
	function getH(){
		var h;
		if(document.innerHeight){ h=document.innerHeight;
		} else if(document.documentElement.clientHeight){ h=document.documentElement.clientHeight;
		} else if(document.body){ h=document.body.clientHeight; }
		return h;
	}
	
	function getOffsetLayer(){

		//tmp = (parseInt(getH() - divHeight) / 2);
		
		tmp = 350;
		
		//alert(getH())
		//alert(divHeight)
		///alert(tmp)
		
		return tmp;
	}
	
	function getScrollTop(){
		if(document.all){
			scrOfY = window.document.documentElement.scrollTop
		}else{
			scrOfY = window.pageYOffset;	
		}
		return scrOfY;
	}
	
	function checkEnter(e){ //e is event object passed from function invocation
		var characterCode
		
		if(e && e.which){ //if which property of event object is supported (NN4)
			e = e
			characterCode = e.which //character code is contained in NN4's which property
		}
		else{
			e = event
			characterCode = e.keyCode //character code is contained in IE's keyCode property
		}
		
		if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
			//document.forms[0].submit() //submit the form
			document.location='catalogo.php?busqueda='+document.getElementById('campobusqueda').value;
			return false 
		}else{
			return true 
		}
	
	}
	
	function checkEnterProducto(e,articulo){ //e is event object passed from function invocation
		var characterCode
		
		if(e && e.which){ //if which property of event object is supported (NN4)
			e = e
			characterCode = e.which //character code is contained in NN4's which property
		}
		else{
			e = event
			characterCode = e.keyCode //character code is contained in IE's keyCode property
		}
		
		if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
			//document.location='catalogo.php?busqueda='+document.getElementById('campobusqueda').value;
			comprarProducto(articulo,document.getElementById("carrito_unidades").value);
			CerrarFicha(articulo);
			return false 
		}else{
			return true 
		}
	
	}
	
	function checkEnterProductoCarrito(e,articulo){ //e is event object passed from function invocation
		var characterCode
		
		if(e && e.which){ //if which property of event object is supported (NN4)
			e = e
			characterCode = e.which //character code is contained in NN4's which property
		}
		else{
			e = event
			characterCode = e.keyCode //character code is contained in IE's keyCode property
		}
		
		if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
			//document.location='catalogo.php?busqueda='+document.getElementById('campobusqueda').value;
			comprarProductoCarrito(articulo,document.getElementById("carrito_unidades").value);
			//setTimeout('');
			return false 
		}else{
			return true 
		}
	
	}
	
	function selecciona_value() {
		
		objInput = document.getElementById('carrito_unidades');
		
	    var valor_input = objInput.value; 
	    var longitud = valor_input.length; 

	    if (objInput.setSelectionRange) { 
	        objInput.focus(); 
	        objInput.setSelectionRange (0, longitud); 
	    } 
	    else if (objInput.createTextRange) { 
	        var range = objInput.createTextRange() ; 
	        range.collapse(true); 
	        range.moveEnd('character', longitud); 
	        range.moveStart('character', 0); 
	        range.select(); 
	    } 
	} 
	
	function mostrarMensaje(txt,tiempo){
		document.getElementById('mensaje_actualizar').innerHTML = "<br/><br/><br/><br/><b>"+txt+"</b><br/><br/><br/><br/><br/>";
		document.getElementById('mensaje_actualizar').style.display = "block";
		tim1 = setTimeout("document.getElementById('mensaje_actualizar').style.display = 'none';",tiempo);
	}
	
	/*
	window.onload = function(){
		actualizarEstado();
	};
	*/

