//first detect the users browser to determine which disable key script to use
browsername=navigator.appName;
if (browsername.indexOf("Netscape")!=-1)
{browsername="NS"}
else
{if (browsername.indexOf("Microsoft")!=-1)
{browsername="MSIE"}
else {browsername="N/A"}};

//document.write (browsername);

//if browser is a Gecko, use this key disable script
if(browsername=="NS")
{

// Keys to be disabled can be added to the lists below.
// The number is the key code for the particular key
// and the text is the description displayed in the
// status window if the key [combination] is pressed.

var badKeys = new Object();
badKeys.single = new Object();
badKeys.single['8'] = 'Backspace outside text fields';
badKeys.single['13'] = 'Enter outside text fields';
//badKeys.single['116'] = 'F5 (Refresh)'; [geckos think a lowercase t is F5 due to using keypress below; however keypress needs to be there for the netscape browser]
//badKeys.single['122'] = 'F11 (Full Screen)';

badKeys.alt = new Object();
badKeys.alt['37'] = 'Alt+Left Cursor';
badKeys.alt['39'] = 'Alt+Right Cursor';

function checkKeyCode(type, code) {
if (badKeys[type][code]) {
return true;
} else {
return false;
}
}
function getKeyText(type, code) {
return badKeys[type][code];
}

var ie=document.all;
var w3c=document.getElementById&&!document.all;

function keyEventHandler(evt) {
this.target = evt.target || evt.srcElement;
this.keyCode = evt.keyCode || evt.which;
var targtype = this.target.type;
if (w3c) {
if (document.layers) {
this.altKey = ((evt.modifiers & Event.ALT_MASK) > 0);
this.ctrlKey = ((evt.modifiers & Event.CONTROL_MASK) > 0);
this.shiftKey = ((evt.modifiers & Event.SHIFT_MASK) > 0);
} else {
this.altKey = evt.altKey;
this.ctrlKey = evt.ctrlKey;
}
// Internet Explorer
} else {
this.altKey = evt.altKey;
this.ctrlKey = evt.ctrlKey;
}
// Find out if we need to disable this key combination
var badKeyType = "single";
if (this.ctrlKey) {
badKeyType = "ctrl";
} else if (this.altKey) {
badKeyType = "alt";
}
if (checkKeyCode(badKeyType, this.keyCode)) {
return cancelKey(evt, this.keyCode, this.target, getKeyText(badKeyType, this.keyCode));
}
}

function cancelKey(evt, keyCode, target, keyText) {
if (keyCode==8 || keyCode==13) {
// Don't want to disable Backspace or Enter in text fields
if (target.type == "text" || target.type == "textarea") {
window.status = "";
return true;
}
}
if (evt.preventDefault) {
evt.preventDefault();
evt.stopPropagation();
} else {
evt.keyCode = 0;
evt.returnValue = false;
}
window.status = keyText+" is disabled";
return false;
}

function addEvent(obj, evType, fn, useCapture) {
// General function for adding an event listener
if (obj.addEventListener) {
obj.addEventListener(evType, fn, useCapture);
return true;
} else if (obj.attachEvent) {
var r = obj.attachEvent("on" + evType, fn);
return r;
} else {
alert(evType+" handler could not be attached");
}
}
function addKeyEvent() {
// Specific function for this particular browser
var e = (document.addEventListener) ? 'keypress' : 'keydown';
addEvent(document,e,keyEventHandler,false);
}
addKeyEvent();
}


//not a gecko browser, use this key disable script
else
{
function validateKey (evt) 
{				
if (evt.altKey)
{return false;}

	//Backspace and if it was pressed in a textbox		    
	var e = event.srcElement.tagName;
	if (event.keyCode == 8 && e != "INPUT" && e != "TEXTAREA" && e != "PASSWORD")
	{
	event.cancelBubble = true;
	event.returnValue = false;
	}
	
	//Refresh [F5]	
	if(window.event && window.event.keyCode == 116)
    {
    // Capture and remap F5
    window.event.keyCode = 505;
    }
	if(window.event && window.event.keyCode == 505)
    {
    // New action for F5
    return false;
    // Must return false or the browser will refresh anyway
    }
    	
	//end checks

return true;        
}

//end (if/else gecko browser condition)
}


//disable the right mouse click on ALL browsers
document.oncontextmenu=new Function("return false");


// begin LB addition - Jan 2009
// Prevents drag and drop of page images in IE & Geckos

// IE  
document.ondragstart = function(e) {  
return false;  
}  

// Gecko  
document.onmousedown = function(e) {  

if (e && e.preventDefault) {  
var t = e.target;  
var nName = t.nodeName.toLowerCase();  

if (nName == "img") {  
e.preventDefault();  
return false;  
}  

t = t.parentNode;  
}  
}
// end LB addition


			
