/*
	functions:
		function activaOp()
		function desactivaOp()
		function mostraTaula()
		function setVisited()

		function lastMod()
		function y2Kyear()

		function zeropad()
		function zeroesPad(p1,p2)

		function showDigits()
        function getTodayDate(fieldName) 
		function setPageText(text)

*/
	function activaOp()
	{
		var nom  = arguments[0] + "On.gif";
		var nomBr = arguments[0] + "BrOn.gif";
		var nomBrOff = arguments[0] + "BrOff.gif";

		var imatge = document.getElementById(arguments[0]);
		var lon = imatge.src.length;
		var srcNom = imatge.src.substring(lon-nomBrOff.length,lon)
		if (srcNom == nomBrOff)
		{
			imatge.src = nomBr;
		}
		else
		{
			imatge.src = nom;
		}
	}

	function desactivaOp()
	{
		var nom = arguments[0] + "Off.gif";
		var nomBr = arguments[0] + "BrOff.gif";
		var nomBrOn = arguments[0] + "BrOn.gif";

		var imatge = document.getElementById(arguments[0]);
		var lon = imatge.src.length;
		var srcNom = imatge.src.substring(lon-nomBrOn.length,lon)
		if (srcNom == nomBrOn)
		{
			imatge.src = nomBr;
		}
		else
		{
			imatge.src = nom;
		}
	}

	function mostraTaula()
	{
		var taula = getElementById(arguments[0]);
		if (taula.style.display == "none")
		{
			taula.style.display = "inline";
		}
		else
		{
			taula.style.display = "none";
		}
	}

	function setVisited()
	{
		var nom = arguments[0] + "BrOn.gif";
		var imatge = document.getElementById(arguments[0]);
		imatge.src = nom;
	}

	function lastMod()
	{
		var monthNames = new Array( 'enero','febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre' );

		var lastDate = new Date( document.lastModified );

		year = y2kYear( lastDate );
		month = lastDate.getUTCMonth();
		day = lastDate.getUTCDate();
		hour = lastDate.getUTCHours();
		minute = lastDate.getUTCMinutes();
		second = lastDate.getUTCSeconds();

		printDate = zeroPad(day) + " " + monthNames[ month ] + " " + year + "&nbsp;" + zeroPad(hour) + ":" + zeroPad(minute) + ":" + zeroPad(second) + " UTC";
		return printDate;
	}

	function y2kYear( theDate )
	{
		wrongYear = theDate.getUTCFullYear();
		rightYear = wrongYear % 100;
		rightYear += (rightYear < 38) ? 2000 : 1900;
		return rightYear;
	}

	function zeroPad( theNumber )
	{
		if( theNumber < 10 )
		{
			theNumber = "0" + theNumber;
		}
		return theNumber;
	}


	function showDigits() 
	{
		if (arguments[0] ==null) return;

		cadena ="<table border=0 cellpadding=0 cellspacing=0><tr>";
			   
		var digit = arguments[0]+"";
		for (i=0;i < digit.length; i++)
		{
			cadena +="<td><img src='../images/digit"+digit.substring(i,i+1)+".gif' border=0></img></td>";
		}

		cadena +="</tr></table>";
		return cadena;
	}

	function zeroesPad( theNumber,padSize )
	{
		while ( theNumber.length < padSize )
		{
			theNumber = "0" + theNumber;
		}
		return theNumber;
	}


	function getTodayDate(fieldName) 
	{
		var Avui = new Date();
		var Any = Avui.getYear();

		var Mes 	= Avui.getMonth()+1;
		if (Mes < 10) Mes = "0"+Mes
		var Dia 	= Avui.getDate();

		if (fieldName !=null)
		{
			var fechaIn = document.getElementById(fieldName);
			fechaIn.value = Any + "-" + Mes + "-" + Dia;
		}
		else
		{
			return Any + "-" + Mes + "-" + Dia;
		}
	}


	function setPageText(text)
	{
		//var bd = parent.frames["leftFrame"].document.getElementById("bodyBackgr");
		//bd.background = "images/menuText_"+text+".jpg";
	}