//-- CARGAMOS LOS COMENTARIOS LUEGO DE CARGAR TODO EL DOM DE LA HOME
Event.observe(window, 'load', EA_loadCantidadTotalComentarios);

///////////////////////////////////////////////////////////////////////////////////////////
///////////// FUNCION PARA CARGAR LOS BANNERS TOP Y CABECERA
function EA_loadCantidadTotalComentarios() {
	var arraySpanComent = $$('span.AjaxCantComent');
	if((arraySpanComent) && arraySpanComent.size() > 0){
		arraySpanComent.each(
				 function(unSpan){
					 var idNoti = unSpan.getAttribute('id').split('_');
					 idNoti = idNoti[1];
					 //alert(idNoti);
					 EA_AJAXRefreshContenido(unSpan.getAttribute('id'),
					 	"idNoti=" + idNoti + "&accion=getCantComentario"
					 );
				}
			);
	}
}
//--------------------------------------------------------------------------------------

///////////////////////////////////////////////////////////////////////////////////////////
///////////// FUNCION PARA 
function responderComentario( params, mostrarBloque ){
	EA_goToScroll('zonaComentarios');
	if(mostrarBloque == 1){
		Effect.BlindDown('bloqueResponderComentario', { duration: 1.0 });
	}
}
//--------------------------------------------------------------------------------------

///////////////////////////////////////////////////////////////////////////////////////////
///////////// FUNCION PARA 
function cancelarComentario(){
	Effect.BlindUp('bloqueResponderComentario', { duration: 1.0 });
}
//--------------------------------------------------------------------------------------

///////////////////////////////////////////////////////////////////////////////////////////
///////////// FUNCION PARA 
function EA_validateComentario( f ){
	var error = "";
	new Effect.Pulsate($('bloqueResponderComentario'), { pulses: 2 });
		
	if(isBlanco(f.nombre.value))
		error+="Error: Ingrese su nombre. \n";
	
	if(!isEmail(f.email.value))
		error+="Error: Ingrese correctamente direccion de correo electronico. \n";
	
	if(isBlanco(f.texto.value)|| f.texto.value.length <= 10)
		error+="Error: Ingrese el texto del comentario! \n";
	
	
	if(error != ""){
		alert(error);
	 	return false;
	}
	else{
		f.submit();
	}
	
}
//--------------------------------------------------------------------------------------

///////////////////////////////////////////////////////////////////////////////////////////
///////////// FUNCION PARA 
function cancelarLoginUser(){
	Effect.BlindUp('bloqueResponderComentario', { duration: 1.0 });
}
//--------------------------------------------------------------------------------------

///////////////////////////////////////////////////////////////////////////////////////////
///////////// FUNCION PARA 
function EA_validateLogin( f ){
	if(isBlanco(f.username.value)|| f.username.value.length <= 3){
		alert("ERROR: el nombre de usuario es obligatorio!");
		f.username.focus();
		return false;	
	}
	if(isBlanco(f.pass.value) || f.pass.value.length <= 3){
		alert("ERROR: la contraseņa es obligatoria!");
		f.pass.focus();
		return false;	
	}
	return true;
}
//--------------------------------------------------------------------------------------


///////////////////////////////////////////////////////////////////////////////////////////
///////////// Abre una nueva ventana de registro de usuarios
function openNuevoUsuarioRegistrado( redirect ) {
	openPopUp( window, './nuevoUsuario.php?' + redirect , 420, 380, 1, 1 );
}
//--------------------------------------------------------------------------------------

///////////////////////////////////////////////////////////////////////////////////////////
///////////// FUNCION PARA 
function EA_validateNuevoUsuarioRegistrado( f ){
	if(isBlanco(f.nombre.value)|| f.nombre.value.length <= 3){
		alert("ERROR: Tu nombre es obligatorio!");
		f.nombre.focus();
		return false;	
	}
	if(isBlanco(f.apellido.value)|| f.apellido.value.length <= 3){
		alert("ERROR: Tu apellido es obligatorio!");
		f.apellido.focus();
		return false;	
	}
	if(isBlanco(f.username.value)|| f.username.value.length <= 3){
		alert("ERROR: el nombre de usuario es obligatorio!");
		f.username.focus();
		return false;	
	}
	if(isBlanco(f.pass.value) || f.pass.value.length <= 3){
		alert("ERROR: la contraseņa es obligatoria!");
		f.pass.focus();
		return false;	
	}
	if(!isEmail(f.email.value)){
		alert("ERROR: el correo electronico es obligatorio!");
		f.email.focus();
		return false;	
	}
	
	return true;
}
//--------------------------------------------------------------------------------------

///////////////////////////////////////////////////////////////////////////////////////////
///////////// mostramos todos los comentarios
function EA_mostrarTodosLosComentarios() {
	$$('div.divComentario').each(function(unDiv) {
			if($(unDiv.id) && $(unDiv.id).style.display == 'none'){
				//$(unDiv.id).style.display = 'block';
				$(unDiv.id).appear( { duration: 1.5 });
			}
		}
	);
	return false;
}
//--------------------------------------------------------------------------------------
