
//Abrir Ventana con imagen por Tunait
var ventana
var cont=0
var titulopordefecto = "Tu Titulo de la ventana"
function afoto(cual,titulo)
{
if(cont==1){ventana.close();ventana=null}
if(titulo==null){titulo=titulopordefecto}
ventana=window.open('','ventana','resizable=no,sc rollbars=no,width=50,height=50')
ventana.document.write('<html><head><title>' + titulo + '</title></head><body style="overflow:hidden" marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" scroll="no"  onUnload="opener.cont=0"><div align="center"><a href="javascript:this.close()"><img src="' + cual + '" onLoad="opener.redimensionar(this.width, this.height)" style="border:none"></a></div>')
ventana.document.close()
cont++
}
function redimensionar(ancho, alto)
{
ventana.resizeTo(ancho+5,alto+30)
ventana.moveTo((screen.width-ancho)/2,(screen.height-alto)/2) //centra la ventana. Eliminar si no se quiere centrar el popup
}	

function validarCampos(){
	if (document.datos.titulo.value==""){
		alert("El campo TITULO esta vacío, por favor rellénelo.");
		document.datos.titulo.focus();
	}else{
		document.datos.submit();
	}
}

function validarProductos(){
	if (document.datos.titulo.value==""){
		alert("El campo TITULO esta vacío, por favor rellenelo.");
		document.datos.titulo.focus();
	}
	else{
		document.datos.submit();
	}
}

	function abrirPopup(ancho,alto,urlImagen){
		alineacionHorizontal = (screen.width-ancho)/2
		alineacionVertical = (screen.height-alto)/2
		window.open(urlImagen, '_blank', 'width=' + ancho +',height=' + alto + ',titlebar, left=' + alineacionHorizontal + ',top= '+ alineacionVertical + ',scrollbars');
	}

