function desativaArea() {
	data = new Date();
	hora = data.getHours();
	minuto = data.getMinutes();

	if (hora >= 18) {
		document.formChat.area[1].disabled = true;
	}

//	if ((hora >= 19) && (minuto >= 30)) {
	if (hora >= 19) {		
		document.formChat.area[2].disabled = true;
	}

}

function validaSubmit (form) {

  temp = form.valor.value;
  temp = temp.replace( ".", "");
  temp = temp.replace( ",", "");
  form.valor.value = temp;

  temp = form.cep.value;
  temp = temp.replace( "-", "");
  form.cep.value = temp;

  return(true);
 
}


function FormataValor(campo,tammax,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.pagamento[campo].value;
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	tam = vr.length;

	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){ tam = tam - 1 ; }
	
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 2 ){ 
	 		document.pagamento[campo].value = vr ; }
	 	if ( (tam > 2) && (tam <= 5) ){
	 		document.pagamento[campo].value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 6) && (tam <= 8) ){
	 		document.pagamento[campo].value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 9) && (tam <= 11) ){
	 		document.pagamento[campo].value = vr.substr( 0, tam - 8 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 12) && (tam <= 14) ){
	 		document.pagamento[campo].value = vr.substr( 0, tam - 11 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 15) && (tam <= 17) ){
	 		document.pagamento[campo].value = vr.substr( 0, tam - 14 ) + '.' + vr.substr( tam - 14, 3 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ;}
	}		
	else { 
	  if ( tecla != 9 ) {
	    return(false);
	  }
	}
	
}


function FormataNumero(campo,tammax,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.pagamento[campo].value;
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	tam = vr.length;

	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){	tam = tam - 1 ; }
		
	if ( tecla == 9 || tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
	  document.pagamento[campo].value = vr ;
	}		
	else { 
	  return(false);
	  }
	
}


function formataCep(teclapres){
//Formata o campo cep de acordo com a tecla pressionada

  var tammax = 9;
  var pos = 5;
  var tecla = teclapres.keyCode;

  vr = document.pagamento.cep.value;
  vr = vr.replace( "-", "" );
  vr = vr.replace( ".", "" );
  vr = vr.replace( "/", "" );
  tam = vr.length ;

  if (tam < tammax && tecla != 8) { 
    tam = vr.length + 1 ;
  }

  if (tecla == 8 ){ 
    tam = tam - 1 ; 
  }
	
  if ( tecla==9 || tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105){
    if ( tam <= 2 ){
	  document.pagamento.cep.value = vr ;
	}
	if ( tam > pos && tam <= tammax ){
	  document.pagamento.cep.value = vr.substr( 0, pos ) + '-' + vr.substr( pos, tam-1 );
	}
  }
  else {
    return(false);
  }
  
  return(true);
  
}


function mudaValor (valor, op) {
	document.formChat.areaValor.value = valor;
	
	if (op) {
		document.getElementById('trOFF').style.display = 'none';
		document.getElementById('trON').style.display = '';
	}
	
	else {
		document.getElementById('trOFF').style.display = '';
		document.getElementById('trON').style.display = 'none';
	}
	
}


function verificaDados() {

	if (document.formChat.area[0].checked) {
	
		openWindow('http://ncc.plugin.com.br/Chat4/cliente/frm_login.asp?IDArea=2&sel=HomePage', 'remote');
	
	}
	else if (document.formChat.area[1].checked) {
	
		openWindow('http://ncc.plugin.com.br/chat_adm/cliente/frm_login.asp?IDArea=4&sel=HomePage', 'remote');
	
	}

	else if (document.formChat.area[2].checked) {
	
		openWindow('https://ncc.uolhost.com.br/chat_uol_host/cliente/frm_login.asp?IDArea=2', 'remote');
	
	}
//			document.formChat.submit();
	
}


function support(size, field1, field2){
	if (validate())
//		contato_int_full(size,field1, field2, '', '')
		verificaDados();
}

function validate(){
	username = document.form_login.username.value;
	email = document.form_login.email.value;
	if (username == null || username == ""){
		alert("Preencha o nome")
		document.form_login.username.focus()
		return false;
	}
	if (email == null || email == ""){
		alert("Preencha o email")
		document.form_login.email.focus()
		return false;
	}
	return true;

}


function openWindow(url, name)
{ var winWidth = 488;
  var winHeight = 481;
  var winTop = parseInt((screen.availHeight - winHeight) / 2);
  var winLeft = parseInt((screen.availWidth - winWidth) / 2);
			  
  popupWin = window.open(url,name,"width=" + winWidth + ",height=" + winHeight + ",top=" + winTop + ",left=" + winLeft + ",resizable=no,scrollbars=no,statusbar=no");
  if (popupWin.opener == null) popupWin.opener = self;
}
// done hiding -->