/******************************* PRELOAD IMAGES ************************/
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

MM_preloadImages('img/bckTopo00.jpg');

/********************* DIV AMIGO *************************************/
function ShowEnviaAmigo(item1, item2){
	if((BrowserDetect.browser == "Explorer")&&(BrowserDetect.version == "6")){
		document.getElementById("ifrBusca").style.visibility = "hidden";
	}
	document.getElementById(item1).style.display = "block";
	document.getElementById(item2).style.display = "block";
}

function CloseEnviaAmigo(item1, item2){
	if((BrowserDetect.browser == "Explorer")&&(BrowserDetect.version == "6")){
		for (i=1; i<6; i++){
			document.getElementById("ifrBusca").style.visibility = "visible";
		}
	}
	document.getElementById(item1).style.display = "none";
	document.getElementById(item2).style.display = "none";
}


/************** CHECA SE CAMPO JÁ FOI PREENCHIDO, SE NÃO, RETORNA AO ESTADO INICIAL */
function ChecaCampo(idField,strMsg){
	if(idField.value == strMsg){
		idField.value = "";
	}else
		if(idField.value == ""){
			idField.value = strMsg;
	}
}

/*********************************************************/
/* VALIDA E-MAIL */

function checa_mail(mail){
	var str, arroba, ponto
	str=mail
	for (i=0; i < (mail.length-1); i++){
		if ((i > 0) && (str.charAt(i)=="@")) {
			arroba=true
		} else
			if ((str.charAt(i)==".") && (arroba)) {
				ponto=true
			}
	}
	if ((! arroba) || (! ponto))
		return false
	else
		return true
}

/**************************************************/
/* PEGA EXTENSÃO */

function pega_extensao(arq){
	var s, extensao, posicao;
	extensao = "";
	s = arq;
	for (i = s.length; i > 0; i--){
		if (s.charAt(i) == "."){
			posicao = i;
			i = 0;
		}
	}
	for (i = posicao; i < s.length; i++)
		extensao = extensao + s.charAt(i);
	return(extensao.toLowerCase());
}


/*********************************************************/
/* TAB AUTOMÁICO */

var isNN = (navigator.appName.indexOf("Netscape")!=-1);

function autoTab(input,len, e) {
  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;
}