function toggleSidebarItem(linkElement) {
  var sidebarItem = $(linkElement).up(".sidebarItem");

  if (!sidebarItem) return;

  if (sidebarItem.hasClassName("open")) {
    sidebarItem.removeClassName("open");
    sidebarItem.addClassName("closed");
  } else {
    sidebarItem.removeClassName("closed");
    sidebarItem.addClassName("open");    
  }
}

function reportabusepopup(obj,xoffset, yoffset,id) {
	var xval = findPosX(obj);
	var yval = findPosY(obj);
	var popup = document.getElementById('reportabusePopup_'+id);
	if (popup) {
		popup.style.position = 'absolute';
		popup.style.top = (yval + yoffset) + "px";
		popup.style.left = (xval + xoffset) + "px";
		popup.style.display = 'block';
	}
	return false;
}

function closeReportabuse (id) {
	document.getElementById('reportabusePopup_'+id).style.display='none';
}

function reportabuse (id) {
	document.getElementById('reportabusePopup_'+id).style.display='none';
	document.getElementById('abuse_'+id).style.display='none';
	document.getElementById('saveReportAbuseReceived_'+id).style.display='';
}

function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent) {
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
	} else if(obj.y) {
        curtop += obj.y;
	}
    return curtop;
  }
  
		function getWindowHeight() {
			var windowHeight = 0;
			if (typeof(window.innerHeight) == 'number') {
				windowHeight = window.innerHeight;
			}
			else {
				if (document.documentElement && document.documentElement.clientHeight) {
					windowHeight = document.documentElement.clientHeight;
				}
				else {
					if (document.body && document.body.clientHeight) {
						windowHeight = document.body.clientHeight;
					}
				}
			}
			return windowHeight;
		}
		function setContent() {
			if (document.getElementById) {
				var windowHeight = getWindowHeight();
				if (windowHeight > 0) {
					var contentElement = document.getElementById('reportabusePopup1');
					var contentHeight = 600;
					if (windowHeight - contentHeight > 0) {
						contentElement.style.position = 'absolute';
						contentElement.style.top = ((windowHeight / 2) + document.documentElement.scrollTop - (contentHeight / 2)) + 'px';
						contentElement.style.left = '300px';
						//contentElement.style.margin = 'auto';
					}
					else {
						contentElement.style.position = 'static';
					}
				}
			}
		}

function increaseFav(id) {
	var element = document.getElementById('fav_'+id);
	if (element) {
		var favlink = element.getElementsByTagName('a');
		if (favlink && favlink[0].className == "saveReportAbuse") {
			favlink[0].style.display = 'None';
		}
		if (favlink && favlink[1].className == "saveReportAbuse") {
			favlink[1].style.display = '';
		}
	}
}

function decreaseFav(id) {
	var element = document.getElementById('fav_'+id);
 	if (element) {
		var favlink = element.getElementsByTagName('a');
		if (favlink && favlink[1].className == "saveReportAbuse") {
			favlink[1].style.display = 'None';
		}
		if (favlink && favlink[0].className == "saveReportAbuse") {
			favlink[0].style.display = '';
		}
	}
}

function splitTextEmployeeName(s)
{
	aPos=s.indexOf('@');
	if(aPos>0)
	{
		fPart=s.substring(0,aPos);
		lPart=s.substring(aPos,s.length);
		return fPart + "<br/>" +lPart;
	}
	return s;
}
