// To disable function keys and other unwanted features of IE.
function CheckKey() 
{
	try
		{
		var X = window.event.keyCode;
		var Ctrl = window.event.ctrlKey;
		var Alt  = window.event.altKey;

		// Throw away backspaces when not in a text field to prevent unwanted going back in history
		if (window.event && (X == 8))
			{
			if (typeof(window.event.srcElement.type) == "undefined")
				{
				// Cancel the backspace when not on a control (this happens when no control has focus)
				window.event.cancelBubble = true;
				window.event.returnValue = false;
				return false;
				}
			
			if (window.event.srcElement.type.match("text") || window.event.srcElement.type.match("password")) 
				{
				if (window.event.srcElement.readOnly)
					{
					// Cancel the backspace when on a readonly text box
					window.event.cancelBubble = true;
					window.event.returnValue = false;
					return false;
					}
			
				return true;
				}

			// Try to cancel the backspace
			window.event.cancelBubble = true;
			window.event.returnValue = false;
			return false;
			}

		if (Ctrl)
			{
			switch (X)
				{
				case 67:  // Ctrl-C - Enabled for clipboard copy
				case 70:  // Ctrl-F - Enabled for find
				case 86:  // Ctrl-V - Enabled for clipboard paste
				case 88:  // Ctrl-X - Enabled for clipboard cut
				case 89:  // Ctrl-Y - Enabled for redo
				case 90:  // Ctrl-Z - Enabled for undo
					{
					break;
					}
				default:
					{
					// Disable all other Ctrl-letters
					if ((X >= 65) && (X <= 90))
						{
						event.keyCode = 0;
						return false;
						}

					// Disable all Ctrl-numbers
					if ((X >= 48) && (X <= 57))
						{
						event.keyCode = 0;
						return false;
						}
					}
				}
			}

		// alt-left arrow	
		if (Alt && X == 37) 
			{
			return false;
			}

		// Disable all function keys (F1 to F12)
		if ((X >= 112) && (X <= 123))
				{
				var iFKey;
				
				iFKey = X - 111;
				
				if (event.shiftKey)
					iFKey += 12;

				if (iFKey == 1)
					{
					top.window.opener.openSabre(1);
					event.keyCode = 0;
					return false;
					}
				
				event.keyCode = 0;
				return false;
				}
		}
	catch (exc)
		{
		}
}


// This function disables the right click of mouse on the page
if (window.Event)
	{
	document.captureEvents(Event.MOUSEUP);
	}

function nocontextmenu() 
{
	// Turn off right-click context menu, but only if not in a text control.
	
	if (typeof(window.event.srcElement.type) == "undefined")
		{
		event.cancelBubble = true;
		event.returnValue = false;
		return false;
		}

	if (window.event.srcElement.type.match("text"))
		{
		return true;
		}

	event.cancelBubble = true;
	event.returnValue = false;

	return false;
}

function norightclick(e)
{
	if (window.Event) 
		{
		if (e.which == 2 || e.which == 3)
			return false;
		}
	else if (event.button == 2 || event.button == 3)
		{
		event.cancelBubble = true, event.returnValue = false;
		return false;
		}
}

if (document.layers)
	{
	document.captureEvents(Event.MOUSEDOWN);
	}

function mouseDown(e)
{
	var shiftPressed = 0;
		
	if (parseInt(navigator.appVersion) > 3)
		{
		if (navigator.appName == "Netscape")
			shiftPressed = (e.modifiers-0 > 3);
		else 
			shiftPressed = event.shiftKey;
				
		if (shiftPressed) 
			{
			alert("shift-click is disabled.");
			return false;
			}
		}
		
	if (window.Event) 
		{
		if (e.which == 2 || e.which == 3) 
			return false;
		}
	else if (event.button == 2 || event.button == 3) 
		{
		event.cancelBubble = true, event.returnValue = false;
		return false;
		}

	return true;
}
	
// Disable Help
function dsble_Help()
{
	return false;
}

if (parseInt(navigator.appVersion) > 3) 
	{
	document.onmousedown = mouseDown;

	if (navigator.appName == "Netscape")
		document.captureEvents(Event.MOUSEDOWN);
	}

//Capturing the mousedown and mouseup events
document.oncontextmenu = nocontextmenu;
document.onmousedown = mouseDown;
document.onmouseup = mouseDown;
document.onkeydown = CheckKey;
document.onhelp = dsble_Help;

