function chekeado(o){
	var bAux=false;
	var ln=o.length;
	if(ln>1){
		for(var x=0;x<ln;x++){
			bAux=bAux||o[x].checked;
		}
	}
	else{
		bAux=o.checked;
	}
	return bAux;
}

function pilloIdAutor(o){
	var ln=o.length;
	if(ln>0){
		for(var x=0;x<ln;x++){
			if(o[x].checked){
				bAux=o[x].value;
			}
		}
	}
	else{
		bAux=o.value;
	}
	return bAux;
}

function opc(pag){
	//para campos hidden
	var f=document.formu;
	f.action=pag;
	f.submit();
	
	//para session
//	document.location=pag;
}
function opc2(element,pag,idarea){
	document.forms[0].elements[element].value=idarea;
	document.forms[0].action=pag;
	document.forms[0].submit();
	
	//para session
//	document.location=pag;
}
var ie,ns4,ns6;
if(document.all)ie = true;
else if(document.layers)ns4 = true;
else if(document.getElementById)ns6 = true;

function openUp(url,h,w){ bn = (ns4 || ns6) ? open(url,h+'BN'+w,'toolbar=no,location=no,,status=no,scrollbars=yes,resizable=no,copyhistory=no,width='+w+',height='+h+',top='+((screen.height/2)-h)+',left='+((screen.width/2)-w)):open(url,h+'BN'+w,'toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,copyhistory=no,width='+w+',height='+h+',top='+((screen.height/2)-h)+',left='+((screen.width/2)-w)); 
}
function injektdata(hiden,element,data,texto){
	opener.document.forms[0].elements[hiden].value=data;
	opener.document.forms[0].elements[element].value=texto;
	window.close();
}

function validarLibro(){
	var f=document.formu;
	if(f.fisbnfac.value==""){
		alert("Introduzca un ISBN.");
		f.fisbnfac.focus();
		return false;
	}
	else if(f.ftitulo.value==""){
		alert("Introduzca un título.");
		f.ftitulo.focus();
		return false;
	}
	else if(f.fidAutor21.value==""){
		alert("Seleccione el primer autor.");
		document.location="#autor";
		return false;
	}
	else if(f.fidTema21.value==""){
		alert("Seleccione el tema principal.");
		document.location="#tema";
		return false;
	}
	else if(f.fidColeccion.value==""){
		alert("Introduzca una colección.");
		document.location="#coleccion";
		return false;
	}
	else if(f.fprecio.value==""){
		alert("Introduzca un precio.");
		f.fprecio.focus();
		return false;
	}
	else{
		//antesdesubir();
		if(validaCadenas()){
			return true;
		}
	}
}

function validaImg(){
	var f=document.formu;
	var b=true;
	if(f.subirImg.checked){
		if(f.elFicheroImg.value==""){
			b=true;
		}
		else{
			 if(f.elFicheroImg.value.toLowerCase().indexOf(".gif")!=-1 || f.elFicheroImg.value.toLowerCase().indexOf(".jpg")!=-1){
			 	b=true;
			 }
			 else{
				b=false;
			 }
		}
	}
	return b;
}

function validaPdf(){
	var f=document.formu;
	var b=true;
	if(f.subirPdf.checked){
		if(f.elFicheroPdf.value==""){
			b=true;
		}
		else{
			 if(f.elFicheroPdf.value.toLowerCase().indexOf(".pdf")!=-1){
			 	b=true;
			 }
			 else{
				b=false;
			 }
		}
	}
	return b;
}

function validaCubierta(){
	var f=document.formu;
	var b=true;
	if(f.subir.checked){
		if(f.elFichero.value==""){
			b=true;
		}
		else{
			 if(f.elFichero.value.toLowerCase().indexOf(".gif")!=-1 || f.elFichero.value.toLowerCase().indexOf(".jpg")!=-1){
			 	b=true;
			 }
			 else{
				b=false;
			 }
		}
	}
	return b;
}