﻿// JScript File

 
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
} 
function addCss(cssCode) {
  var styleElement = document.createElement('style');
  styleElement.type = 'text/css';
  if (styleElement.styleSheet) {
    styleElement.styleSheet.cssText = cssCode;
  } else {
    styleElement.appendChild(document.createTextNode(cssCode));
  }
  document.getElementsByTagName('head')[0].appendChild(styleElement);
}

function addRssLink(fileName) {
//debugger;

var styleElement = document.createElement('link');
  styleElement.type = 'application/rss+xml';
  styleElement.rel = 'alternate';
  styleElement.href=fileName;
  styleElement.title='RSS';

  
  document.getElementsByTagName('head')[0].appendChild(styleElement);
}
  
function getKeyCode(e)
{
	if (window.event)
		return window.event.keyCode;
	else if (e)
		return e.which;
	else
		return null;
}
  
function keyRestrict(e, validchars) {
	var key='', keychar='';
	key = getKeyCode(e);
	if (key == null) return true;
	keychar = String.fromCharCode(key);
	keychar = keychar.toLowerCase();
	validchars = validchars.toLowerCase();
	if (validchars.indexOf(keychar) != -1)
		return true;
	if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
		return true;
	return false;
}

function isValueInRange(value, minValue, maxValue) {
  if ((value < minValue) || (value > maxValue)) {
    return false;
  } else {
    return true;
  }
}