/**********************************************************
Funções Gerais
**********************************************************/
function Erro(_msg) { alert(_msg.toString()); }
function Msg(_msg1) { alert(_msg1.toString()); }
function ScrollToElement(theElement) {
    var X = 0, Y = 0;    
    while (theElement != null) {
        X += theElement.offsetLeft;
        Y += theElement.offsetTop;
        theElement = theElement.offsetParent;
    }
    window.scrollTo(X, Y);
    
}

/**********************************************************
Eventos na MasterPage
**********************************************************/

function replaceURLWithHTMLLinks(text) {
    var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/i;
    return text.replace(exp, "<a href='$1'>$1</a>");
}

$(function () {
    $('#Frase span').html(replaceURLWithHTMLLinks($('#Frase span').text()));
    $('#MenuTopicos').hide();
    $('#MenuCursos').hide();
    $('.Araguaina').addClass('SiteAtivo');
    $('.Araguaina > a').css('color', '#fff');

    $(".LinkTopoCursos").click(function () {
        $('.MenuTopoCursos').slideToggle("slow");
    });

});
/***********************************************************
Modal
***********************************************************/
$(document).ready(function() {
    $('a[name=modal]').click(function(e) {
        e.preventDefault();
        var id = $(this).attr('href');
        //var maskHeight = $(document).height();
        var maskHeight = $('#dialog').height();
        var maskWidth = $(window).width();
        $('#mask').css({ 'width': maskWidth, 'height': maskHeight + 40 });
        $('#mask').fadeIn(400);
        $('#mask').fadeTo("fast", 0.8);
        //Get the window height and width
        var winH = $(window).height();
        var winW = $(window).width();
        //$(id).css('top', winH / 2 - $(id).height() / 2);
        $(id).css('left', winW / 2 - $(id).width() / 2);
        $(id).slideDown();
    });
    $('.window .close').click(function(e) {
        e.preventDefault();
        $('#mask').fadeOut(500);
        $('.window').slideUp();
    });
    $('#mask').click(function() {
        //$(this).hide();
        //$('.window').hide();
    });
});
/**********************************************************
Abas
**********************************************************/
$(function() {
    var tabContainers = $('div.tabs > div');
    tabContainers.hide().filter(':first').show();

    $('div.tabs ul.tabNavigation a').click(function() {
        tabContainers.hide();
        tabContainers.filter(this.hash).show();
        $('div.tabs ul.tabNavigation a').removeClass('selected');
        $(this).addClass('selected');
        return false;
    }).filter(':first').click();
});
$(function() {
    var tabContainers = $('div.tabs2 > div');
    tabContainers.hide().filter(':first').show();

    $('div.tabs2 ul.tabNavigation a').click(function() {
        tabContainers.hide();
        tabContainers.filter(this.hash).show();
        $('div.tabs2 ul.tabNavigation a').removeClass('selected');
        $(this).addClass('selected');
        return false;
    }).filter(':first').click();
});
$(function() {
    var tabContainers = $('div.tabsTopicos > div');
    tabContainers.hide().filter(':first').show();

    $('div.tabsTopicos ul.tabNavigation a').click(function() {
        tabContainers.hide();
        tabContainers.filter(this.hash).show();
        $('div.tabsTopicos ul.tabNavigation a').removeClass('selected');
        $(this).addClass('selected');
        return false;
    }).filter(':first').click();
});



