//limpa texto do input text
function clearField(field) {
    field.value = "";
    field.focus();
}

function data(checkStr,checkOK) {
	for (i = 0;  i < checkStr.length;  i++) {
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
				break;
		if (j == checkOK.length) {
			return (false);
			break;
		}
	}
	return (true);
}	

//função para ver se encontrou o caracter ' ou |
function caracteres_esp(checkStr){
	var checkOK = "'|";
	var i ;
	for (i = 0;  i < checkStr.length;  i++){
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		if (ch == checkOK.charAt(j)){
			return (false);
		} 
	}
	return (true);
} 
//-----------------------------------------------------
//Validação da pesquisa
//-----------------------------------------------------
function ValidaPesquisa(theForm,id){
	if (theForm.pesquisa.value == ""){
		if (id == "1")	
			alert("Por favor preencha o campo \"Pesquisa\".");
		if (id == "2")
			alert("The field \"Search\" cannot be null.");						
		theForm.pesquisa.focus();
		return (false);
	}
	if (!caracteres_esp(theForm.pesquisa.value)){
		if (id == "1")
			alert("O campo \"Pesquisa\" não pode ter o(s) caracter(es) \'\ e \|\ .");   
		if (id == "2")
			alert("The field \"Search\" cannot contain the character(s) \'\ and \|\ .");						
		theForm.pesquisa.focus();
		return (false);
	}

return (true);
}

//abre janela da mailing list
function Mailing(url) {
	newwin=window.open (url, "imagem", "width=250,height=200,top=250,left=300,resizable=no,status=no,toolbar=no,scrollbars=no");
	if (!newwin.opener) newwin.opener=self;
		if(parseInt(navigator.appVersion) >= 4){
			newwin.window.focus();
		}
}

//------------------------------------------------------
//abre popup da imagem da noticia
//------------------------------------------------------
var win=null;

function Popup(imURL,Fam,Ref) { 
	closeWin();
	win = window.open( "popup.html?"+imURL, "Artigo","height=100,width=100,top=250,left=300,resizable=no,status=no,toolbar=no,scrollbars=no"); 
	win.focus();  
} 
//fecha popup do artigo
function closeWin(){
	  if(win && ! win.closed && win.open){
		  win.close();
		  win=null;
	  }
}

function MM_preloadImages() {
	if (document.images) {
		var imgFiles = MM_preloadImages.arguments;
		if (document.preloadArray==null){
			document.preloadArray = new Array();
		}
		var i = document.preloadArray.length;
		with (document) 
		for (var j=0; j<imgFiles.length; j++) {
			if(imgFiles[j].charAt(0)!="#"){
				preloadArray[i] = new Image;
				preloadArray[i++].src = imgFiles[j];
			}
		}
	}
}
