function isEmail (emailStr) {
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(emailStr))) { 
		return false;
	} else {
		return true;
	}
}

	function autoTab(input,len, e) {
		var isNN = (navigator.appName.indexOf("Netscape")!=-1);
		var keyCode = (isNN) ? e.which : e.keyCode; 
		var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
		if(input.value.length >= len && !containsElement(filter,keyCode)) {
			input.value = input.value.slice(0, len);
			input.form[(getIndex(input)+1) % input.form.length].focus();
		}
		function containsElement(arr, ele) {
			var found = false, index = 0;
			while(!found && index < arr.length)
				if(arr[index] == ele)
					found = true;
				else
					index++;
				return found;
		}
		function getIndex(input) {
			var index = -1, i = 0, found = false;
			while (i < input.form.length && index == -1)
				if (input.form[i] == input)
					index = i;
				else i++;
					return index;
		}
		return true;
	}

function hilite (obj, hexcolor) {
	obj.style.cursor = 'pointer';
	obj.style.backgroundColor = hexcolor;
}

function janela_prod (id_prod) {
    var desktop = window.open('/zoom_prod.php?id_prod=' + id_prod, '_new', 'top=50,left=0,width=500,height=500,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no');
}

function janela (url, target, wd, ht, toolbar, loca, status, menubar, scroll, resize) {
    var desktop = window.open(url, target, 'top=50,left=0,width=' + wd + ',height=' + ht + ',toolbar=' + toolbar + ',location=' + loca + ',status=' + status + ',menubar=' + menubar + ',scrollbars=' + scroll + ',resizable=' + resize);
}

function HiliteItem (myitem) {
	myitem.style.backgroundColor = '#FFFFCC';
}
function UnliteItem (myitem) {
	myitem.style.backgroundColor = '';
}

<!-- Original:  Mario Costa (mariocosta@openlink.com.br) -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

function currencyFormat(fld, milSep, decSep, e) {
	var sep = 0;
	var key = '';
	var i = j = 0;
	var len = len2 = 0;
	var strCheck = '0123456789';
	var aux = aux2 = '';
	var whichCode = (window.Event) ? e.which : e.keyCode;
	if (whichCode == 13) return true;  // Enter
	key = String.fromCharCode(whichCode);  // Get key value from key code
	if (strCheck.indexOf(key) == -1) return false;  // Not a valid key
	len = fld.value.length;
	for(i = 0; i < len; i++)
		if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
	aux = '';
	for(; i < len; i++)
		if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
	aux += key;
	len = aux.length;
	if (len == 0) fld.value = '';
	if (len == 1) fld.value = '0'+ decSep + '0' + aux;
	if (len == 2) fld.value = '0'+ decSep + aux;
	if (len > 2) {
		aux2 = '';
		for (j = 0, i = len - 3; i >= 0; i--) {
			if (j == 3) {
				aux2 += milSep;
				j = 0;
			}
			aux2 += aux.charAt(i);
			j++;
		}
		fld.value = '';
		len2 = aux2.length;
		for (i = len2 - 1; i >= 0; i--)
			fld.value += aux2.charAt(i);
			fld.value += decSep + aux.substr(len - 2, len);
		}
	return false;
}

function number_format(number, laenge, sep, th_sep ) {
	number = Math.round( number * Math.pow(10, laenge) ) / Math.pow(10, laenge);
	str_number = number+"";
	arr_int = str_number.split(".");
	if(!arr_int[0]) arr_int[0] = "0";
	if(!arr_int[1]) arr_int[1] = "";
	if(arr_int[1].length < laenge){
		nachkomma = arr_int[1];
		for(i=arr_int[1].length+1; i <= laenge; i++){  nachkomma += "0";  }
		arr_int[1] = nachkomma;
	}
	if(th_sep != "" && arr_int[0].length > 3){
		Begriff = arr_int[0];
		arr_int[0] = "";
		for(j = 3; j < Begriff.length ; j+=3){
			Extrakt = Begriff.slice(Begriff.length - j, Begriff.length - j + 3);
			arr_int[0] = th_sep + Extrakt +  arr_int[0] + "";
		}
		str_first = Begriff.substr(0, (Begriff.length % 3 == 0)?3:(Begriff.length % 3));
		arr_int[0] = str_first + arr_int[0];
	}
	return arr_int[0]+sep+arr_int[1];
}

function validateForm_busca() {
	if (document.busca.word.value.length < 3) {
		alert("A palavra precisa ter pelo menos 3 caracteres");
		document.busca.word.focus();
		return false;
	}
	return true;
}
function envia_form_busca() {
	if (validateForm_busca()) {
		if(navigator.appName == "Netscape") {
			document.busca.submit();
		} else {
			busca.submit();
		}
	}
}
