function ConfirmMsg(msg) {
document.returnValue = confirm(msg);
}

function add(id)
{
    cart_window = window.open('http://topcinema.ru/cart/index.php?id='+id+'&s=2', 'cart', 'width=790, height=700, toolbar=no, scrollbars=yes');
    cart_window.focus();
}

function init()
{
    $(".text_button")
        
        .bind("mouseover", function() 
        {   
            $(this).addClass("text_button_hover");
        })
        
        .bind("mouseout", function() 
        {
            $(this).removeClass("text_button_hover");
        })
        
        .bind("click", function()
        {
            eval($(this).attr("callback"));
        });
    
    $(".season_link, .serial_link")
        
        .bind("mouseover", function() 
        {   
            $(this).addClass("fc3f86f0 underline");
        })
        
        .bind("mouseout", function() 
        {
            $(this).removeClass("fc3f86f0 underline");
        })
        
        .bind("click", function()
        {
            eval($(this).attr("callback"));
        });
        
    $(".comment_form_button")
        
        .bind("mouseover", function() 
        {   
            $(this).addClass("comment_form_button_hover");
        })
        
        .bind("mouseout", function() 
        {
            $(this).removeClass("comment_form_button_hover");
        })
        
        .bind("click", function()
        {
            eval($(this).attr("callback"));
        });
        
    $("#comment_submit")
        
        .bind("mouseover", function() 
        {   
            $(this).addClass("comment_submit_hover");
        })
        
        .bind("mouseout", function() 
        {
            $(this).removeClass("comment_submit_hover");
        })
        
        .bind("click", function()
        {
            nick = $("#nick").attr("value");
            serial_id = $("#serial_id").attr("value");
            comment = $("#comment").val();
            request({id: serial_id, nick: nick, comment: comment});
        });
        
        $("div[link]").bind("click", function()
        {
            go_($(this).attr("link"));
        }).hoverclass("menu_link_hover");
}

function go_(link)
{
    if ( link != document.location )
    {
        window.location.href = link;
    }
}

function request(q)
{
    $.post('request.php', {q: $.toJSON(q)}, function (data)
    {   
        eval(data);
    });
}

function request_html(instance, q)
{
    $.post('request.php', {q: $.toJSON(q)}, function (data)
    {   
        //$("#test").html(data) 
        $(instance).html(data);
    });
}

function tdata(id)
{
    $("#tdata"+id).toggleClass("hidden");
}

$.fn.hoverclass = function(classname)
{
    $(this)
        .bind("mouseover", function()
        {
            $(this).addClass(classname);
        })
        .bind("mouseout", function()
        {
            $(this).removeClass(classname);
        });
    
    return this;
}