﻿// JScript File

var lCurrentPos_wg = 0;
function addUserToWG(sUserIDs) {
  var lAction = 0;
  var lCurrentPos = -1;
  
  if (document.getElementById("wgAdd_" + sUserIDs).src.indexOf("/img/user1_preferences.png") >= 0) {
    document.getElementById("wgAdd_" + sUserIDs).src = "/img/user1_add.png";
  } else {
    lAction = 10;
    lCurrentPos = 1;
    document.getElementById("wgAdd_" + sUserIDs).src = "/img/user1_preferences.png";
  }
  
  // Open a connection to the server
  sURL = "/AJAX/WorkingGroups.aspx?lA=" + lAction + "&sU=" + sUserIDs + "&lC=" + lCurrentPos;
  xmlHttp.open("GET", sURL, true);

  // Setup a function for the server to run when it's done
  xmlHttp.onreadystatechange = done;

  // Send the request
  xmlHttp.send(null);
  
  lCurrentPos_wg = 1;
}
function done() {
//    alert("AJAX call done" + xmlHttp.readyState);
}
function removeUserFromWG(lUserID) {
document.getElementById('f_WG').src="/inc/appCtrWorkingGroups.asp?a=2&sU=" + lUserID + "&rnd=" + Math.random() + "&lC=" + lCurrentPos_wg;
  document.getElementById("u_" + lUserID + "_wg").style.display="none";
}
function removeGroupFromWG(lGroupID) {
  document.getElementById('f_WG').src="/inc/appCtrWorkingGroups.asp?a=2&sU=&rnd=" + Math.random() + "&lC=" + lGroupID;
  document.getElementById("g_" + lGroupID + "_wg").style.display="none";
}
function setWGCount(lUserCount, lGroupCount) {
  if (lGroupCount > 0) {
    document.getElementById('s_WG').style.display = "";
    document.getElementById('s_WG_u').innerHTML = lUserCount;
    document.getElementById('s_WG_g').innerHTML = lGroupCount;  
  }
}