var phraseTimeout;

function register_company_profile_change(opt)
{
    if(opt == 0)
    {
        $('#company_profile_extra_p').show();
    }
    else
    {
        $('#company_profile_extra_p').hide();
    }
}

function usermenu_up()
{
    $("#popular_downloads_link").removeClass('selected');
    $("#popular_downloads_link").find('a').removeClass('up').addClass('down');
    $("#latest_downloads_link").removeClass('selected');
    $("#latest_downloads_link").find('a').removeClass('up').addClass('down');
    $(".dropdown").slideUp(300, function(callback) {}); 
    $("#container").click(function() {});
}
function login_up()
    {
        $("#login_form").slideUp(300, function(callback) {
                $("#login_link a").parent().removeClass('selected')
                $("#login_link a").removeClass('up').addClass('down')
            })
            $("#container").click(function() {});
    }

    function login_down()
    {
        $("#login_form").slideDown(300)
        $("#login_link a").parent().addClass('selected')
        $("#login_link a").removeClass('down').addClass('up')
        $("#id_email").focus()
    }

function showTipInfo()
{

        $('.dic-phrase').hover(function() {
        
            if ($(this).hasClass('dic-phrase-hover'))
            {

                if (typeof phraseTimeout != 'undefined')
                    clearTimeout(phraseTimeout);

                return;
            }
            if (typeof phraseTimeout != 'undefined')
            {
                clearTimeout(phraseTimeout);
            }

            $('#nodes .dic-phrase-hover').removeClass('dic-phrase-hover');
            $('#dic-phrase-overlay').remove();

            $(this).addClass('dic-phrase-hover');
             var id = $(this).attr('id').replace('dic-phrase-', '');

            $('body').append('<div id="dic-phrase-overlay"><div class="dic-phrase-definition">' + $(this).children('.dic-text').html() + '</div><div class="dic-phrase-icon"><div class="icon bg"></div></div><div class="clear"></div><div class="dic-phrase-arrow bg"></div></div>');
            var phraseOffset = $(this).children('.dic-phrase-first-letter').offset();


            var coordinates = {};

            coordinates.top = phraseOffset.top - $('#dic-phrase-overlay').outerHeight(true) - 10;
            if (phraseOffset.left - $('#dic-phrase-overlay').outerWidth(true) + 33 < 5)
            {
                $('#dic-phrase-overlay .dic-phrase-arrow').addClass('dic-phrase-arrow-left');
                coordinates.left = phraseOffset.left - 6;
            }
            else
            {
                coordinates.left = phraseOffset.left - $('#dic-phrase-overlay').outerWidth(true) + 33;
            }
            $('#dic-phrase-overlay').offset(coordinates);
            

           //coordinates.top = 10;
           //coordinates.left = 10;


            var _this = this;
            $('#dic-phrase-overlay').hover(function() {
                if (typeof phraseTimeout != 'undefined')
                {
                    clearTimeout(phraseTimeout);
                }
            }, function() {
                phraseTimeout = setTimeout(function() {                    
                    $('#dic-phrase-overlay').remove();
                    $(_this).removeClass('dic-phrase-hover');
                }, 400);
            });
        }, function() {
            var _this = this;
            phraseTimeout = setTimeout(function() {

                $('#dic-phrase-overlay').remove();
                $(_this).removeClass('dic-phrase-hover');
            }, 400);

        });
}

function showRegistrationForm()
{
    //alert('aaa');
}

function sdkPost(form, url, t)
{
    $.post(url, $("#"+form).serialize(), function(data)
    {
        //alert($(t).parents(".axnode").attr('id'));
        if(data)
            $("#"+$(t).parents(".axnode").attr('id')).html(data);
        else
            location.reload(true);
    });
}



function downloadLeadReload()
{
    $('#notReadyDownload').hide();
    $('#ReadyDownload').show();
}

function trainChange(val)
{
    var allInputs = $(":input");
    var ch = val;
    $(":input").each(function($ch) {
        $(this).attr("disabled", false);
    });
    $(":input").each(function($ch) {        
        var tmp = '';
        tmp = ch + '_' + $(this).val();
        for (var i = 0; i < ex_exclude.length; i++)
        {            
            if(ex_exclude[i] == tmp)
            {
                if($(this).attr('type') == 'checkbox')
                {
                    $(this).attr('checked', false);
                }
                if($(this).attr('type') == 'radio')
                {
                    $(this).attr('checked', false);
                }
                $(this).attr("disabled", true);
            }
        }
  });

}

