
/*--- Área de Serviços---*/
function GetXMLHttpRequest(){
        try {
            return new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch(e){}
            try {
                return new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch(e){}
            try {
                return new XMLHttpRequest();
            }
        catch(e){}       
      
        return null;
    }
     var xmlhttp=GetXMLHttpRequest();
   
	// Recuperação de senha 
	
	function recupera_senha(){
		if (document.form_servicos.select_servico.value == "webmail"){
			alert('Favor entrar em contato com nosso departamento de atendimento:  \n \t\t55 11 5033-5900');
		}else if (document.form_servicos.select_servico.value == "portal"){
			enviaEmail();
		}
		
	}

	// Funções para identificar o Serviço selecionado
		function identifica_servico(){
			if (document.form_servicos.select_servico.value == "webmail"){				
				submeter_mail();
			}else if (document.form_servicos.select_servico.value == "portal"){				
				document.form_servicos.senha.value = document.form_servicos.password.value;				
				if(login()){
				var popup = abrirPopup('/customerportal/redireciona-servicos.aspx','CustomerPortal','width=890,height=500,status=1,scrollbars=0,toolbars=0,resize=0');
				document.form_servicos.submit();
				}
			}			
		}
		function identifica_servicoOC(){			
				//document.form_servicos.senha.value = document.form_servicos.password.value;				
				if(login()){
				var popup = abrirPopup('/customerportal/redireciona-servicos.aspx','CustomerPortal','width=890,height=500,status=1,scrollbars=0,toolbars=0,resize=0');
				document.form_servicos.submit();
				window.close();
			}			
		}
function Trim(str){return str.replace(/^\s+|\s+$/g,"");}

function abrirPopup(){
var pagina = arguments[0];
var janela = arguments[1]
var parms = arguments[2];
var mpg_popup;
document.form_servicos.action=pagina;
     if(navigator.appName.indexOf("Netscape") != -1) {
       mpg_popup = window.open('',janela,parms);
       document.form_servicos.target=janela;
     }
    else {
       mpg_popup = window.open('',janela,parms);
       document.form_servicos.target=janela;
    }
    return true;
}

function enviaEmail()
{
    mensagem="";
    campo="divMsg";
    email = document.getElementById("email").value;
    var url="/customerportal/esqueci-senha.aspx?email=" + email;
    url=url+"&sid="+Math.random();
    xmlhttp.open("GET",url,false);
    xmlhttp.send(null);
    document.getElementById(campo).innerHTML="";
    if (xmlhttp.readyState==4)
    {
    retorno = xmlhttp.responseText;
        if(retorno == "1"){
            mensagem="Sua senha enviada para o e-mail: " + email;
        }
        else if(retorno == "2")
            mensagem = "E-mail n&atilde;o localizado: " + email;
        else if(retorno == "3")
            mensagem = "Aten&ccedil;&atilde;o! ocorreu uma falha na tentativa do envio. Tente novamente mais tarde.";
         else if(retorno == "4")
            mensagem = "E-mail n&atilde;o informado.";   
            else
            mensagem = "Aten&ccedil;&atilde;o! ocorreu uma falha na tentativa do envio. Tente novamente mais tarde.";
    }
            document.getElementById(campo).innerHTML="<label class=\"asuasenha\">"+mensagem+"</label>";
}
var email="";
function login()
{
    document.getElementById("divMsg").innerHTML="<label class=\"asuasenha\">Carregando...</label>";
    var bool = true;
    var txtEmail = document.getElementById("email");
    var txtSenhaNovaVerif = document.getElementById("txtSenhaNovaVerif");
    var txtSenha= document.getElementById("senha_servicos");
    var url="/customerportal/login.aspx?email=" + txtEmail.value;
    url=url+"&senha=" + txtSenha.value;
    url=url+"&sid="+Math.random();
    xmlhttp.open("GET",url,false);
    xmlhttp.send(null);

    if (xmlhttp.readyState==4)
    {
        var retorno = xmlhttp.responseText;
        if(retorno=="0"){
            document.getElementById("divMsg").innerHTML="<label class=\"emailerrado\" style=\"margin-left:170px;\">E-mail ou senha inv&aacute;lido!</label>";
            bool = false;
        }
        else if(retorno=="2"){
            document.getElementById("divMsg").innerHTML="<label class=\"asuasenha\">Sua senha atual esta expirada, favor cadastrar uma nova senha.</label>";
            document.getElementById("lblLogin").className ='lblSenhaAtual';
            document.getElementById("lblSenha").className ="lblSenhaNova";
            document.getElementById("divConfirmaSenha").style.display="block";
            document.getElementById("lblConfirmaSenha").style.display="block";
            document.getElementById("ok").style.display="none";
            document.getElementById("btnTrocaSenha").style.display="block";
            document.getElementById("esqueci").style.display="none";
            txtSenhaNovaVerif.style.display="block";
            email = txtEmail.value;
            document.getElementById("senhaAtual").style.display="block";
            document.getElementById("senhaAtual").value = txtSenha.value;
            txtEmail.style.display="none";
            txtEmail.value = txtSenha.value;
            txtSenha.value = "";
         bool = false;
        }else if(retorno!="1"){
            document.getElementById("divMsg").innerHTML="<label class=\"asuasenha\">Erro no sistema ao tentar efetuar o login.</label>";
            bool = false;
        }else
            document.getElementById("divMsg").innerHTML="";
     
    }
    return bool;
}
function alteraSenha(tipo){
    var txtEmail = document.getElementById("senhaAtual");
    var txtSenhaNovaVerif = document.getElementById("txtSenhaNovaVerif");
    var txtSenha= document.getElementById("senha_servicos");
    if(Trim(txtEmail.value)=="" || Trim(txtSenha.value)==""){
        document.getElementById("divMsg").innerHTML="<label class=\"asuasenha\">Campos email e senha n&atilde;o podem estar em branco.</label>";
    }
    else
    if(txtEmail.value != txtSenha.value){
        if(txtSenha.value == txtSenhaNovaVerif.value){
            document.getElementById("lblLogin").className ="lblemail";
            document.getElementById("lblSenha").className ="lblsenha";
            var url="/customerportal/alterar-senha.aspx?email=" + email;
            url=url+"&senha=" + txtEmail.value;
            url=url+"&novaSenha=" + txtSenha.value;
            url=url+"&sid="+Math.random();
            xmlhttp.open("GET",url,false);
            xmlhttp.send(null);
            document.getElementById("divMsg").innerHTML="";
            if (xmlhttp.readyState==4)
            {
                var retorno = xmlhttp.responseText;
                if(retorno=="0"){
                    document.getElementById("divMsg").innerHTML="<label class=\"asuasenha\">Erro ao alterar a senha.</label>";
                }
                if(retorno=="1"){
                    document.getElementById("divMsg").innerHTML="<label class=\"asuasenha\" style=\"margin-left:145px;\">Senha alterada com sucesso.</label>";
                    document.getElementById("divConfirmaSenha").style.display="none";
                    document.getElementById("lblConfirmaSenha").style.display="none";
                    document.getElementById("ok").style.display="block";
                    document.getElementById("btnTrocaSenha").style.display="none";
                    document.getElementById("senhaAtual").style.display="none";
                    document.getElementById("email").style.display="block";  
                    document.getElementById("esqueci").style.display="block";
                    txtSenhaNovaVerif.style.display="none";
                    document.getElementById("email").value = email;
  //                  txtSenha.value="";
				    if(login()){
				        var popup = abrirPopup('/customerportal/redireciona-servicos.aspx','CustomerPortal','width=890,height=500,status=1,scrollbars=0,toolbars=0,resize=0');
				        document.form_servicos.submit();
				        if(tipo=="cookpit")
	    				    window.close();
			        }
               }
            }
        }else{
            document.getElementById("divMsg").innerHTML="<label class=\"asuasenha\">Nova senha e confirma&ccedil;&atilde;o de senha n&atilde;o coincidem.</label>";
        }    
    }else{ document.getElementById("divMsg").innerHTML="<label class=\"asuasenha\">A nova senha n&atilde;o pode ser igual a senha atual.</label>";
}
    return false;

}
	
	// Funções para acesso ao Webmail -------
	
		function submeter_mail(){
			var email = document.form_servicos.EMail.value.split('@');
			
			if (navigator.appName == "Netscape"){
				document.form_servicos.LoginType.value = "xul";
				
			}else if(navigator.appName == "Microsoft Internet Explorer"){
				document.form_servicos.LoginType.value = "xp";
				
			}else{
				document.form_servicos.LoginType.value = "simple";
			}					
			
				document.form_servicos.username.value = email[0];
				document.form_servicos.pop3host.value = email[1];
				
			if(document.form_servicos.pop3host.value == "dualtec.com.br" ){
				
				/*
				document.form_servicos.User.value = document.form_servicos.EMail.value;
				
				document.form_servicos.action ="http://mail.dualtec.com.br/WorldClient.dll?View=Main";
				document.form_servicos.submit();
				*/
				
				document.form_servicos.username.value = ("dualtec\\"+email[0]);
				document.form_servicos.action ="https://mail.exchange.dualtec.com.br/owa/auth/owaauth.dll";						
				document.form_servicos.submit();

				
			}else{
				document.form_servicos.action ="http://mail.atmail.dualtec.com.br/mail/atmail.pl";
				document.form_servicos.submit();
				
			}
			
						
			
		}
		
//--- Popups da área de Casos de sucessos.		----


		function exibe_video(cliente){
			
			switch (cliente) {
				case "oesp":path_depoimento="/conteudo/casos/oesp/oesp.htm"
				break;
				case "sepao":path_depoimento="/conteudo/casos/sepao/sepao.htm"
				break;
				case "jumaq":path_depoimento="/conteudo/casos/jumaq/jumaq.htm"
				break;
				case "fecap":path_depoimento="/conteudo/casos/fecap/fecap.htm"
				break;
				case "escola_da_vila":path_depoimento="/conteudo/casos/escola_da_vila/escola_da_vila.htm"
				break;
				
			}
			cyber = window.open(path_depoimento,"","scrollbars=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyrighttoolbar=no,top=100,left=100,width="+(screen.width-10)+",height="+(screen.height-10)+"");
		}		
		
		function exibe_depoimento(cliente){
			
			switch (cliente) {
				case "oesp":path_depoimento="/conteudo/casos/oesp/leia/leia_oesp.asp"
				break;
				case "sepao":path_depoimento="/conteudo/casos/sepao/leia/leia_sepao.asp"
				break;
				case "jumaq":path_depoimento="/conteudo/casos/jumaq/leia/leia_jumaq.asp"
				break;
				case "fecap":path_depoimento="/conteudo/casos/fecap/leia/fecap.asp"
				break;
				case "escola_da_vila":path_depoimento="/conteudo/casos/escola_da_vila/leia/escola_da_vila.asp"
				break;
			}
			cyber = window.open(path_depoimento,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,menubar=no,width=800,height=490,left=' + (screen.width - 800) / 2 + ',top=' + (screen.height - 490) / 2 + '');	
		}
		
		function exibe_audio(cliente){	
		
			switch (cliente) {
				case "oesp":path_depoimento="/conteudo/casos/oesp/escute/audio.htm"
				break;
				case "sepao":path_depoimento="/conteudo/casos/sepao/escute/audio.htm"
				break;
				case "jumaq":path_depoimento="/conteudo/casos/jumaq/escute/audio.htm"
				break;
				case "fecap":path_depoimento="/conteudo/casos/fecap/escute/audio.htm"
				break;
				case "escola_da_vila":path_depoimento="/conteudo/casos/escola_da_vila/escute/audio.htm"
				break;
				case "eldorado":path_depoimento="/conteudo/casos/eldorado_lauro/escute/eldorado.htm"
				break;
			}

		
			cyber = window.open(path_depoimento,"","scrollbars=no,location=no,directories=no,status=no,menubar=no,resizable=no,toolbar=no,top=100,left=100,width=220,height=212");
		}
		


//Iprime as informacoes na div de suporte - editar o formualrio aqui	

function suporteAcesso(retorno){
	
	var str = new String();
	str = '';
	str += '<a href="JavaScript:void(0)" onclick="document.getElementById(\''+ retorno +'\').style.display = \'none\';" class="fechar">fechar</a>';
	str += '<h2>Atendimento via chat</h2>';
	str += '<span>Status do atendente:<iframe src="http://dualtec.mysuite.com.br/empresas/dua/verifica.php" frameborder=0 scrolling=no></iframe></span>';
	str += '<h3>Para abertura de chamado <a href="javascript:AbreJanela(\'http://suporte.dualtec.com.br/Customer/SubmitTicket.aspx\');">clique aqui</a>.</h3>';
	str += '<h3>Para consultar um chamado <a href="javascript:AbreJanela(\'http://suporte.dualtec.com.br/Customer/Gettickets.aspx\');">clique aqui</a>.</h3>';
	document.getElementById(retorno).innerHTML = str;
	document.getElementById(retorno).style.display = 'block';
//	carrega('chat');

    
};

function AbreJanela(link){
    window.open(link,'Janela','toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,menubar=yes,width='+ window.screen.width +',height='+  window.screen.height);
};

function AbreOcorrencia(link){
    window.open(link,'Janela','toolbar=no,location=no,directories=yes,status=yes,menubar=no,scrollbars=yes,resizable=no,menubar=no,width=750,height=400');
};

//Fecha a div de suporte	

function toggle(obj)
{
    var obj = document.getElementById(obj);
    
    if (obj.style.display == 'none') {
        obj.style.display = 'block';
    } else
    if (obj.style.display == 'block') {
        obj.style.display = 'none';
    }
}

//Para integracao com a ferramenta de chat
    var ObjXML;


  function criaXMLHttpRequest(){
       try {
            return new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch(e){}
        try {
            return new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(e){}
        try {
            return new XMLHttpRequest();
        }
        catch(e){}       
      
        return null;
    };

    function carrega(dvSource){
        
        var url = 'http://dualtec.mysuite.com.br/empresas/dua/verifica.php';
        ObjXML  = criaXMLHttpRequest();
        ObjXML.open('GET',url,true);
        ObjXML.onreadystatechange   = function(){recebeXML(dvSource);}
        ObjXML.send(null);        
        
    };
  
    
    function recebeXML(Destino){
        
        if(ObjXML.readyState == 4){
            
            if(ObjXML.status == 200){
                
                var xml;
                var IdTexto;
                var Texto;
                
                Texto = ObjXML.responseText;
                document.getElementById(Destino).innerHTML = Texto
            }
        }
    };


// CSS Browser Selector   v0.2.5
// Documentation:         http://rafael.adm.br/css_browser_selector
// License:               http://creativecommons.org/licenses/by/2.5/
// Author:                Rafael Lima (http://rafael.adm.br)
// Contributors:          http://rafael.adm.br/css_browser_selector#contributors
var css_browser_selector = function() {
	var 
		ua=navigator.userAgent.toLowerCase(),
		is=function(t){ return ua.indexOf(t) != -1; },
		h=document.getElementsByTagName('html')[0],
		b=(!(/opera|webtv/i.test(ua))&&/msie (\d)/.test(ua))?('ie ie'+RegExp.$1):is('gecko/')? 'gecko':is('opera/9')?'opera opera9':/opera (\d)/.test(ua)?'opera opera'+RegExp.$1:is('konqueror')?'konqueror':is('applewebkit/')?'webkit safari':is('mozilla/')?'gecko':'',
		os=(is('x11')||is('linux'))?' linux':is('mac')?' mac':is('win')?' win':'';
	var c=b+os+' js';
	h.className += h.className?' '+c:c;
}();