function TelefoneFormat(Campo, e) { 
    var key = ''; 
    var len = 0; 
    var strCheck = '0123456789'; 
    var aux = ''; 
    var whichCode = (window.Event) ? e.which : e.keyCode; 
     
    if (whichCode == 13 || whichCode == 8 || whichCode == 0) 
    { 
        return true;  // Enter backspace ou FN qualquer um que não seja alfa numerico 
    } 
    key = String.fromCharCode(whichCode); 
    if (strCheck.indexOf(key) == -1){ 
        return false;  //NÃO E VALIDO 
    } 
     
    aux =  Telefone_Remove_Format(Campo.value); 
     
    len = aux.length; 
    if(len>=10) 
    { 
        return false;    //impede de digitar um telefone maior que 10 
    } 
    aux += key; 
     
    Campo.value = Telefone_Mont_Format(aux); 
    return false; 
}
function  Telefone_Mont_Format(Telefone) 
{ 
    var aux = len = ''; 
     
    len = Telefone.length; 
    if(len<=9) 
    { 
        tmp = 5; 
    } 
    else 
    { 
        tmp = 6; 
    } 
     
    aux = ''; 
    for(i = 0; i < len; i++) 
    { 
        if(i==0) 
        { 
            aux = '('; 
        } 
        aux += Telefone.charAt(i); 
        if(i+1==2) 
        { 
            aux += ') '; 
        } 
         
        if(i+1==tmp) 
        { 
            aux += '-'; 
        } 
    } 
    return aux ; 
} 

function  Telefone_Remove_Format(Telefone) 
{ 
    var strCheck = '0123456789'; 
    var len = i = aux = ''; 
    len = Telefone.length; 
    for(i = 0; i < len; i++) 
    { 
        if (strCheck.indexOf(Telefone.charAt(i))!=-1) 
        { 
            aux += Telefone.charAt(i); 
        } 
    } 
    return aux; 
}


function getIt(m){
n=m.name;
//p1=document.forms[0].elements[n]
p1=m
ValidatePhone()
}
function testphone(obj1){
p=obj1.value
//alert(p)
p=p.replace("(","")
p=p.replace(")","")
p=p.replace("-","")
p=p.replace("-","")
//alert(isNaN(p))
if (isNaN(p)==true){
alert("Check phone");
return false;
}
}
//  End -->

function abrir_janela(www,nome,w,h,s,m) {
	if (!s) {
		s = 'no';
	}
	if (!m) {
		m = 'no';
	}
	var height = window.screen.height - 160;
	var width = window.screen.width;
	var top = (height- h)/2;
	var left = (width - w)/2;
	window.open(www,nome,"top=" + top + ",left="+ left +",width="+w+",height="+h+"menubar="+s+",scrollbars="+m)
} 

function vota_enquete() {
	document.getElementById('enquete').submit();
}

function completaData(campo) 
{ 
      qtdcaracteres = (campo.value).length; 

      if(qtdcaracteres == 2 || qtdcaracteres == 5) 
        campo.value = campo.value + "/"; 
} 

function completaCEP(campo) 
{ 
      qtdcaracteres = (campo.value).length; 

      if(qtdcaracteres == 5) 
        campo.value = campo.value + "-"; 
}