// ***************** 
// Funciones propias
// *****************

function dibujaIFrame(num, src, style) {
	pixHeight = new String(pixHeight);
	pixHeight = pixHeight.replace("px", "");
	pixHeight +="px";
	var src;
	var idIFrame;
	idIFrame = "marcointerior" + num;
	if (idIFrame == "marcointerior_col1")
		src = "int_col1.php";
	if (src == "foros/index.php" && document.all)
		scroll = "yes";
	else
	    scroll = "auto";
	if (!src)
		src="int_vacio.php";
	document.write("<iframe align='top' id='"+idIFrame+"' name='"+idIFrame+"' src='"+src+"' width='100%' scrolling='"+scroll+"' frameborder='0' style='height:"+(pixHeight)+"; "+style+"'> Marco interior </iframe>");
}

function redibujaIFrame() {
	var IFrame;
	var pixHeight=alturaIFrame();
	if(document.getElementById("serie")) { // Series de colaboraciones
		pixHeight+=27;
		if(document.all)
			pixHeight+=2;
	}
	else if(document.getElementById("index")) { // P&aacute;gina principal
		pixHeight+=25;
		if(document.all)
			pixHeight+=2;
	}
	else if(document.getElementById("autor")) { // Publicaciones convencionales
		pixHeight+=44;
		if(document.all)
			pixHeight+=1;
	}
	else if(document.getElementById("7")) { // Presentaci&oacute;n publicaciones
		pixHeight+=50;
	}
	else if(document.getElementById("parcial")) { // Secciones 5, 6 y 8
		pixHeight+=45;
		if(document.all)
			pixHeight+=7;
	}
	pixHeight=pixHeight+"px";
	if(IFrame=document.getElementById("marcointerior"))
		IFrame.style.height=pixHeight;
	else if(IFrame=document.getElementById("marcointerior1")) {
		document.getElementById("marcointerior1").style.height=pixHeight;
		document.getElementById("marcointerior2").style.height=pixHeight;
	}
	else if(IFrame=document.getElementById("marcointerior_col1")) {
		document.getElementById("marcointerior_col1").style.height=pixHeight;
		document.getElementById("marcointerior_col2").style.height=pixHeight;
	}
}

function alturaIFrame() {
	var minimo=500;  // M&iacute;nima altura del &aacute;rea de visualizaci&oacute;n
	var k=200;		// N&uacute;mero a restar para ajustar el tama&ntilde;o del IFrame
	var alturaDoc=0;
	var alturaIFrame=0;
	// opera Netscape 6 Netscape 4x Mozilla
	if(window.innerHeight) {
		alturaDoc=window.innerHeight;
	}
	// IE 4 IE 5 Mozilla
	if(document.body.clientHeight) {
		alturaDoc=document.body.clientHeight;
	}
	// IE 6
	if(document.documentElement.clientHeight) {
		alturaDoc=document.documentElement.clientHeight;
	}
	if(alturaDoc>minimo)	// Si es mayor, ajustamos el tama&ntilde;o del IFrame para que encaje en pantalla
		alturaIFrame=alturaDoc-k;
	else		// Si no, otorgamos al IFrame la altura m&iacute;nima (la visualizaci&oacute;n en pantalla no ser&aacute; total)
		alturaIFrame=minimo-k;
	return alturaIFrame;
}

function abreVentana(documento,anchura,altura,scroll) {
	window.open(documento,"","resizable=yes,toolbar=no,directories=no,scrollbars="+scroll+",menubar=no,statusbar=no,width="+anchura+",height="+altura);
}

function nuevaBusqueda() {
	editorial=document.form_buscar.editorial.value;
	tema=document.form_buscar.tema.value;
	top.frames.marcointerior.frames.libros.location="int82.php?editorial="+editorial+"&tema="+tema;
}

function esconderMensaje() {
	document.getElementById("mensaje").style.visibility="hidden";
}

function esconderCarrito(spanId) {
	document.getElementById(spanId).style.visibility="hidden";
}

function sumarCarrito(idLibro) {
	editorial=top.frames.marcointerior.frames.buscar.document.form_buscar.editorial.value;
	tema=top.frames.marcointerior.frames.buscar.document.form_buscar.tema.value;
	cantidad=document.getElementById("libro"+idLibro).value;
	top.frames.marcointerior.frames.buscar.location="int81.php?editorial="+editorial+"&tema="+tema+"&libro="+idLibro+"&cantidad="+cantidad;
	spanCarrito="spanCarrito"+idLibro;
	document.getElementById(spanCarrito).style.visibility="visible";
	setTimeout("esconderCarrito(spanCarrito)",1000);
}

function volverCarrito(reset) {
	if(reset==1)
		top.frames.marcointerior.location="int80.php?reset=1";
	else
		top.frames.marcointerior.location="int80.php";
}

function realizarPedido() {
	top.frames.marcointerior.location="int84.php";
}

function enviarFormComprador() {
	nombre=document.datosComprador.nombre.value;
	email=document.datosComprador.email.value;
	email2=document.datosComprador.email2.value;
	direccion=document.datosComprador.direccion.value;
	cp=document.datosComprador.cp.value;
	poblacion=document.datosComprador.poblacion.value;
	if(nombre==""||email==""||direccion==""||cp==""||poblacion=="") {
		document.datosComprador.status_fallo.value=1;
		return;
	}
	var filtro=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if(!filtro.test(email)) {
		document.datosComprador.status_fallo.value=2;
		return;
	}
	if(!document.datosComprador.condiciones.checked) {
		document.datosComprador.status_fallo.value=3;
		return;
	}
	if(email!=email2) {
		document.datosComprador.status_fallo.value=4;
		return;
	}
	document.datosComprador.action="int85.php";
}

function enviarFormPizarra() {
	nombre=document.formPizarra.nombre.value;
	lugar=document.formPizarra.lugar.value;
	pais=document.formPizarra.pais.value;
	nombre_web=document.formPizarra.nombre_web.value;
	email=document.formPizarra.email.value;
	web=document.formPizarra.web.value;
	haiku1=document.formPizarra.haiku1.value;
	haiku2=document.formPizarra.haiku2.value;
	haiku3=document.formPizarra.haiku3.value;
	haiku4=document.formPizarra.haiku4.value;
	haiku5=document.formPizarra.haiku5.value;
	if(nombre==""||lugar==""||pais==""||email=="") {
		document.formPizarra.status_fallo.value=1;
		return;
	}
	var filtro=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if(!filtro.test(email)) {
		document.formPizarra.status_fallo.value=2;
		return;
	}
	document.formPizarra.action="int6part3.php";
}

function resultadosBusquedaVersatil() {
	autor = document.form_antologia.autor.value;
	traductor = document.form_antologia.traductor.value;
	pal_clave = document.form_antologia.pal_clave.value;
	novedades = document.form_antologia.novedades.checked;
	top.frames.marcointerior2.location = "int_resbusver.php?autor=" + autor + "&traductor=" + traductor + "&pal_clave=" + pal_clave + "&novedades=" + novedades;
}

// *************** 
// Otras funciones
// ***************

// Deshabilita bot&oacute;n derecho del rat&oacute;n

document.oncontextmenu=new Function("return false")
	
// Deshabilita selecci&oacute;n de texto

function disableSelect(e) {
	return false;
}

//if IE4+
if(document.all)
	document.onselectstart=new Function("return false");
//if MZ
else
{
	document.onmousedown=disableSelect;
}
