var NS4 = (navigator.appName.indexOf("Netscape")>=0 && !document.getElementById)? true : false;
var IE4 = (document.all && !document.getElementById)? true : false;
var IE5 = (document.getElementById && document.all)? true : false;
var NS6 = (document.getElementById && navigator.appName.indexOf("Netscape")>=0 )? true: false;
var W3C = (document.getElementById)? true : false;
var ventana1=null;

var TEMPORIZADOR=1000;
var INCREMENTO=2;
var INTERVALO=null;
var desplegable=null;
var valorM=new Array();
var BLOQUEO=null;

// Control de iframe. Lupa.
function abre_pagina(cual){
   ventana1=window.open(cual,'foto','top=50, left=100, width=475, height=350, scrollbars=1,toolbars=no,location=no,directories=0,status=0,menubar=0,resizable=0');
   ventana1.focus();
}

function indicaPantalla(){
//alert("largo: "+screen.availHeight+"\nancho: "+screen.availWidth);
var pantalla=screen.availWidth;
if((pantalla<1024) || (!document.all))
   document.body.style.overflow="auto";

 window.moveTo(0,0);
if (document.all) {
     window.resizeTo(screen.availWidth,screen.availHeight);
} 

if (document.layers || document.getElementById) {
	if (window.outerHeight<screen.availHeight || window.outerWidth<screen.availWidth){
		window.outerHeight = screen.availHeight;
		window.outerWidth = screen.availWidth;
	}
}

}

function pulsada(e) {
  var correctos=new Array("0","1","2","3","4","5","6","7","8","9",",");
      estado=false
          if(document.all) {
              codigoTecla = event.keyCode
              cadenaTecla = (String.fromCharCode(event.keyCode));
          } else if(document.layers) {
              codigoTecla = e.which
              cadenaTecla = String.fromCharCode(e.which);
          } else if(document.getElementById) {
              codigoTecla = (window.Event) ? e.which : e.keyCode;
              cadenaTecla=(String.fromCharCode(codigoTecla));
          }
	if((cadenaTecla==',') && (decimal==0))
		   return false;
          for(i=0;i<correctos.length;i++)  {
              if(cadenaTecla==correctos[i])
                  estado=true;
          }
  if((codigoTecla==8) || (codigoTecla==0))
	  estado=true;
          if(estado==false) {
              if(document.all)
                  event.returnValue = false;
              else
                  return false;
          }
}

function aumentar(cual,como,donde) {
	var sobrado=0;
   var actual=parseInt(document.forms[0].elements[cual].value); 
   if(isNaN(actual))
      actual=0;
   actual+=como;
   if(actual>StockArticulos[donde])
      actual=StockArticulos[donde];
   if(actual<0)
      actual=0;
   document.forms[0].elements[cual].value=actual.toString();
}

function cargamos_cosas(dime,objeto) {
	var resultado=eval(dime);
	resultado=(NS4)? document.layers[objeto] : (IE4)? document.all[objeto] : (W3C)? document.getElementById(objeto) : null;
	return resultado;
}

function losrestos() {
valorM[1]=desplegable.style.top;
valorM[2]=desplegable.style.height;
valorM[0]='0px';
}
function visuaD(cual,altura) {
//alert(desplegable.style.height+' menu: '+valorM[2]);
	desplegable.style.visibility='visible';
	desplegable.style.height=altura+'px';
	var h = Math.round(Math.cos(0.5 * Math.PI * (INCREMENTO / 10)) * 35);
//	if(parseInt(menuV[cual][2])<=altura) {
	if(parseInt(valorM[2])<=altura) {
		clearTimeout(INTERVALO);
//		alert(altura+"...>"+parseInt(menuV[cual][0].style.height));
	} else {
		altura+=INCREMENTO;
		INTERVALO=setTimeout("visuaD('"+cual+"','"+altura+"');",h);
		}
}

function visuaE(cual) {
	//82px
    var nose=document.getElementById(cual);	
	if(cual=='LosProductos')
		document.getElementById('Layer1').style.height='92px';
	nose.style.height='1px';
//	nose.style.visibility='visible';
	INTERVALO=setTimeout("visuaD('"+nose+"','"+1+"');",TEMPORIZADOR/10);
}

function ocultar() {
   var i;
   clearTimeout(INTERVALO);

document.getElementById('Layer1').style.height='50px';
    desplegable.style.visibility='hidden';
	
}