// frame breakout //
// if (window != top) top.location.href = location.href; 

// easy edit popup control //
function runEdit(newURL) 
	{
		var l = (screen.width-730)/2;
		var h = (screen.height-560)/2;
		myRemote = launch(newURL, "EditContent", "scrollbars=0,height=560,width=730,left="+l+",top="+h+"","HTMLEditor");
	}
function launch(newURL, newName, newFeatures, orgName) 
	{
		var remote = window.open(newURL, newName, newFeatures);
		if (remote.opener == null) remote.opener = window;
		remote.opener.name = orgName;
		return remote;
	}

// Email Validation Javascript
// copyright 23rd March 2003, by Stephen Chapman, Felgall Pty Ltd

// You have permission to copy and use this javascript provided that
// the content of the script is not changed in any way.

function validateEmail(addr,man,db) {
if (addr == '' && man) {
   if (db) alert('email address is mandatory');
   return false;
}
if (addr == '') return true;
var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
for (i=0; i<invalidChars.length; i++) {
   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
      if (db) alert('email address contains invalid characters');
      return false;
   }
}
for (i=0; i<addr.length; i++) {
   if (addr.charCodeAt(i)>127) {
      if (db) alert("email address contains non ascii characters.");
      return false;
   }
}

var atPos = addr.indexOf('@',0);
if (atPos == -1) {
   if (db) alert('email address must contain an @');
   return false;
}
if (atPos == 0) {
   if (db) alert('email address must not start with @');
   return false;
}
if (addr.indexOf('@', atPos + 1) > - 1) {
   if (db) alert('email address must contain only one @');
   return false;
}
if (addr.indexOf('.', atPos) == -1) {
   if (db) alert('email address must contain a period in the domain name');
   return false;
}
if (addr.indexOf('@.',0) != -1) {
   if (db) alert('period must not immediately follow @ in email address');
   return false;
}
if (addr.indexOf('.@',0) != -1){
   if (db) alert('period must not immediately precede @ in email address');
   return false;
}
if (addr.indexOf('..',0) != -1) {
   if (db) alert('two periods must not be adjacent in email address');
   return false;
}
var suffix = addr.substring(addr.lastIndexOf('.')+1);
if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
   if (db) alert('invalid primary domain in email address');
   return false;
}
return true;
}

/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Cyanide_7 |  */
var isNN = (navigator.appName.indexOf("Netscape")!=-1);

function autoTab(input,len, e) {
  var keyCode = (isNN) ? e.which : e.keyCode; 
  var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
  if(input.value.length >= len && !containsElement(filter,keyCode)) {
    input.value = input.value.slice(0, len);
    input.form[(getIndex(input)+1) % input.form.length].focus();
  }

  function containsElement(arr, ele) {
    var found = false, index = 0;
    while(!found && index < arr.length)
    if(arr[index] == ele)
    found = true;
    else
    index++;
    return found;
  }

  function getIndex(input) {
    var index = -1, i = 0, found = false;
    while (i < input.form.length && index == -1)
    if (input.form[i] == input)index = i;
    else i++;
    return index;
  }
  return true;
}

/* Use script to filter input boxes  */
function InputLetterNumber(e)
{
 var key;
 var keychar;

 if (window.event)
  key = window.event.keyCode;
 else if (e)
  key = e.which;
 else
  return true;
  keychar = String.fromCharCode(key);
  keychar = keychar.toLowerCase();

 // control keys
 if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) )
    return true;
 // alphas and numbers
 else if ((("abcdefghijklmnopqrstuvwxyz0123456789").indexOf(keychar) > -1))
  return true;
 else
  return false;
}

function InputNumber(e)
{
 var key;
 var keychar;

 if (window.event)
  key = window.event.keyCode;
 else if (e)
  key = e.which;
 else
  return true;
  keychar = String.fromCharCode(key);
  keychar = keychar.toLowerCase();

 // control keys
 if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) )
    return true;
 // alphas and numbers
 else if ((("0123456789").indexOf(keychar) > -1))
  return true;
 else
  return false;
}

