﻿function GoPage(url)
{
	window.location.href = url;
}


var enterHandled = false;
// handle [enter] keypress - submit form by sending click command to appropriate button
function HandleEnter(e, elm)
{
	e = e || window.event;
	
	if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13))	// [enter] keypress?
	{
		if (!enterHandled)	// has the [enter] keypress already been handled once on the page
		{
			enterHandled = true;
			document.getElementById(elm).click();	// send click command to appropriate button			
		}
		else
		{
			return false;
		}
		
		return true;
		
	}
	else	// FIX: firefox/mozilla try to resubmit if validation fails and alert box is closed using [enter] keypress (enters a loop)
	{
		enterHandled = false;	// don't handle [enter] keypress again until another key has been pressed
	}
	
	return false;
	
}


var enterHandled_IsEnter = false;
// check [enter] keypress - was this keypress an [enter]?
function IsEnter(e)
{
	e = e || window.event;
	
	if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13))	// [enter] keypress?
	{
		if (!enterHandled_IsEnter)	// has the [enter] keypress already been handled once on the page
		{
			enterHandled_IsEnter = true;
			return true;		
		}
		else
		{
			return false;
		}
		
		return true;
		
	}
	else	// FIX: firefox/mozilla try to resubmit if validation fails and alert box is closed using [enter] keypress (enters a loop)
	{
		enterHandled_IsEnter = false;	// don't handle [enter] keypress again until another key has been pressed
	}
	
	return false;
	
}


//To show/hide instructional text in the note textbox
function ShowHideText(id, action, instructionalText)
{
	var textValue = id.value;
	
	if ((action == 'Hide') && (textValue == instructionalText || isBlank(textValue) || isEmpty(textValue)))
	{
		id.value = '';
	}
	else if (action == 'Show' && (textValue == instructionalText || isBlank(textValue) || isEmpty(textValue)))
	{
		id.value = instructionalText;
	}
	
}
