$(document).ready(function(){
	genera_mapeos();
	genera_filtros();
});
function genera_mapeos() {
	$("form").each(function(){
		$(this).append("<input type=\"hidden\" name=\"mapeos\" value='"+obtener_mapeo($(this))+"' />");
	})
}
function obtener_mapeo(formulario){
	var mapeo = "";
	$(formulario + ":input").each(function(){
		//sólo se añaden en el mapeo todos aquellos campos que tienen nombre y título
		if($(this).attr("name")!="" && $(this).attr("title")!="")
			mapeo += "\""+$(this).attr("name")+"\":\""+$(this).attr("title")+"\",";
	})
	if(mapeo.length>0) mapeo = "{"+mapeo.substr(0,mapeo.length-1)+"}";
	return mapeo;	//elimino último ;
}
function genera_filtros() {
	$("form").each(function(){
		$(this).append("<input type=\"hidden\" name=\"filtros\" value='"+obtener_filtros($(this))+"' />");			
	})
}
function obtener_filtros(formulario){
	var filtros = "";
	$(formulario + ":input").each(function(){
		//sólo se añaden en el listado de filtros todos aquellos campos que tienen nombre y clase
		if($(this).attr("name")!="" && $(this).attr("class")!="")
			filtros += "\""+$(this).attr("name")+"\":\""+$(this).attr("class")+"\",";
	})
	if(filtros.length>0) filtros = "{"+filtros.substr(0,filtros.length-1)+"}";
	return filtros;
}
