<!--

  function FixURL( Element ) {
    if( !Element.value.match(/http:\/\//gi) && !Element.value.match(/https:\/\//gi) && !Element.value.match(/ftp:\/\//gi) && Element.value != '' ) Element.value = 'http://' + Element.value;
  }

  function DisplayForm( Form ) {
    j = Form.elements.length;
    var s = new String;
    for(i=0;i<j;i++) s = s + i + ', ' + Form.elements[i].name + ': ' + Form.elements[i].value + '\n';
    s = s + 'Action: ' + Form.action + '\n';
    alert(s);
  }

  function replace(str, from, to) {
    var i = str.indexOf(from);
    if (!from || !str || i == -1) return str;
    var newstr = str.substring(0, i) + to;
    if (i+from.length < str.length)
    newstr += replace(str.substring(i+from.length,str.length),from,to);
    return newstr;
  }

  function correctEmail(email) {
    badKeys = " /:;$%^&*()!|\~`=+'><"       //a list of invalid email characters
    
  
    if (email == "") {           //email field can not be empty
    alert("You have not keyed in an email address. Please try again.")
    return false
    }

    if (email == " ") {           //email field can not be empty
    alert("You have not keyed in an email address. Please try again.")
    return false
    }
    
    for (i=0; i<badKeys.length; i++){       //email field can not contain any badKeys
    badChar=badKeys.charAt(i)    
    if (email.indexOf(badChar, 0) > -1) {      //cycles through each character and checks to see if it is valid or not
    alert("There is an invalid character in the email address. Please try again.")  
    return false
      }
    }

    atPos = email.indexOf("@", 0)         // must have a @ 
    if (atPos == -1){
    alert("There must be a @ with in your customer's email address. Please try again.")
    return false
    }
    
    if (atPos < 1) {          //If there is an "@" it can not be the first character of the email address
    alert("The @ character can not be your first character within the email address. Please try again.")
    return false
    }
 
    if(email.indexOf("@", atPos+1) != -1){       // can only have one @
      alert("There can only be one @ within the email address. Please try again.")
    return false
      }

    periodPos = email.indexOf(".", atPos)
    if (periodPos <= atPos + 2) {       //has to have at least a char after the "."
    alert("Invalid email address.  There should be at least 2 characters after the period. Please try again.")
    return false
      }

    if (periodPos < atPos + 1){        //There must be at least one character between the "@" and the "."
    alert("There should be at least one '.' after the @ symbol in the email address. Please try again.")
    return false
    }

 
    return true            //If all returns true then the email address is true
  }




// define using <span id='the_code'>
function CopyToClipboard() {
  obj = null;
  if(document.getElementById) obj=document.getElementById('the_code');
  if (obj) window.clipboardData.setData('Text', obj.innerText);
}
//if(document.getElementById) document.write(" - <a href='javascript:CopyToClipboard()'>Copy Example Code to your Clipboard</a><BR>");




// D I S P L A Y   T O D A Y ' S   D A T E
// Style 1: March 17, 2000
// Style 2: Mar 17, 2000
// Style 3: Saturday March 17, 2000
// Style 4: Sat Mar 17, 2000
// Style 5: Sat March 17, 2000
// Style 6: 17 March 2000
// Style 7: 17 Mar 2000
// Style 8: 17 Mar 00
// Style 9: 3/17/00
// Style 10: 3-17-00
// Style 11: Saturday March 17
// Style 12: Saturday, March 17, 2000
function DisplayDate(style) {
  months = new Array();
  months[1] = "January";  months[7] = "July";
  months[2] = "February"; months[8] = "August";
  months[3] = "March";    months[9] = "September";
  months[4] = "April";    months[10] = "October";
  months[5] = "May";      months[11] = "November";
  months[6] = "June";     months[12] = "December";

  months2 = new Array();
  months2[1] = "Jan"; months2[7] = "Jul";
  months2[2] = "Feb"; months2[8] = "Aug";
  months2[3] = "Mar"; months2[9] = "Sep";
  months2[4] = "Apr"; months2[10] = "Oct";
  months2[5] = "May"; months2[11] = "Nov";
  months2[6] = "Jun"; months2[12] = "Dec";

  days = new Array();
  days[1] = "Sunday";    days[5] = "Thursday";
  days[2] = "Monday";    days[6] = "Friday";
  days[3] = "Tuesday";   days[7] = "Saturday";
  days[4] = "Wednesday";

  days2 = new Array();
  days2[1] = "Sun"; days2[5] = "Thu";
  days2[2] = "Mon"; days2[6] = "Fri";
  days2[3] = "Tue"; days2[7] = "Sat";
  days2[4] = "Wed";

  todaysdate = new Date();
  date  = todaysdate.getDate();
  day  = todaysdate.getDay() + 1;
  month = todaysdate.getMonth() + 1;
  yy = todaysdate.getYear();
  year = (yy < 1000) ? yy + 1900 : yy;
  year2 = 2000 - year; year2 = (year2 < 10) ? "0" + year2 : year2;

  dateline = new Array();
  dateline[1] = months[month] + " " + date + ", " + year;
  dateline[2] = months2[month] + " " + date + ", " + year;
  dateline[3] = days[day] + " " + months[month] + " " + date + ", " + year;
  dateline[4] = days2[day] + " " + months2[month] + " " + date + ", " + year;
  dateline[5] = days2[day] + " " + months[month] + " " + date + ", " + year;
  dateline[6] = date + " " + months[month] + " " + year;
  dateline[7] = date + " " + months2[month] + " " + year;
  dateline[8] = date + " " + months2[month] + " " + year2;
  dateline[9] = month + "/" + date + "/" + year2;
  dateline[10] = month + "-" + date + "-" + year2;
  dateline[11] = days[day] + " " + months[month] + " " + date;
  dateline[12] = days[day] + ", " + months[month] + " " + date + ", " + year;

  document.write(dateline[style]);
}





// B A N N E R   A D   P O P U P
// image = location of image to display
// link = where you will go when you click on image
// usage example: DisplayBanner('../images/banner-ad.jpg',520,220,'http://www.newswire.ca/en/webcast/viewEvent.cgi?eventID=669020')
function DisplayBanner(image,imgwidth,imgheight,link) {
  // has person seen banner today; cookie set to expire after 1 day
  if(getCookie('DisplayBanner') == null) {
    var now = new Date;
    now.setTime(now.getTime() + 30 * 1000);  // adjust for 30 seconds expiry; good for testing
    //now.setTime(now.getTime() + 24 * 60 * 60 * 1000);  // adjust for 24 hours expiry
    // now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);  // adjust for 365 days
    setCookie('DisplayBanner','true',now,'/');
    banner = window.open('','win','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=' + imgwidth + ',height=' + imgheight);
    banner.focus();
    banner.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">');
    banner.document.write('<html>');
    banner.document.write('<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0">');
    banner.document.write('<a href="javascript:window.open(\'' + link + '\',\'win2\',\'toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1,width=720,height=600\');parent.close();"><img border="0" src="' + image + '"></a>');
    banner.document.write('</html>');
    banner.document.write('</body>');
  }
}

// parse url to retrieve form GET values
function GetParm(string,parm) {
  // returns value of parm from string
  var startPos = string.indexOf(parm + "=");
  if (startPos > -1) {
    startPos = startPos + parm.length + 1;
    var endPos = string.indexOf("&",startPos);
    if (endPos == -1)
      endPos = string.length;
    temp = unescape(string.substring(startPos,endPos));
    temp = SearchReplace(temp,'+',' ');
    return temp;
  }
  return '';
}

// search and replace 1 character
// handy when converting '+' in URL to a space when using GetParm
function SearchReplace( str, oldChar, newChar ) {
  var oldString = new String;
  var newString = new String;
  oldString = str;
  newString = '';
  len = oldString.length;
  for(i=0;i<len;i++) {
    temp = oldString.charAt(i);
    if( temp == oldChar ) { temp = newChar; }
    newString = newString + temp;
  }
  return newString;
}

// modified version of Tidy
// automatically set length of currency
function FormatCurrency(y) {
  max_length=("" + y).length + 4; // length of text input
  spacing="$           ";
  x=Math.floor(y);
  xx=y-x;
  xx=xx+"00.00" // cents only (with zeroes)
  a=xx.indexOf(".");
  q=x+xx.substring(a,a+3);
  ql= (q.length<max_length)?(max_length-q.length):0;
  r=(y)?spacing.substring(0,ql)+q:"";
  return (r);
}


function DisplayTime() {
  now = new Date();
  hour = now.getHours();
  minute = now.getMinutes();
  second = now.getSeconds();
  if( hour < 10 ) hour = '0' + hour;
  if( minute < 10 ) minute = '0' + minute;
  if( second < 10 ) second = '0' + second;
  alert('Time: ' + hour + ':' + minute + ':' + second);
}

function validateTime(Form) {
  value = Form.value;
  diffpos = value.indexOf(":");
  lastpos = value.length - 1;
  var last_index_of = value.lastIndexOf(":");
  var hours = new Number(value.substring(0,diffpos));
  var minutes = new Number(value.substring((last_index_of+1),value.length));
  if ((diffpos != 1 && diffpos != 2) || (lastpos - diffpos) != 2 || hours > 12 || minutes > 59) {
    Form.value = '';
    alert('Invalid time. Try again.');
    return false;
  }
  else return true;
}


//// CURRENCY
max_length=12;                         //max_length= length of text input
spacing="$               ";            // if $ sign is not wanted, remove it from spacing string.

// strips an input of any wierd characters and excessive decimal places, and puts a $ sign in front
// e.g.) <input type=text size=12 onchange='clean(this)'>
function clean (w){
    spacing="$               ";
    max_length=12;
  if(!w){
      alert("missing input after "+ w2.name);         
      return(0);
  }
  y="0"+w.value;                          //0 to prevent NaN
  yl=y.length;
  for(z=0;z<yl;z++){
    if(y.charAt(z)<"." || y.substring(z,z+1)>"9" || y.substring(z,z+1)=="/"){
      y=(y.substring(0,z) + y.substring(z+1));
      z--;
      yl--;
    }
  }
  y=parseFloat(y);
  x=Math.floor(y);
  xx=y-x;
  xx=xx+"00.00"                 //xx=the cents only (with zeroes).
  a=xx.indexOf(".");
  q=x+xx.substring(a,a+3);

  ql= (q.length < max_length)?(max_length-q.length):0;
  w.value=(y)?spacing.substring(0,ql)+q:"";
  r=parseFloat(q);                            //should be dddd.dd
  w2=w;
  return (r);
}

// converts it into a dollar format
// e.g.) <input type=text size=12 onchange='document.frusin.gst.value=tidy(clean(this)*0.125)'>
function tidy (y){
    max_length=12;                         //max_length= length of text input
    spacing="$               ";
    x=Math.floor(y);
    xx=y-x;
    xx=xx+"00.00"                 //xx=the cents only (with zeroes).
    a=xx.indexOf(".");
    q=x+xx.substring(a,a+3);
    ql= (q.length<max_length)?(max_length-q.length):0;   
    r=(y)?spacing.substring(0,ql)+q:"";
    return (r);
}

// display: tidy() prepares input for display leaving 2 decimal places
// like tidy, without the $ sign, or the spacing to align the decimal points
function display(numb){
  if (parseFloat(numb)){
    if (numb== Math.round(numb)){
      return ( numb + ".00")
    }
    else {
      numb=(numb + "0");
      return (numb.substring(0,(numb.indexOf(".")+3)))
    }
  }
  else{
    return "0.00"
  }
}

// complement to display, similar in function to clean. It removes commas and spaces (but not other characters) from an input
// e.g.) <input type=text name=k size=12 onchange='this.form.o=display(trim(this)/11)'>
function trim(w){
  if(!w){
      return(0);
  }
  y=w.value;                          //0 to prevent NaN
  yl=y.length;
  for(z=0;z<yl;z++){
    if(y.charAt(z)=="," || y.substring(z,z+1)==" " || y.substring(z,z+1)=="/"){
      y=(y.substring(0,z) + y.substring(z+1));
      z--;
      yl--;
    }
  }
  numb=parseFloat(y);
  if (isNaN(numb)){
      w.value='';
      return 0}  
    if (numb== Math.round(numb)){
        w.value= numb + ".00"
        return parseFloat( numb + ".00")
    }
    else {
        numb=(numb + "0");
        w.value=numb.substring(0,(numb.indexOf(".")+3))
        return parseFloat(numb.substring(0,(numb.indexOf(".")+3)))
    }
}

//// END CURRENCY

function SearchReplace(str, oldChar, newChar) {
  var oldString = new String;
  var newString = new String;
  oldString = str;
  newString = '';
  len = oldString.length;
  for(i=0;i<len;i++) {
    temp = oldString.charAt(i);
    if( temp == oldChar ) { temp = newChar; }
    newString = newString + temp;
  }
  return newString;
}



function formatDate(date) {
  time = 'am';
  year = date.substring(0,4);
  month = date.substring(5,7);
  day = date.substring(8,10);
  hour = date.substring(11,13);
  minutes = date.substring(14,16);
  seconds = date.substring(17,19);
  if(month.charAt(0) == '0') { month = month.charAt(1); }
  if(day.charAt(0) == '0') { day = day.charAt(1); }
  if(hour.charAt(0) == '0') { hour = hour.charAt(1); }
  switch (month) {
    case '1':
      month = "January";
      break;
    case '2':
      month = "February";
      break;
    case '3':
      month = "March";
      break;
    case '4':
      month = "April";
      break;
    case '5':
      month = "May";
      break;
    case '6':
      month = "June";
      break;
    case '7':
      month = "July";
      break;
    case '8':
      month = "August";
      break;
    case '9':
      month = "September";
      break;
    case '10':
      month = "October";
      break;
    case '11':
      month = "November";
      break;
    case '12':
      month = "December";
      break;
    default:
      break;
  }
  hour = parseInt(hour);
  if(hour > 0) {
    if(hour == 12) { time = 'pm'; }
    if(hour > 12) { time = 'pm'; hour = hour - 12; }
    document.write(month + ' ' + day + ', ' + year + ' ' + hour + ':' + minutes + ' ' + time);
  } else document.write(month + ' ' + day + ', ' + year);
}


function openFullWindow(url) {
  mywin = window.open(url,"win",',type=fullWindow,fullscreen,scrollbars=no');
}

function openWindow(url,x,y) {
  mywin = window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=' + x + ',height=' + y + '');
}

function openWindow2(url,x,y) {
  mywin = window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=' + x + ',height=' + y + '');
}

function openWindow3(url,x,y) {
  mywin = window.open(url,"win",'toolbar=1,location=1,directories=0,status=1,menubar=1,scrollbars=0,resizable=1,width=' + x + ',height=' + y + '');
}

function openWindow4(url,x,y) {
  mywin = window.open(url,"win",'toolbar=1,location=1,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=' + x + ',height=' + y + '');
}

function openWindow5(url,x,y) {
  mywin = window.open(url,"win",'toolbar=1,location=1,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=' + x + ',height=' + y + '');
}

// Added screen coordinates (Allen)
function openWindowXY(url,x,y,screenX,screenY,top,left) {
  mywin = window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=' + x + ',height=' + y + ',screenX=' + screenX + ',screenY=' + screenY + ',top=' + top + ',left=' + left);
}

function closewindow() { window.close(); }

function printPage() {
  if (window.print)
    window.print()
  else
    alert("Sorry, your browser doesn't support this feature.");
}

// Error Trap JavaScript Errors
function doNothing() {
  return true
}

window.onerror = doNothing

// function to set the Status Bar message
function setStatusBar(msg) {
  if (document.images) {
    window.status = msg
    return true
  }
  return false
}

// function to check for 'Enter' key
function checkForEnter(e) {
  e = (e) ? e : event
  var charCode = (e.which) ? e.which : e.keyCode
  if (charCode == 13) {
    return true
  }
  return false
}

function checkForNum(Form, e) {
  tempvalue = Form.value;
  e = (e) ? e : event;
  var charCode = (e.which) ? e.which : e.keyCode;
  // accept characters 0-9 and backspace
  if ((charCode >= 48 && charCode <= 58) || charCode >= 96 && charCode <= 105 || charCode == 8) {
    return true;
  }
  value = '';
  for(i=0;i<tempvalue.length-1;i=i+1) {
    value = value + tempvalue.charAt(i);
  }
  Form.value = value;
  return false;
}

// ...
// onchange = "highlight( event, null )"
// highlight( event, document.forms[0].element[0] )
var highlightcolor = "lightyellow";
var backgroundcolor = "#FFFFFF";
var ns6 = document.getElementById && !document.all;
var previous = '';
var eventobj;
var intended = /INPUT|TEXTAREA|SELECT|OPTION/;

// check whether element clicked is form element
function checkel( which ) {
	if( which.style && intended.test(which.tagName) ) {
		if( ns6 && eventobj.nodeType == 3 ) eventobj = eventobj.parentNode.parentNode;
		return true;
	}
	else return false;
}

// highlight form element
function highlight( e, element ) {
	eventobj = ns6 ? e.target : event.srcElement;
	if( element != null ) eventobj = element;
	if( previous != '' ) {
		if( checkel(previous) ) previous.style.backgroundColor = '';
		previous = eventobj;
		if( checkel(eventobj) ) eventobj.style.backgroundColor = highlightcolor;
	}
	else {
		if( checkel(eventobj) ) eventobj.style.backgroundColor = highlightcolor;
		previous = eventobj;
	}
}

// dim form element
function dim( e, element ) {
  eventobj = ns6? e.target : event.srcElement;
	if( element != null ) eventobj = element;
  if( previous != '' ) {
    if( checkel(previous) ) previous.style.backgroundColor = '';
    previous = eventobj;
    if( checkel(eventobj) ) eventobj.style.backgroundColor = backgroundcolor;
  }
  else {
    if( checkel(eventobj) ) eventobj.style.backgroundColor = backgroundcolor;
    previous = eventobj;
  }
}
// ...

// display all values of elements in form; used for debugging
function DisplayForm(Form) {
  j = Form.elements.length;
  var s = new String;
  for(i=0;i<j;i++) s = s + i + ', ' + Form.elements[i].name + ': ' + Form.elements[i].value + '\n';
  alert(s);
}

// dynamically select item in list based on what you type in txtSearch field
// <input type="text" name="txtSearch" size="30" onKeyUp="selectSearch('frmSelect', 'txtSearch', 'selList')">
function selectSearch(Form, txtSearch, selList) {
	sSearchString = document.forms[Form].elements[txtSearch].value.toUpperCase();
	iSearchTextLength = sSearchString.length;
	for (j=0; j < document.forms[Form].elements[selList].options.length; j++) {
		sOptionText = document.forms[Form].elements[selList].options[j].text;
		sOptionComp = sOptionText.substr(0, iSearchTextLength).toUpperCase();
		if(sSearchString == sOptionComp) {
			document.forms[Form].elements[selList].selectedIndex = j;
			break;
		}
	}
}



////////////////////// C O O K I E   C U T T I N G ///////////////////////

// name - name of the cookie
// value - value of the cookie
// [expires] - expiration date of the cookie (defaults to end of current session)
// [path] - path for which the cookie is valid (defaults to path of calling document)
// [domain] - domain for which the cookie is valid (defaults to domain of calling document)
// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission
// * an argument defaults when it is assigned null as a placeholder
// * a null placeholder is not required for trailing omitted arguments
// example) setCookie('Nav1','',null,'/')
function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
                  ((expires) ? "; expires=" + expires.toGMTString() : "") +
                  ((path) ? "; path=" + path : "") +
                  ((domain) ? "; domain=" + domain : "") +
                  ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist
// example) getCookie('Nav1')
function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  pattern = /\++/g;  // globally look for 1 or more '+'
  dc = dc.replace(pattern," ");  // replace all '+' with ' '
  return unescape(dc.substring(begin + prefix.length, end));
}

// name - name of the cookie
// [path] - path of the cookie (must be same as path used to create cookie)
// [domain] - domain of the cookie (must be same as domain used to create cookie)
// * path and domain default if assigned null or omitted if no explicit argument proceeds
function deleteCookie(name, path, domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" + 
                      ((path) ? "; path=" + path : "") +
                      ((domain) ? "; domain=" + domain : "") + 
                      "; expires=Fri, 31 Dec 1999";
  }
}

// date - any instance of the Date object
// * hand all instances of the Date object to this function for "repairs"
function fixDate(date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0)
    date.setTime(date.getTime() - skew);
}

//-->
