function centerMe()
	{
	if (navigator.appName.indexOf("Microsoft")!=-1)
		winW = document.body.offsetWidth;
	else
		winW = window.innerWidth;
	var leftx = (winW - 795) /2 ;
	document.getElementById('addgoalform').style.left = leftx + "px";
	}//end of centerMe


function showGoal(num, parentx)
	{
	document.getElementById('myparentx').value = parentx;
	document.getElementById('mytypex').value = 4;

	if (num == 1)
		{
		document.getElementById('addformtitle').innerHTML = 'Add a New Goal';
		document.getElementById('goaltitle').innerHTML = '*Goal Title';
		document.getElementById('goaldetails').innerHTML = 'What exactly do you want to achieve?<br>Make this a SMART goal?';
		document.getElementById('goalsobstacles').innerHTML = 'What is standing in the way of<br>you achieving this goal?';
		}//end of if
	else if (num == 2)
		{
		document.getElementById('addformtitle').innerHTML = 'Add a New Sub Goal';
		document.getElementById('goaltitle').innerHTML = '*Sub Goal Title';
		document.getElementById('goaldetails').innerHTML = 'What exactly do you want to achieve?<br>Make this a SMART sub goal?';
		document.getElementById('goalsobstacles').innerHTML = 'What is standing in the way of<br>you achieving this sub goal?';
		}//end of else if

	if (document.getElementById('addgoalform').style.display == 'block')
		$('#addgoalform').hide("slow");
	else
		{
		centerMe();
		$('#addgoalform').show("slow");
		window.scrollTo(0,100);
		}//end of else
	}//end of showGoal


function showGoalAdmin(num, parentx, userx)
	{
	document.getElementById('myparentx').value = parentx;
	document.getElementById('mytypex').value = 4;
	document.getElementById('myuserx').value = userx;

	if (num == 1)
		{
		document.getElementById('addformtitle').innerHTML = 'Add a New Goal';
		document.getElementById('goaltitle').innerHTML = '*Goal Title';
		document.getElementById('goaldetails').innerHTML = 'What exactly do you want to achieve?<br>Make this a SMART goal?';
		document.getElementById('goalsobstacles').innerHTML = 'What is standing in the way of<br>you achieving this goal?';
		}//end of if
	else if (num == 2)
		{
		document.getElementById('addformtitle').innerHTML = 'Add a New Sub Goal';
		document.getElementById('goaltitle').innerHTML = '*Sub Goal Title';
		document.getElementById('goaldetails').innerHTML = 'What exactly do you want to achieve?<br>Make this a SMART sub goal?';
		document.getElementById('goalsobstacles').innerHTML = 'What is standing in the way of<br>you achieving this sub goal?';
		}//end of else if

	if (document.getElementById('addgoalform').style.display == 'block')
		$('#addgoalform').hide("slow");
	else
		{
		centerMe();
		$('#addgoalform').show("slow");
		window.scrollTo(0,100);
		}//end of else
	}//end of showGoalAdmin


function showAction(parentx,E)
	{
	var posx = 0;
	var posy = 0;
	if (!E)
		var E = window.event;
	if (E.pageX || E.pageY)
		{
		posx = E.pageX;
		posy = E.pageY;
		}//end of if
	else if (E.clientX || E.clientY)
		{
		posx = E.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = E.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
		}//end of else if
	// posx and posy contain the mouse position relative to the document
	posx = (posx - 550) + "px"; 	/*edited for positioning - apr27*/
	posy = (posy - 250) + "px";  	/*edited for positioning - apr27*/
	document.getElementById('myparentx2').value = parentx;

	$('#addactionform').css("top", posy);
	$('#addactionform').css("left", posx);
	$('#addactionform').show("slow");
	}//end of showAction


function showActionAdmin(parentx,userx,E)
	{
	var posx = 0;
	var posy = 0;
	if (!E)
		var E = window.event;
	if (E.pageX || E.pageY)
		{
		posx = E.pageX;
		posy = E.pageY;
		}//end of if
	else if (E.clientX || E.clientY)
		{
		posx = E.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = E.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
		}//end of else if
	// posx and posy contain the mouse position relative to the document
	posx = (posx - 550) + "px"; 	/*edited for positioning - apr27*/
	posy = (posy - 250) + "px";  	/*edited for positioning - apr27*/
	document.getElementById('myparentx2').value = parentx;
	document.getElementById('myuserx2').value = userx;

	$('#addactionform').css("top", posy);
	$('#addactionform').css("left", posx);
	$('#addactionform').show("slow");
	}//end of showAction


function checkGoalForm()
	{
	if (document.getElementById('title').value == "")
		alert("Please Input a Goal Title Before Submitting the Form");
	else
		document.goalform.submit();
	}//end of checkGoalForm


function checkActionForm()
	{
	if (document.getElementById('title2').value == "")
		alert("Please Input an Action Title Before Submitting the Form");
	else
		document.actionform.submit();
	}//end of checkGoalForm


function uploadNewImg(num,E)
	{
	var posx = 0;
	var posy = 0;
	if (!E)
		var E = window.event;
	if (E.pageX || E.pageY)
		{
		posx = E.pageX;
		posy = E.pageY;
		}//end of if
	else if (E.clientX || E.clientY)
		{
		posx = E.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = E.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
		}//end of else if
	// posx and posy contain the mouse position relative to the document
	posx = (posx - 100) + "px"; 	/*edited for positioning - apr27*/
	posy = (posy - 300) + "px"; 	/*edited for positioning - apr27*/

	$('#newimagediv').css("top", posy);
	$('#newimagediv').css("left", posx);
	$('#newimagediv').show("slow");
	document.changemyimage.goalid.value = num;
	}//end of uploadNewImg


function uploadNewFile(num,E)
	{
	var posx = 0;
	var posy = 0;
	if (!E)
		var E = window.event;
	if (E.pageX || E.pageY)
		{
		posx = E.pageX;
		posy = E.pageY;
		}//end of if
	else if (E.clientX || E.clientY)
		{
		posx = E.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = E.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
		}//end of else if
	// posx and posy contain the mouse position relative to the document
	posx = (posx - 300) + "px"; 	/*edited for positioning - apr27*/
	posy = (posy - 240) + "px"; 	/*edited for positioning - apr27*/
	document.changemyfile.goalid.value = num;
	$('#newfilediv').css("top", posy);
	$('#newfilediv').css("left", posx);
	$('#newfilediv').show("slow");
	}//end of uploadNewFile


function changeParent(num,num2,E)
	{
	var posx = 0;
	var posy = 0;
	if (!E)
		var E = window.event;
	if (E.pageX || E.pageY)
		{
		posx = E.pageX;
		posy = E.pageY;
		}//end of if
	else if (E.clientX || E.clientY)
		{
		posx = E.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = E.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
		}//end of else if
	// posx and posy contain the mouse position relative to the document
	posx = (posx - 450) + "px"; 		/*edited for positioning - apr27*/
	posy = (posy - 240) + "px"; 		/*edited for positioning - apr27*/
	document.changemyparent.goalid.value = num;
	document.changemyparent.goalparent.value = num2;
	$('#changeparentdiv').css("top", posy);
	$('#changeparentdiv').css("left", posx);
	$('#changeparentdiv').show("slow");
	}//end of changeParent


function addParentFunction(num,E)
	{
	var posx = 0;
	var posy = 0;
	if (!E)
		var E = window.event;
	if (E.pageX || E.pageY)
		{
		posx = E.pageX;
		posy = E.pageY;
		}//end of if
	else if (E.clientX || E.clientY)
		{
		posx = E.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = E.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
		}//end of else if
	// posx and posy contain the mouse position relative to the document
	posx = (posx - 150) + "px";
	posy = (posy - 10) + "px";
	document.addmyparent.goalid2.value = num;
	$('#addparentdiv').css("top", posy);
	$('#addparentdiv').css("left", posx);
	$('#addparentdiv').show("slow");
	}//end of addParent


function checkSubmitImg()
	{
	if (document.changemyimage.imagefile2.value == "")
		alert("Please complete the form properly before submitting it");
	else
		document.changemyimage.submit();
	}//end of checkSubmitImg


function checkSubmitFile()
	{
	if (document.changemyfile.newfile.value == "")
		alert("Please complete the form properly before submitting it");
	else
		document.changemyfile.submit();
	}//end of checkSubmitFile


function showoptions(num)
	{
	if (eval("document.getElementById('goaloptions" + num + "').style.display == 'block'"))
		{
		eval("document.getElementById('goaloptions" + num + "').style.display = 'none'");
		eval("document.getElementById('optionslink" + num + "').innerHTML = 'Show Options'");
		eval("document.getElementById('optionslink" + num + "').style.left = '41px'");
		}//end of if
	else
		{
		eval("document.getElementById('goaloptions" + num + "').style.display = 'block'");
		eval("document.getElementById('optionslink" + num + "').innerHTML = 'Hide Options'");
		eval("document.getElementById('optionslink" + num + "').style.left = '48px'");
		}//end of else
	}//end of showoptions


function showoptions2(num)
	{
	if (eval("document.getElementById('goaloptions" + num + "').style.display == 'block'"))
		{
		eval("document.getElementById('goaloptions" + num + "').style.display = 'none'");
		eval("document.getElementById('optionslink" + num + "').innerHTML = 'Show Options'");
		eval("document.getElementById('optionslink" + num + "').style.left = '41px'");
		}//end of if
	else
		{
		eval("document.getElementById('goaloptions" + num + "').style.display = 'block'");
		eval("document.getElementById('optionslink" + num + "').innerHTML = 'Hide Options'");

		if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))
			eval("document.getElementById('optionslink" + num + "').style.left = '60px'");
		else
			eval("document.getElementById('optionslink" + num + "').style.left = '48px'");
		}//end of else
	}//end of showoptions2


function showTracker(parentx,duex,edate,goalname,E)
	{
	if (duex == "Ongoing")
		alert ("Please input a goal due date first before accessing this function");
	else
		{
		var posx = 0;
		var posy = 0;
		if (!E)
			var E = window.event;
		if (E.pageX || E.pageY)
			{
			posx = E.pageX;
			posy = E.pageY;
			}//end of if
		else if (E.clientX || E.clientY)
			{
			posx = E.clientX + document.body.scrollLeft
				+ document.documentElement.scrollLeft;
			posy = E.clientY + document.body.scrollTop
				+ document.documentElement.scrollTop;
			}//end of else if
		// posx and posy contain the mouse position relative to the document
		posx = (posx - 650) + "px"; 	/*edited for positioning - apr27*/
		posy = (posy - 400) + "px"; 	/*edited for positioning - apr27*/

		document.getElementById('trackerparentx').value = parentx;
		document.getElementById('trackerenddate2').value = edate;
		document.getElementById('trackergoalnamex').value = goalname;
		document.getElementById('trackerfinish2').value = duex;

		$('#trackerdivx').css("top", posy);
		$('#trackerdivx').css("left", posx);
		$('#trackerdivx').show("slow");
		}//end of else
	}//end of showTracker


function regIsNumber(fData)
	{
	var reg = new RegExp("(^[-]?[0-9]+[\.]?[0-9]+$)|(^[-]?[0-9]+$)");
	return reg.test(fData);
	}//end of regIsNumber


function checkTracker()
	{
	if (document.trackerformz.trackername.value == "" || document.trackerformz.trackerunit.value == "" || document.trackerformz.trackervalue.value == "" || document.trackerformz.trackerdate.value == "" || document.trackerformz.trackerendvalue.value == "")
		alert("Please complete the form properly before submitting it");
	else
		{
		if (!regIsNumber(document.trackerformz.trackervalue.value) || !regIsNumber(document.trackerformz.trackerendvalue.value))
			alert("Please make sure that the 'Starting Value' and the 'Goal Target Value' are both valid numbers");
		else
			{
			var datetemp = document.trackerformz.trackerdate.value.split(" ");
			if (datetemp[1] == 'Jan')
				datetemp[1] = 1;
			else if (datetemp[1] == 'Feb')
				datetemp[1] = 2;
			else if (datetemp[1] == 'Mar')
				datetemp[1] = 3;
			else if (datetemp[1] == 'Apr')
				datetemp[1] = 4;
			else if (datetemp[1] == 'May')
				datetemp[1] = 5;
			else if (datetemp[1] == 'Jun')
				datetemp[1] = 6;
			else if (datetemp[1] == 'Jul')
				datetemp[1] = 7;
			else if (datetemp[1] == 'Aug')
				datetemp[1] = 8;
			else if (datetemp[1] == 'Sep')
				datetemp[1] = 9;
			else if (datetemp[1] == 'Oct')
				datetemp[1] = 10;
			else if (datetemp[1] == 'Nov')
				datetemp[1] = 11;
			else if (datetemp[1] == 'Dec')
				datetemp[1] = 12;

			var datetemp2 = datetemp[2] + ", " + datetemp[1] + ", " + datetemp[0];
			var date1 = new Date(datetemp2);
			var date2 = new Date(document.trackerformz.trackerenddate.value);

			if(date1 >= date2)
				alert ("Start Date cannot be greater than or equal to the End date");
			else
				document.trackerformz.submit();
			}//end of else
		}//end of else
	}//end of checkTracker


function checkTracker2()
	{
	if (document.trackerformz22.trackervalue22.value == "" || document.trackerformz22.trackerdate22.value == "")
		alert("Please complete the form properly before submitting it");
	else
		{
		if (!regIsNumber(document.trackerformz22.trackervalue22.value))
			alert("Please make sure that the 'Value' is a valid number");
		else
			{
			var datetemp = document.trackerformz22.trackerdate22.value.split(" ");
			if (datetemp[1] == 'Jan')
				datetemp[1] = 1;
			else if (datetemp[1] == 'Feb')
				datetemp[1] = 2;
			else if (datetemp[1] == 'Mar')
				datetemp[1] = 3;
			else if (datetemp[1] == 'Apr')
				datetemp[1] = 4;
			else if (datetemp[1] == 'May')
				datetemp[1] = 5;
			else if (datetemp[1] == 'Jun')
				datetemp[1] = 6;
			else if (datetemp[1] == 'Jul')
				datetemp[1] = 7;
			else if (datetemp[1] == 'Aug')
				datetemp[1] = 8;
			else if (datetemp[1] == 'Sep')
				datetemp[1] = 9;
			else if (datetemp[1] == 'Oct')
				datetemp[1] = 10;
			else if (datetemp[1] == 'Nov')
				datetemp[1] = 11;
			else if (datetemp[1] == 'Dec')
				datetemp[1] = 12;

			var datetemp2 = datetemp[2] + ", " + datetemp[1] + ", " + datetemp[0];
			var date1 = new Date(datetemp2);
			var date2 = new Date(document.trackerformz22.trackerenddate22.value);

			if(date2 < date1)
				alert ("The date cannot be greater than the End date");
			else
				document.trackerformz22.submit();
			}//end of else
		}//end of else
	}//end of checkTracker2


var newWin = null;
function popUp(strURL, strHeight, strWidth)
	{
	if (newWin != null && !newWin.closed)
		newWin.close();

	var strOptions="";
	strOptions="scrollbars," + "resizable,height=" + strHeight + ",width=" + strWidth;

	newWin = window.open(strURL, 'newWin', strOptions);
	newWin.focus();
	}//end of popup

function showHideContent(pImg,pdivId)
{
	objList = document.getElementById(pdivId);
	if(objList.style.display=="none")
	{
		objList.style.display= "block";
		pImg.src="images/hide.png"
	}
	else if(objList.style.display=="block")
	{
		objList.style.display= "none";
		pImg.src="images/show.png"
	}
}

function showImg(Opt,cImg)
{
	imgChange = document.getElementById(cImg);
	imgChange.src="images/show.png"
	
	if(Opt.value=="all" || Opt.value=="unassigned")
	{
		imgChange.style.display= "none";
	}
	
	else
	{
		imgChange.style.display= "inline";
	}
}

function roll(hImg)
{
	imgOne = hImg.src;
	if(imgOne=="http://www.impactfulactions.com/images/show.png")
	{
		hImg.src = "http://www.impactfulactions.com/images/show-hvr.png";
	}
	else if(imgOne=="http://www.impactfulactions.com/images/hide.png")
	{
		hImg.src = "http://www.impactfulactions.com/images/hide-hvr.png";
	}
}

function rollOut(hImg)
{
	imgTwo = hImg.src;
	if(imgTwo=="http://www.impactfulactions.com/images/show-hvr.png")
	{
		hImg.src = "http://www.impactfulactions.com/images/show.png";
	}
	else if(imgTwo=="http://www.impactfulactions.com/images/hide-hvr.png")
	{
		hImg.src = "http://www.impactfulactions.com/images/hide.png";
	}
}