//Limpa Todos os campos de um formulário
function clearForm(objForm) {
	for(i=0;i<=(objForm.length - 1);i++){
		vType = (objForm.item(i).name).substring(0,3)
		switch(vType){
			case "txt":
				(objForm.item(i)).value = ""
			case "chk":
				(objForm.item(i)).checked = false
			case "lst":
				(objForm.item(i)).selectedIndex = 0
		}
	}
}

//Aplica a mascara desejada a um campo texto
function maskFormat(mask,obj){
	if(obj.value != ""){
		sObj = obj.value.toString()
		nString = ""
		for(i=0;i<(sObj.length);i++){
			if(!isNaN(sObj.charAt(i)) && (sObj.charAt(i) != " ")) {
				nString = nString + sObj.charAt(i)
			}
		}
		j = 0
		k = 0
		mString = ""
		while(j < nString.length && k < mask.length){
			if(mask.charAt(k).toUpperCase() == "N"){
				mString = mString + nString.charAt(j)
				j = j+1
			} else {
				mString = mString + mask.charAt(k)
			}
			k = k+1
		}
		obj.value = mString
	}
}

//Mostra a dica do campo em um objeto SPAN de nome info
function msg_onfocus(msg) {
	info.innerHTML = msg
}

//Mostra o tamanho da caixa e texto ou textarea em um objeto SPAN passado em objCounter
function counter(obj, objCounter,maxLength){
	if((obj.value).length > maxLength){
		obj.value = (obj.value).substring(0,maxLength)
	}
	objCounter.innerText = "(" + (obj.value).length + "/" + maxLength + ")"
}

function validateFloat(Obj) {
	if (isNaN(Obj.value)) {
		val = Obj.value.toString()
		newval = ''
		for (i=0;i<=val.length;i++) {
			if (!isNaN(val.substring(i,i+1)) || val.substring(i,i+1) == '.' || val.substring(i,i+1) == ',') {
				if (val.substring(i,i+1) == ',') {
					newval = newval + '.'
				} else {
					newval = newval + val.substring(i,i+1)
				}
			}
		}
		Obj.value = newval
		Obj.focus()
	}
}
