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
}


var _img_grande;

			function mostrar() {
				var ops = "top=" + ((screen.height - _img_grande.height) / 2);
				ops += ",left=" + ((screen.width - _img_grande.width) / 2);
				ops += ",width=" + _img_grande.width + ",height=" + _img_grande.height;
				var contenido = "<html><body style='background-image: url(" + _img_grande.src + ")'></body></html>";
				var ventana = window.open("", "", ops);
				ventana.document.write(contenido);
				ventana.document.close();
			}

			function cargando() {
				if (_img_grande.complete) mostrar();
				else setTimeout("cargando()", 100);
			}

			function abrir(imagen)	{
				_img_grande = new Image();
				_img_grande.src = imagen;
				cargando();
			}

function valida_login()
{
  if (login.usuario.value=="" || login.clave.value=="") 
  	 alert("Indique su usuario y contraseña para acceder.");
  else
  	 login.submit();
}


function valida_contacto()
{
  if (contacto.nombre.value=="" || contacto.apellido.value=="" || contacto.email.value=="" || contacto.empresa.value=="" || contacto.pais.value=="" || contacto.telefono.value=="" ) 
  	 alert("Ha de cumplimentar los campos obligatorios.");
  else
  	 contacto.submit();
}

function cargarFoto(Foto, id)
{
	document.getElementById("imgFotogrande").src=Foto;
	actual=document.getElementById("estado").value;
	document.getElementById("estado").value=id;
	document.getElementById(id).className="trojo";
	document.getElementById(actual).className="tgris";
}

function pasaFoto(id)
{
	actual=document.getElementById("estado").value;
	nueva=parseInt(actual) + parseInt(id) 
	if (nueva>parseInt(total))
	{	nueva=1;}
	if (nueva==0)
	{  nueva=parseInt(total)}

	campo="foto"+nueva;
	document.getElementById("imgFotogrande").src=document.getElementById(campo).value;
	document.getElementById("estado").value=nueva;
	document.getElementById(actual).className="tgris";
	document.getElementById(nueva).className="trojo";
}


function valida_registro_usuario()
{
  if (registro.nombre.value=="" || registro.apellido.value==""  || registro.direccion.value=="" || registro.localidad.value=="" || registro.cp.value=="" || registro.pais.value=="" || registro.telefono.value==""  || registro.email.value=="" || registro.empresa.value=="" || registro.cif.value=="" || registro.departamento.value=="")  
  	 alert("Ha de cumplimentar todos los campos para proceder al registro.");
  else
  	 registro.submit();
}

function skDeterminarIdiomaNaveg() {   
var idiomaNavegador = new String;   
if (navigator.language){      
idiomaNavegador = navigator.language;      
// En este caso, el idioma devuelto puede contener el       
// subcódigo de idioma (p.ej. "es-ES").   
} 
else 
{      
idiomaNavegador = navigator.browserLanguage;      
// En este caso, el idioma devuelto solo conteniene el       
// código de idioma (p.ej. "es")   
}   
return idiomaNavegador;
}


var imagen=new Image();


function mostrar(save,alt)
{
  winWidth=imagen.width;
  winHeight=imagen.height;
  winLeft= (screen.width) ? (screen.width-winWidth)/2 : 0;
  winTop= (screen.height) ? (screen.height-100-winHeight)/2 : 0;
  winset="menubar=0,status=0,width="+winWidth+",height="+winHeight+",titlebar=no";
  winset+=",top="+winTop+",left="+winLeft;
  var aux=open("","",winset);
  
  
  aux.document.writeln("<HTML><HEAD><TITLE>MecanoContinental.com</TITLE>");    
  aux.document.writeln("<BODY bgcolor='#ffffff' leftmargin=0 topmargin=0 marginwidth=0 marginheight=0><CENTER>");
  aux.document.writeln("<img  src='"+imagen.src+"' alt='"+alt+"' >");
  aux.document.writeln("</CENTER></BODY></HTML>");
}

function EsperaCarga(save1,alt1)
{
 if (imagen.width>1 && imagen.height>1) 
    {//alert(imagen.width+"///"+imagen.height);
	 mostrar(save1,alt1);
	 return true} 
  else { setTimeout('EsperaCarga('+save1+',"'+alt1+'")', 200);}
}

function Verfoto(url,save,alt)
//url -> Directorio en el que se encuentra la imagen desde la home
//save -> Booleano que indica si se puede salvar con el boton derecho o no
//alt -> Texto alternativo de la imagen
{
  //var base="http://www.findfine.com/"
  imagen.width=0;
  imagen.height=0;
  imagen.src=url;
  EsperaCarga(save,alt);
}

