var help_messages = new Array();
var div_window, frm_window;
var process_focus = true;

help_messages[0] = "";
help_messages[1] = "Please choose the begin and end dates for the period you want. Press the <table width=\"100%\" border=\"0\"><tr><td align=\"center\" valign=\"middle\" width=\"1\"><img src=\"/img/calendar_gray.gif\" width=\"19\" height=\"19\" /></td><td>button and select the date in calendar.</td></tr></table>Press <b>\"Refresh\"</b> button after you finish selecting all criteria to refresh the data.";
help_messages[2] = help_messages[1];
help_messages[3] = "Please choose the project you want. Select <b>\"All\"</b> option to see the work for all your projects.<br>Press <b>\"Refresh\"</b> button after you finish selecting your criteria.";
help_messages[4] = "Please choose the specific task of above project you want. Select the <b>\"All\"</b> option to see all tasks in the project.<br>Press the <b>\"Refresh\"</b> button after you finish selecting your criteria.";
help_messages[5] = "Please choose the employee you want. Select the <b>\"All\"</b> option to see the work of all employees for selected project/task.<br>Press the <b>\"Refresh\"</b> button after you finish selecting your criteria.";
if (window.navigator.userAgent.indexOf("Firefox")>=1)
	help_messages[6] = "Please select the grouping method:<br><table width=\"100%\" border=\"0\"><tr><td width=\"1%\" valign=\"top\"><li style=\"list-style: image; list-style-image: url(/img/list-item.gif); \">&nbsp;</li></td><td valign=\"top\" style=\"padding-top: 2px;\"><b>None</b> will return all detail records for the period/project/task/employee chosen  (you can view the employee's report for any record) </td></tr><tr><td width=\"1%\" valign=\"top\"><li style=\"list-style: image; list-style-image: url(/img/list-item.gif); \">&nbsp;</li></td><td valign=\"top\" style=\"padding-top: 2px;\"><b>Tasks</b> will return records grouped by task (with hours for each employee) for the period/project/task chosen</td></tr><tr><td width=\"1%\" valign=\"top\"><li style=\"list-style: image; list-style-image: url(/img/list-item.gif); \">&nbsp;</li></td><td valign=\"top\" style=\"padding-top: 2px;\"><b>Projects</b> will return records grouped by project (with hours for each employee) for the period/project chosen.</td></tr></table>";
else
	help_messages[6] = "Please select the grouping method:<br><table width=\"100%\" border=\"0\"><tr><td width=\"1%\" valign=\"top\"><li>&nbsp;</li></td><td><b>None</b> will return all detail records for the period/project/task/employee chosen  (you can view the employee's report for any record) </td></tr><tr><td width=\"1%\" valign=\"top\"><li>&nbsp;</li></td><td><b>Tasks</b> will return records grouped by task (with hours for each employee) for the period/project/task chosen</td></tr><tr><td width=\"1%\" valign=\"top\"><li>&nbsp;</li></td><td><b>Projects</b> will return records grouped by project (with hours for each employee) for the period/project chosen.</td></tr></table>";

function hide_window()
{
	if (div_window != null) 
	{
  		div_window.style.display = "none";
	}
	if (frm_window != null && blnMSIE ) 
	{
		frm_window.style.display = "none";
	}
}

function prepare_for_hide_window(prepare)
{ 
	if (div_window == null) 
		return;
	if (!process_focus)
		return;
	if (prepare) 
	{
		if (blnMSIE)
		{
			if (div_window.style.display == 'none') 
				return;
	 		div_window.onblur = hide_window;
 			div_window.focus();
	 	}
		else 
		{
			if (document.getElementById('help_focus_controller').style.display == 'none') 
				return;
		 	document.getElementById('help_focus_controller').onblur = hide_window;
 			document.getElementById('help_focus_controller').focus();
	 	}
 	}
	else 
	{
		if (blnMSIE)
		{
	 		div_window.onblur = null;
	 	}
		else 
		{
		 	document.getElementById('help_focus_controller').onblur = null;
	 	}
 	}
}

function draw_addit_window(capt, msg)
{
	var str_buffer = new String (
		"<table id=\"help_text_field\" style=\"BORDER-RIGHT: 1px outset black; BORDER-TOP:1px outset black;BORDER-LEFT: 1px outset black;BORDER-BOTTOM: 1px outset black ;\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td><table style=\"BORDER-RIGHT: 1px outset white; BORDER-TOP:1px outset white;BORDER-LEFT: 1px outset white;BORDER-BOTTOM: 1px outset white ;\" cellpadding=\"4\" cellspacing=\"0\" width=\"100%\">\n"+
		"<tr><td height=\"10\" align=\"right\" class='CalendarTitle'><div style=\"float:left; text-transform:uppercase; font-weight:bold;\"> &nbsp;" + capt + "</div><a href=\"javascript:hide_window()\"><image src=\"/img/close.gif\" border=\"0\" width=\"16\" height=\"15\" alt=\"Close\"></a></td></tr>"+
		"<tr bgcolor=\"#d5d5d5\"><td>\n");
	
	str_buffer += "<font color=\"#333333\" name=\"tahoma\" >";
	str_buffer += msg;
	str_buffer += "</font>";
	str_buffer += "</td></tr></table></td></tr></table>\n";

	if (!blnMSIE)
	{
		str_buffer += "<input id=help_focus_controller type=text style='height:0;width:0;'/>\n";
	}
	div_window.innerHTML = str_buffer;
}

function show_addit_window(str_obj, str_title, str_msg)
{
	var objPos = document.getElementById(str_obj);
	if (!objPos) return;
	if (objPos.disabled) return;

	if (div_window == null) 
	{
		div_window = document.createElement('DIV');
		div_window.id = "div_window";
		div_window.backgroundColor = "#A9A9A9";
		div_window.style.display = "none";
		div_window.style.zIndex = 99998;
		div_window.style.position = "absolute";
		div_window.style.whiteSpace = "nowrap";
		div_window.width = 240;
		div_window.style.width = "250px";
		div_window.style.height = "90px";
//		div_window.style.border = "1px solid black";
		div_window.onmouseout= new Function('prepare_for_hide_window(true);');
		div_window.onmouseover= new Function('prepare_for_hide_window(false);');
		document.body.appendChild(div_window);
	}

	draw_addit_window(str_title, str_msg);

	if (frm_window == null && blnMSIE) 
	{
		frm_window = document.createElement("IFRAME");
		frm_window.id = "frm_window";
		frm_window.src = "javascript:false;";
		frm_window.scrolling = "no"; 
		frm_window.frameborder = "0";
		frm_window.style.position = "absolute"; 
		frm_window.style.top = "0px";
		frm_window.style.left = "0px";
		frm_window.style.display = "none";
		frm_window.style.width = "250px";
		frm_window.style.height = div_window.style.height;
		document.body.appendChild(frm_window);
	}

	var t = 0;
	var l = 0;
	var state = false;
	var cNode = document.getElementById(str_obj);
	while (cNode.tagName != 'BODY')
	{ 
		l += cNode.offsetLeft; 
       	t += cNode.offsetTop; 
       	cNode = cNode.offsetParent; 
    }
	t++;

	div_window.style.top = (t + objPos.offsetHeight);
	div_window.style.left = l;
	div_window.style.display = "block";
	if ((l + div_window.offsetWidth) > document.body.clientWidth)
	{
		l = document.body.clientWidth - div_window.offsetWidth;
		div_window.style.left = l;
	}
	
	div_window.focus();

	if(blnMSIE)
	{
		frm_window.style.top = (t + objPos.offsetHeight);
		frm_window.style.left = l;
		frm_window.style.width = div_window.style.posWidth ;
		frm_window.style.height = div_window.style.posHeight;
		frm_window.style.zIndex = div_window.style.zIndex - 1;
		frm_window.style.display = "block";
		frm_window.backgroundColor = "black";
	}
	
	var field_obj = document.getElementById("help_text_field");
	if (field_obj != null)
	{
		if (div_window != null)
		{
			div_window.style.height = field_obj.offsetHeight;
		}
		if (frm_window != null)
		{
			frm_window.style.height = field_obj.offsetHeight
		}
	}
}

function show_help_window(str_obj, msg_id)
{
	var objPos = document.getElementById(str_obj);
	if (!objPos) return;
	if (objPos.disabled) return;

	var msg;
	var m_id = msg_id;
	
	if (m_id < 0)
		m_id = 0;
	if (m_id > 6)
		m_id = 0;

	msg = help_messages[m_id];

	show_addit_window(str_obj, "help", msg);
}

