//////////////////////////////////////////////////////////////////////////////////////////////////
// Este arquivo contem funcoes uteis para uso da Sitecom                                        //
// Desenvolvido por: Aroldo Luis Leonardo                                                       //
//                                                                                              //
// Data de desenvolvimento: 08/02/2006                                                          //
// Data da ultima alteracao: 19/06/2006                                                         //
//////////////////////////////////////////////////////////////////////////////////////////////////



// Esta função so permite digitação de Numeros
function Numero(Valor1, Valor2) {
	if (Valor1 < 48 && Valor1 != 8 || Valor1 > 57) {
	return false;}
	if (Valor2 < 48 && Valor2 != 8 || Valor2 > 57) {
	event.keyCode = 0}
}


// Esta função verifica se o cep digitado se encontra é válido para o cep selecionado
function chkCEP(UF, Cep, Prefixo) {

}

// Função usada para setar o idioma na interface administrativa
function setIdioma(x, prm) {
	prm = (prm == "") ? "?idm=" : prm+"&idm=";
	location.href=prm + x.options[x.selectedIndex].value;
}

// Função usada para setar o idioma no site
function setIdiomaSite(chave, prm) {
	prm = (prm == "") ? "?idm=" : prm+"&idm=";
	location.href = prm + chave;
}

// Função usada para abrir popup
function PopupSk(pagina, largura, altura) {
    var remote = null;
    remote = window.open(pagina,'popup','toolbar=no, location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,menubar=no,width='+largura+',height='+altura);
}

// Função para mudar um label conforme idioma setado, passar por parâmetro 
// a chave do idioma atual e uma coleção do tipo { {chave, valor}, {chave, valor}, ...}
// onde chave = a chave da lingua, o padrao é "Pt-Br" e valor é o texto a retornar
// caso seja essa a lingua atual.
// Exemplo: prtTextoIdioma({IDIOMAKEY}, 'Pt-Br', 'Olá Mundo!', 'Eng', 'Hello World!');
function prtTextoIdioma() {
  var args=prtTextoIdioma.arguments;
  if (args[0] == "") args[0] = "Pt-Br";
  for (i=1; i<(args.length-1); i+=2) {

  
  	if (args[i] == args[0]) document.write(args[i+1]);
  }
}

function hideshow(which) {
	if (!document.getElementById|document.all) {
		return
	} else {
		if (document.getElementById)
			oWhich = eval ("document.getElementById('" + which + "')")
		else
			oWhich = eval ("document.all." + which)
	}

	window.focus()
	if (oWhich.style.display=="none")
		oWhich.style.display=""
	else
		oWhich.style.display="none"
}


function setshow(which) {
	if (!document.getElementById|document.all) {
		return
	} else {
		if (document.getElementById)
			oWhich = eval ("document.getElementById('" + which + "')");
		else
			oWhich = eval ("document.all." + which);
	}

	window.focus();
	oWhich.style.display="";
}


function sethide(which) {
	if (!document.getElementById|document.all) {
		return
	} else {
		if (document.getElementById)
			oWhich = eval ("document.getElementById('" + which + "')");
		else
			oWhich = eval ("document.all." + which);
	}

	window.focus();
	oWhich.style.display="none";
}



// Oculta um quadro de itens caso não tenha nenhum item a ser exibido
// dQuadro -> O quadro que deseja ocultar caso não tenha nenhum item
// allKeys -> Todos as Chaves concatenadas pertinente ao quadro que deseja testar
function exibeQuadro(dQuadro, allKeys) {
	if(allKeys == '') sethide(dQuadro);
}



function isEmpty(s)
      { return ((s == null) || (s.length == 0)) }

function isWhitespace (s){
	var whitespace = " \t\n\r";
	var i;
	if (isEmpty(s)) return true;
	for (i = 0; i < s.length; i++){
		var c = s.charAt(i);
		if (whitespace.indexOf(c) == -1) return false;
	}
	return true;
}	  

function isEmail (s){
	if (isEmpty(s)) 
		if (isEmail.arguments.length == 1) 
			return false;
		else 
			return (isEmail.arguments[1] == true);

	if (isWhitespace(s)) 
		return false;
		
	var i = 1;
	var sLength = s.length;

	while ((i < sLength) && (s.charAt(i) != "@")){
		i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) 
		return false;
    else i += 2;

    while ((i < sLength) && (s.charAt(i) != ".")){
		i++
    }

    if ((i >= sLength - 1) || (s.charAt(i) != ".")) 
		return false;
    else 
		return true;
}


function restaura_img_src(name) {
  var img = eval((navigator.appName.indexOf('Netscape', 0) != -1) ? 'document'+'.'+name : 'document.all.'+name);
  if (name == '')
    return;
  if (img && img.altsrc) {
    img.src = img.altsrc;
    img.altsrc = null;
  }
}

function muda_img_src(name, rpath) {
  var img = eval((navigator.appName.indexOf('Netscape', 0) != -1) ? 'document'+'.'+name : 'document.all.'+name);
  if (name == '')
    return;
  if (img) {
    img.altsrc = img.src;
    img.src    = rpath;
  }
}