//<![CDATA[
function addEvent(node, event, callback)
{
	(document.all) ? node.attachEvent("on" + event, callback) : node.addEventListener(event, callback, false);
}

function str_pad(string, length)
{
	while (string.length < length)
	{
		string = "0" + string;
	}
    return string;
}


function limpiar(campo, valor)
{
	if(campo.value == valor)
	{
		campo.value = "";
	}
}

function restaurar(campo, valor)
{
	if (campo.value == "")
	{
		campo.value = valor;
	}
}

/**
 * Marca con CSS la sección del menú que sea la activa en ese momento.
 * @param color string El color en que se marcará el enlace
 */
function marcarSeccionActiva(color)
{
	var url = (document.URL.substring(document.URL.lastIndexOf("/")));
	//quitamos la cadena "query"
	var pos = url.indexOf("?");
	if (pos != -1) { url = url.substring(0, pos); }
	
	var enlace = $("a[@href*='" + url + "']");
	enlace.css("background-color", color);
	enlace.css("border-color", "#000");
}

function mostrarCuantosCaracteresFaltan()
{
	var textarea = document.getElementById("txtMetadatos");
	var parrafo = document.getElementById("caracteres");
	
	var texto = textarea.value;
	var quedan = ((100 - texto.length) > 0) ? (100 - texto.length) : 0;
	parrafo.innerHTML = "Quedan " + quedan + "/100 caracteres";
	textarea.value = texto.substring(0, 100);
}

$("document").ready(
	function()
	{
		$("a + ul").css("display", "none");
		marcarSeccionActiva("#df4a22");
		 $("tbody tr:odd").css("background-color", "#eee");
	}
);

//]]>
