/* 
    author: mosquito 
    email: kpi.mosquito@gmail.com
*/

$(document).ready(function(){
    $("ul.voting a").each(function(){
        $(this).text("");
    });
    
    $("ul.voting a").live("click", function(){
        $.ajax({
            type:       'post',
            url:        '/ajax_vote.php?pid='+$(this).attr("pid")+'&value='+$(this).attr("value"),
            success:    function(response){ 
                data = eval('(' + response + ')');
                alert(data.info_msg);
                    
                if (data.rating_msg != null){
                    $("ul.voting").html(data.rating_msg);
                }
            }
        }); 

        return false;
    });

    $("td.products_image").mouseover(function(){   
        $("div.productInfo", $(this)).css({"left": Math.round($(this).offset().left + 50) });
        $("div.productInfo", $(this)).css({"top": Math.round($(this).offset().top + 50) });
        
        $("div.productInfo", $(this)).css({"display": "block"});
    });

    $("td.products_image").mouseout(function(){   
        $("div.productInfo", $(this)).css({"display": "none"});
    });
});
