function print_r(arr, level) {
    var print_red_text = "";
    if(!level) level = 0;
    var level_padding = "";
    for(var j=0; j<level+1; j++) level_padding += "    ";
    if(typeof(arr) == 'object') {
        for(var item in arr) {
            var value = arr[item];
            if(typeof(value) == 'object') {
                print_red_text += level_padding + "'" + item + "' :<br />";
                print_red_text += print_r(value,level+1);
        }
            else
                print_red_text += level_padding + "'" + item + "' => \"" + value + "\"<br />";
        }
    }

    else  print_red_text = "===>"+arr+"<===("+typeof(arr)+")";
    return print_red_text;
}


var countid=0;
var nosel=false;

//var ress={1:{divopt:'<div id="voteo1" style="display:none;">text2<br /><a href="javascript:void(0);" onClick="tores(1);">res</a></div>',divres:'<div id="voter1" style="display:none;">res2<br /><a href="javascript:void(0);" onClick="tovot(1);">vote</a></div>',data:'{opt1:1,res1:1}'},2:{divopt:'',divres:'<div id="voter2" style="display:none;">res3</div>',data:'{opt2:0,res2:1}'},3:{divopt:'',divres:'<div id="voter3" style="display:none;">res4</div>',data:'{opt3:0,res3:1}'},4:{divopt:'<div id="voteo4" style="display:none;">text5<br /><a href="javascript:void(0);" onClick="tores(4);">res</a></div>',divres:'<div id="voter4" style="display:none;">res5<br /><a href="javascript:void(0);" onClick="tovot(4);">vote</a></div>',data:'{opt4:1,res4:1}'}};

function go(id) {
    return document.getElementById(id);
}

function tores(id) {
    go('voteo'+id).style.display='none';
	go('voter'+id).style.display='block';
}

function tovot(id) {
    go('voter'+id).style.display='none';
	go('voteo'+id).style.display='block';
}

function uuu() {
    //go('loadcount').innerHTML=loadcount+'';
    //go('countid').innerHTML=countid+'';
    //go('blocks').innerHTML=print_r(blocks);
}

function rClk() {
 if (!nosel) {
    countid++;
    countid=(countid>(allcount-1))?allcount-1:countid;
    uuu();
    if (loaded[countid]==0) {
       var oldVote=go('voteDinamic').innerHTML;

        nosel=true;
        var ajax = new dle_ajax();
        ajax.requestFile = "ajax/voteidx.php";
        ajax.setVar("moveid", countid);
        ajax.setVar("vci", vci);
        ajax.method = 'GET';
        ajax.element = 'qqq';
        ajax.executeJSON = true;

        ajax.onCompletion = function() {

            loaded[countid]=1;
            var ress=eval('('+ajax.response+')');
            var www=eval('('+ress['data']+')');
            for(var item in www) { blocks[item]=www[item]; }
            go('voteDinamic').innerHTML=oldVote+ress['divvote'];
            //if (blocks['opt'+(countid-1)]!=0) {go('vote'+(countid-1)).style.display='none';}
            go('vote'+(countid-1)).style.display='none';
            go('vote'+countid).style.display='block';
            go('cpages').innerHTML=(countid+1)+' / '+allcount;
            nosel=false;
        }
        ajax.sendAJAX('');
    } else {
            //if (blocks['opt'+(countid-1)]!=0) {go('vote'+(countid-1)).style.display='none';}
            go('vote'+(countid-1)).style.display='none';
            go('vote'+countid).style.display='block';
            go('cpages').innerHTML=(countid+1)+' / '+allcount;
    }
 }
}


function lClk() {
 if (!nosel) {
	countid--;
	countid=(countid<0)?0:countid;
	uuu();
	//if (blocks['opt'+(countid+1)]!=0) {go('vote'+(countid+1)).style.display='none';}
	go('vote'+(countid+1)).style.display='none';
	go('vote'+countid).style.display='block';
	go('cpages').innerHTML=(countid+1)+' / '+allcount;
 }
}


function doVote(vid) {
    var ajax = new dle_ajax();
    var formobj=document.getElementById('fvoter'+vid);
    var isvote=false;
    for (var i = 0; i < formobj.vitem.length; i++) {
      if (formobj.vitem[i].checked) {ajax.setVar("vitem", formobj.vitem[i].value); isvote=true;}
    }

    if (isvote) {
      ajax.setVar("voteidx", vid);
      ajax.requestFile = "ajax/voteidx.php";
      ajax.method = 'GET';
      ajax.element = 'voter'+vid;
      ajax.onCompletion = function() {      	  go('voteo'+vid).style.display='none';
      	  go('voter'+vid).style.display='block';
      	  blocks['opt'+vid]=0;
      }
      ajax.sendAJAX('');
    }

    return false;

}



function a(sss) {
var old=document.getElementById('qqq1').innerHTML;
document.getElementById('qqq1').innerHTML=old+sss;
}