var bgSwap = '';
var myHiEl = ''; //global variable shared between mouseover and mouseout

function doStaffPopUp (userid, staffid, username, photo, title, firstname, lastname, photo2 ) {

        var myRegExp = /'/;
        firstname = firstname.replace(myRegExp,"%27");
        lastname = lastname.replace(myRegExp,"%27");

        if ( title.length == 0 ) {
           title = firstname + ' '+lastname;
        }

        var myRegExp = /'/;
        title = title.replace(myRegExp,"%27");
        if ( photo ) {
           photo = photo.replace(myRegExp,"%27");
        }
        if ( photo2 ) {
           photo2 = photo2.replace(myRegExp,"%27");
       	} 
	sH=screen.height - 16;
	sW=screen.width - 16;
	
	myPopUp = document.getElementById("popOverHelp");

	if (!myPopUp) {
   	   popOverHelp = document.createElement("div");
	   popOverHelp.setAttribute("id","popOverHelp");
	   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 = '121px';

		containerDiv = document.createElement("div");
		containerDiv.setAttribute("style", "position:relative;float:none;clear:both;width:120px;height:auto;vertical-align:middle;margin:2px 0px 0px 0px;padding:0px;");
		myPopUp.appendChild(containerDiv);
		
		span1 = document.createElement("span");
		span1.setAttribute("style","width:120px;height:auto;position:relative;float:left;margin:0px;padding:2px 0px 2px 0px;cursor:pointer;");
		anchor1 = document.createElement("a");
		anchor1.setAttribute("href", "#");
		anchor1.className = 'popupItem';
	
		anchor1.onclick=Function("window.open(\'/cms/staffeditor/"+userid+"?bio=professional\', \'staffEditorWindow\', \'top=20px, left=20px, width=600px, height=545px, status=no, scrollbars=no, resizable=yes\');hidePopOverHelp(document);");
		text1 = document.createTextNode("Professional profile");

		anchor1.appendChild(text1);
		span1.appendChild(anchor1);
		containerDiv.appendChild(span1);
		
		containerDiv = document.createElement("div");
		containerDiv.setAttribute("style", "position:relative;float:none;clear:both;width:120px;height:auto;vertical-align:middle;margin:2px 0px 0px 0px;padding:0px;");
		myPopUp.appendChild(containerDiv);
		
		span1 = document.createElement("span");
		span1.setAttribute("style","width:120px;height:auto;position:relative;float:left;margin:0px;padding:2px 0px 2px 0px;cursor:pointer;");
		anchor1 = document.createElement("a");
		anchor1.setAttribute("href", "#");
		anchor1.className = 'popupItem';
	
		anchor1.onclick=Function("window.open(\'/cms/staffeditor/"+userid+"?bio=personal\', \'staffEditorWindow\', \'top=20px, left=20px, width=600px, height=545px, status=no, scrollbars=no, resizable=yes\');hidePopOverHelp(document);");
		text1 = document.createTextNode("Personal profile");

		anchor1.appendChild(text1);
		span1.appendChild(anchor1);
		containerDiv.appendChild(span1);

        containerDiv = document.createElement("div");
        containerDiv.setAttribute("style", "position:relative;float:none;clear:both;width:120px;height:auto;vertical-align:middle;margin:2px 0px 2px 0px;padding:0px;");
        myPopUp.appendChild(containerDiv);

        span1 = document.createElement("span");
        span1.setAttribute("style","width:120px;height:auto;position:relative;float:left;margin:0px 0px 0px 0px;padding:0px;cursor:pointer;");
        anchor1 = document.createElement("a");
        anchor1.setAttribute("href", "#");
	anchor1.className = 'popupItem';
        anchor1.onclick=Function("window.open(\'/cms/staffattribeditor/" + staffid + "\', \'staffAttEditorWindow\', \'top=20px, left=20px, width=600px, height=545px, status=no, scrollbars=no, resizable=yes\');hidePopOverHelp(document);");
        text1 = document.createTextNode("Attributes");

        anchor1.appendChild(text1);
        span1.appendChild(anchor1);
        containerDiv.appendChild(span1);
	popUpSeparator(myPopUp);

	containerDiv = document.createElement("div");
	containerDiv.setAttribute("style", "position:relative;float:none;clear:both;width:120px;height:auto;vertical-align:middle;margin:2px 0px 0px 0px;padding:0px;");
	myPopUp.appendChild(containerDiv);
		
	span1 = document.createElement("span");
	span1.setAttribute("style","width:116px;height:auto;position:relative;float:left;margin:0px;padding:2px 0px 0px 4px;text-align:left;font-size:1.0em;");

	text1 = document.createTextNode('Photos');
	span1.appendChild(text1);
	containerDiv.appendChild(span1);

	containerDiv = document.createElement("div");
	containerDiv.setAttribute("style", "position:relative;float:left;clear:both;width:61px;height:auto;vertical-align:middle;margin:0px 0px 0px 0px;padding:0px;");
	myPopUp.appendChild(containerDiv);

	containerDiv = document.createElement("div");
	containerDiv.setAttribute("style", "position:relative;float:left;clear:both;width:61px;height:auto;vertical-align:middle;margin:0px 0px 0px 0px;padding:0px;");
	myPopUp.appendChild(containerDiv);

	span1 = document.createElement("span");
	span1.setAttribute("style","width:120px;height:auto;position:relative;float:left;margin:0px 2px 0px 0px;padding:2px 1px 2px 0px;cursor:pointer;");
	anchor1 = document.createElement("a");
	anchor1.setAttribute("href", "#");
	anchor1.onclick=Function("window.open(\'/cms/staffeditor?Command=FileUpload&legend=" + title + "&response=updateclose&username="+username+"\', \'contentCatEditorWindow\', \'top=200px, left=200px, width=450px, height=100px, status=no, scrollbars=no, resizable=yes\');hidePopOverHelp(document);");
	text1 = document.createTextNode("Add Professional");

	anchor1.className = 'popupItem';

	anchor1.appendChild(text1);
	span1.appendChild(anchor1);
	containerDiv.appendChild(span1);	 


	if ( photo.length > 1 ) {
   	   containerDiv = document.createElement("div");
	   containerDiv.setAttribute("style", "position:relative;float:left;clear:both;width:61px;height:auto;vertical-align:middle;margin:0px 0px 0px 0px;padding:0px;");
	   myPopUp.appendChild(containerDiv);

	   span1 = document.createElement("span");
	   span1.setAttribute("style","width:120px;height:auto;position:relative;float:left;margin:0px 2px 0px 0px;padding:2px 1px 2px 0px;cursor:pointer;");
   	   anchor1 = document.createElement("a");
	   anchor1.setAttribute("href", "#");
	   anchor1.onclick=Function("window.open(\'/cms/staffeditor?Command=FileUpload&legend=" + title + "&response=closerefresh&replace="+photo+"\', \'contentCatEditorWindow\', \'top=200px, left=200px, width=450px, height=100px, status=no, scrollbars=no, resizable=yes\');hidePopOverHelp(document);");

	   text1 = document.createTextNode("Replace Professional");

	   anchor1.className = 'popupItem';

	   anchor1.appendChild(text1);
	   span1.appendChild(anchor1);
	   containerDiv.appendChild(span1);	 
        }

	containerDiv = document.createElement("div");
	containerDiv.setAttribute("style", "position:relative;float:left;clear:both;width:61px;height:auto;vertical-align:middle;margin:0px 0px 0px 0px;padding:0px;");
	myPopUp.appendChild(containerDiv);

	span1 = document.createElement("span");
	span1.setAttribute("style","width:120px;height:auto;position:relative;float:left;margin:0px 2px 0px 0px;padding:2px 1px 2px 0px;cursor:pointer;");
	anchor1 = document.createElement("a");
	anchor1.setAttribute("href", "#");
	anchor1.onclick=Function("window.open(\'/cms/staffeditor?Command=FileUpload&legend=" + title + "&personal=1&response=updateclose&username="+username+"\', \'contentCatEditorWindow\', \'top=200px, left=200px, width=450px, height=100px, status=no, scrollbars=no, resizable=yes\');hidePopOverHelp(document);");

	text1 = document.createTextNode("Add Personal");

	anchor1.className = 'popupItem';

	anchor1.appendChild(text1);
	span1.appendChild(anchor1);
	containerDiv.appendChild(span1);	 

	if ( photo2 && photo2.length > 1 ) {
   	   containerDiv = document.createElement("div");
	   containerDiv.setAttribute("style", "position:relative;float:left;clear:both;width:61px;height:auto;vertical-align:middle;margin:0px 0px 0px 0px;padding:0px;");
	   myPopUp.appendChild(containerDiv);

	   span1 = document.createElement("span");
	   span1.setAttribute("style","width:120px;height:auto;position:relative;float:left;margin:0px 2px 0px 0px;padding:2px 1px 2px 0px;cursor:pointer;");
   	   anchor1 = document.createElement("a");
	   anchor1.setAttribute("href", "#");
	   anchor1.onclick=Function("window.open(\'/cms/staffeditor?Command=FileUpload&legend=" + title + "&personal=1&response=closerefresh&replace="+photo2+"\', \'contentCatEditorWindow\', \'top=200px, left=200px, width=450px, height=100px, status=no, scrollbars=no, resizable=yes\');hidePopOverHelp(document);");

	   text1 = document.createTextNode("Replace Personal");

	   anchor1.className = 'popupItem';

	   anchor1.appendChild(text1);
	   span1.appendChild(anchor1);
	   containerDiv.appendChild(span1);	 
        }

	popUpSeparator(myPopUp);

        containerDiv = document.createElement("div");
        containerDiv.setAttribute("style", "position:relative;float:left;clear:both;width:120px;height:auto;vertical-align:middle;margin:0px;padding:0px;");
        myPopUp.appendChild(containerDiv);

        span1 = document.createElement("span");
        span1.setAttribute("style","width:120px;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/admin\', \'\', \'top=0px, left=0px, width=" + sW + "px, height=" + "550px, menubar=yes,location=yes,toolbar=yes,status=yes,scrollbars=yes, resizable=yes\');hidePopOverHelp(document);");
        text1 = document.createTextNode("Administration");
        anchor1.className = 'popupItem';

        anchor1.appendChild(text1);
        span1.appendChild(anchor1);
        containerDiv.appendChild(span1);

	popUpSeparator(myPopUp);

        containerDiv = document.createElement("div");
        containerDiv.setAttribute("style", "position:relative;float:left;clear:both;width:120px;height:auto;vertical-align:middle;margin:0px;padding:0px;");
        myPopUp.appendChild(containerDiv);

        span1 = document.createElement("span");
        span1.setAttribute("style","width:120px;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(myPopUp) {
                containerDiv = document.createElement("div");
                containerDiv.setAttribute("style", "position:relative;float:none;clear:both;width:120px;height:auto;vertical-align:middle;margin:0px;")

                myPopUp.appendChild(containerDiv);

		span1 = document.createElement("span");
                span1.setAttribute("style","display:inline;width:120px;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:99px;");
                   span1.appendChild(img1);
                }


		containerDiv.appendChild(span1);

		span1 = document.createElement("span");
		span1.setAttribute("style","width:120px;position:relative;float:left;clear:both;margin-bottom:5px;");
		text1 = document.createTextNode("");

		span1.appendChild(text1);
		containerDiv.appendChild(span1);

}


function editCursor(myEl) {
		myEl.style.cursor = 'pointer';
		bgSwap = myEl.style.backgroundColor;
		myEl.style.backgroundColor = '#EFEFEF';
}

function regularCursor(myEl) {
		myEl.style.cursor = 'default';
		myEl.style.backgroundColor = bgSwap;
}

function addEditIcon(myEl, e) {
	
	var mySource;

	if(!e){e=window.event;}
	
	if(e) {
		mySource=e.target?e.relatedTarget:e.fromElement;
	}
	if(!e){return;}

	//the next line checks to see if the luser moved outside myEl

	if (myEl && !document.getElementById('editIcon')) {
		myImage = document.createElement("img");
		myImage.id = "editIcon";
		myImage.src = "/global/images/toolbar/edit3d.gif";
		myImage.style.position = "absolute";
		myImage.style.width = '16px';
		myImage.style.height = '16px';
		myImage.style.margin = '0px';
		myImage.style.padding = '0px';
		myImage.style.border = '0';
		myEl.style.marginTop?myImage.style.top = parseInt(myEl.style.marginTop) + 'px':myImage.style.top = '0px';
		myEl.style.marginRight?myImage.style.left = parseInt(myEl.offsetWidth) - 16 - parseInt(myEl.style.marginRight) + 'px':myImage.style.left = parseInt(myEl.offsetWidth) - 16 + 'px';
   		myEl.appendChild(myImage);
	}
}

function removeEditIcon(myEl, e) {

	var myEvent;
	var myDestination;

	if(!e){e=window.event;}
	
	if(e) {
		//myEl=e.target?e.target:e.srcElement;
		myDestination=e.target?e.relatedTarget:e.toElement;
	}
	if(!e){return;}

	//the next line checks to see if the luser moved outside myEl

        if(!myDestination){return;} 

	if ((myDestination.parentNode != myEl) && (myDestination != myEl) && myEl){
		myEl.removeChild(document.getElementById('editIcon'));
	}
}

