
function clickAcesso(id){
	document.getElementById(id).style.display = "block";
}

function MouseOut(id){
	document.getElementById(id).style.display = "none";
}

function mandaValor(campo,legenda,valor){
	var box = document.getElementById(campo);
	var frm = document.getElementById(campo+"_frm");

	box.innerHTML = legenda;
	frm.value = valor;
}

function submitValCamp(campo){
	if (document.getElementById(campo).value != '')
	{
	location.href = document.getElementById(campo).value;
	}
}

function proximaFoto(){
	if (fotoCorrente<strImg.length-1){
		fotoCorrente++;
		document.images.imgThumb.src = strImg[fotoCorrente];
		escreveLnk(fotoCorrente);
	}
}

function fotoAnterior(){
	if (fotoCorrente>0){
		fotoCorrente--;
		document.images.imgThumb.src = strImg[fotoCorrente];
		escreveLnk(fotoCorrente);
	}
}

function escreveLnk(id){
	for(i=0; i<strImg.length; i++)
	{
		document.getElementById("fotos_"+i).style.display = "none";
	}
	document.getElementById("fotos_"+id).style.display = "block";
}

/*Conta caracteres no campo*/
function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit) {
		field.value = field.value.substring(0, maxlimit);
	}
	else{ 
		document.getElementById(countfield).innerHTML = maxlimit - field.value.length;
	}
}

// Função para aceitar apenas números em campos texto
function soNumeros(e){
     var key;
     var keychar;

     if (window.event) {
        key = window.event.keyCode;
     } else if (e) {
        key = e.which;
     } else {
        return true;
     }

     keychar = String.fromCharCode(key);

     // teclas de controle
     if ((key==null) || (key==0) || (key==8) ||
          (key==9) || (key==13) || (key==27) ) {
        return true;
     } else if ((("0123456789").indexOf(keychar) > -1)) {
        return true;     
     } else {
        return false;
     }
}

	function limparCombo( objCombo , strSelecione )
	{
		while(objCombo.options.length > 0) 
				objCombo.options[0]=null;
		objCombo.options[objCombo.options.length] = new Option( strSelecione , '' )
	}

	function carregaComboAjax(link, destino, strSelecione) 
	{
		AjaxRequest.get(
			{	'url': link
				,'onError': function (req){	alert ( req.responseText );	}
				,'onSuccess':function(req) { 

					var itens = new String ( req.responseText );

					if (itens == 'vazio')
					{
						while(destino.options.length > 0) 
							destino.options[0]=null;
						destino.options[destino.options.length] = new Option( strSelecione , '' )
						return;
					}

					//divide em vírgula
					var vet = itens.split( ',' );

					//Limpa Combo
					while(destino.options.length > 0) 
						destino.options[0]=null;

					//Verifica se o array possui itens

					if (vet.length > 0)
					{

						destino.options[destino.options.length] = new Option( strSelecione , '' )

						for ( i = 0 ; i < vet.length ; i++ )
						{
							var strId = vet[i].split( '|' );
							if (strId[1] != '' && strId[0] != '')
							{
								destino.options[destino.options.length] = new Option( strId[1] , strId[0] )
							}
						}
					}				
				}
			}
		);
	}