function pAppear(value) {	
	Effect.toggle(value, 'blind', { duration: 0.5 });
}


function getUrl(name) {
	var newwin = 0;
	//var root = 'http://localhost/agua/web/site_dev.php/';
	var root = 'http://aguamineralvilanova.tempsite.ws/web/site_dev.php/';
	//var root = 'http://192.168.20.1/projects/vilanova/agua_vilanova/web/index.php/';
	if(name == 'diferencial') {
		url= root+'home/diferencial';
	} else if(name == 'institucional') {
		url= root+'institucional';
	} else if(name == 'produtos') {
		url= root+'produto';
	} else if(name == 'pedidos') {
		url= root+'pedido';
		//newwin = 1;
	} else if(name == 'contato') {
		url= root+'contato';
	} else if(name == 'fonte') {
		url= root+'fonte';
	} else if(name == 'dica') {
		url= root+'novidade';
	} else if(name == 'home') {
		url= root+'home';	
	}
	if(newwin == 1) {
		window.open(url);
	} else {
		window.location = url;
	}
}

function showId(id) {
	$(id).style.display = 'block';
}
function hideId(id) {
	$(id).style.display = 'none';
}
function somente_numero(campo){
    var digits="0123456789"
    var campo_temp
    for (var i=0;i<campo.value.length;i++){
      campo_temp=campo.value.substring(i,i+1)    
      if (digits.indexOf(campo_temp)==-1){
            campo.value = campo.value.substring(0,i);
            break;
       }
    }
}
function formataTel(evt) {
var obj;
    if (navigator.appName.indexOf("Netscape") != -1) obj = evt.target;
    else obj = evt.srcElement;
    qtd = obj.value.length;
    if (qtd == 2) obj.value = "("+obj.value+")";
    if (qtd == 7) obj.value = obj.value+"-";
    if (qtd == 12 && evt.keyCode == 8) {
    character = tiraChar(obj.value, "-");
        obj.value = character.substring(0,7)+"-"+character.substring(7,12);
    }
    if (qtd == 13) {
    character = tiraChar(obj.value, "-");
    obj.value = character.substring(0,8)+"-"+character.substring(8,12);
		}
}
function tiraChar(texto, caracter) {
	var ret;
  for (i=0; i < texto.length; i++) {
  if (texto.substring(i, i+1) == caracter)
  	ret = texto.substring(0, i)+texto.substring(i+1, texto.length);
  }
  return ret;
}

function currencyFormat(fld, milSep, decSep, e) {
  var sep = 0;
  var key = '';
  var i = j = 0;
  var len = len2 = 0;
  var strCheck = '0123456789';
  var aux = aux2 = '';
  var whichCode = (window.Event) ? e.which : e.keyCode;

  if (whichCode == 13) return true;  // Enter
  if (whichCode == 8) return true;  // Delete
  key = String.fromCharCode(whichCode);  // Get key value from key code
  if (strCheck.indexOf(key) == -1) return false;  // Not a valid key
  len = fld.value.length;
  for(i = 0; i < len; i++)
  if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
  aux = '';
  for(; i < len; i++)
  if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
  aux += key;
  len = aux.length;
  if (len == 0) fld.value = '';
  if (len == 1) fld.value = '0'+ decSep + '0' + aux;
  if (len == 2) fld.value = '0'+ decSep + aux;
  if (len > 2) {
    aux2 = '';
    for (j = 0, i = len - 3; i >= 0; i--) {
      if (j == 3) {
        aux2 += milSep;
        j = 0;
      }
      aux2 += aux.charAt(i);
      j++;
    }
    fld.value = '';
    len2 = aux2.length;
    for (i = len2 - 1; i >= 0; i--)
    fld.value += aux2.charAt(i);
    fld.value += decSep + aux.substr(len - 2, len);
  }
  return false;
}

function confirma() {
	if(confirm('Você confirma esta ação?')){
		return true;
	} else {
		return false;
	}
}
function confirmaDefinitivo() {
	if(confirm('Suas informações são definitivas. Tem certeza que elas são corretas?')){
		return true;
	} else {
		return false;
	}
}
