﻿function IsElementSelectable(element){
   if (element==null) return false;
   if (element.tagName=="INPUT") return true;
   if (element.tagName=="SELECT") return true;
   if (element.tagName=="TEXTAREA") return true;
   
   var e = element;       
   while (e!=null) {
     if (e.id=="divnoselectable") return false;
     if (e.id=="ctl00_divcontent")
       return true;
     e = e.parentElement;
   }
   return false;
}


document.onselectstart = function(){     
  return IsElementSelectable(document.activeElement);
  
}

 
document.onselectionchange = function(){

 var rng = document.selection.createRange(); 
 if (!IsElementSelectable(rng.parentElement()))   
   document.selection.empty();
 
} 


function ClearDebug(text){
  var div = document.getElementById("divDebug");
  div.innerHTML = text;
}

function WriteDebug(text){
  var div = document.getElementById("divDebug");
  div.innerHTML += text +"<br/>";
}  