/*Version: $Id: user_admin.js 1669 2006-01-24 10:10:32Z kglass $*/

/*******************************************/
/* User list popup toolbox menu            */
/*******************************************/

	
function doUserPopUp (editor_href, username, userid, is_staff, noemail ) {
				
	sH=screen.height - 16;
	sW=screen.width - 16;
				
	myPopUp = document.getElementById("popOverHelp");

	if (!myPopUp) {
	    popOverHelp = document.createElement("div");
	    popOverHelp.setAttribute("id","popOverHelp");
	    popOverHelp.setAttribute("visibility","visible");
	    popOverHelp.onclick = Function("hidePopOverHelp(document);");

	    document.getElementsByTagName("body")[0].appendChild(popOverHelp);
	    myPopUp = document.getElementById("popOverHelp");
	} 
	else {
	   while (myPopUp.childNodes.length > 0) {
		myPopUp.removeChild(myPopUp.childNodes[myPopUp.childNodes.length - 1]);
	   }
	}

        myPopUp.style.backgroundColor = '#eeeeee'; 
        myPopUp.style.border = '1px ridge lightgrey'; 
        myPopUp.style.width = '126px';
	
	containerDiv = document.createElement("div");

	containerDiv.setAttribute("style", "position:relative;float:none;clear:both;width:125px;height:auto;vertical-align:middle;margin:2px 0px 0px 0px;padding:0px;");

	myPopUp.appendChild(containerDiv);
				
	span1 = document.createElement("span");
	span1.setAttribute("style","width:125px;height:auto;position:relative;float:left;margin:0px 0px 0px 0px;padding:2px 0px 0px 0px;cursor:pointer;");
	anchor1 = document.createElement("a");
	anchor1.setAttribute("href", "#");
	anchor1.onclick=Function("window.open(\'" + editor_href + "\', \'userEditorWindow\', \'top=10px, left=10px, width=600px, height=545px, status=no, scrollbars=no, resizable=yes\');hidePopOverHelp(document);");
	text1 = document.createTextNode("Edit");

	anchor1.className = 'popupItem';

	anchor1.appendChild(text1);
	span1.appendChild(anchor1);
	containerDiv.appendChild(span1);
				
	containerDiv = document.createElement("div");

	containerDiv.setAttribute("style", "position:relative;float:none;clear:both;width:125px;height:auto;vertical-align:middle;margin:2px 0px 0px 0px;padding:0px;");
	myPopUp.appendChild(containerDiv);
		
	span1 = document.createElement("span");
	span1.setAttribute("style","width:125px;height:auto;position:relative;float:left;margin:0px 0px 0px 0px;padding:0px;");
	anchor1 = document.createElement("a");
	anchor1.setAttribute("href","#");
	anchor1.onclick = Function("window.open(\'/cms/userrights/"+userid+"\', \'\', \'top=0px, left=0px, width=600px, height=545px, menubar=no,location=no,toolbar=no,status=no,scrollbars=yes, resizable=yes\');hidePopOverHelp(document);");
	text1 = document.createTextNode("Security");

	anchor1.className = 'popupItem';
				
	anchor1.appendChild(text1);
	span1.appendChild(anchor1);
	containerDiv.appendChild(span1);

	containerDiv = document.createElement("div");
	containerDiv.setAttribute("style", "position:relative;float:none;clear:both;width:125px;height:auto;vertical-align:middle;margin:2px 0px 0px 0px;padding:0px;");
	myPopUp.appendChild(containerDiv);
		
	span1 = document.createElement("span");
	span1.setAttribute("style","width:125px;height:auto;position:relative;float:left;margin:0px 0px 0px 0px;padding:2px 0px 0px 0px;");
	anchor1 = document.createElement("a");
	anchor1.className = 'popupItem';
	anchor1.setAttribute("href","#");
	anchor1.onclick = Function("window.open(\'/cms/userattribedit/"+userid+"\', \'\', \'top=0px, left=0px, width=600px, height=545px, menubar=no,location=no,toolbar=no,status=no,scrollbars=yes, resizable=yes\');hidePopOverHelp(document);");
	text1 = document.createTextNode("Attributes");
				
	anchor1.appendChild(text1);
	span1.appendChild(anchor1);
	containerDiv.appendChild(span1);

	containerDiv = document.createElement("div");
	containerDiv.setAttribute("style", "position:relative;float:none;clear:both;width:125px;height:auto;vertical-align:middle;margin:2px 0px 0px 0px;padding:0px;");
	myPopUp.appendChild(containerDiv);
		
	span1 = document.createElement("span");
	span1.setAttribute("style","width:125px;height:auto;position:relative;float:left;margin:0px 0px 0px 0px;padding:2px 0px 0px 0px;");
	anchor1 = document.createElement("a");
	anchor1.setAttribute("href","#");
	anchor1.onclick = Function("window.open(\'/cms/userwires/"+userid+"\', \'\', \'top=0px, left=0px, width=600px, height=545px, menubar=no,location=no,toolbar=no,status=no,scrollbars=yes, resizable=yes\');hidePopOverHelp(document);");
	text1 = document.createTextNode("Email settings");
				
	anchor1.className = 'popupItem';
	anchor1.appendChild(text1);
	span1.appendChild(anchor1);
	containerDiv.appendChild(span1);

	containerDiv = document.createElement("div");
	containerDiv.setAttribute("style", "position:relative;float:none;clear:both;width:125px;height:auto;vertical-align:middle;margin:2px 0px 0px 0px;padding:0px;");
	myPopUp.appendChild(containerDiv);
		
	span1 = document.createElement("span");
	span1.setAttribute("style","width:125px;height:auto;position:relative;float:left;margin:0px 0px 0px 0px;padding:2px 0px 0px 0px;");
	anchor1 = document.createElement("a");
	anchor1.setAttribute("href","#");
	anchor1.onclick = Function("window.open(\'/cms/password_popup/"+username+"?popup=1\', \'\', \'top=20px, left=20px, width=500px, height=245px, menubar=no,location=no,toolbar=no,status=no,scrollbars=yes, resizable=yes\');hidePopOverHelp(document);");
	text1 = document.createTextNode("Password");
				
	anchor1.className = 'popupItem';
	anchor1.appendChild(text1);
	span1.appendChild(anchor1);
	containerDiv.appendChild(span1);

	popUpSeparator();

	containerDiv = document.createElement("div");
	containerDiv.setAttribute("style", "position:relative;float:none;clear:both;width:125px;vertical-align:middle;margin:2px 0px 0px 0px;padding:0px;background:red;");
	myPopUp.appendChild(containerDiv);

	if ( is_staff == 'Y' ) {
			
    	   span1 = document.createElement("span");
	   span1.setAttribute("style","width:125px;height:auto;position:relative;float:left;margin:0px 0px 0px 0px;padding:2px 0px 0px 0px;");
	   anchor1 = document.createElement("a");
	   anchor1.setAttribute("href","#");
	   anchor1.onclick = Function("window.open(\'/cms/useredit/"+username+"/staff_directory\', \'\', \'top=20px, left=20px, width=600px, height=600px, menubar=no,location=no,toolbar=no,status=no,scrollbars=yes, resizable=yes\');hidePopOverHelp(document);");

	   text1 = document.createTextNode("Edit Staff profile");
				
	   anchor1.appendChild(text1);
	   anchor1.className = 'popupItem';
	   span1.appendChild(anchor1);
	   containerDiv.appendChild(span1);

 	}

	if ( is_staff == 'N' ) {

    	   span1 = document.createElement("span");
	   span1.setAttribute("style","width:125px;position:relative;float:left;margin:0px 0px 0px 0px;padding:2px 0px 0px 0px;");

	   var form1 = document.createElement("form");
	   form1.setAttribute("name","formAddStaff");
	   form1.setAttribute("id","formAddStaff_"+userid);
	   form1.setAttribute("action","/cms/staffdirectory");
	   form1.setAttribute("method","POST");

	   var hidden1 = document.createElement("input");
	   hidden1.setAttribute("type","hidden");
	   hidden1.setAttribute("name","username");
	   hidden1.setAttribute("value",username);
	   
	   form1.appendChild(hidden1);
	   
	   var hidden2 = document.createElement("input");
	   hidden2.setAttribute("type","hidden");
	   hidden2.setAttribute("name","action");
	   hidden2.setAttribute("value","add");

	   form1.appendChild(hidden2);
	   
	   anchor1 = document.createElement("a");
	   anchor1.setAttribute("href","#");
	   anchor1.onclick = Function("document.getElementById('formAddStaff_"+userid+"').submit();hidePopOverHelp(document);");

	   text1 = document.createTextNode("Create Staff profile");

	   anchor1.className = 'popupItem';
	   anchor1.appendChild(text1);

	   span1.appendChild(anchor1);
	   form1.setAttribute("style","display:none;height:0px;");
	   span1.appendChild(form1);
	   containerDiv.appendChild(span1);

 	}

	popUpSeparator();

        containerDiv = document.createElement("div");
        containerDiv.setAttribute("style", "position:relative;float:left;clear:both;width:100%;height:auto;vertical-align:middle;margin:0px;padding:0px;");
        myPopUp.appendChild(containerDiv);

        span1 = document.createElement("span");
        span1.setAttribute("style","width:100%;height:auto;position:relative;float:left;margin:0px 0px 0px 0px;padding:0px;");
        anchor1 = document.createElement("a");
        anchor1.setAttribute("href","/cms/logout");
        text1 = document.createTextNode("Logout");
        anchor1.className = 'popupItem';

        anchor1.appendChild(text1);
        span1.appendChild(anchor1);
        containerDiv.appendChild(span1);

};				

function popUpSeparator() {
                containerDiv = document.createElement("div");
                containerDiv.setAttribute("style", "position:relative;float:none;clear:both;width:125px;height:auto;vertical-align:middle;margin:0px;")

                myPopUp.appendChild(containerDiv);
                
                span1 = document.createElement("span");
                span1.setAttribute("style","display:inline;width:125px;position:relative;height:1px;float:left;clear:both;margin-top:5px;padding-top;5px;border-bottom:1px solid darkgrey;");
                        
                var detect = navigator.userAgent.toLowerCase();
                if ( detect.indexOf('msie') + 1 ) {
                   var img1 = document.createElement("img");
                   img1.setAttribute("src","/global/images/icons/nav_separator_line.gif");
                   img1.setAttribute("style","width:100px;");
                   span1.appendChild(img1);
                }
        
        
                containerDiv.appendChild(span1);

                span1 = document.createElement("span");
                span1.setAttribute("style","width:125px;position:relative;float:left;clear:both;margin-bottom:5px;");
                text1 = document.createTextNode("");
        
                span1.appendChild(text1); 
                containerDiv.appendChild(span1);
}

document.getElementsByClass = function (needle)
{
  var         my_array = document.getElementsByTagName("*");
  var         retvalue = new Array();
  var        i = 0;
  var        j = 0;

  for (i = 0, j= 0; i < my_array.length; i++)
  {
    var c = " " + my_array[i].className + " ";
    if (c.indexOf(" " + needle + " ") != -1)
      retvalue[j++] = my_array[i];
  }
  return retvalue;
}

