
Function.prototype.inheritsFrom = function( parentClassOrObject ){
	if ( parentClassOrObject.constructor == Function )
	{
		//Normal Inheritance
		this.prototype = new parentClassOrObject;
		this.prototype.constructor = this;
		this.prototype.parent = parentClassOrObject.prototype;
	}
	else
	{
		//Pure Virtual Inheritance
		this.prototype = parentClassOrObject;
		this.prototype.constructor = this;
		this.prototype.parent = parentClassOrObject;
	}
	return this;
}

function switchDisplay(elem){
  var elem = document.getElementById(elem) ? document.getElementById(elem) : elem;
  if(elem){
    if(!elem.style.display) elem.style.display = 'block';
    elem.style.display = elem.style.display == 'block' ? 'none' : 'block';
  }
}

  if (typeof window.event != 'undefined'){ 
  	document.onkeydown = function(){
  	  if(event.keyCode == 8){ //backspace
        if(event.srcElement.tagName.toUpperCase() == 'TEXTAREA'){
          return true;
        }else if(event.srcElement.tagName.toUpperCase() == 'INPUT'){
          if(event.srcElement.type.toUpperCase() == 'TEXT' || event.srcElement.type.toUpperCase() == 'PASSWORD'){ 
            return true;
          }else{
            return false;
          }
        }else{
          return false;
        }
      }
  	}
  }else{
  	document.onkeypress = function(e){
      if(e.keyCode == 8){ //backspace
        if(e.target.nodeName == 'TEXTAREA'){
          return true;
        }else if(e.target.nodeName == 'INPUT'){
          if(e.target.type.toUpperCase() == 'TEXT' || e.target.type.toUpperCase() == 'PASSWORD'){ 
            return true;
          }else{
            return false;
          }
        }else{
          return false;
        }
      }
  	}
	}
//}

function getElementsByClass(node,searchClass,tag){
  var classElements = new Array();
  var els = node.getElementsByTagName(tag);
  var elsLen = els.length;
  for (i = 0, j = 0; i < elsLen; i++){
    if (els[i].className == searchClass){
      classElements[j++] = els[i];
    }
  }
	return classElements;
}

function setClassCSS(cname, rname, val){
  if (!document.styleSheets) return;
  
  var css = new Array();
  if (document.styleSheets[0].cssRules)  // Standards Compliant
    css = document.styleSheets[0].cssRules;
  else
    css = document.styleSheets[0].rules;  // IE 

  for(i=0;i<css.length;i++){
    if(css[i].selectorText == cname){
      css[i].style[rname] = val;
      //css[i].style.cssText="font-weight:normal; color:red";
      //style[element] = value;
    }
  }
}

//disableBackSpace();