/*************************************************************/
/*   Key Down Event
/*************************************************************/
//Disable backspace except in text fields
document.onkeydown = onKeyDown;
function onKeyDown()
{
		if (window.event.keyCode == 8 && whichElement(event) != 'text')
			return false;
		else
			return true;
}

/*************************************************************/
/*   Mouse Down Event
/*************************************************************/
function whichElement(e)
{
   var targ
   if (!e) 
      var e = window.event
   if (e.target) 
      targ = e.target
   else if (e.srcElement) 
      targ = e.srcElement
   if (targ.nodeType == 3) 
      targ = targ.parentNode
   
   var type
   type = targ.type
   //alert("You clicked on a " + type + " element.")
   return type;
}

document.onmousedown = mouseDown;
function mouseDown() 
{
    // Disable right-click menu
    if (event.button==2 && whichElement(event) == 'text') 
    {
        document.oncontextmenu=new Function("return true;");
        return true;
    }
    else
    {
        document.oncontextmenu=new Function("return false;");
        return false; 
    }
}

/*************************************************************/
/*   Select Event
/*************************************************************/
//Disable select on page
document.onselectstart=function()
{
	if(whichElement(event) == 'text')
		return true;
	else
		return false;
}