﻿function trim(str) 
	{
		return str.replace(/\s*$/,"");
	}
function enterKeyPressed(e)
{
        var enterPressed = false;
		if (window.event && window.event.keyCode == 13) 
		{
			enterPressed = true;
		}

		else if (e && e.which == 13) {
			enterPressed = true;
		}
		return enterPressed;
}
function ShowHide(id)
{
    var doc = document.getElementById(id)
    if(doc.style.display == "block")
    {
        doc.style.display = "none";
    }
    else
    {
        doc.style.display = "block";
    }
}
function SetReadMessage(messageId)
{
    SubmitFrame('CAction.aspx?a=mr&id=' + messageId);
}
function DeleteMessage(deleteUrl)
{
    if(confirm('Are you sure you want to delete this item?'))
    {
        document.forms[0].action = deleteUrl;
        document.forms[0].submit();
    }
}
function DeleteMultipleMessages(deleteUrl)
{
    if(confirm('Are you sure you want to modify these items?'))
    {
        document.forms[0].action = deleteUrl;
        document.forms[0].submit();
    }
}
function SubmitFrame(url)
{
    document.getElementById('AjaxIFrame').src = url;
}
function SubmitPage(url)
{
    document.forms[0].action = url;
    document.forms[0].submit();
}
function DeleteItem(url)
{
    if(confirm('Are you sure you want to delete this item?'))
    {
        SubmitPage(url);
    }
}
function ActivityChartChange()
{
    var url = "getchart.aspx?ct=";
    var timeId = document.getElementById('Interval').value;
    var measureId = document.getElementById('measure').value;
    if(timeId == 'Hourly')
    {
        url += 'ADHD';
    }
    else
    {
        url += 'ADDD';
    }
    url += '&measure=' + measureId;
    document.getElementById('ActivityIFrame').src = url;
}
function FeedbackChartChange()
{
    var url = "getchart.aspx?ct=";
    var measureId = document.getElementById('measure').value;
    url += 'ADFD&measure=' + measureId;
    document.getElementById('ActivityIFrame').src = url;
}

function SurveyChartChange()
{
    var url = "getchart.aspx?ct=";
    var measureId = document.getElementById('measure').value;
    url += 'ADSD&measure=' + measureId;
    document.getElementById('ActivityIFrame').src = url;
}
var offsetxpoint=-60 //Customize x offset of tooltip
	var offsetypoint=20 //Customize y offset of tooltip
	var ie=document.all
	var ns6=document.getElementById && !document.all
	var enabletip=false
	if (ie||ns6)
	
	function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
	}

function OpenPopUp(playerId, e)
{
var tipobj=document.all? document.all["PopUpDiv"] : document.getElementById? document.getElementById("PopUpDiv") : "";
   var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
	var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
	//Find out how close the mouse is to the corner of the window
	var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
	var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

	var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

	//if the horizontal distance isn't enough to accomodate the width of the context menu
	if (rightedge<tipobj.offsetWidth)
	//move the horizontal position of the menu to the left by it's width
	tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
	else if (curX<leftedge)
	tipobj.style.left="5px"
	else
	//position the horizontal position of the menu where the mouse is positioned
	tipobj.style.left=curX + 150 +offsetxpoint+"px"

	//same concept with the vertical position
	if (bottomedge<tipobj.offsetHeight)
	{
	    tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
	}
	else
	{
	    tipobj.style.top=curY+ offsetypoint - 25 +"px"
	}
	if(tipobj.style.top[0] == "-")
	{
	   tipobj.style.top = "20px"; 
	}
	if(tipobj.style.left[0] == "-")
	{
	   tipobj.style.left = "0px"; 
	}
	tipobj.style.visibility="visible";
	document.getElementById("PopUpFrame").src = "PlayerInfo.aspx?pId=" + playerId;
}
function ClosePopUp()
{
    var tipobj=document.all? document.all["PopUpDiv"] : document.getElementById? document.getElementById("PopUpDiv") : "";
    tipobj.style.visibility = "hidden";
	document.getElementById("PopUpFrame").src = "donothing.htm";
}
