function update_live_match()
{
    var wrapperId = '#live-match-inner';
    var postFile = 'live/acum';

    $.post(postFile, {}, function(data)
    {
        $(wrapperId).fadeOut('2000', function()
        {
            $(this).html(data).fadeIn();
        }).html();
    });

    //alert(base_url);
    //alert(location.href);
    if(base_url == location.href)
        setTimeout('update_live_match()', 60000);
}

function ticket_update_content(html)
{
    if (html != '')
        $('.top_top_login').html(html);
    return false;
}

function ticket_show(html)
{
    if (ticket_is_open())
        return false;

    $("div.top_top_top_login").fadeOut('slow', function()
    {
        $("div.top_login").animate(
        {
            top: "290px",
        }, 'slow', function()
        {            
            $('.top_top_login').fadeIn('slow');
            $('.top_top_login').addClass('is_visible');
        });
    });
}

function ticket_is_open()
{
    return $('.top_top_login').hasClass('is_visible');
}

$(document).ready(function()
{
    update_live_match();
    
    
    $('td.ticket_add_trigger').click(function() {
        //MINIMAL VALIDATION
        if (is_user == 0) //redirect user to login form, do not add to ticket
        {
            //$('a.top_log').click();
            //return false;
        }
        
        var el = $(this);
        var el_parent = $(this).parent();
        
        var EventID = el.attr('title');
        var Rang = el.attr('headers');
                    
        $.fancybox.showActivity();
        $.ajax(
        {
            type: "POST",
            cache: false,
            url: "soap/ticket/",
            data: 'EventID=' + EventID + '&Rang=' + Rang + '&op=add',
            success: function(html)
            {
                $.fancybox.hideActivity();

                // add or remove hover persisten classes
                el.addClass('hover');

                ticket_update_content(html);
                ticket_show(html);
            }
        });        
    });
    //jGrowl
    
    //$.jGrowl("Semnaleaza erorile sau bugurile pe care le observi pe noul site!<br /><br /><strong>Impreuna putem fi mai buni.</strong><br/><br/><a href='mailto: website@gsbet.ro'>website@gsbet.ro</a>", { life: 20000 });       
    
});

