
function adminBorrarPublicacion(id_publicacion)	{
	
	if (confirm('¿Borrar esta publicación?'))	{
		document.getElementById("form-eliminar-publicacion-" + id_publicacion).submit();
	}
}



function todos(nombre_array, tamano)	{

	for (i = 0; i < tamano ; i++)	{
		id_mbro = eval(nombre_array + '[' + i + ']' );
		//alert(id_mbro + "---");
		//alert(nombre_array + '_' + id_mbro);
		if (document.getElementById(nombre_array + '_' + id_mbro).checked == true)
			document.getElementById(nombre_array + '_' + id_mbro).checked = false;
		else
			document.getElementById(nombre_array + '_' + id_mbro).checked = true;	
	}
}


function adminBuscarUsuarios()	{
	
	param_str = '/admin1r3d1/miembros';
	
	if (document.getElementById("form-busqueda-miembros").texto_busqueda.value != "")	{	
		param_str += '/texto-busqueda/' + urlencode(document.getElementById("form-busqueda-miembros").texto_busqueda.value);
	}
	if	(document.getElementById("form-busqueda-miembros").ordenar_por.value != 0 ) {
		param_str += '/ordenar_por/' + urlencode(document.getElementById("form-busqueda-miembros").ordenar_por.value);
	}
	if	(document.getElementById("form-busqueda-miembros").provincia.value != 0 ) {
		param_str += '/provincia/' + urlencode(document.getElementById("form-busqueda-miembros").provincia.value);
	}
		
	window.location.href= param_str;	
}

function adminBuscarPublicaciones(tipo)	{
	var redirect = '/admin1r3d1/publicaciones/tipo/' + tipo;

	if (document.getElementById("form-busqueda-publicaciones").texto_busqueda.value != "")	{
		redirect += '/texto-busqueda/' + urlencode(document.getElementById("form-busqueda-publicaciones").texto_busqueda.value); 	
	}
	
	if (document.getElementById("form-busqueda-publicaciones").subseccion.value > 0)	{
		redirect += '/subseccion/'+ document.getElementById("form-busqueda-publicaciones").subseccion.value; 	
	}
	
	if (document.getElementById("form-busqueda-publicaciones").ordenar_por.value != 0)	{
		redirect += '/ordenar_por/'+ document.getElementById("form-busqueda-publicaciones").ordenar_por.value; 	
	}
	
	if (document.getElementById("form-busqueda-publicaciones").fecha_1_dd.value != 0)	{
		redirect += '/fecha_1_dd/'+ document.getElementById("form-busqueda-publicaciones").fecha_1_dd.value; 	
	}
	
	if (document.getElementById("form-busqueda-publicaciones").fecha_1_mm.value != 0)	{
		redirect += '/fecha_1_mm/'+ document.getElementById("form-busqueda-publicaciones").fecha_1_mm.value; 	
	}
	
	if (document.getElementById("form-busqueda-publicaciones").fecha_1_yyyy.value != 0)	{
		redirect += '/fecha_1_yyyy/'+ document.getElementById("form-busqueda-publicaciones").fecha_1_yyyy.value; 	
	}
	
	if (document.getElementById("form-busqueda-publicaciones").fecha_2_dd.value != 0)	{
		redirect += '/fecha_2_dd/'+ document.getElementById("form-busqueda-publicaciones").fecha_2_dd.value; 	
	}
	
	if (document.getElementById("form-busqueda-publicaciones").fecha_2_mm.value != 0)	{
		redirect += '/fecha_2_mm/'+ document.getElementById("form-busqueda-publicaciones").fecha_2_mm.value; 	
	}
	
	if (document.getElementById("form-busqueda-publicaciones").fecha_2_yyyy.value != 0)	{
		redirect += '/fecha_2_yyyy/'+ document.getElementById("form-busqueda-publicaciones").fecha_2_yyyy.value; 	
	}
	
	if (document.getElementById("form-busqueda-publicaciones").provincia.value > 0)	{
		redirect += '/provincia/'+ document.getElementById("form-busqueda-publicaciones").provincia.value; 	
	}
	
	if (document.getElementById("form-busqueda-publicaciones").activas.checked)	{
		redirect += '/activas/'+ document.getElementById("form-busqueda-publicaciones").activas.value; 	
	}
	
	if (document.getElementById("form-busqueda-publicaciones").no_activas.checked)	{
		redirect += '/no_activas/'+ document.getElementById("form-busqueda-publicaciones").no_activas.value; 	
	}
	
	
	window.location.href= redirect;
}

function adminBorrarPublicaciones()	{
	if (confirm('¿Aplicar cambios?'))	{
		document.getElementById("form-publicaciones").submit();
	}
}


function adminBorrarGrupos()	{
	if (confirm('¿Elimnar los grupos seleccionados?'))	{
		document.getElementById("form-grupos").submit();
	}
}


function adminBorrarBoletines()	{
	if (confirm('¿Borrar estos boletines?'))	{
		document.getElementById("form-boletines").submit();
	}
}

function adminBorrarUsuariosGrupos()	{
	if (confirm('¿Eliminar estos usuarios del grupo?'))	{
		document.getElementById("form-usuarios-grupos").submit();
	}
}



function adminBorrarUsuarios()	{
	
	if (confirm('¿Aplicar cambios?'))	{
		document.getElementById("form-miembros").submit();
	}
}

function adminComentarios()	{
	if (confirm('¿Aplicar cambios?'))	{
		document.getElementById("form-comentarios").submit();
	}
}

function adminOperacionesDestacados(tipo)	{
	document.getElementById("tipo_operacion").value = tipo;
	if (tipo == 'borrar')	{
		if (confirm('¿Borrar destacados?'))	{
			document.getElementById("form-destacados").submit();
		}
	}
	else if (tipo == 'ordenar')	{
		document.getElementById("form-destacados").submit();
	}	
}

function adminOperacionesRotador(tipo)	{
	document.getElementById("tipo_operacion").value = tipo;
	if (tipo == 'borrar')	{
		if (confirm('¿Borrar del rotador?'))	{
			document.getElementById("form-rotador").submit();
		}
	}
	else if (tipo == 'ordenar')	{
		document.getElementById("form-rotador").submit();
	}	
}

//////////////

//
// Funciones para el envio del form de login
//

var handleSuccess_enviarFormLoginAdmin = function(o){
	if(o.responseText !== undefined){
				
		var messages = [];
		var mensajeError = '';
        // Use the JSON Utility to parse the data returned from the server
        try {
            messages = YAHOO.lang.JSON.parse(o.responseText);
            for(var campo in messages) { 
             		for (var razon in messages[campo])	{
             			if (messages[campo][razon] !== undefined && messages[campo][razon] != '')	
             				mensajeError += "<p>&raquo; " + messages[campo][razon] + "</p>\n";
             				
             			 
             				clase = new String(document.getElementById(campo).className);
             				
             				//alert(clase + "Error");
							document.getElementById(campo).className = clase + "Error";
             		} 
             }
             if (mensajeError != '')	{
             	document.getElementById("mensaje-error").innerHTML = mensajeError;
             	document.getElementById("mensaje-error").className = "mensaje-error";
             }
             else	{
             	document.getElementById('form-login-admin').submit();
             }
            
        }
        catch (x) {
            alert("JSON Parse failed! " + x);
            return;
        }
	}
};

var handleFailure_enviarFormLoginAdmin = function(o){
	if(o.responseText !== undefined){
		div.innerHTML = "<li>Transaction id: " + o.tId + "</li>";
		div.innerHTML += "<li>HTTP status: " + o.status + "</li>";
		div.innerHTML += "<li>Status code message: " + o.statusText + "</li>";
	}
};

var callback_enviarFormLoginAdmin =
{
  success:handleSuccess_enviarFormLoginAdmin,
  failure:handleFailure_enviarFormLoginAdmin
};

function enviarFormLoginAdmin()	{

	//Reset todos los estilos:
	
	document.getElementById("correo-electronico").className		= "form_campoBuscadorHome";
	document.getElementById("password").className 				= "form_campoBuscadorHome";
   
	// argument formId can be the id or name attribute value of the
	// HTML form, or an HTML form object.
	var formObject = document.getElementById('form-login-admin');
	YAHOO.util.Connect.setForm(formObject);
	// This example facilitates a POST transaction.
	// An HTTP GET can be used as well.
	var request = YAHOO.util.Connect.asyncRequest('POST', '/validar/formulario', callback_enviarFormLoginAdmin);
}

///////////////////


var handleSuccess_enviarFormBoletin = function(o){
	if(o.responseText !== undefined){
				
		var messages = [];
		var mensajeError = '';
        // Use the JSON Utility to parse the data returned from the server
        try {
            messages = YAHOO.lang.JSON.parse(o.responseText);
            for(var campo in messages) { 
             		for (var razon in messages[campo])	{
             			if (messages[campo][razon] !== undefined && messages[campo][razon] != '')	
             				mensajeError += "<p>&raquo; " + messages[campo][razon] + "</p>\n";
             				
             			 
             				clase = new String(document.getElementById(campo).className);
             				
             				//alert(clase + "Error");
							document.getElementById(campo).className = clase + "Error";
             		} 
             }
             if (mensajeError != '')	{
             	document.getElementById("mensaje-error").innerHTML = mensajeError;
             	document.getElementById("mensaje-error").className = "mensaje-error";
             }
             else	{
             	document.getElementById('form-boletin').submit();
             }
            
        }
        catch (x) {
            alert("JSON Parse failed! " + x);
            return;
        }
	}
};

var handleFailure_enviarFormBoletin = function(o){
	if(o.responseText !== undefined){
		div.innerHTML = "<li>Transaction id: " + o.tId + "</li>";
		div.innerHTML += "<li>HTTP status: " + o.status + "</li>";
		div.innerHTML += "<li>Status code message: " + o.statusText + "</li>";
	}
};

var callback_enviarFormBoletin =
{
  success:handleSuccess_enviarFormBoletin,
  failure:handleFailure_enviarFormBoletin
};

function enviarFormBoletin()	{

	//Reset todos los estilos:
	
   
	// argument formId can be the id or name attribute value of the
	// HTML form, or an HTML form object.
	var formObject = document.getElementById('form-boletin');
	YAHOO.util.Connect.setForm(formObject);
	// This example facilitates a POST transaction.
	// An HTTP GET can be used as well.
	var request = YAHOO.util.Connect.asyncRequest('POST', '/validar/formulario', callback_enviarFormBoletin);
}

////////////////////
var handleSuccess_lista_subsecciones = function(o){
	if(o.responseText !== undefined){
		document.getElementById("menu_subsecciones").innerHTML = o.responseText;
	}
};

var handleFailure_lista_subsecciones = function(o){
	if(o.responseText !== undefined){
		div.innerHTML = "<li>Transaction id: " + o.tId + "</li>";
		div.innerHTML += "<li>HTTP status: " + o.status + "</li>";
		div.innerHTML += "<li>Status code message: " + o.statusText + "</li>";
	}
};

var callback_lista_subsecciones =
{
  success:handleSuccess_lista_subsecciones,
  failure:handleFailure_lista_subsecciones
};

function lista_subsecciones(id_tipo_publicacion, tipo)	{
	document.getElementById("menu_subsecciones").innerHTML	= '<div style=\'text-align:center\'><img src=\'/images/ajax-loader.gif\'></div>';
	document.getElementById('menu_publicaciones').innerHTML = '';
	var request = YAHOO.util.Connect.asyncRequest('GET', '/admin1r3d1/listasubsecciones/id_tipo_publicacion/' + id_tipo_publicacion + '/tipo/' + tipo, callback_lista_subsecciones);
}

var handleSuccess_lista_publicaciones = function(o){
	if(o.responseText !== undefined){
		document.getElementById("menu_publicaciones").innerHTML = o.responseText;
	}
};

var handleFailure_lista_publicaciones = function(o){
	if(o.responseText !== undefined){
		div.innerHTML = "<li>Transaction id: " + o.tId + "</li>";
		div.innerHTML += "<li>HTTP status: " + o.status + "</li>";
		div.innerHTML += "<li>Status code message: " + o.statusText + "</li>";
	}
};

var callback_lista_publicaciones =
{
  success:handleSuccess_lista_publicaciones,
  failure:handleFailure_lista_publicaciones
};

function lista_publicaciones(id_tipo_publicacion, id_subseccion, tipo)	{
	document.getElementById("menu_publicaciones").innerHTML	= '<div style=\'text-align:center\'><img src=\'/images/ajax-loader.gif\'></div>';
	var request = YAHOO.util.Connect.asyncRequest('GET', '/admin1r3d1/listapublicaciones/id_tipo_publicacion/' + id_tipo_publicacion + '/id_subseccion/' + id_subseccion + '/tipo/' + tipo, callback_lista_publicaciones);
}

///////

var handleSuccess_Publicaciones = function(o){
	if(o.responseText !== undefined){
		document.getElementById("div_publicaciones").innerHTML = o.responseText;
	}
};

var handleFailure_Publicaciones = function(o){
	if(o.responseText !== undefined){
		div.innerHTML = "<li>Transaction id: " + o.tId + "</li>";
		div.innerHTML += "<li>HTTP status: " + o.status + "</li>";
		div.innerHTML += "<li>Status code message: " + o.statusText + "</li>";
	}
};

var callback_Publicaciones =
{
  success:handleSuccess_Publicaciones,
  failure:handleFailure_Publicaciones
};

function agregareliminarPublicaciones(accion, tipo)	{

	if (accion == 'agregar')	{
		len = document.getElementById("publicaciones_agregar").length
		i = 0
		chosen = ""
		
		for (i = 0; i < len; i++) {
			if (document.getElementById("publicaciones_agregar")[i].selected) {
				chosen = chosen + document.getElementById("publicaciones_agregar")[i].value + ","
			}
		}
	}
	else if (accion == 'eliminar')	{
		var id_publicaciones		= document.getElementById("ids_publicaciones").value;
		var id_publicaciones_array	= id_publicaciones.split(",");
	
			len = id_publicaciones_array.length
			i = 0
			chosen = ""
			
			for (i = 0; i < len; i++) {
				if (id_publicaciones_array[i] > 0)	{ 
					//alert (id_publicaciones_array[i] + ' ---- ' + document.getElementById("eliminar_publicacion_" + id_publicaciones_array[i]).checked);
					if (document.getElementById("eliminar_publicacion_" + id_publicaciones_array[i]).checked) {
						chosen = chosen + id_publicaciones_array[i] + ","
					}
				}
			}
	}
	
	document.getElementById("div_publicaciones").innerHTML	= '<div style=\'text-align:center\'><img src=\'/images/ajax-loader.gif\'></div>';
	var request = YAHOO.util.Connect.asyncRequest('GET', '/admin1r3d1/publicacionesagrupar/'+ accion + '_id_publicaciones/' + chosen + '/tipo/' + tipo, callback_Publicaciones);
}

//////////////////
function previsualizarBoletin()	{
	var id_publicaciones		= document.getElementById("ids_publicaciones").value;
	var id_publicaciones_array	= id_publicaciones.split(",");
	tmp							= new Array();
	hay_error					= false;


	len = id_publicaciones_array.length
	i = 0
	param_str = ""
			
	for (i = 0; i < len; i++) {
		if (id_publicaciones_array[i] > 0)	{
			//alert (document.getElementById("orden_publicacion_" + id_publicaciones_array[i]).value);
			tmp[i] = document.getElementById("orden_publicacion_" + id_publicaciones_array[i]).value;
			
			//id_publicacion-posicion
			param_str = param_str + id_publicaciones_array[i] + '-' + tmp[i] + ',';
		} 
	}
	
	//alert(param_str);
	
	window.open('/admin1r3d1/previsualizarboletin/titulo/' + urlencode(document.getElementById("titulo").value) + '/id_publicaciones/' + param_str + '/fecha_envio/' + urlencode(document.getElementById("fecha_envio").value));
	
}


function ordenarPublicaciones(tipo)	{
	var id_publicaciones		= document.getElementById("ids_publicaciones").value;
	var id_publicaciones_array	= id_publicaciones.split(",");
	tmp							= new Array();
	hay_error					= false;
	var publicaciones			= new Array();

	len = id_publicaciones_array.length
	i = 0
	param_str = ""
			
	for (i = 0; i < len; i++) {
		if (id_publicaciones_array[i] > 0)	{
			//alert (document.getElementById("orden_publicacion_" + id_publicaciones_array[i]).value);
			tmp[i] 				= document.getElementById("orden_publicacion_" + id_publicaciones_array[i]).value;
			titulo_publicacion	= document.getElementById("titulo_publicacion_" + id_publicaciones_array[i]).value;
			
			var publicacion = {id: id_publicaciones_array[i], orden: tmp[i], titulo: titulo_publicacion};
			
			publicaciones[i] = publicacion;
			
			//id_publicacion-posicion
			//param_str = param_str + id_publicaciones_array[i] + '-' + tmp[i] + ',';
		} 
	}
	
	
	for(var i = 0, n = tmp.length; i < n; i++) {
      for(var x = i + 1 ; x < n; x++)
         if(tmp[x]==tmp[i]) {
			alert('La posición ' + tmp[x] + ' tiene mas de una publicación');
			hay_error	= true;
		}
	}
	
	
	var jsonStr = YAHOO.lang.JSON.stringify(publicaciones);
	
	//alert(jsonStr);
	
	document.getElementById("datos_publicaciones").value = jsonStr;
	
	
	if (!hay_error)	{
	
		var formObject = document.getElementById('form-dummy-publicaciones');
		YAHOO.util.Connect.setForm(formObject);
		document.getElementById("div_publicaciones").innerHTML	= '<div style=\'text-align:center\'><img src=\'/images/ajax-loader.gif\'></div>';
		var request = YAHOO.util.Connect.asyncRequest('POST', '/admin1r3d1/publicacionesagrupar/ordenar_id_publicaciones/1/tipo/' + tipo, callback_Publicaciones);
	
		
		//var request = YAHOO.util.Connect.asyncRequest('GET', '/admin1r3d1/publicacionesboletin/ordenar_id_publicaciones/' + param_str, callback_PublicacionesBoletin);
	}
	
}

function popupImagenPublicaciones(id_publicacion, tipo)	{
	window.open ("/admin1r3d1/formimagenpublicacion/id/" + id_publicacion + "/tipo/" + tipo,"imagenpublicacion","menubar=no,width=350,height=250"); 
}

function enviarFormDestacados()	{
	document.getElementById('form-destacados').submit();
}


///////////////////////////

var glob_id_publicacion;

var handleSuccess_toogleDestacado = function(o){
	if(o.responseText !== undefined){
		resultado_toogle	= o.responseText;
		var messages = [];
		var mensajeError = '';
		
		try {
            messages = YAHOO.lang.JSON.parse(o.responseText);
            
            if (messages['respuesta'] !== undefined && messages['respuesta'] != '')	{
            		
            		if (messages['respuesta'] == "AGREGADO")	{
	            		document.getElementById("img_destacado_" + glob_id_publicacion).src	= '/images/backend/ok.gif';
	            	}
	            	else if (messages['respuesta'] == "ELIMINADO")	{
	            		document.getElementById("img_destacado_" + glob_id_publicacion).src	= '/images/backend/no_ok.gif';
	            	}
            }
        }
        catch (x) {
            alert("JSON Parse failed! " + x + o.responseText);
            return;
        }
	}
};

var handleFailure_toogleDestacado = function(o){
	if(o.responseText !== undefined){
		mensaje = "<li>Transaction id: " + o.tId + "</li>";
		mensaje += "<li>HTTP status: " + o.status + "</li>";
		mensaje += "<li>Status code message: " + o.statusText + "</li>";
		alert(mensaje);
	}
};

var callback_toogleDestacado =
{
  success:handleSuccess_toogleDestacado,
  failure:handleFailure_toogleDestacado
};


function toogleDestacado(id_publicacion,id_tipo_publicacion)	{
	glob_id_publicacion = id_publicacion;
	
	document.getElementById("img_destacado_" + id_publicacion).src	= '/images/ajax-loader.gif';
	var request = YAHOO.util.Connect.asyncRequest('GET', '/admin1r3d1/toogledestacado/id/' + id_publicacion + '/id_tipo_publicacion/' + id_tipo_publicacion, callback_toogleDestacado);
}

var handleSuccess_toogleRotador = function(o){
	if(o.responseText !== undefined){
		resultado_toogle	= o.responseText;
		var messages = [];
		var mensajeError = '';
		
		try {
            messages = YAHOO.lang.JSON.parse(o.responseText);
            
            if (messages['respuesta'] !== undefined && messages['respuesta'] != '')	{
            		
            		if (messages['respuesta'] == "AGREGADO")	{
	            		document.getElementById("img_rotador_" + glob_id_publicacion).src	= '/images/backend/ok.gif';
	            	}
	            	else if (messages['respuesta'] == "ELIMINADO")	{
	            		document.getElementById("img_rotador_" + glob_id_publicacion).src	= '/images/backend/no_ok.gif';
	            	}
            }
        }
        catch (x) {
            alert("JSON Parse failed! " + x + o.responseText);
            return;
        }
	}
};

var handleFailure_toogleRotador = function(o){
	if(o.responseText !== undefined){
		mensaje = "<li>Transaction id: " + o.tId + "</li>";
		mensaje += "<li>HTTP status: " + o.status + "</li>";
		mensaje += "<li>Status code message: " + o.statusText + "</li>";
		alert(mensaje);
	}
};

var callback_toogleRotador =
{
  success:handleSuccess_toogleRotador,
  failure:handleFailure_toogleRotador
};


function toogleRotador(id_publicacion)	{
	glob_id_publicacion = id_publicacion;
	document.getElementById("img_rotador_" + id_publicacion).src	= '/images/ajax-loader.gif';
	var request = YAHOO.util.Connect.asyncRequest('GET', '/admin1r3d1/tooglerotador/id/' + id_publicacion, callback_toogleRotador);
}

var handleSuccess_toogleActivo = function(o){
	if(o.responseText !== undefined){
		resultado_toogle	= o.responseText;
		var messages = [];
		var mensajeError = '';
		
		try {
            messages = YAHOO.lang.JSON.parse(o.responseText);
            
            if (messages['respuesta'] !== undefined && messages['respuesta'] != '')	{
            		
            		if (messages['respuesta'] == "AGREGADO")	{
	            		document.getElementById("img_activo_" + glob_id_publicacion).src	= '/images/backend/ok.gif';
	            	}
	            	else if (messages['respuesta'] == "ELIMINADO")	{
	            		document.getElementById("img_activo_" + glob_id_publicacion).src	= '/images/backend/no_ok.gif';
	            	}
            }
        }
        catch (x) {
            alert("JSON Parse failed! " + x + o.responseText);
            return;
        }
	}
};

var handleFailure_toogleActivo = function(o){
	if(o.responseText !== undefined){
		mensaje = "<li>Transaction id: " + o.tId + "</li>";
		mensaje += "<li>HTTP status: " + o.status + "</li>";
		mensaje += "<li>Status code message: " + o.statusText + "</li>";
		alert(mensaje);
	}
};

var callback_toogleActivo =
{
  success:handleSuccess_toogleActivo,
  failure:handleFailure_toogleActivo
};


function toogleActivo(id_publicacion)	{
	glob_id_publicacion = id_publicacion;
	document.getElementById("img_activo_" + id_publicacion).src	= '/images/ajax-loader.gif';
	var request = YAHOO.util.Connect.asyncRequest('GET', '/admin1r3d1/toogleactivo/id/' + id_publicacion, callback_toogleActivo);
}
////////////////////////

var glob_id_posicion;

var handleSuccess_toogleActivoPosicion = function(o){
	if(o.responseText !== undefined){
		resultado_toogle	= o.responseText;
		var messages = [];
		var mensajeError = '';
		
		try {
            messages = YAHOO.lang.JSON.parse(o.responseText);
            
            if (messages['respuesta'] !== undefined && messages['respuesta'] != '')	{
            		
            		if (messages['respuesta'] == "AGREGADO")	{
	            		document.getElementById("img_posicion_" + glob_id_posicion).src	= '/images/backend/ok.gif';
	            	}
	            	else if (messages['respuesta'] == "ELIMINADO")	{
	            		document.getElementById("img_posicion_" + glob_id_posicion).src	= '/images/backend/no_ok.gif';
	            	}
            }
        }
        catch (x) {
            alert("JSON Parse failed! " + x + o.responseText);
            return;
        }
	}
};

var handleFailure_toogleActivoPosicion = function(o){
	if(o.responseText !== undefined){
		mensaje = "<li>Transaction id: " + o.tId + "</li>";
		mensaje += "<li>HTTP status: " + o.status + "</li>";
		mensaje += "<li>Status code message: " + o.statusText + "</li>";
		alert(mensaje);
	}
};

var callback_toogleActivoPosicion =
{
  success:handleSuccess_toogleActivoPosicion,
  failure:handleFailure_toogleActivoPosicion
};


function toogleActivoPosicion (id_posicion)	{
	glob_id_posicion = id_posicion;
	document.getElementById("img_posicion_" + id_posicion).src	= '/images/ajax-loader.gif';
	var request = YAHOO.util.Connect.asyncRequest('GET', '/admin1r3d1/toogleactivoposicion/id/' + id_posicion, callback_toogleActivoPosicion);
}


/////////////////////////
var handleSuccess_enviarFormDestacado = function(o){
	if(o.responseText !== undefined){
				
		var messages = [];
		var mensajeError = '';
        // Use the JSON Utility to parse the data returned from the server
        try {
            messages = YAHOO.lang.JSON.parse(o.responseText);
            for(var campo in messages) { 
             		for (var razon in messages[campo])	{
             			if (messages[campo][razon] !== undefined && messages[campo][razon] != '')	
             				mensajeError += "<p>&raquo; " + messages[campo][razon] + "</p>\n";
             		} 
             }
        }
        catch (x) {
            alert("JSON Parse failed! " + x);
            return;
        }
        
        if (mensajeError != '')	{
           	document.getElementById("mensaje-error").innerHTML = mensajeError;
           	document.getElementById("mensaje-error").className = "mensaje-error";
        }
        else	{
           	document.getElementById('form-destacado').submit();
        }
	}
};

var handleFailure_enviarFormDestacado = function(o){
	if(o.responseText !== undefined){
		mensaje = "<li>Transaction id: " + o.tId + "</li>";
		mensaje += "<li>HTTP status: " + o.status + "</li>";
		mensaje += "<li>Status code message: " + o.statusText + "</li>";
		alert(mensaje);
	}
};

var callback_enviarFormDestacado =
{
  success:handleSuccess_enviarFormDestacado,
  failure:handleFailure_enviarFormDestacado
};

function enviarFormDestacado()	{

	
	// argument formId can be the id or name attribute value of the
	// HTML form, or an HTML form object.
	var formObject = document.getElementById('form-destacado');
	YAHOO.util.Connect.setForm(formObject);
	// This example facilitates a POST transaction.
	// An HTTP GET can be used as well.
	var request = YAHOO.util.Connect.asyncRequest('POST', '/validar/formulario', callback_enviarFormDestacado);
}

/////////////////////////
var handleSuccess_enviarFormMiembro = function(o){
	if(o.responseText !== undefined){
				
		var messages = [];
		var mensajeError = '';
        // Use the JSON Utility to parse the data returned from the server
        try {
            messages = YAHOO.lang.JSON.parse(o.responseText);
            for(var campo in messages) { 
             		for (var razon in messages[campo])	{
             			if (messages[campo][razon] !== undefined && messages[campo][razon] != '')	
             				mensajeError += "<p>&raquo; " + messages[campo][razon] + "</p>\n";
             		} 
             }
        }
        catch (x) {
            alert("JSON Parse failed! " + x);
            return;
        }
        
        if (mensajeError != '')	{
           	document.getElementById("mensaje-error").innerHTML = mensajeError;
           	document.getElementById("mensaje-error").className = "mensaje-error";
        }
        else	{
           	document.getElementById('form-miembro').submit();
        }
	}
};

var handleFailure_enviarFormMiembro = function(o){
	if(o.responseText !== undefined){
		mensaje = "<li>Transaction id: " + o.tId + "</li>";
		mensaje += "<li>HTTP status: " + o.status + "</li>";
		mensaje += "<li>Status code message: " + o.statusText + "</li>";
		alert(mensaje);
	}
};

var callback_enviarFormMiembro =
{
  success:handleSuccess_enviarFormMiembro,
  failure:handleFailure_enviarFormMiembro
};

function enviarFormMiembro()	{

	
	// argument formId can be the id or name attribute value of the
	// HTML form, or an HTML form object.
	var formObject = document.getElementById('form-miembro');
	YAHOO.util.Connect.setForm(formObject);
	// This example facilitates a POST transaction.
	// An HTTP GET can be used as well.
	var request = YAHOO.util.Connect.asyncRequest('POST', '/validar/formulario', callback_enviarFormMiembro);
}







// {{{ urlencode
function urlencode( str ) {
    // URL-encodes string
    // 
    // +    discuss at: http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_urlencode/
    // +       version: 809.1713
    // +   original by: Philip Peterson
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: AJ
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // %          note: info on what encoding functions to use from: http://xkr.us/articles/javascript/encode-compare/
    // *     example 1: urlencode('Kevin van Zonneveld!');
    // *     returns 1: 'Kevin+van+Zonneveld%21'
    // *     example 2: urlencode('http://kevin.vanzonneveld.net/');
    // *     returns 2: 'http%3A%2F%2Fkevin.vanzonneveld.net%2F'
    // *     example 3: urlencode('http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a');
    // *     returns 3: 'http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a'
                                     
    var histogram = {}, histogram_r = {}, code = 0, tmp_arr = [];
    var ret = str.toString();
    
    var replacer = function(search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };
    
    // The histogram is identical to the one in urldecode.
    histogram['!']   = '%21';
    histogram['%20'] = '+';
    
    // Begin with encodeURIComponent, which most resembles PHP's encoding functions
    ret = encodeURIComponent(ret);
    
    for (search in histogram) {
        replace = histogram[search];
        ret = replacer(search, replace, ret) // Custom replace. No regexing
    }
    
    // Uppercase for full PHP compatibility
    return ret.replace(/(\%([a-z0-9]{2}))/g, function(full, m1, m2) {
        return "%"+m2.toUpperCase();
    });
    
    return ret;
}// }}}

