// JavaScript Document
function redireccion(pagina) {

	document.location.href=pagina;

}

function easy_add_row(section, callback) {
	callback = typeof callback == "function" ? callback : function(){};
	
	if ( typeof section === "string") {
		//row = $("table#" + section + " tr:last").clone();
		//target = 
		section = $("table#" + section)[0];
	}
	
	var row = $("tr:last", section).clone();
	 
	$("input[type!='hidden']", row).each(function () {
		$(this).val("");
	});
	
	$(section).append(row);
	
	callback.apply(row);
	
	return $(row);
}

function prepare_geo_fields(cp, loc, prov) {
	$("#" + loc).attr("readonly", "readonly");
	$("#" + prov).attr("readonly", "readonly");

	$("#" + cp).autocomplete("ajax/autocomplete.php?from=cp",
		
		{
			width: 400,
			max: 100,
			autoFill: true,
			formatItem: function (row) {
				return row[0] + ": " + row[1] + " - " + row[2];
			},
			formatResult : function (row) {
				return row[0];
			}
		
		}).result(function (event, data, formatted) {
			$("#" + loc).val(data[1]);
			$("#" + prov).val(data[2])
		});
}

$(document).ready(function () {
	/*if ($("#tools_box.alerts li").length == 0) {
		$("#tools_box.alerts").hide();
	}
	*/
	//$("input:text").setMask();
	
	$("#tools_box.alerts li a").click( function() {
		enlace = $(this).attr('href');
		$(enlace).addClass('error_msg');
	}); 

});


