﻿$(document).ready(function(){    /*--------------------------CARROSSEL HOME----------------------*/    //negrito no primeiro botao noticia    $('#noticia_0').removeClass('botao_noticia');    $('#noticia_0').addClass('botao_preto');    //esconde todo o conteudo das noticias    for(i=1;i<5;i++){        $('#textcontent_'+i).hide();    }    //esconde todas as imagens    for(i=1;i<5;i++){        $('#img_tv_'+i).hide();    }    for(i=0;i<5;i++){        clickPass('#noticia_'+i, '#textcontent_'+i, '#img_tv_'+i);    }    function clickPass(div,noticia,tv){        $(div).click(function(){            escondeNoticias();            passaNoticia(noticia, tv);            $(div).removeClass('botao_noticia');            $(div).addClass('botao_preto');        })    }    function passaNoticia(noticia,tv){        escondeNoticias();        $(tv).fadeIn();        $(noticia).fadeIn();    }    function escondeNoticias(){        $('#noticia_0').addClass('botao_noticia');        $('#noticia_0').removeClass('botao_preto');        $('#noticia_1').addClass('botao_noticia');        $('#noticia_1').removeClass('botao_preto');        $('#noticia_2').addClass('botao_noticia');        $('#noticia_2').removeClass('botao_preto');        $('#noticia_3').addClass('botao_noticia');        $('#noticia_3').removeClass('botao_preto');        $('#noticia_4').addClass('botao_noticia');        $('#noticia_4').removeClass('botao_preto');        $('#textcontent_0').hide();        $('#textcontent_1').hide();        $('#textcontent_2').hide();        $('#textcontent_3').hide();        $('#textcontent_4').hide();                $('#img_tv_0').hide();        $('#img_tv_1').hide();        $('#img_tv_2').hide();        $('#img_tv_3').hide();        $('#img_tv_4').hide();    }    // Anima TV    var q = 4;    var i = 1;    // A cada 3 segundos ele troca a imagem, simulando o click no botão    window.setInterval(function(){        $('#noticia_'+ i).click();        if( i == q-1 ){            i = 0;        } else {            i++;        }    }, 7000);    /*----------------------------POSICIONAMENTO ------------------------*/    if(window.location.pathname == '/' || window.location.pathname == '/?lang=de' ){        $('#header').addClass('header-sobrescrito');                $('#header').append('<div id="espaco_do_aluno"><strong>Espaço do Aluno:</strong><form id="form1" name="form1" method="post" action="http://produtos.qualityts.com.br/repository/login/verificaLogin/produto/sigaaweb/" ><input type="hidden" id="acessoRemoto" name="acessoRemoto" value="true" /><input type="hidden" id="cliente" name="cliente" value="benjaminconstant" /><input type="hidden" id="produtoOriginal" name="produtoOriginal" value="sigaaweb" /><input type="hidden" name="clieunidade" id="clieunidade" value="28" /><input type="text" name="usuario" id="usuario_input"  class="bt" size="20"/><input name="senha" class="bt" type="password" id="senha_input" size="20" /><input valign=absmiddle type="submit" id="entrar" value="" /></form></div>');        }        function loginHandler(msg){        if(msg.getElementsByTagName("tipo")[0].firstChild.data == 'Link'){            window.location = msg.getElementsByTagName("message")[0].firstChild.data;        }else if(msg.getElementsByTagName("tipo")[0].firstChild.data == '1'){            alert(msg.getElementsByTagName("message")[0].firstChild.data);        }else if(msg.getElementsByTagName("tipo")[0].firstChild.data == '2'){            $('#dialog').jqm({                ajax: 'http://produtos.qualityts.com.br/repository/alerta/index/modal/mensagem/'+msg.getElementsByTagName("id")[0].firstChild.data+'/codigoerro/'+msg.getElementsByTagName("codigoErro")[0].firstChild.data            });            $('#dialog').jqmShow();        }    }    function formataProntuario(objeto, sMask, evtKeyPress){        if(isInteger(objeto.value.charAt(0))){            txtBoxFormat(objeto, sMask, evtKeyPress);        }    }    function isInteger(s){        return (s.toString().search(/^-?[0-9]+$/) == 0);    }    function txtBoxFormat(objeto, sMask, evtKeyPress) {        var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;        if(document.all) {            nTecla = evtKeyPress.keyCode;        } else if(document.layers) {            nTecla = evtKeyPress.which;        } else {            nTecla = evtKeyPress.which;            if (nTecla == 8) {                return true;            }        }        sValue = objeto.value;        sValue = sValue.toString().replace( "-", "" );        sValue = sValue.toString().replace( "-", "" );        sValue = sValue.toString().replace( ".", "" );        sValue = sValue.toString().replace( ".", "" );        sValue = sValue.toString().replace( "/", "" );        sValue = sValue.toString().replace( "/", "" );        sValue = sValue.toString().replace( ":", "" );        sValue = sValue.toString().replace( ":", "" );        sValue = sValue.toString().replace( "(", "" );        sValue = sValue.toString().replace( "(", "" );        sValue = sValue.toString().replace( ")", "" );        sValue = sValue.toString().replace( ")", "" );        sValue = sValue.toString().replace( " ", "" );        sValue = sValue.toString().replace( " ", "" );        fldLen = sValue.length;        mskLen = sMask.length;        i = 0;        nCount = 0;        sCod = "";        mskLen = fldLen;        while (i <= mskLen) {            bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/") || (sMask.charAt(i) == ":"))            bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))            if (bolMask) {                sCod += sMask.charAt(i);                mskLen++;            }            else {                sCod += sValue.charAt(nCount);                nCount++;            }            i++;        }        objeto.value = sCod;        if (nTecla != 8) {            if (sMask.charAt(i-1) == "9") {                return ((nTecla > 47) && (nTecla < 58));            }            else {                return true;            }        }        else {            return true;        }    }    function formhandler_loginForm(formObj) {        var form_data = ""        form_data += "&produto=" + escape(formObj.elements["produto"].value);        form_data += "&cliente=" + escape(formObj.elements["cliente"].value);        form_data += "&clieunidade=" + escape(formObj.elements["clieunidade"].value);        form_data += "&usuario=" + escape(formObj.elements["usuario"].value);        form_data += "&senha=" + escape(formObj.elements["senha"].value);        form_data = form_data.substring(1, form_data.length);        $.ajax({            type: "POST",            url: "http://produtos.qualityts.com.br/repository/login/verificaLogin",            dataType: "xml",            data: form_data,            success: function(responseMsg, textStatus){                loginHandler(responseMsg);            },            error: function(XMLHttpRequest, textStatus, errorThrown) {                alert(XMLHttpRequest.responseText);            }        });        return false;    }  /*  if(document.forms["loginForm"].elements["usuario"].type != "select-one" && document.forms["loginForm"].elements["usuario"].type != "select-multiple" && document.forms["loginForm"].elements["usuario"].length){        document.forms["loginForm"].elements["usuario"][0].focus();    }else{        document.forms["loginForm"].elements["usuario"].focus();    }*/})
