
/**
 * Toggle display of note div.
 *
 * @param	string	id			the div id
 * @param	boolean	show		whether to show (true) or hide
 * @param	object	position	a simple object which holds the coords to place the div
 * @return	void
 **/
function toggleNote(id, show, position)
{
	var note = document.getElementById(id);
	
	if (note)
	{
		if (position)
		{
			note.style.left = (position.x - 200) + 'px';
			note.style.top = (position.y - 40) + 'px';
		}
		note.style.display = show ? 'block' : 'none';
	}
}

/**
 * Find the position of the cursor on screen.
 *
 * @param	event	e the cursor event
 * @return	object	a simple object to hold the X and Y coords
 **/
function getCursorPosition(e)
{
    e = e || window.event;
    var cursor = {x:0, y:0};
	
    if (e.pageX && e.pageY)
	{
        cursor.x = e.pageX;
        cursor.y = e.pageY;
    } 
    else
	{
        var de = document.documentElement;
        var b = document.body;
        cursor.x = e.clientX + (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
        cursor.y = e.clientY + (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
    }
    return cursor;
}

/**
 * Confirm that user really, really wants to apply for a job. If the confirm dialogue
 * returns "OK", the confirmation checkbox is set to "checked" and the form will submit.
 *
 * @param	element	form	the form
 * @param	string	msg		the message to use for the confirm dialogue
 * @return	boolean
 **/
function confirmApply(form, msg)
{
	if (form.apply_confirm.checked)
	{
		return true;
	}
	else if (confirm(msg))
	{
		form.apply_confirm.checked = true;
		return true;
	}
	else
	{
		return false;
	}
}

function showResume(uri)
{
	if (uri)
	{
		var attributes = 'width=640,menubar=no,scrollbars=yes,resizable=yes,location=no';
		window.open(uri, 'resume_pane', attributes);
	}
	return false;	
}
