if (document.layers)
 {
	mostrar="show";
	ocultar="hide";
 }
else
 {
	mostrar="visible";
	ocultar="hidden";
 }

var activa=null;

function colorbarras()
 {
	var nav=navigator.appName;
	var version=parseInt(navigator.appVersion);
	if (nav=="Microsoft Internet Explorer")
	 {
		document.body.style.scrollbarFaceColor="#B8B8B8";
		document.body.style.scrollbarArrowColor="#000000";
		document.body.style.scrollbarTrackColor="#D9DBDC";
		document.body.style.scrollbarShadowColor="#000000";
		document.body.style.scrollbarHighlightColor="#B3B3B3";
		document.body.style.scrollbar3dlightColor="#B3B3B3";
		document.body.style.scrollbarDarkshadowColor="#E6E6E6";
	 }
 }

function validar_ent()
 {
	var mens="";
	valor=true;
	if(document.forms[0].elements[0].value.length==0)
	 {
		mens="Número de Cliente\n";
	 }
	if(document.forms[0].elements[1].value.length==0)
	 {
		mens=mens+"Clave\n";
	 }
	if (mens)
	 {
		window.alert("Debe de indicar los siguientes datos:\n\n"+mens);
		valor=false;
	 }
	else 
	 {
		mens=valalfanumerico(document.forms[0].elements[0].value);
		if (mens)
		 {
			window.alert(mens+" el Número de Cliente");
			valor=false;
		 }
		else
		 {
			mens=valalfanumerico(document.forms[0].elements[1].value);
			if (mens)
			 {
				window.alert(mens+" la Clave");
				valor=false;
			 }
		 }
	 }
	return(valor);
 }

function mostrarcapa(nombrecapa)
 {	
	if (activa!=null) { activa.style.visibility=ocultar;activa.style.display="none";}
	if (document.layers)
	 {
		obj=document.layers[nombrecapa]
	 }
	else if (document.all && !document.getElementById)
	 {
		obj=eval(document.all[nombrecapa]);
	 }
	else
	 {	
		obj=eval(document.getElementById(nombrecapa));
	//	document.layers[nombrecapa].style.visibility=mostrar;
	//	activa=document.layers[nombrecapa];
	 }
	if (obj.style.visibility=="visible" || obj.style.visibility=="show")
	 {
		obj.style.visibility=ocultar;
		obj.style.display="none";
	 }
	else
	 {
		obj.style.visibility=mostrar;
		obj.style.display="";
		activa=obj;
	 }
 }

function nula(){}

function ocultarcapa()
 {
	if (activa!=null) { activa.style.visibility=ocultar;activa.style.display="none";}
 }

function ventanaa()
 {
	ancho=screen.width;
	alto=screen.height;
	mitada=(ancho-400)/2;
	mitadb=(alto-130)/2;
	id=window.open("./aviso_legal.html","","width=450,height=350,screenX="+mitada+",screenY="+mitadb+",left="+mitadb+",top="+mitadb+",scrollbars=1,titlebar=0,menubar=0,status=0,toolbar=0");
 }

function ventanab()
 {
	ancho=screen.width;
	alto=screen.height;
	mitada=(ancho-400)/2;
	mitadb=(alto-130)/2;
	id=window.open("./clausula.html","","width=450,height=350,screenX="+mitada+",screenY="+mitadb+",left="+mitadb+",top="+mitadb+",scrollbars=1,titlebar=0,menubar=0,status=0,toolbar=0");
 }

function ventanac()
 {
	ancho=screen.width;
	alto=screen.height;
	mitada=(ancho-200)/2;
	mitadb=(alto-100)/2;
	id=window.open("./cv.asp","","width=700,height=750,screenX="+mitada+",screenY="+mitadb+",left="+mitadb+",top="+mitadb+",scrollbars=1,titlebar=0,menubar=0,status=0,toolbar=0");
 }

function valalfanumerico(cadena)
 {	
	carac=new String("");
	num=new String("");
	men=""
	cadval=new String("0123456789ABCDEFGHIJKLMNÑOPQRSTUVWXYZ'.");
	num=cadena.toUpperCase();
	longitud=num.length;
	carac="";
	for (i=0;i<longitud;i++) if(!(cadval.indexOf(num.charAt(i))+1)) carac=carac+num.charAt(i);
	if (carac) men="Los caracteres '"+carac+"' no están permitidos en ";
	return(men);
 }

function ejecutar(valor)
 {
	 document.forms[0].elements[2].value=valor;
 }

function ejecutar1(ind)
 {
	 document.forms[1].elements[0].value=ind;
	 document.forms[1].elements[1].value="borrar";
	 document.forms[1].submit();
 }

function destino(num)
 {
	document.forms[1].elements[2].value=num;
	document.forms[1].submit();
	setTimeout("imprimir()",1000);
 }

function imprimir2(formulario)
 {
	formulario.submit();
	setTimeout("imprimir()",1000);
 }


function imprimir()
 {
	parent.frames.compra.focus();
	parent.frames.compra.print();
	parent.focus();
 }

function ir()
 {
	document.forms[0].action = "../rgs/index.asp";
	document.forms[0].submit();
 }

function ejecuta(valor)
 {
	var si=window.confirm("Pulse Aceptar para borrar su pedido actual.");
	if (si)
	 {
		document.forms[1].elements[1].value=valor;
		document.forms[1].submit();
	 }
 }

function validar_bus()
 {
	var mens="";
	valor=true;
	if(document.forms[0].elements[0].value.length==0)
	 {
		window.alert("No ha indicado ningún texto para que sea buscado"); 		 
		valor=false;
	 }
	return(valor);
 }

function validar_obs()
 {
	var mens="";
	valor=true;
	if(document.forms[1].elements[2].value.length>270)
	 {
		window.alert("El campo de observaciones no puede exceder los 270 caracteres");
		valor=false;
	 }
	return(valor);
 }