function countSelectedChk(form,str,idxStart,chkCount)
{
	var countChecked = 0;
	for(i=idxStart;i<=chkCount;i++)
	{
		obj = eval("form." + str + i);
		if(obj!=null)
		{
			if(obj.checked)	countChecked++;
		}
	}
	return countChecked;
}  


function selectAllChk(form,str,idxStart,chkCount)
{
	for(i=idxStart;i<=chkCount;i++)
	{
		obj = eval("form." + str + i);
		if(obj!=null)
		{
			obj.click();
		}
	}
}  


function excluirReg(form,str,idxStart,chkCount,delPage)
{	
	var msg = "Todos os registros marcados serão excluídos do banco de dados" +
		  " e não poderão ser recuperados. \nVocê tem certeza que deseja excluí-los?";
	var countChecked = countSelectedChk(form,str,idxStart,chkCount);

	if(countChecked>0) 
	{
 		if(confirm(msg))
		{
			form.submit();
		}
	}
	else alert("Você precisa selecionar pelo menos um registro!");
}




//============================================
// checks if an email address is valid
// ARGS
//	e: String - an email address to be checked
//
// author: http://www.perlscriptsjavascripts.com
function check_email(e) {
	var ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

	for(i=0; i < e.length ;i++){		
		if(ok.indexOf(e.charAt(i))<0){ 			
			return (false);
		}	
	} 

	//if (document.images) {		
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two)) {			
			return (-1);		
		} 

	//}
}