/***************************************************/
/*****************VENTANA***************************/
/***************************************************/
function ventana(pagina,ancho,alto) 
	{
	window.open(pagina, 'popup', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width='+ancho+', height='+alto+', left = 100,top = 50');
	}

/***************************************************/
/*****************DECISION**************************/
/***************************************************/
function decision(message, url)
	{
	if(confirm(message)) location.href = url;
	}

/***************************************************/
/*****************SELECCIONAR TODO******************/
/***************************************************/
function seleccionar_todo()
	{
   for (i=0;i<document.f1.elements.length;i++)
      if(document.f1.elements[i].type == "checkbox")
         document.f1.elements[i].checked=1
	}

/***************************************************/
/*****************DESELECCIONAR TODO****************/
/***************************************************/
function deseleccionar_todo()
	{
   for (i=0;i<document.f1.elements.length;i++)
      if(document.f1.elements[i].type == "checkbox")
         document.f1.elements[i].checked=0
	} 

/***************************************************/
/*****************OPEN DIR**************************/
/***************************************************/
function openDir( form ) 
	{ 
	var newIndex = form.campo.selectedIndex; 
	cururl = form.campo.options[ newIndex ].value; 
	window.location.assign( cururl ); 
	}

/***************************************************/
/*****************BORRAR_USUARIO********************/
/***************************************************/
function borrar_usuario()
	{
	if (document.getElementById("usuario").value == "Usuario...")
		{
			document.getElementById("usuario").value = ""
		}
	}

/***************************************************/
/*****************COLOCAR USUARIO*******************/
/***************************************************/
function colocar_usuario()
	{
	if (document.getElementById("usuario").value == "")
		{
			document.getElementById("usuario").value = "Usuario..."
		}
	}

/***************************************************/
/*****************BORRAR_CONTRASEÑA*****************/
/***************************************************/
function borrar_contrasena()
	{
	if (document.getElementById("contrasena").value == "Contraseña...")
		{
			document.getElementById("contrasena").value = ""
		}
	}

/***************************************************/
/*****************COLOCAR_CONTRASEÑA****************/
/***************************************************/
function colocar_contrasena()
	{
	if (document.getElementById("contrasena").value == "")
		{
			document.getElementById("contrasena").value = "Contraseña..."
		}
	}


/***************************************************/
/*****************VALIDAR_EMAIL*********************/
/***************************************************/
function validarEmail(valor) 
	{
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor))
		{
   		//alert("La dirección de email " + valor    + " es correcta.") 
   		return (true)
  		} else {
   		//alert("La dirección de email es incorrecta.");
   		return (false);
  		}
	}

/***************************************************/
/*****************VALIDA_REGISTRO*******************/
/***************************************************/
function Validar_registro() 
	{
	var sigue=true;
	var emailvalido = validarEmail(document.getElementById("email").value)
	
	dia_nacimiento = document.getElementById("nacimiento_dia").value;
	mes_nacimiento = document.getElementById("nacimiento_mes").value;
	ano_nacimiento = document.getElementById("nacimiento_ano").value;
	
	/*=============================INICIO PARA LA FECHA DE INGRESO=============================*/
	var monthLength = 
    new Array(31,28,31,30,31,30,31,31,30,31,30,31);
	
	// check for bisestile year
	if (ano_nacimiento/4 == parseInt(ano_nacimiento/4))
		monthLength[1] = 29;
	
	if (dia_nacimiento > monthLength[mes_nacimiento-1])
		{
		mensaje_alerta= "La Fecha de Nacimiento es Invalida.";
		sigue = false;
		}
	/*=============================FIN PARA LA FECHA DE INGRESO=============================*/

	if (document.getElementById("captcha").value=='')
		{
		sigue = false;
		mensaje_alerta= "Debe ingresar el Codigo de Seguridad.";
		}
	if (document.getElementById("ciudad").value==0)
		{
		sigue = false;
		mensaje_alerta= "Debe elegir una ciudad.";
		}
	if (document.getElementById("apellido").value=='')
		{
		sigue = false;
		mensaje_alerta= "Debe colocar un Apellido.";
		}
	if (document.getElementById("nombre").value=='')
		{
		sigue = false;
		mensaje_alerta= "Debe colocar un nombre.";
		}
	if (!emailvalido)
		{
		sigue = false;
		mensaje_alerta= "El email es invalido o esta en blanco.";
		}
	if (document.getElementById("registro_contrasena").value == '' || (document.getElementById("registro_contrasena").value != document.getElementById("registro_repetir_contrasena").value))
		{
		sigue = false;
		mensaje_alerta= "Las dos contraseñas no coinciden o estan en blanco.";
		}
	if (document.getElementById("registro_usuario").value=='' || document.getElementById("registro_usuario").value.indexOf(",") != -1)
		{
		sigue = false;
		mensaje_alerta= "Debe colocar un Usuario. El usuario no debe contener el caracter \",\" (coma)";
		}

	if (!sigue)
		{
		alert (mensaje_alerta)
		return false;
		}
		else 
		{
		return true;
		}
	}

/***************************************************/
/*****************VALIDA_SUBIR_FOTO*****************/
/***************************************************/
function Validar_subir_foto() 
	{
	var sigue=true;
	
	dia = document.getElementById("dia").value;
	mes = document.getElementById("mes").value;
	ano = document.getElementById("ano").value;
	
	if (dia < 10)
		{ dia = "0" + dia }
	if (mes < 10)
		{ mes = "0" + mes }
	
	fecha=ano + mes + dia;
	
	fecha_hoy = new Date();
	hoy_mes = fecha_hoy.getMonth()+1;
	hoy_dia = fecha_hoy.getDate().toString();
	hoy_ano = fecha_hoy.getFullYear().toString();
	if (hoy_dia < 10)
		{ hoy_dia = "0" + hoy_dia }
	if (hoy_mes < 10)
		{ hoy_mes = "0" + hoy_mes }
	hoy = hoy_ano + hoy_mes + hoy_dia;
	
	/*=============================INICIO VALIDA FECHA=============================*/
	var monthLength = 
    new Array(31,28,31,30,31,30,31,31,30,31,30,31);
	
	// check for bisestile year
	if (ano/4 == parseInt(ano/4))
		monthLength[1] = 29;
	
	if (dia > monthLength[mes-1])
		{
		mensaje_alerta= "La Fecha es Invalida.";
		sigue = false;
		}
	/*=============================FIN VALIDA FECHA=============================*/

	if (hoy < fecha)
		{
		mensaje_alerta= "La Fecha debe ser menor a HOY.";
		sigue = false;
		}
	if (document.getElementById("foto").value=='')
		{
		sigue = false;
		mensaje_alerta= "No ha elegido una foto.";
		}

	if (!sigue)
		{
		alert (mensaje_alerta)
		return false;
		}
		else 
		{
		var subiendoFoto;
		subiendoFoto= document.getElementById('subiendo_foto');
		subiendoFoto.innerHTML = '<img src="imagenes/ajax-loader.gif" align="absmiddle" /><span class="texto_general" style="color:#BFE61C;"><strong>Subiendo la foto. Aguarde por favor...</strong></span>';
		return true;
		}
	}

/***************************************************/
/*****************NUEVO_AJAX************************/
/***************************************************/
function nuevoAjax(){
	var xmlhttp=false;
 	try {
 		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 	} catch (e) {
 		try {
 			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
 		} catch (E) {
 			xmlhttp = false;
 		}
  	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

/***************************************************/
/*****************VERIFICAR_USUARIO*****************/
/***************************************************/
function verificarUsuario(){
	var usuario, checkUsuario;
	checkUsuario = document.getElementById('checkUsuario');
	usuario = document.getElementById('registro_usuario').value;
	ajax=nuevoAjax();
	ajax.open("GET", "ajax/chequear_usuario.php?usuario="+usuario, true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
		//Para que los acentos salgan bien
		resul=unescape(ajax.responseText);
        resultado=resul.replace(/\+/gi," ");
		checkUsuario.innerHTML = resultado
	 	}else{
		checkUsuario.innerHTML = '<img src="imagenes/ajax-loader.gif" align="absmiddle" /><span class="texto_general" style="color:#BFE61C;"><strong>Cargando...</strong></span>';
		}
	}
	ajax.send(null)
}

/***************************************************/
/*****************BORRAR_CHECK_USUARIO**************/
/***************************************************/
function borrar_CheckUsuario()
	{
		document.getElementById('checkUsuario').innerHTML = "";
	}

/***************************************************/
/*****************BUSCAR_PROVINCIA******************/
/***************************************************/
function buscarProvincia(){
	var pais, contenidoProvincia, contenidoCiudad;
	contenidoProvincia = document.getElementById('contenidoProvincia');
	contenidoCiudad = document.getElementById('contenidoCiudad');
	pais = document.getElementById('pais').value;
	ajax=nuevoAjax();
	ajax.open("GET", "ajax/seleccionar_provincias.php?pais="+pais, true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
		//Para que los acentos salgan bien
		resul=unescape(ajax.responseText);
        resultado=resul.replace(/\+/gi," ");
		contenidoProvincia.innerHTML = resultado;
	 	contenidoCiudad.innerHTML = '<select class="campo_general_roll" name="ciudad" disabled="disabled"><option class="campo_general_roll" value="0">Ciudades...</option></select>';
		}else{
		contenidoProvincia.innerHTML = '<img src="imagenes/ajax-loader.gif" align="absmiddle" /><span class="texto_general" style="color:#BFE61C;"><strong>Cargando...</strong></span>';
		}
	}
	ajax.send(null)
}

/***************************************************/
/*****************BUSCAR_CIUDADES******************/
/***************************************************/
function buscarCiudad(){
	var provincia, contenidoCiudad;
	contenidoCiudad = document.getElementById('contenidoCiudad');
	provincia = document.getElementById('provincia').value;
	ajax=nuevoAjax();
	ajax.open("GET", "ajax/seleccionar_ciudades.php?provincia="+provincia, true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
		//Para que los acentos salgan bien
		resul=unescape(ajax.responseText);
        resultado=resul.replace(/\+/gi," ");
		contenidoCiudad.innerHTML =resultado
	 	}else{
		contenidoCiudad.innerHTML = '<img src="imagenes/ajax-loader.gif" align="absmiddle" /><span class="texto_general" style="color:#BFE61C;"><strong>Cargando...</strong></span>';
		}
	}
	ajax.send(null)
}

/***************************************************/
/*****************CAMPO AGREGAR CIUDAD**************/
/***************************************************/
function campoAgregarCiudad(){
	var agregarCiudad;
	agregarCiudad = document.getElementById('agregar_ciudad');
	agregarCiudad.innerHTML = 'Nueva ciudad: <input type="text" class="campo_general" id="ciudad_nueva" />&nbsp;<input type="button" class="campo_general" value="Agregar ciudad" onclick="agregarCiudad();" />';
}

/***************************************************/
/***************CAMPO AGREGAR PROVINCIA*************/
/***************************************************/
function campoAgregarProvincia(){
	var agregarProvincia;
	agregarProvincia = document.getElementById('agregar_provincia');
	agregarProvincia.innerHTML = 'Nueva provincia: <input type="text" class="campo_general" id="provincia_nueva" />&nbsp;<input type="button" class="campo_general" value="Agregar provincia" onclick="agregarProvincia();" />';
}

/***************************************************/
/*****************AGREGAR_CIUDAD********************/
/***************************************************/
function agregarCiudad(){
	var provincia, ciudad_nueva, contenidoCiudad;
	contenidoCiudad = document.getElementById('contenidoCiudad');
	ciudad_nueva = document.getElementById('ciudad_nueva').value;
	provincia = document.getElementById('provincia').value;
	if (ciudad_nueva=='')
		{
		alert("Debes colocar un nombre a la nueva ciudad.");	
		}
		else
		{
		ajax=nuevoAjax();
		ajax.open("GET", "ajax/agregar_ciudad.php?ciudad_nueva="+ciudad_nueva+"&provincia="+provincia, true);
		ajax.onreadystatechange=function() 
			{
			if (ajax.readyState==4) 
				{
				//Para que los acentos salgan bien
				resul=unescape(ajax.responseText);
				resultado=resul.replace(/\+/gi," ");
				contenidoCiudad.innerHTML = resultado
				}else{
				contenidoCiudad.innerHTML = '<img src="imagenes/ajax-loader.gif" align="absmiddle" /><span class="texto_general" style="color:#BFE61C;"><strong>Cargando...</strong></span>';
				}
			}
		ajax.send(null);
		}
}

/***************************************************/
/*****************AGREGAR_PROVINCIA*****************/
/***************************************************/
function agregarProvincia(){
	var pais, provincia_nueva, contenidoProvincia;
	contenidoProvincia = document.getElementById('contenidoProvincia');
	provincia_nueva = document.getElementById('provincia_nueva').value;
	pais = document.getElementById('pais').value;
	if (provincia_nueva=='')
		{
		alert("Debes colocar un nombre a la nueva provincia.");	
		}
		else
		{
		ajax=nuevoAjax();
		ajax.open("GET", "ajax/agregar_provincia.php?provincia_nueva="+provincia_nueva+"&pais="+pais, true);
		ajax.onreadystatechange=function() 
			{
			if (ajax.readyState==4) 
				{
				//Para que los acentos salgan bien
				resul=unescape(ajax.responseText);
				resultado=resul.replace(/\+/gi," ");
				contenidoProvincia.innerHTML = resultado
				}else{
				contenidoProvincia.innerHTML = '<img src="imagenes/ajax-loader.gif" align="absmiddle" /><span class="texto_general" style="color:#BFE61C;"><strong>Cargando...</strong></span>';
				}
			}
		ajax.send(null);
		}
}

/***************************************************/
/*****************BORRAR_CODIGO_INCORRECTO**********/
/***************************************************/
function borrarCodigoIncorrecto(){
	var codigo_incorrecto;
	codigo_incorrecto = document.getElementById('codigo_incorrecto');
	codigo_incorrecto.innerHTML = '';
}

/***************************************************/
/*****************VALIDA_COMENTARIO*******************/
/***************************************************/
function Validar_comentario() 
	{
	var sigue=true;

	if (document.getElementById("comentario").value=='')
		{
		sigue = false;
		mensaje_alerta= "Debe ingresar un comentario.";
		}

	if (!sigue)
		{
		alert (mensaje_alerta)
		return false;
		}
		else 
		{
		return true;
		}
	}

/***************************************************/
/*************VALIDA_MODIFICAR_DATOS****************/
/***************************************************/
function Validar_modificar_datos_personales() 
	{
	var sigue=true;
	var emailvalido = validarEmail(document.getElementById("email").value)
	
	dia_nacimiento = document.getElementById("nacimiento_dia").value;
	mes_nacimiento = document.getElementById("nacimiento_mes").value;
	ano_nacimiento = document.getElementById("nacimiento_ano").value;
	
	/*=============================INICIO PARA LA FECHA DE INGRESO=============================*/
	var monthLength = 
    new Array(31,28,31,30,31,30,31,31,30,31,30,31);
	
	// check for bisestile year
	if (ano_nacimiento/4 == parseInt(ano_nacimiento/4))
		monthLength[1] = 29;
	
	if (dia_nacimiento > monthLength[mes_nacimiento-1])
		{
		mensaje_alerta= "La Fecha de Nacimiento es Invalida.";
		sigue = false;
		}
	/*=============================FIN PARA LA FECHA DE INGRESO=============================*/


	if (document.getElementById("apellido").value=='')
		{
		sigue = false;
		mensaje_alerta= "Debe colocar un Apellido.";
		}
	if (document.getElementById("nombre").value=='')
		{
		sigue = false;
		mensaje_alerta= "Debe colocar un nombre.";
		}
	if (!emailvalido)
		{
		sigue = false;
		mensaje_alerta= "El email es invalido o esta en blanco.";
		}
	if ((document.getElementById("contrasena").value != '' || document.getElementById("repetir_contrasena").value != '') && (document.getElementById("contrasena").value != document.getElementById("repetir_contrasena").value))
		{
		sigue = false;
		mensaje_alerta= "Las dos contraseñas no coinciden.";
		}

	if (!sigue)
		{
		alert (mensaje_alerta)
		return false;
		}
		else 
		{
		return true;
		}
	}


/***************************************************/
/******VERIFICA_CONTRASEÑAS_EN_MODIFICAR_DATOS******/
/***************************************************/
function verifica_contrasenas(){
	var contrasena_distintas = document.getElementById('contrasena_distintas');
	if ((document.getElementById('contrasena').value != '' || document.getElementById('repetir_contrasena').value != '' ) &&  (document.getElementById('contrasena').value != document.getElementById('repetir_contrasena').value))
		{
		contrasena_distintas.innerHTML = '<br>Las dos contraseñas son distintas';
		}else{
		contrasena_distintas.innerHTML = '';
		}
}

/***************************************************/
/*****************CAMPO MODIFICAR FOTO**************/
/***************************************************/
function campoModificarFoto(){
	var modificarFoto;
	modificarFoto = document.getElementById('modificarFoto');
	modificarFoto.innerHTML = '<input type="file" name="foto" class="campo_general" /><br /><a href="javascript:quitarCampoModificarFoto();">Perdon! No modificar.</a>';
}

/***************************************************/
/*************QUITAR CAMPO MODIFICAR FOTO***********/
/***************************************************/
function quitarCampoModificarFoto(){
	var modificarFoto;
	modificarFoto = document.getElementById('modificarFoto');
	modificarFoto.innerHTML = '<a href="javascript:decision(\'¿Seguro que desea borrar esta foto de su perfil?\',\'borrar_foto_perfil.php\');">Borrar Foto</a>  |  <a href="javascript:campoModificarFoto();">Modificar Foto</a>';
}

/***************************************************/
/********************PREVIA COLORES*****************/
/***************************************************/
function previaColores(){
	var previaColores;
	colorFondoTMP = document.getElementById('cfondo_Hex').value;
	colorTextoTMP = document.getElementById('ctexto_Hex').value;
	colorLinkTMP = document.getElementById('clink_Hex').value;
	colorHoverTMP = document.getElementById('chover_Hex').value;
	
	previaColores = document.getElementById('divPreviaColores');
	previaColores.innerHTML = '';
	previaColores.innerHTML = '<span class="texto_general"><a href="javascript:previaColores();"><strong>ACTUALIZAR</strong></a></span><style type="text/css"> .estiloPreviaColores { font-family:Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color:#'+colorTextoTMP+'; background-color: #'+colorFondoTMP+'; } .estiloPreviaColores a { color: #'+colorLinkTMP+'; text-decoration:underline; } .estiloPreviaColores a:hover { color: #'+colorHoverTMP+'; text-decoration:underline; } </style> <div class="estiloPreviaColores" style="height:50px; border:#FFFFFF solid 1px; padding-top:15px;">Texto sin link<br /><a href="javascript:;">Texto con link :: Pasa el mouse por aqui</a>';
}

/***************************************************/
/**********VALIDA_MODIFICAR_DATOS_FLOG**************/
/***************************************************/
function Validar_modificar_datos_flog() 
	{
	var sigue=true;

	if (document.getElementById("titulo").value=='')
		{
		sigue = false;
		mensaje_alerta= "Debe colocar un Titulo a tu Flog.";
		}

	if (!sigue)
		{
		alert (mensaje_alerta)
		return false;
		}
		else 
		{
		return true;
		}
	}

/***************************************************/
/*************VALIDA_CONTACTENOS********************/
/***************************************************/
function Validar_contactenos() 
	{
	var sigue=true;
	var emailvalido = validarEmail(document.getElementById("email").value)
	
	if (document.getElementById("nombre").value=='')
		{
		sigue = false;
		mensaje_alerta= "Debes colocar tu nombre.";
		}
	if (!emailvalido)
		{
		sigue = false;
		mensaje_alerta= "El email es invalido o esta en blanco.";
		}
	if (document.getElementById("donde").value=='')
		{
		sigue = false;
		mensaje_alerta= "Debes colocar de dónde sos.";
		}
	if (document.getElementById("asunto").value=='')
		{
		sigue = false;
		mensaje_alerta= "Debes colocar un asunto.";
		}
	if (document.getElementById("mensaje").value=='')
		{
		sigue = false;
		mensaje_alerta= "Debes colocar un mensaje.";
		}


	if (!sigue)
		{
		alert (mensaje_alerta)
		return false;
		}
		else 
		{
		return true;
		}
	}

/***************************************************/
/*********VALIDA_RECORDAR_CONTRASENA****************/
/***************************************************/
function Validar_recordar_contrasena() 
	{
	var sigue=true;
	var emailvalido = validarEmail(document.getElementById("email").value)
	
	if (document.getElementById("usuario").value=='')
		{
		sigue = false;
		mensaje_alerta= "Debes colocar tu usuario.";
		}
	if (!emailvalido)
		{
		sigue = false;
		mensaje_alerta= "El email es invalido o esta en blanco.";
		}

	if (!sigue)
		{
		alert (mensaje_alerta)
		return false;
		}
		else 
		{
		return true;
		}
	}

/***************************************************/
/************BUSCAR_PROVINCIA_BUSCADOR**************/
/***************************************************/
function buscarProvinciaBuscador(){
	var pais, contenidoProvincia, contenidoCiudad;
	contenidoProvincia = document.getElementById('contenidoProvincia');
	contenidoCiudad = document.getElementById('contenidoCiudad');
	pais = document.getElementById('pais').value;
	ajax=nuevoAjax();
	ajax.open("GET", "ajax/seleccionar_provincias_buscador.php?pais="+pais, true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
		//Para que los acentos salgan bien
		resul=unescape(ajax.responseText);
        resultado=resul.replace(/\+/gi," ");
		contenidoProvincia.innerHTML = resultado;
	 	contenidoCiudad.innerHTML = '<select class="campo_general_roll" name="ciudad" disabled="disabled"><option class="campo_general_roll" value="0">Todas...</option></select>';
		}else{
		contenidoProvincia.innerHTML = '<img src="imagenes/ajax-loader.gif" align="absmiddle" /><span class="texto_general" style="color:#BFE61C;"><strong>Cargando...</strong></span>';
		}
	}
	ajax.send(null)
}

/***************************************************/
/*************BUSCAR_CIUDADES_BUSCADOR**************/
/***************************************************/
function buscarCiudadBuscador(){
	var provincia, contenidoCiudad;
	contenidoCiudad = document.getElementById('contenidoCiudad');
	provincia = document.getElementById('provincia').value;
	ajax=nuevoAjax();
	ajax.open("GET", "ajax/seleccionar_ciudades_buscador.php?provincia="+provincia, true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
		//Para que los acentos salgan bien
		resul=unescape(ajax.responseText);
        resultado=resul.replace(/\+/gi," ");
		contenidoCiudad.innerHTML = resultado
	 	}else{
		contenidoCiudad.innerHTML = '<img src="imagenes/ajax-loader.gif" align="absmiddle" /><span class="texto_general" style="color:#BFE61C;"><strong>Cargando...</strong></span>';
		}
	}
	ajax.send(null)
}

/***************************************************/
/*****************PONER EMOTICON********************/
/***************************************************/
function ponerEmoticon(emoticon)
	{
	document.getElementById("comentario").value += emoticon;
	}

/***************************************************/
/******************ENVIAR_COMENTARIO****************/
/***************************************************/
function enviarComentario(){
	var comentario, nombre, email, foto, flog, comentario_nuevo, formulario_comentario;
	var parametros;
	comentario_nuevo = document.getElementById('comentario_nuevo');
	formulario_comentario = document.getElementById('formulario_comentario');
	comentario = document.getElementById('comentario').value;
	nombre = document.getElementById('nombre').value;
	email = document.getElementById('email').value;
	foto = document.getElementById('foto').value;
	flog = document.getElementById('flog').value;
	parametros = "comentario="+comentario+"&nombre="+nombre+"&email="+email+"&foto="+foto+"&flog="+flog;
	ajax=nuevoAjax();
	ajax.open("POST", "ajax/enviar_comentario.php", true);
	
	//Send the proper header information along with the request
	ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajax.setRequestHeader("Content-length", parametros.length);
	ajax.setRequestHeader("Connection", "close");
	
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
		//Para que los acentos salgan bien
		resul=unescape(ajax.responseText);
        resultado=resul.replace(/\+/gi," ");
		comentario_nuevo.innerHTML = resultado
		formulario_comentario.innerHTML = '<strong>Tu comentario fue enviado.<br>Actualiza la pagina para poder enviar otro.</strong><br>';
	 	}else{
		comentario_nuevo.innerHTML = '<span class="texto_general_flog"><strong>Cargando nuevo comentario...</strong></span>';
		}
	}
	ajax.send(parametros)
}

/***************************************************/
/**************VISTA PREVIA COMENTARIO**************/
/***************************************************/
function vistaPrevia(){
	var comentario, comentario_nuevo;
	var parametros;
	comentario_nuevo = document.getElementById('comentario_nuevo');
	comentario = document.getElementById('comentario').value;
	parametros = "comentario="+comentario;
	ajax=nuevoAjax();
	ajax.open("POST", "ajax/vista_previa.php", true);
	
	//Send the proper header information along with the request
	ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajax.setRequestHeader("Content-length", parametros.length);
	ajax.setRequestHeader("Connection", "close");
	
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
		//Para que los acentos salgan bien
		resul=unescape(ajax.responseText);
        resultado=resul.replace(/\+/gi," ");
		comentario_nuevo.innerHTML = resultado
	 	}else{
		comentario_nuevo.innerHTML = '<span class="texto_general_flog"><strong>Cargando vista previa...</strong></span>';
		}
	}
	ajax.send(parametros)
}

/***************************************************/
/*************AGREGAR SITIO FAVORITO****************/
/***************************************************/
function agregarSitio(){
	var sitio_nombre, sitio_url, flog_id, lista_sitios;
	lista_sitios = document.getElementById('lista_sitios');
	sitio_nombre = document.getElementById('sitio_nombre').value;
	sitio_url = document.getElementById('sitio_url').value;
	flog_id = document.getElementById('flog_id').value;
	//Borro los campos
	document.getElementById('sitio_nombre').value = "";
	document.getElementById('sitio_url').value = "";
	ajax=nuevoAjax();
	ajax.open("GET", "ajax/agregar_sitio.php?nombre="+ sitio_nombre +"&url="+ sitio_url +"&flog="+ flog_id, true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
		lista_sitios.innerHTML = ajax.responseText;
		}else{
		lista_sitios.innerHTML = '<img src="imagenes/ajax-loader.gif" align="absmiddle" /><span class="texto_general" style="color:#BFE61C;"><strong>Cargando...</strong></span>';
		}
	}
	ajax.send(null)
}

/***************************************************/
/*************BORRAR SITIO FAVORITO*****************/
/***************************************************/
function borrarSitio(id){
	var flog_id,lista_sitios;
	lista_sitios = document.getElementById('lista_sitios');
	flog_id = document.getElementById('flog_id').value;
	ajax=nuevoAjax();
	ajax.open("GET", "ajax/borrar_sitio.php?id="+id+"&flog="+flog_id, true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
		lista_sitios.innerHTML = ajax.responseText;
		}else{
		lista_sitios.innerHTML = '<img src="imagenes/ajax-loader.gif" align="absmiddle" /><span class="texto_general" style="color:#BFE61C;"><strong>Cargando...</strong></span>';
		}
	}
	ajax.send(null)
}

/***************************************************/
/********************VOTACION***********************/
/***************************************************/
function flogVotar(foto,voto){
	var votar_links,votar_resultados;
	votar_links = document.getElementById('votar_links');
	votar_resultados = document.getElementById('votar_resultados');
	votar_links.innerHTML = '<strong>Gracias por votar!</strong>';
	ajax=nuevoAjax();
	ajax.open("GET", "ajax/flog_votar.php?foto="+foto+"&voto="+voto, true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
		votar_resultados.innerHTML = ajax.responseText;
		}else{
		votar_resultados.innerHTML = '<span class="texto_general_flog"><strong>Cargando...</strong></span>';
		}
	}
	ajax.send(null)
}

/***************************************************/
/*************VALIDA_ENVIAR_EMAIL*******************/
/***************************************************/
function Valida_enviar_email() 
	{
	var sigue=true;
	var miEmailvalido = validarEmail(document.getElementById("mi_email").value);
	var listaEmails = document.getElementById("emails").value;
	
	//Quito los espacios en blanco y salto de lineas y los separo por coma y compruebo que no haya mas de 10
	if (listaEmails!='')
		{
		var espacio = " ";
		var salto = "\n";
		var nada = "";
		listaEmails = listaEmails.split(espacio).join(nada);
		listaEmails = listaEmails.split(salto).join(nada);
		var emails = listaEmails.split(",");
		
		var cantidadEmails = emails.length;
		
		if (cantidadEmails<=10)
			{
			for (var i=0; i<=cantidadEmails-1; i++)
				{
				if (!validarEmail(emails[i]))
					{
					sigue = false;
					mensaje_alerta= "Este email de tu amigo esta mal escrito: "+emails[i];
					}
				}
			}else{
			sigue = false;
			mensaje_alerta= "El maximo de emails son 10.";
			}
		}else{
		sigue = false;
		mensaje_alerta= "Debes colocar al menos un email de un amigo.";
		}
	
	
	if (document.getElementById("mi_nombre").value=='')
		{
		sigue = false;
		mensaje_alerta= "Debes colocar tu Nombre.";
		}
	if (!miEmailvalido)
		{
		sigue = false;
		mensaje_alerta= "Tu email es invalido o esta en blanco.";
		}
	

	if (!sigue)
		{
		alert (mensaje_alerta)
		return false;
		}
		else 
		{
		return true;
		}
	}

/***************************************************/
/********************SUBIR_URL**********************/
/***************************************************/
function subirURL(){
	var que_subir;
	
	que_subir = document.getElementById('que_subir');
	que_subir.innerHTML = 'URL: <input type="text" name="foto_url" class="campo_general" style="width:400px;" id="foto" /><span id="subiendo_foto" class="texto_general"></span><br><a href="javascript:subirArchivo();">Subir foto que este en Mi PC</a>';
}

/***************************************************/
/******************SUBIR_ARCHIVO********************/
/***************************************************/
function subirArchivo(){
	var que_subir;
	
	que_subir = document.getElementById('que_subir');
	que_subir.innerHTML = '<input type="file" name="foto" class="campo_general" style="width:230px;" id="foto" /><span id="subiendo_foto" class="texto_general"></span><br /><a href="javascript:subirURL();">Subir foto que este en otro sitio (URL)</a>';
}