//Javascript Document

/*_______________________________________
  |                                      |
  |    IT'S NOT COPY, WAS MADE BY RISSO  |
  | 	   thiago.risso@gmail.com        |
  |______________________________________|*/


Array.prototype.have = function(value)
{
	for(a in this)
	{
		if(this[a] === value)	
			return true;
	}
	return false;
}

function browser()
{
	B = navigator.userAgent;
	if((B.indexOf("Mac")> -1)&&(B.indexOf("MSIE") > -1))
		{
		bw = "MacIE";
		}
	else if(B.indexOf("Netscape") > -1)
		{
		bw = "Netscape";
		}
	
	else if(B.indexOf("Opera") > -1)
		{
		bw = "Opera";
		}
	else if((B.indexOf("MSIE") > -1) && (B.indexOf("Opera") == -1))
		{
		bw = "IE";
		}
	else if((B.indexOf("Mozilla") > -1)&& (B.indexOf("MSIE") == -1)&&(B.indexOf("Opera") == -1))
		{
		bw= "Mozilla";
		}
	return bw;
}


function addEvent(obj, evType, fn)
{
    if(obj.addEventListener){
        obj.addEventListener(evType, fn, false);
        return true;
    } 
	else if (obj.attachEvent)
	{
		var r = obj.attachEvent('on'+evType, fn);
		return r;
    } 
	else 
	{
        return false;
    }
}

function removeEvent( obj, type, fn )
{
	if ( obj.detachEvent ) 
	{
		obj.detachEvent( 'on'+type, obj[type+fn] );
		obj[type+fn] = null;
	} 
	else 
	{
		obj.removeEventListener( type, fn, false );
	}
} 


function apareceCarregando()
{
	doc = window.document;
		jan = window;

		if(!doc.getElementById('dv_carregando_xml'))
		{
			dv = doc.createElement("DIV");
			
			dv.style.width = '80px';
			dv.style.height = '18px';
			dv.style.paddingTop = '2px';
			dv.style.textAlign = 'center';
			
			dv.style.position = 'absolute';
			dv.style.backgroundColor = '#666666';
			dv.style.color = '#FFFFFF';
			dv.style.fontFamily = 'Arial';
			dv.style.fontSize = '11px';
			dv.style.fontWeight = 'bold';		
			dv.id = 'dv_carregando_xml';
			dv.innerHTML = 'Carregando...';
				
			
			if(doc.body)
				doc.body.appendChild(dv);
			else
				doc.all.appendChild(dv);

		}
	
	div = doc.getElementById('dv_carregando_xml');
	
	div.style.top = '0px';
	lf = jan.innerWidth ? jan.innerWidth : (jan.document.body.clientWidth ? jan.document.body.clientWidth : 800 );
	lf-=82;
	div.style.left = lf+'px';
	div.style.visibility='visible';
}

function someCarregando()
{
	doc = window.document;

	div = doc.getElementById('dv_carregando_xml');
	div.style.visibility='hidden';
}


// -------------------  FUNÇÕES DE VALIDAÇÃO ---------------------------------------// 


function verifFormCurrency(valor,obj)
{
	if(!valor)
	{
		if(obj)
			valor=obj.value;
	}
	
	if(valor == "")
		valor = '0';
	
	if(valor.indexOf(".")>-1)
		return true;
	else if(valor.indexOf(",")>-1)
		while(valor.indexOf(",")>-1)
			valor=valor.replace(",",".");
	else if(valor != "")
		valor= valor + '.00'
	
	if(obj)
		obj.value=valor;
			
	return false;
	
}


function trim(valor)
{	
	while(valor.indexOf(" ")==0)
	{
		valor=valor.substr(1,valor.length);
		if(valor.length==0)break;
	}
	while(valor.lastIndexOf(" ")==(valor.length-1))
	{
		valor=valor.substr(0,valor.length-1);
		if(valor.length==0)break;
	}
	return valor;
}

function valida_formato_data(data,previsao,previsao_atual)
{
		var erro;
		erro=true;
		data1=new Date();
		diav=data.substr(0,2);
		mesv=data.substr(3,2);
		anov=data.substr(6,4);
		barra1=data.substr(2,1);
		barra2=data.substr(5,1);
		if((barra1!="/")||(barra2!="/"))
		{
			erro=false;
		}
		
		ano=new Number;
		mes=new Number;
		dia=new Number;
		ano=Math.abs(anov);
				
		anoR=data1.getYear();
		mesR=data1.getMonth()+1;
		diaR=data1.getDate();
		
		if(browser()!="IE")
			{
			anoR+=1900;
			}
			
		
			
		mes=Math.abs(mesv);
		dia=Math.abs(diav);

		dataH = new Date(anoR,mesR,diaR);
		
		tmStH = dataH.getTime();
		dateA = new Date(ano,mes,dia);
		tmStD = dateA.getTime();
		
		if(previsao_atual) //Data futura ou data autal
			dataMenor=(tmStD < tmStH)?true:false;
		else //SOMENTE DATA FUTURA
			dataMenor=(tmStD <= tmStH)?true:false;
		
		if(previsao==true)
			{
				if((ano.toString()=='NaN')||(dataMenor))
					erro=false;
			}
		else if((ano.toString()=='NaN'))
			{   
			   erro=false;
			}
		if(ano < 1900)
			{
				 erro=false;
			}
			
		if((mes.toString()=='NaN')||(mes<1)||(mes > 12))
			{
				erro=false;
			}
			
		if((dia.toString()=="NaN")||(dia<1)||(dia > 31))
			{
				erro=false;
			}
			
		if (mes==1 || mes==3 || mes==5 || mes==7 || mes==8 || mes==10 || mes==12)
            {
                if (dia>31)
            	  {
				  		erro=false;
                  }
            }
         if (mes==2)
            {
            if ((ano%4)==0)
               {
                  if (dia>29)
                     {
                      erro=false;
                      }
               }
            if ((ano%4)!=0)
               {
                  if (dia>28)
                      {
							erro=false;
                      }
                }                  
            }
        if (mes==4 || mes==6 || mes==9 || mes==11)
            {
                if (dia>30)
                {
					erro=false;
                }
            }

		return erro;
}

function verifica_numero(num)
{
	a = new Number;
	a=Math.abs(num);
	if(a.toString()=='NaN')
		return false;
	else
		return true;
}

function valida_email(email)
{
	var erEmail = /^[\w-]+(\.[\w-]+)*(\.@|@)(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
	if( ! (erEmail.test(email)))
		return false;
	else
		return true;
}

function valida_site(site)
{
   var erSite = /^([a-z0-9]{2,20}\.)(([a-z0-9]{2,20}\.)+)([a-z]{3}|[a-z]{1,3}\.[a-z]{2})$/;
   if (!(erSite.test(site)))
      return false;
   else
      return true;
}

function validaMoeda(valor)
{
	var erMoeda = /^[0-9]{1,5}\.[0-9]{2}$/;
	if(erMoeda.test(valor))
		return true;
	else
		return false;
}

function validaMes(mes)
	{
		if(isNaN(mes))
			return false;
		
		if(mes == "")
			return false;
	
		var er_mes = /^0.[1-9]{2}|[1-9]{1}|[10-12]{2}$/
		if(!er_mes.test(mes))
			return false;
		
		return true;
	}


function validaAno(ano)
{
	if(isNaN(ano))
		return false;
	
	if(ano == "")
		return false;

	if((ano < 1900 )||(ano > 2100))
		return false;
	
	return true;
}

function validaHora(hora,tipo)
{
	if(tipo=='H:M')
		var expR = /^(([0-1]{1}[0-9]{1})||([2]{1}[0-3]{1})):([0-5]{1}[0-9]{1})$/
	else if(tipo == 'H:M:S')
		var expR = /^(([0-1]{1}[0-9]{1})||([2]{1}[0-3]{1})):([0-5]{1}[0-9]{1}):([0-5]{1}[0-9]{1})$/
	else
	{
		alert('Tipo de hora invalida :'+tipo+'!!\n Coloque H:M  ou H:M:S ');
		return false;
	}
		
	if(expR.test(hora))
		return true;
	else
		return false;
}

function validaFormatoArquivo(file,extension)
{
	if(!extension)
		extension = "[\\w]{3,4}";
		
	var type = "^(([\\w]{1}\\:\\\\)|(\\\\\\\\)|(\\/)).*.\\."+extension+"$";
	// ORIGINAL = /^(([\w]{1}\:\\)|(\\\\)|(\/)).*.\.[\w]{3,4}$/;
												
	er = new RegExp(type);

	return er.test(file);
}

// ------------------- FIM DAS  FUNÇÕES DE VALIDAÇÃO ---------------------------------------// 

// -------------------------- FUNÇÕES DE POSICIONAMENTO --------------------------------//
function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function getHeight(obj)
{
	h = (obj.clientHeight || obj.offsetHeight);
	return h;
}

function getWidth(obj)
{
	w = (obj.clientWidth || obj.offsetWidth);
	return w;
}

/******  getWindowHeight and getWindowWidth is copy from http://quirksmode.org *******/
function getWindowHeight()
{
	if (self.innerHeight) 
	{
		// all except Explorer
		return  self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{
		// Explorer 6 Strict Mode
		return document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		// other Explorers
		return document.body.clientHeight;
	}
}

function getWindowWidth()
{
	if (self.innerWidth) 
	{
		// all except Explorer
		return  self.innerWidth;
	}
	else if (document.documentElement && document.documentElement.clientWidth)
	{
		// Explorer 6 Strict Mode
		return document.documentElement.clientWidth;
	}
	else if (document.body)
	{
		// Explorer 6 Strict Mode
		return document.body.clientWidth;
	}
}
/* ********************************************************************************** */

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}


function Centralizar(obj)
{
	obj = document.getElementById(obj);
	
	wW = getWindowWidth();
	wH = getWindowHeight();
	
	clH = getHeight(obj);
	clW = getWidth(obj);
	
	obj.style.top = (wH/2) - (clH/2) + 'px';
	obj.style.left = (wW/2) - (clW/2) + 'px';
}

function closePopUp()
{
	document.getElementById('dv_popup').style.display='none'
}


// ----------------------- FIM  FUNÇÕES DE POSICIONAMENTO --------------------------------//

// ---------------------- FUNÇÕES DE FORM -----------------------------------------------//

function limita(obj,qtdChar)
{
	if(obj.value.length > qtdChar)
	{
		alert("Este campo pode conter apenas " + qtdChar +" caracteres !");
		val = obj.value;
		obj.value = val.substr(0,qtdChar);
		obj.focus();
		return false;
	}
}

function getValues(form,pagina,retorna,tipo_ret,Tid,method,nQuebra)	
{
	nQuebra = nQuebra ? nQuebra :false;
	if(!method)
		method='GET';
	var campos = new Array;
	var values = new Array;
	var ids = new Array;
	var y =0;
	
	nElement = form.elements.length;
	for(x=0;x<nElement; x++)
		{
			if((form.elements[x].tagName.toUpperCase()!='FIELDSET')&&(form.elements[x].tagName.toUpperCase()!='LEGEND'))
				if((form.elements[x].type.indexOf('text') > -1)||(form.elements[x].type.indexOf('file') > -1)||(form.elements[x].type.indexOf('select') > -1)||(form.elements[x].type.indexOf('hidden') > -1)||(form.elements[x].type.indexOf('password') > -1)||(form.elements[x].tagName.toUpperCase()=='TEXTAREA'))
					{
						
						if(form.elements[x].type.indexOf('select-multiple') > -1)
							{
								for(z=0;z<form.elements[x].options.length;z++)
								{
									if(form.elements[x].options[z].selected)
									{
										campos[campos.length]=form.elements[x].name;	
										values[values.length]=form.elements[x].options[z].value;
										ids[ids.length]=form.elements[x].id;
									}
								}
							}
						else
							{
								if(form.elements[x].tagName.toUpperCase()=='TEXTAREA')
								{
									var val = form.elements[x].value;
									
									var z=0;
									if(!nQuebra)
									{
										while(val.indexOf("\n") > -1 || z > val.length)
										{
											val = val.replace("\n","%0A");
											z++;
										}
									}
									
									var z=0;
									
									while(val.indexOf("\r") > -1  || z > val.length)
									{
										val = val.replace("\r","");
										z++;
									}
									
																						
									values[values.length]=val;
									}
								else
									values[values.length]=form.elements[x].value;

								campos[campos.length]=form.elements[x].name;
								ids[ids.length]=form.elements[x].id;
							}
					}
				else if(((form.elements[x].type.indexOf('checkbox') > -1) && (form.elements[x].checked))||((form.elements[x].type.indexOf('radio') > -1) && (form.elements[x].checked)))
					{
							campos[campos.length]=form.elements[x].name;	
							values[values.length]=form.elements[x].value;
							ids[ids.length]=form.elements[x].id;
					}

		}
		
		if(!retorna)
			loadXML(pagina,true,'',method,campos,values);
		else
			if(tipo_ret == 'campos')
				return campos;
			else if(tipo_ret == 'values')
				return values;
		return true;
}

function montaGet(arrVars,arrValues)
{
	var arg = "";
	if((arrVars))
		{
			if((arrVars.constructor==Array)&&(arrValues))
				{
					for(x=0;x<arrVars.length;x++)
						{
							if(arrValues[x])
								if(x==0)
									arg+=arrVars[x]+'='+arrValues[x];
								else
									arg+="&"+arrVars[x]+'='+arrValues[x];
							else
								if(x==0)
									arg+=arrVars[x]+'=';
								else
									arg+="&"+arrVars[x]+'=';
						}
				}
			return "?"+arg;
		}
	else
		{
			return false;
		}
	}
	
	
function limpaCampos(campos,excecao,form,janela)
{
	if(!janela)
		janela = self;
	//alert(campos.constructor);
	if(campos)
	{
		var cnstr = excecao.constructor;
	
		for(w=0;w=campos.length;w++)
		{
			ultimo = campos.pop();
			cp = janela.document.getElementById(ultimo);
			//alert(cp);

			
			if(!excecao)
				var verif = false;
			else if(excecao.have)
				var verif = excecao.have(cp.name);
			else if(cp.name == excecao)
				var verif = true;
			/*if(cp.name == 'categoria' || cp.name =='vestibular')
				alert(verif);
			*/
			if(!verif)
			{	
				if((cp.type)&&((cp.type.toUpperCase().indexOf('RADIO')>-1)||(cp.type.toUpperCase().indexOf('CHECKBOX')>-1)))
					cp.checked = false;
				else if((cp.type)&&((cp.type.toUpperCase().indexOf('SELECT')>-1)))
					cp.selectedIndex = 0;
				else if(cp.type)
					cp.value='';
			}
		}
	}
	else
	{
		frm = janela.document.getElementById(form);
		for(x=0;x<frm.elements.length; x++)
		{
			if((frm.elements[x].tagName.toUpperCase()!='FIELDSET')&&(frm.elements[x].tagName.toUpperCase()!='LEGEND'))
			{
				cp = frm.elements[x];
				if((cp.type)&&((cp.type.toUpperCase().indexOf('RADIO')>-1)||(cp.type.toUpperCase().indexOf('CHECKBOX')>-1)))
					cp.checked = false;
				else if((cp.type)&&((cp.type.toUpperCase().indexOf('SELECT')>-1)))
					cp.selectedIndex = 0;
				else if((cp.type)&&(cp.type.toLowerCase()!="button")&&(cp.type.toLowerCase()!="submit"))
					cp.value='';
			}
		}
	}
}

function limpaTudo(janela,excessao)
{
	if(!janela)
		janela=self;
		
	
	if(janela.objGrid)
	{
		for(ab=0;ab<janela.objGrid.length;ab++)
		{
			if(janela.objGrid[ab])
				janela.objGrid[ab].clearRows();
		}
	}
	
	ipts = janela.document.getElementsByTagName('input');
	for(x=0;x<ipts.length;x++)
	{
			cp = ipts[x];
			if(cp.name != excessao)
			{
				if((cp.type)&&((cp.type.toUpperCase().indexOf('RADIO')>-1)||(cp.type.toUpperCase().indexOf('CHECKBOX')>-1)))
					cp.checked = false;
				else if((cp.type)&&((cp.type.toUpperCase() !='BUTTON')&&(cp.type.toUpperCase() !='FILE')&&(cp.type.toUpperCase() !='SUBMIT')))
					cp.value='';
			}
		}
			
	    sel = document.getElementsByTagName('select');
		for(x=0;x<sel.length;x++)
		{
			cp = sel[x];
			if(cp.name != excessao)
			{
				cp.selectedIndex = 0;
			}
		}
	
		txt = document.getElementsByTagName('textarea');
		for(x=0;x<txt.length;x++)
		{
			cp = txt[x];
			if(cp.name != excessao)
			{
				cp.value = "";
			}
		}
}

function limpaForm(form,janela)
{
	if(!janela)
		janela = self;
	//alert(campos.constructor);
		frm = janela.document.getElementById(form);
		for(x=0;x<frm.elements.length; x++)
		{
			if((frm.elements[x].tagName.toUpperCase()!='FIELDSET')&&(frm.elements[x].tagName.toUpperCase()!='LEGEND'))
			{
				cp = frm.elements[x];
				if((cp.type)&&((cp.type.toUpperCase().indexOf('RADIO')>-1)||(cp.type.toUpperCase().indexOf('CHECKBOX')>-1)))
					cp.checked = false;
				else if((cp.type)&&((cp.type.toUpperCase().indexOf('SELECT')>-1)))
					cp.selectedIndex = 0;
				else if(cp.type == 'file')
				{
					cp.value='';
				}
				else if((cp.type)&&(cp.type.toLowerCase()!="button")&&(cp.type.toLowerCase()!="submit"))
					cp.value='';
			}
		}
}

function getForm(form)
{
	frm = document.getElementById(form);
	arrCampos = getValues(frm,'',true,'campos');
	arrValores = getValues(frm,'',true,'values');
	var get = montaGet(arrCampos,arrValores);
	return get;
}

function desselect(obj)
{
  obj.selectedIndex = -1;
}

function loadFromGrid(grid,seq,campos,campoId)
{
	id = grid.selectedIds[0];
	ln = grid.selectedSeqs[0]
	
	for(x=0;x<seq.length;x++)
		{
			var valor = grid.getValueColumn(ln,seq[x]);
			if(document.getElementById(campos[x]))
				document.getElementById(campos[x]).value = valor;
		}
		
	if(document.getElementById(campoId))
		document.getElementById(campos[x]).value = id;
}


function Submete(url,target,form)
{
	document.getElementById(form).action = url;
	document.getElementById(form).target = target;
	document.getElementById(form).submit();
}

function preencheData(obj)
{
	if(obj.value == "")
	{
		data = new Date();
		hora = data.getHours();
		hora = new String(hora);
		minu = data.getMinutes();
		minu = new String(minu);
				
		if(hora.length ==1)
			hora = '0'+hora;
			
		if(minu.length == 1)
			minu = '0'+minu;
				
		obj.value = hora+":"+minu;
	}
}

function alterValue(obj,valor,frame)
{
	if(!frame)
		frame = self;
		
	if(!frame.document.getElementById(obj))
		return false;
	else
		frame.document.getElementById(obj).value = valor;	
}
	
function Disable(obj,val,frame)
{
	if(!frame)
		frame = self;
	if(!frame.document.getElementById(obj))
		return false;
	else
		frame.document.getElementById(obj).disabled = val;		
}

function checkById(obj,chk,frame)
{
	if(!frame)	
		frame=self;
	if(frame.document.getElementById(obj))
		{
			if(!chk)
				chk = false;
			else
				chk = true;
			frame.document.getElementById(obj).checked = chk;
		}
}

function check(obj,valor,frame,form,F)
{
	if(F)
	{
		var CHECK = false;
		var UNCHECK = true;
	}
	else
	{
		var CHECK = true;
		var UNCHECK = false;
	}
		
	if(!frame)
		frame = self;

	if(!(eval("frame.document."+form+"."+obj)))
		return false;
	else
	{
		Els = eval("frame.document."+form+"."+obj);
		if(Els.length)
		{
			nEl = Els.length;
			for(x=0;x<nEl;x++)
				{
					objChk = eval("frame.document."+form+"."+obj+"["+x+"]");
					if(objChk.value == valor)
						objChk.checked = CHECK;
					else if(objChk.type.toLowerCase() == 'radio')
						objChk.checked = UNCHECK;
				}				
		}
		else
		{
			if(Els.value == valor)
				Els.checked = CHECK;
		}
	}
}
	
function Select(obj,value,frame)
{
	//VERIFICA SE FOI PASSADO O PARAMETRO FRAME
	if(!frame)
		 frame = self;
			
	//Verifica a existencia do OBJETO	
	if(!frame.document.getElementById(obj))
		return false;
	else
		{
			var sel=frame.document.getElementById(obj);	
			tipo = sel.type.toUpperCase();
			if(tipo.indexOf("SELECT")==-1)
				return false;
			else
				{
					var selid = sel.id;
					
					var opts = sel.options;
					var index = -1;
					var x=0;
					for(x=0;x<opts.length;x++)
					{
						if(opts[x].value == value)
						{
							index = x;
							break;
						}
					}
					
					if(index!=-1)
						sel.selectedIndex = index;
				}
		}
}
	
function LoadSelect(obj,arrValues,arrTexts,ValSelect,frame)
{
	if(!frame)
	  frame = self;
	
	var index;
	
	if(!frame.document.getElementById(obj))
		return false;
	else
		{
			var sel=frame.document.getElementById(obj);	
			tipo = sel.type.toUpperCase();
			if(tipo.indexOf("SELECT")==-1)
				return false;
			else
				{
					var opts = sel.options;
					for(x=(opts.length-1);x>=0;x--)
						opts[x]=null;
							
					for(x=0;x<arrValues.length;x++)
						{
							sel.options[x] = new Option(arrTexts[x],arrValues[x]);
							if (arrValues[x]==ValSelect)
							   {
								   //sel.options[x].selected = true
								  index = x;
							   }
							if(index!=-1)
							   sel.selectedIndex = index;
						}								
				}
		}
}

// ----------------------- FIM FUNÇÕES DE FORM --------------------------------------- //

// ----------------------- FUNÇÕES DE FRAME ------------------------------------------ //

__frameOcupada = false;

function desocupaFrame()
{
	__frameOcupada = false;
}

function frameOcupada()
{
	__frameOcupada = true;
}

function verifFrame()
{
	if(__frameOcupada)
	{
		alert("Já existe um operação em execução ! Aguarde um momento!");
		return false;
	}
	else
	{
		return true;
	}
}

// ----------------------- FIM FUNÇÕES DE FRAME  --------------------------------------- //

var imgs = new Array();
function preloadImages()
{
	for(x=0;x<arguments.length;x++)
	{
		imgs[x] = new Image();
		imgs[x].src = arguments[x];
	}
}
// ------------------------------------------------------------------------------------ //

function validaBusca()
{
	var campo = document.getElementById('busca');
	
	var palavras = new Array();
	palavras = campo.value.split(" ");
	
	var n_valido = 0;
	var num_palavras = palavras.length;
	for(x=0;x<num_palavras;x++)
	{
		if(palavras[x].length<=3)
			n_valido++;
	}
	if(n_valido>=num_palavras)
	{	
		alert('Inicie a busca com palavras que tenham mais de três caracteres!');
		return false;
	}else{
		return true;
	}
}