﻿
if ( typeof( travelport ) != "undefined" ) {
            
    function pollResults() {
        var aIndiVotes = new Array();
        var voteTotal = 0;
        for(i=0; i<$(".PollOptionResult").length; i++) {
            varThisVoteCounter = ($(".PollOptionResult:eq(" + i + ")").html() * 1)
            voteTotal += varThisVoteCounter;
            aIndiVotes[i] = varThisVoteCounter;
        }
        for(i=0; i<aIndiVotes.length; i++) {
            var thisPercent = (aIndiVotes[i]/voteTotal) * 100;
            var thisPercentInt = Math.floor(thisPercent/2);
            var replacementCode = "<div class='pollResultContainer'><span>" + Math.floor(thisPercent) + "%</span><div class='pollResultPercent'><img src='/images/common/pxl_poll_results.gif' height='5' width='" + thisPercentInt  + "' alt='" + thisPercentInt + "%' /></div></div>"
            $(".PollOptionResult:eq(" + i + ")").html(replacementCode);
        }
    }        
    
    $(document).ready(function() { travelport.web.pollResults = new pollResults(); })
         
}
