var Inquiry = {
    strType:'',    
    /*  */ 
    initStreamPolls: function(pBlock)
    {
        //alert('initStreamPolls');
        pBlock.unbind('mouseover');
        
        pBlock.find('.streampoll').each(function() 
        {
            var nInquiryID = $(this).attr('id').replace('poll', '');    
            // alert(nInquiryID); 
            $(this).find('.itempoll').each(function(nIndex) 
            {
                $(this).click(function(event) { Inquiry.strType = 'stream'; Inquiry.vote(nInquiryID, nIndex+1); event.preventDefault(); }); 
            });
        });
    },
    
    initArticlePolls: function()
    {
        $('.articlepoll').each(function() 
        {
            var nInquiryID = $(this).attr('id').replace('poll', '');
            
            $(this).find('.itempoll').each(function(nIndex) 
            {
                $(this).find('a').click(function(event) { Inquiry.strType = 'article'; Inquiry.vote(nInquiryID, nIndex+1); event.preventDefault(); }); 
            });
        });
    },

    vote: function(nInquiryID, nAnswer) 
    {        
        var params = 'type='+Inquiry.strType;
        
        if(nInquiryID > 0 && nAnswer > 0)
        {
            //alert(strRootPath+'inquiries/vote/answer'+nAnswer+'/'+nInquiryID+'.html');
            $.ajax({
                cache: false,
                data: params,
                url:strRootPath+'inquiries/vote/answer'+nAnswer+'/'+nInquiryID+'.html',
                success: function(data) {
                    // alert(data); 
                    $("#poll"+nInquiryID).replaceWith(data);  
                }
            }); 
        }     
    }
} 
