

function processingDownArrowPending(user,el,id,ia,pop,section){
 if(ia==1){
   $.get("lib/pending.php", { action: "pendingranked", id: -1, article: id}, function(data){
      k = 0;
      var elSel = document.getElementById("admin_userratingname");
      elSel.onchange = function() { processingDownArrowPending(this.options[this.selectedIndex].value,document.xform.admin_userrating_el.value,document.xform.admin_userrating_id.value,0,1,section); }
      results = data.split("|");
      for(i=0;i<results.length-1;i=i+2){
        var elOptNew = document.createElement('option');
        elOptNew.text = results[i];
        elOptNew.value = results[i+1];
        try{
          elSel.add(elOptNew, null); // standards compliant
        }
        catch(ex){
          elSel.add(elOptNew); // IE only
        }
      }
      document.getElementById("admin_userrating_user").value = user;
	  document.getElementById("admin_userrating_el").value = el;
      document.getElementById("admin_userrating_id").value = id;
      popup_show('popup', 'popup_drag', 'popup_exit', 'mouse',-10, -10,user,el,id,-1);
	 });
  } else {
    action = getAction(section);
   $("#"+el).fadeOut("slow", function(){
    $.get("lib/pending.php", { action: action, id: user, article: id, vote: -1 }, function(data){
      results = data.split("|");
      d = results[0];
      sc = results[1];
      lev = results[2];

      if(d == 1){
          location.redirect("/recent/new/");
      } else if(d == 2){
          location.redirect("/errorlog/new/");
      } else {
        if(pop==1){
          exitadpop();
          $("#"+el).fadeIn("slow");
          scxf(id,sc,lev,section);
        } else {
          scxf_na(id,lev,section);
          pendingDownArrowDone(el,id,0,user,section);
        }
      }
      });
    });
  }
}
function processingUpArrowPending(user,el,id,ia,pop,section){
 if(ia==1){
   $.get("lib/pending.php", { action: "pendingranked", id: -1, article: id}, function(data){
      k = 0;
      var elSel = document.getElementById("admin_userratingname");
      elSel.onchange = function() { processingUpArrowPending(this.options[this.selectedIndex].value,document.xform.admin_userrating_el.value,document.xform.admin_userrating_id.value,0,1,section); }
      results = data.split("|");
      for(i=0;i<results.length-1;i=i+2){
        var elOptNew = document.createElement('option');
        elOptNew.text = results[i];
        elOptNew.value = results[i+1];
        try{
          elSel.add(elOptNew, null); // standards compliant
        }
        catch(ex){
          elSel.add(elOptNew); // IE only
        }
      }
      document.getElementById("admin_userrating_user").value = user;
	  document.getElementById("admin_userrating_el").value = el;
      document.getElementById("admin_userrating_id").value = id;
      popup_show('popup', 'popup_drag', 'popup_exit', 'mouse',-10, -10,user,el,id,-1);
	 });
  } else {
 $("#"+el).fadeOut("slow", function(){
    action = getAction(section);
    $.get("lib/pending.php", { action: action, id: user, article: id, vote: 1 }, function(data){
      results = data.split("|");
      d = results[0];
      sc = results[1];
      lev = results[2];

      if(d == 1){
        location.redirect("/recent/new/");
      } else if(d == 2){
        location.redirect("/errorlog/new/");
      } else {
        if(pop==1){
          exitadpop();
          $("#"+el).fadeIn("slow");
          scxf(id,sc,lev,section);
        } else {
          scxf_na(id,lev,section);
          pendingUpArrowDone(el,id,0,user,section);
        }
      }
      });
    });
  }
}
function getAction(section){
  if(section == '_site'){
    result = "pendingvote";
  } else if(section == '_art'){
    result = "pendingarticlevote";
  } else if(section == '_user'){
    result = "pendinguservote";
  } else if(section == '_link'){
    result = "pendinglinkvote";
  } else {
    result = "";
  }
  return(result);
}
function scxf_na(id,lev,section){
  var colorArray=new Array(11);colorArray[0]="#ff0000";colorArray[1]="#cc0000";colorArray[2]="#990000";colorArray[3]="#660000";colorArray[4]="#330000";colorArray[5]="#000000";colorArray[6]="#003300";colorArray[7]="#006600";colorArray[8]="#009900";colorArray[9]="#00cc00";colorArray[10]="#00ff00";
  document.getElementById('level'+section+id).value = lev;
  if(section == '_link' || section == '_art'){
    classname = "pendinglinklight";
  } else {
    classname = "pendinglink";
  }
  document.getElementById("pendinglink"+section+id).className = classname+lev;
}
function scxf(id,sc,lev,section){
  scxf_na(id,lev,section)
  $('#scx'+section+id).fadeOut("fast", function(){
    var s = parseInt(document.getElementById('scx'+section+id).innerHTML);
    document.getElementById('scx'+section+id).innerHTML = parseInt(s) + parseInt(sc);
    $('#scx'+section+id).fadeIn("fast");
  });
}
function pendingUpArrowDone(el,id,a,user,section){
  var swapel = el.replace('up','down');
  toggleUp(el,id,0,a,user,section);
  $('#'+el).fadeIn('slow');

  $('#'+swapel).fadeOut('fast', function(){
    toggleDown(swapel,id,1,a,user,section);
    $('#'+swapel).fadeIn('fast');
  });

  $('#pendinglink'+section+id).fadeOut('fast', function(){
    $('#pendinglink'+section+id).fadeIn('fast');
  });
}
function pendingDownArrowDone(el,id,a,user,section){
  var swapel = el.replace('down','up');
  toggleDown(el,id,0,a,user,section);
  $('#'+el).fadeIn('slow');

  $('#'+swapel).fadeOut('fast', function(){
    toggleUp(swapel,id,1,a,user,section);
    $('#'+swapel).fadeIn('fast');
  });

  $('#pendinglink'+section+id).fadeOut('fast', function(){
    $('#pendinglink'+section+id).fadeIn('fast');
  });
}
function toggleUp(el,id,t,a,user,section){
  x=document.getElementById(el);
  if(t==1){
    x.innerHTML = '<a href=javascript:processingUpArrowPending('+user+',"uparrowwrap'+section+id+'",'+id+','+a+',0,"'+section+'") onMouseOver="uparrowover(\'uparrow1'+section+id+'\');" onMouseOut="uparrowout(\'uparrow1'+section+id+'\');"><div id="uparrow1'+section+id+'" class="uparrow"><em class="ua1"></em><em class="ua2"></em><em class="ua3"></em><em class="ua4"></em><em class="ua5"></em><em class="ua6"></em><em class="ua7"></em><em class="ua8"></em><em class="ua9"></em></div></a>';
  } else {
    x.innerHTML = '<div id="uparrow1'+section+id+'" class="uparrow"><em class="uaF1"></em><em class="uaF2"></em><em class="uaF3"></em><em class="uaF4"></em><em class="uaF5"></em><em class="uaF6"></em><em class="uaF7"></em><em class="uaF8"></em><em class="uaF9"></em></div>';
  }
}
function toggleDown(el,id,t,a,user,section){
  x=document.getElementById(el);
  if(t==1){
    x.innerHTML = '<a href=javascript:processingDownArrowPending('+user+',"downarrowwrap'+section+id+'",'+id+','+a+',0,"'+section+'") onMouseOver="downarrowover(\'downarrow1'+section+id+'\');" onMouseOut="downarrowout(\'downarrow1'+section+id+'\');"><div id="downarrow1'+section+id+'" class="downarrow"><em class="dap1"></em><em class="dap2"></em><em class="dap3"></em><em class="dap4"></em><em class="dap5"></em><em class="dap6"></em><em class="dap7"></em><em class="dap8"></em><em class="dap9"></em></div></a>';
  } else {
    x.innerHTML = '<div id="downarrow1'+section+id+'" class="downarrow"><em class="dapF1"></em><em class="dapF2"></em><em class="dapF3"></em><em class="dapF4"></em><em class="dapF5"></em><em class="dapF6"></em><em class="dapF7"></em><em class="dapF8"></em><em class="dapF9"></em></div>';
  }
}
function arrowdone(el,id,section){
  var starel = document.getElementById(el);
  starel.innerHTML = "<span class=\"downarrowwrap\" id=\"downarrowwrap"+section+id+"\"><div id=\"downarrow1"+section+id+"\" class=\"downarrow\"><em class=\"daF1\"></em><em class=\"daF2\"></em><em class=\"daF3\"></em><em class=\"daF4\"></em><em class=\"daF5\"></em><em class=\"daF6\"></em><em class=\"daF7\"></em><em class=\"daF8\"></em><em class=\"daF9\"></em><span id=\"downarrowrating"+id+"\">"+rating+"</span></div></span>";
}
/*
function changePendingLed(id,section){
  var level = document.getElementById('level'+section+id).value;
  clearPendingLed();
  if(level < 0) level = 0;
  document.getElementById('pendingposition'+level).innerHTML = '*';
}
function clearPendingLed(section){
  for(i=0;i<11;i++){
    document.getElementById('pendingposition'+i).innerHTML = '&nbsp;&nbsp;';
  }
}
*/
function changePendingLed(pid,id){
  var level = document.getElementById('level'+id+pid).value;
  clearPendingLed(pid,id);
  if(level < 0) level = 0;
  document.getElementById('pendingposition_'+pid+'_'+level).innerHTML = '*';
}
function clearPendingLed(pid,id){
  for(i=0;i<11;i++){
    document.getElementById('pendingposition_'+pid+'_'+i).innerHTML = '&nbsp;&nbsp;';
  }
}
function processingPendingPlus(id,section){
  if(document.getElementById("pendingArticles"+section+id).innerHTML == ''){
    $("#pendingArticles"+section+id).slideUp("fast", function(){
      $.get("lib/pending.php", { action: "pendingarticles", id: -1, article: id }, function(data){
        results = data.split("|");
        links = '';
        for(i=0;i<results.length-1;i=i+1){
          links += results[i]+'<br>';
        }
        document.getElementById("pendingArticles"+section+id).innerHTML = links;
        $("#pendingArticles"+section+id).slideDown("slow");
       });
     });
  } else {
    $("#pendingArticles"+section+id).slideDown("slow");
  }
  document.getElementById("pluswrap"+section+id).innerHTML = makeMinus(id,section);
}
function processingPendingMinus(id,section){
  $("#pendingArticles"+section+id).slideUp("slow");
  document.getElementById("pluswrap"+section+id).innerHTML = makePlus(id,section);
}
function makePlus(id,section){
  return('<a href=javascript:processingPendingPlus('+id+',\''+section+'\') onMouseOver="pluschange(\'plus1_'+id+'\',plusovercolor);" onMouseOut="pluschange(\'plus1_'+id+'\',plusbasecolor);"><div id="plus1_'+id+'" class="uparrow"><em class="plus1"></em><em class="plus2"></em><em class="plus3"></em><em class="plus4"></em><em class="plus5"></em><em class="plus6"></em><em class="plus7"></em><em class="plus8"></em><em class="plus9"></em></div></a>');
}
function makeMinus(id,section){
  return('<a href=javascript:processingPendingMinus('+id+',\''+section+'\') onMouseOver="minuschange(\'minus1_'+id+'\',minusovercolor);" onMouseOut="minuschange(\'minus1_'+id+'\',minusbasecolor);"><div id="minus1_'+id+'" class="minus"><em class="minus1"></em><em class="minus2"></em><em class="minus3"></em><em class="minus4"></em><em class="minus5"></em><em class="minus6"></em><em class="minus7"></em><em class="minus8"></em><em class="minus9"></em></div></a>');
}
function uparrowout(uparrow){
  var uparrowel = document.getElementById(uparrow);
  var el1 = uparrowel.firstChild;
  var el2 = el1.nextSibling;
  var el3 = el2.nextSibling;
  var el4 = el3.nextSibling;
  var el5 = el4.nextSibling;
  var el6 = el5.nextSibling;
  var el7 = el6.nextSibling;
  var el8 = el7.nextSibling;
  var el9 = el8.nextSibling;
/*
  el1.style.background = "#009900";
  el2.style.background = "#009900";
  el3.style.background = "#24A724";
  el4.style.background = "#24A724";
  el5.style.background = "#47B547";
  el6.style.background = "#47B547";
  el7.style.background = "#6BC46B";
  el8.style.background = "#8ED28E";
  el9.style.background = "#B2E0B2";
*/
  el1.style.background = "#DDDDDD";
  el2.style.background = "#DDDDDD";
  el3.style.background = "#DDDDDD";
  el4.style.background = "#DDDDDD";
  el5.style.background = "#DDDDDD";
  el6.style.background = "#DDDDDD";
  el7.style.background = "#DDDDDD";
  el8.style.background = "#DDDDDD";
  el9.style.background = "#DDDDDD";
}
function uparrowover(uparrow){
  var uparrowel = document.getElementById(uparrow);
  var el1 = uparrowel.firstChild;
  var el2 = el1.nextSibling;
  var el3 = el2.nextSibling;
  var el4 = el3.nextSibling;
  var el5 = el4.nextSibling;
  var el6 = el5.nextSibling;
  var el7 = el6.nextSibling;
  var el8 = el7.nextSibling;
  var el9 = el8.nextSibling;
  el1.style.background = "#000000";
  el2.style.background = "#000000";
  el3.style.background = "#222222";
  el4.style.background = "#222222";
  el5.style.background = "#444444";
  el6.style.background = "#444444";
  el7.style.background = "#666666";
  el8.style.background = "#888888";
  el9.style.background = "#AAAAAA";
}
function downarrowout(uparrow){
  var uparrowel = document.getElementById(uparrow);
  var el1 = uparrowel.firstChild;
  var el2 = el1.nextSibling;
  var el3 = el2.nextSibling;
  var el4 = el3.nextSibling;
  var el5 = el4.nextSibling;
  var el6 = el5.nextSibling;
  var el7 = el6.nextSibling;
  var el8 = el7.nextSibling;
  var el9 = el8.nextSibling;
/*
  el1.style.background = "#FFD5D5";
  el2.style.background = "#FFAAAA";
  el3.style.background = "#FF8080";
  el4.style.background = "#FF5555";
  el5.style.background = "#FF5555";
  el6.style.background = "#FF2B2B";
  el7.style.background = "#FF2B2B";
  el8.style.background = "#FF0000";
  el9.style.background = "#FF0000";
*/
  el1.style.background = "#DDDDDD";
  el2.style.background = "#DDDDDD";
  el3.style.background = "#DDDDDD";
  el4.style.background = "#DDDDDD";
  el5.style.background = "#DDDDDD";
  el6.style.background = "#DDDDDD";
  el7.style.background = "#DDDDDD";
  el8.style.background = "#DDDDDD";
  el9.style.background = "#DDDDDD";
}
function downarrowover(uparrow){
  var uparrowel = document.getElementById(uparrow);
  var el1 = uparrowel.firstChild;
  var el2 = el1.nextSibling;
  var el3 = el2.nextSibling;
  var el4 = el3.nextSibling;
  var el5 = el4.nextSibling;
  var el6 = el5.nextSibling;
  var el7 = el6.nextSibling;
  var el8 = el7.nextSibling;
  var el9 = el8.nextSibling;
  el1.style.background = "#AAAAAA";
  el2.style.background = "#888888";
  el3.style.background = "#666666";
  el4.style.background = "#444444";
  el5.style.background = "#444444";
  el6.style.background = "#222222";
  el7.style.background = "#222222";
  el8.style.background = "#000000";
  el9.style.background = "#000000";
}
var plusovercolor= "#000";
var plusbasecolor = "#DDDDDD";
var plusbasedarkcolor = "#0033CC";
function pluschange(plus,color){
  var plusel = document.getElementById(plus);
  var el1 = plusel.firstChild;
  var el2 = el1.nextSibling;
  var el3 = el2.nextSibling;
  var el4 = el3.nextSibling;
  var el5 = el4.nextSibling;
  var el6 = el5.nextSibling;
  var el7 = el6.nextSibling;
  var el8 = el7.nextSibling;
  var el9 = el8.nextSibling;
  el1.style.background = color;
  el2.style.background = color;
  el3.style.background = color;
  el4.style.background = color;
  el5.style.background = color;
  el6.style.background = color;
  el7.style.background = color;
  el8.style.background = color;
  el9.style.background = color;
}

var minusovercolor= "#000";
var minusbasecolor = "#DDDDDD";
var minusbasedarkcolor = "#0033CC";
function minuschange(minus,color){
  var minusel = document.getElementById(minus);
  var el1 = minusel.firstChild;
  var el2 = el1.nextSibling;
  var el3 = el2.nextSibling;
  var el4 = el3.nextSibling;
  var el5 = el4.nextSibling;
  var el6 = el5.nextSibling;
  var el7 = el6.nextSibling;
  var el8 = el7.nextSibling;
  var el9 = el8.nextSibling;
  //el1.style.background = color;
  //el2.style.background = color;
  //el3.style.background = color;
  el4.style.background = color;
  el5.style.background = color;
  el6.style.background = color;
  //el7.style.background = color;
  //el8.style.background = color;
  //el9.style.background = color;
}
