	function RedirectLogin(emailUsuario)
	{		
		
		 MOOdalBox.open( // case matters
				"../padmin/lightLogin.php?emailUsuario="+emailUsuario, // the link URL
				"", // the caption (link's title) - can be blank
				"400 300" // width and height of the box - can be left blank
				);
	}
	
	///funciones de upload
    function resultadoUpload(estado, file) 
    {
	    var mensaje="";
	    var mensajeError="";
    
	    MensajeAltaImagen(false);

	    if (estado == 0) mensaje = '<table id="imagen_'+ file +'"  width="420px" cellpadding="0" cellspacing="2" border="0"><tr><td align="center" style="width:100px"><input type="radio" name="listadoImagenes" value="'+file+'" onclick="javascript:ImagenPrincipal(\''+file+'\',\'0\');"  class="check"></td><td style="width:120px"><img src="../fotos/temporal/'+ file + '" width="90px"/></td><td style="width:180px"><span id="btnEliminarImagen'+ file +'" style="cursor:hand;cursor:pointer;color:#000000" onclick="MostrarLoaderEliminarImagen(true,\''+file+'\');xajax_Eliminar_Imagen(\''+ file +'\',\'0\',xajax.getFormValues(\'formulario\'),\'../fotos/temporal/\')">Eliminar esta imagen</span><img id="loadEliminarImagen'+ file +'" src="../images/min-loader.gif" alt="loader" style="display:none"/></td></tr></table>';	   	
	   
	    if (estado == 1) mensajeError = 'Error ! - El Archivo no llego al servidor' ;
	    if (estado == 2) mensajeError = 'Error ! - Solo se permiten Archivos de Imagen gif, jpg o jpeg';
	    if (estado == 3) mensajeError = 'Error ! - No se pudo copiar Archivo. Posible problema de permisos en server';
	    if (estado == 4) mensajeError = 'Error ! - La imagen no puede superar el tama&ntilde;o de 500kb';
	    if (estado == 4) mensajeError = 'Error ! - La imagen no puede superar el tama&ntilde;o de 500kb';
	    if (estado == 5) mensajeError = 'Error ! - La imagen ya se encuentra cargada, suba otra imagen';
	
	    document.getElementById('ErrorImagen').innerHTML="";
	    document.getElementById('ErrorImagen').innerHTML=mensajeError;
	    
	    if(estado==0)
	    {
			///voy agregando las imagenes al hidden de los archivos para luego persistirlas en la base de datos			    
		    var imagenesSubidas = document.getElementById('archivosSubidos').value;
		    imagenesSubidas+=file+';';
		    document.getElementById('archivosSubidos').value=imagenesSubidas;
		    
		    ///actualizo el numero de archivos subidos
		    var cantImagenesSubida = null;
		    if(document.getElementById('cantArchSubidos').value != null && document.getElementById('cantArchSubidos').value!='')
		    {
		    	cantImagenesSubidas = document.getElementById('cantArchSubidos').value;
		    }
		    else
		    {
		    	cantImagenesSubidas=0;
		    }
		    cantImagenesSubidas++;
		    document.getElementById('cantArchSubidos').value = cantImagenesSubidas;	  
		    
		    document.getElementById('divImagenes').innerHTML+=''+mensaje;
		    
		   	///bloqueo la cantidad de imagenes que subo
		    Bloquear_Subida_Imagenes();
		    MostrarCabeceraImagen();
	    }
	    
    }
    
    function OcultarImagen(nomDiv, imagenesHidden, idImagen)
	{
	 	var tblImagenBorrar=document.getElementById(nomDiv);
	 	var divImagen = document.getElementById('divImagenes');
	 	divImagen.removeChild(tblImagenBorrar);
		document.getElementById('archivosSubidos').value = imagenesHidden;
		
		///actualizo el numero de archivos subidos
	    var cantImagenesSubida = null;
	    if(document.getElementById('cantArchSubidos').value != null && document.getElementById('cantArchSubidos').value!='')
	    {
	    	cantImagenesSubidas = document.getElementById('cantArchSubidos').value;
	    }
	    else
	    {
	    	cantImagenesSubidas=0;
	    }
	    cantImagenesSubidas--;
	    
	    document.getElementById('cantArchSubidos').value = cantImagenesSubidas;		
	    
	    ///agrego las imagenes que se borraron en caso de que el id sea distinto de '0'
	    if(idImagen !=0)
	    {
		    var ImagenesBorrar ='';
		    ImagenesBorrar = document.getElementById('imagenesEliminadas').value;
		    ImagenesBorrar+=idImagen+';';
		    document.getElementById('imagenesEliminadas').value = ImagenesBorrar;
	    }
	    
		///bloqueo la cantidad de imagenes que subo
		Bloquear_Subida_Imagenes();
		MostrarCabeceraImagen();
	}
	
	function Bloquear_Subida_Imagenes()
	{
		///obtengo las imagenes subidas
		var imagenesSubidas = document.getElementById('archivosSubidos').value;	
	
		///obtengo la cantidad de imagenes que tengo subida	   
	    var cantImagenes = 0;
	    cantImagenes = document.getElementById('cantArchSubidos').value;
	    
	    ///habilito la cantidad de fotos dependiendo si es un archivo destacado o uno simple
	   	///simple y destacado cantidad de fotos segun el archivo de configuracion, en el caso de que se llegue al monto maximo
	   	///de fotos de bloquea el fileupload
	    if(cantImagenes == document.getElementById('cantFotosSimple').value && document.getElementById('chkdestacado').checked ==false)
	    {
	    	document.getElementById('fileUpload').disabled = true;
	    	document.getElementById('msgAltaImagenes').innerHTML =''; 
	    	document.getElementById('msgAltaImagenes').style.display ='none'; 	    	
	    }
	    else
	    {
	    	if(cantImagenes >document.getElementById('cantFotosSimple').value && 	document.getElementById('chkdestacado').checked ==false)
	    	{
	    		document.getElementById('fileUpload').disabled = true;	
	    		document.getElementById('msgAltaImagenes').innerHTML = 'Su aviso no est&aacute; destacado solamente se tendr&aacute;n en cuenta las primeras tres im&aacute;genes.';
	    		document.getElementById('msgAltaImagenes').style.display ='block'; 
	    	}
	    	else
	    	{
		    	if(cantImagenes == document.getElementById('cantFotosDestacado').value && document.getElementById('chkdestacado').checked ==true)
		    	{
		    		document.getElementById('fileUpload').disabled = true;
		    		document.getElementById('msgAltaImagenes').innerHTML =''; 
		    		document.getElementById('msgAltaImagenes').style.display ='none'; 
		    	}
		    	else
		    	{
		    		document.getElementById('fileUpload').disabled = false;
		    		document.getElementById('msgAltaImagenes').innerHTML =''; 
		    		document.getElementById('msgAltaImagenes').style.display ='none'; 
		    	}
	    	}
	    }
	}
	
	///funcion que habilita o deshabilita el check de destacado
	function HabilitarDestacado(estado)
	{
		if(estado=='true')
		{
			document.getElementById('chkdestacado').disabled=false;
		}
		else
		{
			document.getElementById('chkdestacado').disabled=true;
		}
	}
	
	function MostrarImagen(url)
	{
		window.open(url,"Imagen","width=300, height=300, scrollbars=no, menubar=no, location=no, resizable=no");
	}
	
	function MostrarLoader(estado)
	{
		if(estado)
		{
			document.getElementById('loader').style.display='block';
			document.getElementById('botonera').style.display='none';
		}
		else
		{
			document.getElementById('loader').style.display='none';
			document.getElementById('botonera').style.display='block';
		}
	}

	function MostrarLoaderUsuario(estado)
	{
		if(estado)
		{
			document.getElementById('loaderUsuario').style.display='block';
			document.getElementById('botonGuardarUsuario').style.display='none';
		}
		else
		{
			document.getElementById('loaderUsuario').style.display='none';
			document.getElementById('botonGuardarUsuario').style.display='block';
		}
	}
	
	function MostrarRegistro(estado)
	{
		if(estado)
		{
			document.getElementById('divAltaUsuario').style.display='block';
			document.getElementById('botonAltaAviso').style.display='none';
		}
		else
		{
			document.getElementById('botonAltaAviso').style.display='none';
			document.getElementById('divAltaUsuario').style.display='block';
		}
	}
	
	function MostrarLoaderDatosUsuario(estado)
	{
		if(estado)
		{
			document.getElementById('loaderDatosUsuario').style.display='block';
			document.getElementById('botonDatosGuardarUsuario').style.display='none';
		}
		else
		{
			document.getElementById('loaderDatosUsuario').style.display='none';
			document.getElementById('botonDatosGuardarUsuario').style.display='block';
		}
	}
	
	function MostrarDatosUsuario(estado, mostrarNombre, mostratApellido, mostrarTelefono)
	{
		if(estado)
		{
			document.getElementById('divActualizarUsuario').style.display='block';
			document.getElementById('botonAltaAviso').style.display='none';
		}
		else
		{
			document.getElementById('botonAltaAviso').style.display='none';
			document.getElementById('divActualizarUsuario').style.display='none';
		}
		
		///de aca en adelante habilito los datos a mostrar en los usuario
		if(mostrarNombre)
		{
			document.getElementById('divNombreUsuario').style.display='block';
		}
		else
		{
			document.getElementById('divNombreUsuario').style.display='none';
		}
		
		if(mostratApellido)
		{
			document.getElementById('divApellidoUsuario').style.display='block';
		}
		else
		{
			document.getElementById('divApellidoUsuario').style.display='none';
		}
		
		if(mostrarTelefono)
		{
			document.getElementById('divTelefonoUsuario').style.display='block';
			document.getElementById('divCelularUsuario').style.display='block';
		}
		else
		{
			document.getElementById('divTelefonoUsuario').style.display='none';
			document.getElementById('divCelularUsuario').style.display='block';
		}
	}
	
	function Sin_Precio()
	{
		if(document.getElementById('chksinprecio').checked)
		{
			document.getElementById('precio').disabled=true;
			document.getElementById('moneda').disabled=true;
		}
		else
		{
			document.getElementById('precio').disabled=false;
			document.getElementById('moneda').disabled=false;
		}
	}
	
	function MostrarLoaderEliminarImagen(estado, control)
	{
		if(estado)
		{
			document.getElementById("btnEliminarImagen"+control).style.display="none";
			document.getElementById("loadEliminarImagen"+control).style.display="block";
		}
		else
		{
			document.getElementById("btnEliminarImagen"+control).style.display="block";
			document.getElementById("loadEliminarImagen"+control).style.display="none";
		}
	}
	
	Bloquear_Subida_Imagenes();
	
	if(document.getElementById('chkdestacado').checked)
	{
		HabilitarDestacado('false');		
	}
	else
	{
		HabilitarDestacado('true');
	}
	function ImagenPrincipal(imagen, id)
	{
		document.getElementById('imagenPrincipal').value=imagen;
		document.getElementById('idImagenPrincipal').value=id;
	}
	
	
	

	///funcion que se utiliza en el light login
	function LoaderLogin(estado)
	{
		if(estado) document.getElementById('loaderLogin').style.display='block';
		else document.getElementById('loaderLogin').style.display='none';
	}

	
	
	function MostrarCabeceraImagen()
	{
		if(document.getElementById('cantArchSubidos').value > 0)
		{
			document.getElementById('divImagenesCabecera').style.display='block';
		}
		else
		{
			document.getElementById('divImagenesCabecera').style.display='none';	
		}
	}
	
	function DeshabilitarDestacado()
	{
		if(document.getElementById('id').value!=0 || document.getElementById('id').value!=null)
		{
			document.getElementById('chkdestacado').disabled=true;
		}
	}
	
	//DeshabilitarDestacado();
	MostrarCabeceraImagen();
	
	///funcion que se utiliza en el light login
	function MostrarLoaderRecuperarPassword(estado)
	{
		if(estado) document.getElementById('loaderRecuperarPassword').style.display='block';
		else document.getElementById('loaderRecuperarPassword').style.display='none';
	}
	
	function MensajeAltaImagen(estado)
	{
		if(estado) document.getElementById('mensajeSubida').style.display='block';
		else document.getElementById('mensajeSubida').style.display='none';		
	}
	
	function sugerirCiudad()
	{
		MOOdalBox.open( // case matters
			"../sugerirciudad.php", // the link URL
			"", // the caption (link's title) - can be blank
			"400 210" // width and height of the box - can be left blank
			);
	}