//Función que verifica que el número de caracteres de un campo esté entre min y max
function checkLength(o,n,min,max) {
	if ( o.val().length > max || o.val().length < min ) {
		o.addClass('flagerror');
		return false;
	} else {
		return true;
	}
}

//Función que verifica que el valor de un campo cumpla las condiciones de redexp
function checkRegexp(o,regexp,n) {
	if ( !( regexp.test( o.val() ) ) ) {
		o.addClass('flagerror');
		return false;
	} else {
		return true;
	}
}

//Funciones para hacer swap de imágene
function SimpleSwap(el,which){
	el.src=el.getAttribute(which || "origsrc");
}

function SimpleSwapSetup(){
	var x = document.getElementsByTagName("img");
	for (var i=0;i<x.length;i++){
		var oversrc = x[i].getAttribute("oversrc");
		if (!oversrc) continue;
	    // preload image
	    // comment the next two lines to disable image pre-loading
	    x[i].oversrc_img = new Image();
	    x[i].oversrc_img.src=oversrc;
	    // set event handlers
	    x[i].onmouseover = new Function("SimpleSwap(this,'oversrc');");
	    x[i].onmouseout = new Function("SimpleSwap(this);");
	    // save original src
	    x[i].setAttribute("origsrc",x[i].src);
	}
}

function navCalendario(anio, mes, accion, path){

	var error = false;
	var my_ajax = $.ajax({
		type: "POST",
		async: false,
		data: "anio="+anio+"&mes="+mes+"&accion="+accion,
		url: path + "/calendario_accion",
		timeout: 45000,
		error: function(){
			error=true;
		}
	}).responseText;
	if(!error){
		$("#calendario").html(my_ajax);
	}
}


function showText(id)
{
$("#texto"+id).slideToggle("fast");
$("#vermas"+id).hide();
$("#vermenos"+id).show();
}
function hideText(id)
{
$("#texto"+id).slideToggle("fast");
$("#vermas"+id).show();
$("#vermenos"+id).hide();
}





