

/**
 *	Canvia el color de fons i els textos inicials dels inputs quan hi ha els events focus i blur
 *
 *	@param (object) obj Objecte select
 *	@param (string) sEvent Tipus d'event (focus o blur)
 *	@param (string) content Text inicial de l'input
 */
function focusInputLogin(sEvent, content)	//v2.0
{
	var obj = document.getElementById("usuari");
	if (!obj) return;
	if (content == undefined) content = "";
	if (sEvent == "focus"){
		obj.setAttribute("class", "text");
		obj.setAttribute("className", "text");
		if (obj.value == content) {
			obj.value = "";
		}
	}
	else if (sEvent == "blur"){
		obj.setAttribute("class", "text");
		obj.setAttribute("className", "text");
		if (obj.value == "") {
			obj.value = content;
		}
	}
}


function focusInputPasswordLogin(sEvent)	//v2.0
{
	var pwdTxt = document.getElementById("pwdgestioText");
	var pwd = document.getElementById("pwdgestio");
	if (!pwd || ! pwdTxt) return;

	if (sEvent == "focus"){
		pwd.style.display = "inline";
		pwdTxt.style.display = "none";
		pwd.focus();
	}
	else if (sEvent == "blur"){
		if(pwd.value != "") return;
		pwd.style.display = "none";
		pwdTxt.style.display = "inline";
	}
}

function onSubmitLogin(usrInitValue)
{
	var obj = document.getElementById("usuari");
	if (!obj) return;
	if(obj.value == usrInitValue) obj.value = "";
}



var showHideLoginTO = 0;
var hidingLogin = true;
var showingLogin = false;
function toggleLoginVisibility()
{
	var capa = document.getElementById("login_formulari");
	if(!capa) return;

	clearTimeout(showHideLoginTO);

	if(capa.style.display == "none" || hidingLogin) {
		hidingLogin = false;
		capa.style.height = 0;
		capa.style.display = "block";
		showLogin();
	}
	else {
		showingLogin = false;
		hideLogin();
	}

	// Fem blur a l'anchor on s'ha clickat pq no quedi marcat amb els puntets
	var a = document.getElementById("toggleLoginVisibAnchor");
	if(a) a.blur();

	// Canviem la fletxa de l'anchor
	var fltxa = document.getElementById("imgAnchorToggleLogin");
	if(fltxa) {
		if(showingLogin) 	fltxa.src = nh+"img/up.gif"
		else 				fltxa.src = nh+"img/down.gif"
	}
}

function showLogin()
{
	var capa = document.getElementById("login_formulari");
	var h = parseInt(capa.style.height, 10);
	if(isNaN(h)) h = 0;

	h += 15;

	if(h < 0) h = 0;

	if(h > 120){
		showingLogin = false;
	}
	else{
		capa.style.height = h+"px";
		showHideLoginTO = setTimeout("showLogin()", 30);
		showingLogin = true;
	}
}

function hideLogin()
{
	var capa = document.getElementById("login_formulari");
	var h = parseInt(capa.style.height, 10);
	if(isNaN(h)) h = 0;

	h -= 15;

	if(h < 0) h = 0;

	if(h==0){
		capa.style.display = "none";
		hidingLogin = false;
	}
	else{
		capa.style.height = h+"px";
		showHideLoginTO = setTimeout("hideLogin()", 30);
		hidingLogin = true;
	}
}



function overImgLogin(tthis)
{
	tthis.src= nh+'img/login-boto-submit-hl.png';
}

function outImgLogin(tthis)
{
	tthis.src= nh+'img/login-boto-submit.png';
}

