var NN = false;
var IE = false;
var deletecode = 127;
var backspacecode = 8;
var space = 32;
var quote = 39;
var doublequote = 34;
if (navigator.appName == 'Netscape')
  NN = true;
else
  IE = true;
var version = parseInt(navigator.appVersion);

function isEmpty(data) {
  var nonempty = new RegExp('.+');
  if (window.RegExp)
    return !nonempty.test(data);
}
function isEmail(data) {
  var isemail = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,8}|[0-9]{1,3})(\]?)$/;
  var notemail = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/;
  if (window.RegExp) {
    if (!notemail.test(data) && isemail.test(data))
      return true;
    else
      return false;
  }
}
function isDate(data) {
  var isdate = new RegExp('[0-9]{1,2}[-]{1}[0-9]{1,2}[-]{1}[0-9]{4}');
  if (!isdate.test(data))
    return false;
  var entries = data.split("-");
  var month = parseInt(entries[1], 10) - 1;
  var date = new Date(parseInt(entries[2], 10), month, parseInt(entries[0], 10));

  if (month != date.getMonth())
    return false;
  return date.getTime();
}

function linkmouseover(obj) {
  obj.style.color='blue';
}
function linkmouseout(obj) {
  obj.style.color='#4C5D1A';
}
function leftovercolor(obj) {
  obj.style.color='blue';
}
function leftoutcolor(obj) {
  obj.style.color='#1B2F07';
}
function footerovercolor(obj) {
  obj.style.color='red';
}
function footeroutcolor(obj) {
  obj.style.color='#0716DB';
}
function getWindow(url) {
  newWindow = window.open("http://" + url);
}
function getLink(link) {
  location.href = "/index/content/" + link;
}
function getLinkTarget(link, target) {
  location.href = "/index/content/" + link + "#" + target;
}
function getSubTarget(link, sublink, target) {
  location.href = "/index/content/" + link + "/sublink/" + sublink + "#" + target;
}
function getTarget(sublink, target) {
  document.forms['contactus'].department.selectedIndex = sublink;
  location.href = "#" + target;
}
function getKeyCode(evt) {
  if (NN)
    return evt.which;
  else
    return window.event.keyCode;
}

function getTargetObject(evt) {
  if (NN)
    return evt.target;
  else
    return window.event.srcElement;
}
function checkcode(evt, type) {
  var code = getKeyCode(evt);
  if (!isValidCode(code, type)) {
    if (NN)
      return false;
    else {
      window.event.returnValue=false;
      return false;
    }
  }
  return true;
}

function isValidCode(code, type) {
  if (type == 'c' || type == 'm' || type == 'e')
    return true;
  if (code == deletecode || code == backspacecode || code == 0)
    return true;
  if (type == 'n' && code <= 57 && code >= 48)
    return true;
  if (type == 'l' && (isValidCode(code, 'n') || code <= 90 && code >= 65 || code <= 122 && code >= 97))
     return true;
  if (type == 'a' && (code <= 90 && code >= 48 || code == space || code <= 122 && code >= 97 || code == quote || code == doublequote)) 
    return true;
  if (type == 't' && (code >= 40 && code <= 41 || code == space || isValidCode(code, 'n')))
    return true;
  if (type == 'u' && code != space) {
    if ((isValidCode(code, 'a') || isValidCode(code, 't')))
      return true;
  }
  if (type == 'i' && (isValidCode(code, 'a') || isValidCode(code, 't')))
    return true;
  if (type == 'p' && (isValidCode(code, 'l')))
    return true;
  if (type == 'd' && (isValidCode(code, 'n') || code == 45))
    return true;
  if (type == 'f' && (isValidCode(code, 'n') || code == 46))
    return true;
  return false;
}
function getChildWindow(name, width, height) {
  getNewChildWindow("", name, width, height);
}
function getNewChildWindow(url, name, width, height) {
  newWindow = window.open(url, name, 'dependent,width=' + width + ',height=' + height + ',scrollbars=yes,toolbar=no,location=no,menubar=no, statusbar=no,left=50,screenX=50,top=50,screenY=50');
}

