<script type="text/javascript">
if(!window.voteScript) window.voteScript =
{
trace_vote: function(div, flag)
{
var my_div;
var r = div.id.match(/^vote_(\d+)_(\d+)$/);
for(var i = r[2]; i >= 0; i--)
{
my_div = document.getElementById('vote_'+r[1]+'_'+i);
if(my_div)
{
if(flag)
{
if(!my_div.saved_class)
my_div.saved_className = my_div.className;
if(my_div.className!='star-active star-over')
my_div.className = 'star-active star-over';
}
else
{
if(my_div.saved_className && my_div.className != my_div.saved_className)
my_div.className = my_div.saved_className;
}
}
}
i = r[2]+1;
while(my_div = document.getElementById('vote_'+r[1]+'_'+i))
{
if(my_div.saved_className && my_div.className != my_div.saved_className)
my_div.className = my_div.saved_className;
i++;
}
},
do_vote: function(div, parent_id, arParams)
{
var r = div.id.match(/^vote_(\d+)_(\d+)$/);
var vote_id = r[1];
var vote_value = r[2];
function __handler(data)
{
var obContainer = document.getElementById(parent_id);
if (obContainer)
{
var obResult = document.createElement("DIV");
obResult.innerHTML = data;
obContainer.parentNode.replaceChild(obResult.firstChild, obContainer);
}
}
PShowWaitMessage('wait_' + parent_id, true);
var url = '/bitrix/components/bitrix/iblock.vote/component.php'
arParams['vote'] = 'Y';
arParams['vote_id'] = vote_id;
arParams['rating'] = vote_value;
var TID = CPHttpRequest.InitThread();
CPHttpRequest.SetAction(TID, __handler);
CPHttpRequest.Post(TID, url, arParams);
}
}
</script>
|