function reloadLan(form){
  form.action = "/FntChangeLan.do?loc=" + form.selectLocale.value;
  form.submit();
}

function loginUser(form){
    txNif = document.getElementById("loginNif");
    txUsr = document.getElementById("loginUser");
    txPwd = document.getElementById("loginPasswd");
    if (txNif == null || txUsr == null || txPwd == null){
    	alert("Error al validar el usuario.");
    }else if (txNif.value == "" || txUsr.value == "" || txPwd.value == ""){
    	alert("Falta de rellenar algún dato.");
    }else{
	form.accion.value = "lg";
	form.action = "/Login.do";
	form.submit();
    }    
}

function userLogin(evt,form){
    	Evt = (evt) ? evt : event;
	var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ?
	Evt.keyCode : ((evt.which) ? evt.which : 0));
	if (charCode == 13){
		loginUser(form);
	}
    }

function noLogin(form){
    form.action = "/NoLogin.do";
    form.submit();
}

function numeralsOnly(evt)
{
	Evt = (evt) ? evt : event;
	var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ?
	Evt.keyCode : ((evt.which) ? evt.which : 0));	
	if (charCode > 31 && (charCode < 48 || charCode > 57))
	{
		alert("Introduce un número sin decimales");
		return false;
	}
	return true;
}

function numeralsDecimalsOnly(evt)
{
	Evt = (evt) ? evt : event;
	var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ?
	Evt.keyCode : ((evt.which) ? evt.which : 0));	
	if (charCode > 31 && (charCode < 48 || charCode > 57) && charCode != 46)
	{
		alert("Introduce un número decimal (decimales separados por '.')");
		return false;
	}
	return true;
}

function checkForm(form){		
	for (i=0;i<form.elements.length;i++){
		el = form.elements[i];
		if (el.type == "text" || el.type == "select" || el.type == "select-multiple"){
	    	if (el.value == ""){
	   			alert(el.name);
	   			return false;
	   		}
		}
	}
	return true;	
}
function gotoTC(form){
	mercado = document.getElementById("cabTipoCliente");
	if (mercado != null){
		document.location = "/FntHomeTipCliente.do?cp=" + mercado.value;	
	}
	
}
function gotoCM(form){
	mercado = document.getElementById("cabMercado");
	if (mercado != null){
		document.location = "/FntChangeMrkt.do?cm=" + mercado.value;
	}
}
function openWindow(page,wdth,hgth){
	window.open(page,"POPUPWINDOW","toolbar=no,scrollbars=yes,location=0,statusbar=no,status=no,menubar=no,resizable=yes,width="+wdth+",height="+hgth+",left = 75,top = 75");
}
function checkRegexp(str,expr){
	return str.match(expr);
}