﻿function logarClique(botao)
{
 $.ajax({
   type: "POST",
   url: "LogEstatistica.aspx",
   data: "texto="+botao,
   success: function(data){
     //------
   }
 });        
}

function goToAnchor(nameAnchor){
     window.location.hash=nameAnchor;
}

$(function() {
	$('#linkOrkut, #linkFacebook, #linkTwitter, #linkRss, #linkFale, #linkFormspring, #linkChat, #linkMsn, #icon_parceiro, #icon_indicacao, #icon_senha').tooltip({ 
        track: true, 
        delay: 0, 
        showURL: false,
        fixPNG: true
    });
});

$(document).ready(function(){ 
    $(document).pngFix();
});

$.ajaxSetup ({  
     cache: false  
 });  

$(function () {
        
    $('.bannerPrincipal').anythingSlider({
        easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
        autoPlay: false,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
        delay: 3000,                    // How long between slide transitions in AutoPlay mode
        startStopped: false,            // If autoPlay is on, this can force it to start stopped
        animationTime: 600,             // How long the slide transition takes
        hashTags: false,                 // Should links change the hashtag in the URL?
        buildNavigation: false,          // If true, builds and list of anchor links to link to each slide
	    pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
	    startText: "Go",             // Start text
        stopText: "Stop"
    });
    
    $('.sliderDepoimentos').anythingSlider({
        easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
        autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
        delay: 6000,                    // How long between slide transitions in AutoPlay mode
        startStopped: false,            // If autoPlay is on, this can force it to start stopped
        animationTime: 600,             // How long the slide transition takes
        hashTags: true,                 // Should links change the hashtag in the URL?
        buildNavigation: false,          // If true, builds and list of anchor links to link to each slide
	    pauseOnHover: true
    });

    $('.sliderVestibulares').anythingSlider({
        easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
        autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
        delay: 6000,                    // How long between slide transitions in AutoPlay mode
        startStopped: false,            // If autoPlay is on, this can force it to start stopped
        animationTime: 600,             // How long the slide transition takes
        hashTags: true,                 // Should links change the hashtag in the URL?
        buildNavigation: false,          // If true, builds and list of anchor links to link to each slide
	    pauseOnHover: true
    });

    $('.bannersHome').anythingSlider({
        easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
        autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
        delay: 20000,                    // How long between slide transitions in AutoPlay mode
        startStopped: false,            // If autoPlay is on, this can force it to start stopped
        animationTime: 600,             // How long the slide transition takes
        hashTags: true,                 // Should links change the hashtag in the URL?
        buildNavigation: false,          // If true, builds and list of anchor links to link to each slide
	    pauseOnHover: true
    });

    $('.headlink').hover(
	    function() { $('ul', this).css('display', 'block'); },
	    function() { $('ul', this).css('display', 'none'); }
	);

    $(".bot-cadastre").click(function(){
    //   $('.bannerPrincipal').anythingSlider(2);
        logarClique('CADASTRE-SE');
    });
    
    $(".bot-cadastre2").click(function(){
        $('.bannerPrincipal').anythingSlider(2);
    });    
    
    $(".bot-login").click(function(){
        $('.bannerPrincipal').anythingSlider(4);
    });

    $(".bot-cancelar").click(function(){
        $('.bannerPrincipal').anythingSlider(1);
    });

    $("#btNovaBusca").click(function() {
        if($("#tbNovaBusca").css('display') == 'none') {
            $("#tbNovaBusca").show();
        } else {
            $("#tbNovaBusca").hide();
        }
    });
    
    $("#lnkBuscarTodos").click(function() {
        $("#divBuscaG").hide();
        $("#divBuscaP").hide();
        $("#divBuscaO").hide();
        $("#divBuscaT").hide();
        $("#divBuscaI").hide();
        $("#divBuscaTodos").show();
    });

    $("#btG").click(function() {
        $("#divBuscaG").show();
        $("#divBuscaP").hide();
        $("#divBuscaO").hide();
        $("#divBuscaT").hide();
        $("#divBuscaI").hide();
        $("#divBuscaTodos").hide();
    });

    $("#btP").click(function() {
        $("#divBuscaG").hide();
        $("#divBuscaP").show();
        $("#divBuscaO").hide();
        $("#divBuscaT").hide();
        $("#divBuscaI").hide();
        $("#divBuscaTodos").hide();
    });

    $("#btT").click(function() {
        $("#divBuscaG").hide();
        $("#divBuscaP").hide();
        $("#divBuscaO").hide();
        $("#divBuscaT").show();
        $("#divBuscaI").hide();
        $("#divBuscaTodos").hide();
    });

    $("#btI").click(function() {
        $("#divBuscaG").hide();
        $("#divBuscaP").hide();
        $("#divBuscaO").hide();
        $("#divBuscaT").hide();
        $("#divBuscaI").show();
        $("#divBuscaTodos").hide();
    });

    $("#btO").click(function() {
        $("#divBuscaO").show();
        $("#divBuscaG").hide();
        $("#divBuscaP").hide();
        $("#divBuscaT").hide();
        $("#divBuscaI").hide();
        $("#divBuscaTodos").hide();
    });

    $("#btAgenda").click(function() {
        $("#divAgenda").show();
        $("#divEvento").hide();
    });

    $("#btEvento").click(function() {
        $("#divAgenda").hide();
        $("#divEvento").show();
    });

    $('.menu-entenda')
	.css( {backgroundPosition: "0 -37"} )
	.mouseover(function(){
		$(this).stop().animate(
			{backgroundPosition:"(0 0)"}, 
			{duration:300})
		})
	.mouseout(function(){
		$(this).stop().animate(
			{backgroundPosition:"(0 -37)"}, 
			{duration:300})
		})

    $('.menu-estude')
	.css( {backgroundPosition: "0 -37"} )
	.mouseover(function(){
		$(this).stop().animate(
			{backgroundPosition:"(0 0)"}, 
			{duration:300})
		})
	.mouseout(function(){
		$(this).stop().animate(
			{backgroundPosition:"(0 -37)"}, 
			{duration:300})
		})

    $('.menu-carreira')
	.css( {backgroundPosition: "0 -37"} )
	.mouseover(function(){
		$(this).stop().animate(
			{backgroundPosition:"(0 0)"}, 
			{duration:300})
		})
	.mouseout(function(){
		$(this).stop().animate(
			{backgroundPosition:"(0 -37)"}, 
			{duration:300})
		})

    $('.menu-parcerias')
	.css( {backgroundPosition: "0 -37"} )
	.mouseover(function(){
		$(this).stop().animate(
			{backgroundPosition:"(0 0)"}, 
			{duration:300})
		})
	.mouseout(function(){
		$(this).stop().animate(
			{backgroundPosition:"(0 -37)"}, 
			{duration:300})
		})

    $('.menu-painel')
	.css( {backgroundPosition: "0 -37"} )
	.mouseover(function(){
		$(this).stop().animate(
			{backgroundPosition:"(0 0)"}, 
			{duration:300})
		})
	.mouseout(function(){
		$(this).stop().animate(
			{backgroundPosition:"(0 -37)"}, 
			{duration:300})
		})
});

(function($) {
	$.extend($.fx.step,{
	    backgroundPosition: function(fx) {
            if (fx.state === 0 && typeof fx.end == 'string') {
                var start = $.curCSS(fx.elem,'backgroundPosition');
                start = toArray(start);
                fx.start = [start[0],start[2]];
                var end = toArray(fx.end);
                fx.end = [end[0],end[2]];
                fx.unit = [end[1],end[3]];
            }
            var nowPosX = Array;
            nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
            nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];
            fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];

           function toArray(strg){
               strg = strg.replace(/left|top/g,'0px');
               strg = strg.replace(/right|bottom/g,'100%');
               strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
               var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
               return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
           }
        }
	});
})(jQuery);

function Mascara_Data(txtData, tecla)
{
    separador="/";
    
    tecla=tecla.keyCode;
    
    if ((tecla != 9) &&
        (tecla != 16) &&
        (tecla != 35) &&
        (tecla != 36) &&
        (tecla != 37) &&
        (tecla != 38) &&
        (tecla != 39) &&
        (tecla != 40) &&
        (tecla != 46) )
    {
    if (txtData.value.length < 10)
    {
        valor=txtData.value.split('');
        formatado="";
        
        i=0;
        
        while(i<valor.length)
        {
            caractere=valor[i];
            numeros=/^\d+$/;
            if(numeros.test(caractere) || caractere==separador){ formatado+=String(caractere);}
            if((formatado.length==2 || formatado.length==5) && tecla!=8){formatado+=separador; i++;}
            i++;
        }
        txtData.value=formatado;
    }
    }
}


function echeck(campo) {
    var email = campo.value.toLowerCase();
    var emailpat=/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/;
    var matchArray=email.match(emailpat);
    
    if(matchArray==null)
    {
        return false;
    }
    return true;
}

function ncheck(campo) {
    
    var nome = campo.value;
    var arr = nome.split(" ");

    if(nome.length < 10) { 
        return false;
    }
    
    else if(arr == null) {
        return false;
    }
    
    if(arr.length == 1) {
        return false;
    } else {
        if(arr[0].length < 2) {
            return false;
        }
        else if(arr[1].length < 2) { 
            return false;
        }
    }
    
    return true;
}

function OcultarExibir(controles) 
{
    var myString = controles;

    var mySplitResult = myString.split(",");

    for(i = 0; i < mySplitResult.length; i++){
	    var controle = document.getElementById(mySplitResult[i]);
	    if(controle.style.display == '' || controle.style.display == 'block')
	    {
	        controle.style.display = 'none';
	    } 
	    else 
	    {
	        controle.style.display = 'block';	    
	    }
	    
    }
}

function OcultarExibir2(controles, posicao) 
{
    var myString = controles;
    var mySplitResult = myString.split(",");
    for(i = 0; i < mySplitResult.length; i++){
	    var controle = document.getElementById(mySplitResult[i]);
	    if(controle.style.marginTop == '-1000px')
	    {
	        controle.style.marginTop = posicao + "px";
	    } 
	    else 
	    {
	        controle.style.marginTop = '-1000px';   
	    }
	    
    }
}

function DesabilitarControle(controle) 
{
    var control = document.getElementById(controle);
    
    if(control.disabled == false) 
    {
        control.disabled = true;
    }
    else 
    {
        control.disabled = false;    
    }   
}

function SelecionarOpcaoLista(controle, opcao)
{
    var control = document.getElementById(controle);    
    
    if(control.disabled == true) 
    {
        control.options[0].selected = true;
        return;
    }
    
    for(i = 0; i < control.options.length; i++)
    {
        if(control.options[i].text.toUpperCase() == opcao.toUpperCase())
        {
            control.options[i].selected = true;
            break;
        }
    }
}

function SelecionarTodos(controle)
{
    var control = document.getElementById(controle);

    for(i = 0; i < control.options.length; i++) 
    {
        if(control.options[i].selected == true) 
        {
            control.options[i].selected = false;
        } 
        else 
        {
            control.options[i].selected = true;        
        }
    }
}

function ConfirmaMatricula(){
    if(!confirm('Confirma matrícula na instituição de ensino?')) {
        return false;
    };
}

function ErroCancelamento() {
    alert('Não é possível realizar esse cancelamento, para alterações entre em contato com a Mais Estudo pelo telefone (11) 3822-5214.');
}


function alphanumeric(alphane)
{
	var numaric = alphane;
	for(var j=0; j<numaric.length; j++)
		{
		  var alphaa = numaric.charAt(j);
		  var hh = alphaa.charCodeAt(0);
		  if((hh > 47 && hh<58) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
		  {
		  }
		else	
		  {
			 return false;
		  }
 		}
 return true;
}

function alphaNumOnly(evt)
{	
	var charCode = (evt.which) ? evt.which : window.event.keyCode;
	//alert(charCode);
	if ((charCode <= 13) || (charCode >= 48 && charCode <= 57) || (charCode >= 96 && charCode <= 105))
		return true;
	else if (charCode >= 65 && charCode <= 90)
	{
		var keyChar = String.fromCharCode(charCode);
		//var re = /[a-zA-Z0-9_-]/;
		var re =  /^[a-zA-Z0-9]$/;
		return re.test(keyChar);
	}
	else
	{
	    if ((charCode == 16)|| (charCode == 46)|| (charCode == 17) || (charCode >= 36 && charCode <= 40))
		    return true;
	    else
            return false
	}
}

function OnlyNumbers(evt)
{
    var charCode = (evt.which) ? evt.which : window.event.keyCode;
 /*if (charCode > 31 && (charCode < 48 || charCode > 57))
    return false;*/
    if ((charCode <= 13) || (charCode >= 48 && charCode <= 57) || (charCode >= 96 && charCode <= 105))
		return true;
	else
	{
	    if ((charCode == 16)|| (charCode == 46)|| (charCode == 17) || (charCode >= 36 && charCode <= 40))
		    return true;
	    else
            return false
	}
}

function OnlyNumbersBlur(campo)
{
    var charCode = campo.value;
    if(isNaN(charCode)){
        campo.value = '';
    }
}

function validaCPF(valor) {
    cpf = valor;
    erro = new String;
    if (cpf.length < 11) erro += "Sao necessarios 11 digitos para verificacao do CPF! \n\n";
    var nonNumbers = /\D/;
    if (nonNumbers.test(cpf)) erro += "A verificacao de CPF suporta apenas numeros! \n\n";
    if (cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999"){
        erro += "Numero de CPF invalido!"
    }
    var a = [];
    var b = new Number;
    var c = 11;
    for (i=0; i<11; i++){
        a[i] = cpf.charAt(i);
        if (i < 9) b += (a[i] * --c);
    }
    if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }
    b = 0;
    c = 11;
    for (y=0; y<10; y++) b += (a[y] * c--);
    if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }
    if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10])){
        erro +="Digito verificador com problema!";
    }
    if (erro.length > 0){
        //alert(erro);
        return false;
    }
    return true;
}

function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
