fundoConteudo = function(cor){

	$('tbCont').style.bgcolor = cor;

}

enviaEmail = function(){

	if(validaForm('contatoPf')){
		if(checkMail($('email').value)){			
			return true;
		} else {
			alert('Digite um email valido');
		}
	}

}

validaForm = function(form){

	//alert($(form)[1].name);
	for(i=0; i<$(form).length; i++){
		if(($(form)[i].name != 'acao')){
			if($(form)[i].title){
				if($(form)[i].value == ''){
					alert('Favor preencher o campo '+$(form)[i].title+'!');
					$($(form)[i].id).focus();
					return false;
				}
			}
		}
	}
	return true;

}

function scrlThumbs(d){
	st = 3;
	t = $('thumbs').getElementsByTagName('li');
	var len = t.length;
	tar = [];
	for(i=0; i < len; i++){
		var id = t[i].value;
		tar[i] = id;
	}
  tarl = tar.length;
  clearInterval($('thumbs').timer);
  var l;
  if(d == -1){
    l = 0;
  }else{
    l = t[tarl-1].offsetLeft - ($('thumbs').parentNode.offsetWidth - t[tarl-1].offsetWidth);
  }
  $('thumbs').timer = setInterval(function(){scrlMv(d,l)},st);
}

function scrlMv(d,l){
	ss = 2;
  $('thumbs').style.left = $('thumbs').style.left || '0px';
  var left = $('thumbs').style.left.replace('px','');
  if(d == 1){
    if(l - Math.abs(left) <= ss){
      cnclScrl($('thumbs').id);
      $('thumbs').style.left = '-' + l + 'px';
    }else{
      $('thumbs').style.left = left - ss + 'px';
    }
  }else{
    if(Math.abs(left) - l <= 38){
      cnclScrl($('thumbs').id);
      $('thumbs').style.left = '-38px';
    }else{
      $('thumbs').style.left = parseInt(left) + ss + 'px';
    }
  }
}

function cnclScrl(){clearTimeout($('thumbs').timer)}

function fechaIntro(divs){

	$(divs).style.display = 'none';

}

function chamaPostit(){

	$('postit').style.display = "block";
	postit();

}

function postit(){
	
	if( typeof( window.innerWidth ) == 'number' ) {
    	//Non-IE
		myWidth = window.innerWidth;
	    myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	    //IE 6+ in 'standards compliant mode'
	    myWidth = document.documentElement.clientWidth;
	    myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	    //IE 4 compatible
	    myWidth = document.body.clientWidth;
	    myHeight = document.body.clientHeight;
	}
	
	$('postit').style.left = (myWidth/2) + 230;
	//alert(myWidth );
}

function fechaPostit(){
	$('postit').style.display = "none";
}

function aparecer(divs){

	if(divs == "buscaRapida"){
		$(divs).appear({duration: 1});
	} else {
		$(divs).appear({duration: 1, from: 0, to: 0.7});
	}

}

consultaRepres = function(val){

	if(val == 'interno'){
	
		$('estado').style.display = 'block';
		$('representantes').style.display = 'none';
		
	}else{
		
		$('nulo').selected = 'selected';
		$('estado').style.display = 'none';
		$('representantes').style.display = 'block';
		optRepre('consRepres');
		
	}

}

setDownload = function(val){

	if(val == 'ambientacoes'){
		$('img').style.visibility = 'visible';
	} else {
		$('img').value = '';
		$('img').style.visibility = 'hidden';	
	}

}

checkMail = function(mail){
    var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
    if(typeof(mail) == "string"){
        if(er.test(mail)){ return true; }
    }else if(typeof(mail) == "object"){
        if(er.test(mail.value)){
                    return true;
                }
    }else{
        return false;
        }
}

somenteNumero = function(e){

	var tecla=(window.event)?event.keyCode:e.which;
    if((tecla > 47 && tecla < 58)) return true;
    else{
    if (tecla != 8) return false;
    else return true;
    }

}

charLength = function(e){
	
	/*var mais_um=eval(document.form.caracteres.value.length-1);
mais_um++;

if (document.form.caracteres.value.length>limite)
{
  document.form.caracteres.value='';
  document.form.caracteres.value=valor_limite;
  alert("Você deve digitar no máximo "+limite+" caracteres");
}
else
{
  document.form.exibe.value='';
  document.form.exibe.value=eval(mais_um);
  valor_limite=document.form.caracteres.value;
  document.form.exibe2.value='';
  document.form.exibe2.value=(limite-mais_um);
}

document.form.caracteres.focus();*/

	var tecla=(window.event)?event.keyCode:e.which;
	//alert(tecla);
	if($('msg').value.length >= 1000 && tecla != 8){
		return false;
	} else {
		if(tecla == 8 && $('limite').value != 1000){
			$('limite').value = parseInt($('limite').value) + 1;
		} else {
			$('limite').value = $('limite').value - 1;
		}
		return true;
	}

}

/*function scrlImg(d){
var left = $('thumbs').style.left.replace('px','');
//alert(left);
  if(d == 1){
    if(left <= -38){
  	  menos = parseInt(left) - 3;
      $('thumbs').style.left = menos + 'px';
      //alert($('thumbs').style.left);
    }
  }else{
    if(left >= -38){
      mais = parseInt(left) + 3;
      $('thumbs').style.left = mais + 'px';
      //alert($('thumbs').style.left);
    }
  }
}
*/