/*--[ JAVASCRIPT LIBRARY ]--*/

var doc = document;

var docLoaded = false;
function init()
{ 
	docLoaded = true;
	menuInit();
}

//--[ CURRENT DATE ]

var dow = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
var moy = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var dSuff = ["st", "nd", "rd", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th", "th", "st"];

function writeDate()
{
	// Define elements of date
    var today = new Date();
	var day = dow[today.getDay()];
	var dayOfMonth = today.getDate() + dSuff[today.getDate()-1];
	var month = moy[today.getMonth()];
	var year = today.getYear();

	// Correct year [Mozilla, etc.]
	year += ((year < 1900) ? 1900 : 0)

	// Write date to document
	document.write(day + ",&nbsp;" + dayOfMonth + "&nbsp;" + month + ",&nbsp;" + year);
}

//--[ E-MAIL ADDRESS ENCRYPTER ]

function writeEmail(usr, linkTitle, organisation)
{
	var action = 'mailto:', add2 = '@kerbology', add3 = '.com';
	var eAdd = usr + add2 + add3;
	linkTitle = (linkTitle == " ") ? eAdd : linkTitle;
	doc.write('<a href="' + action + eAdd + '" title="Click to contact ' + organisation + ' by e-mail">' + linkTitle + '</a>');
}

//--[ E-mail Address Encrypter (v1.0) ]

function email(emailUser,emailDomain) 
{
	//var str = 'mailto:';
	//if(!eDomain) eDomain = wsDomain;                 
	window.location = 'mailto:' + emailUser + "@" + emailDomain;
}


//--[ Confirm Record Deletion ]

function confirmDelete(type)
{
    //blur();
    return confirm('Are you sure you want to delete this ' + type + '?');
}


function bookmarkPage()
{
    if (document.all) {
        window.external.AddFavorite(location.href, document.title);
    } else if (window.sidebar) {
        window.sidebar.addPanel(document.title, location.href, "");
    } else {
        alert("Please click Command-D to add this page to your bookmarks/favourites");
    }
}


//--[ EVENT HANDLER ]

/* Thanks to Scott Andrew */
function addEvent(obj, evType, fn){
    if (obj.addEventListener){ 
        obj.addEventListener(evType, fn, true); 
        return true; 
    } else if (obj.attachEvent){ 
        var r = obj.attachEvent("on"+evType, fn); 
        return r; 
    } else { 
        return false; 
    } 
}


//--[ IMAGE SWAPPER ]

function swapImage(target, filename) {
	document[target].src = filename;
}


//----------------------------------------------------------------------------
// Code to determine the browser and version.
//----------------------------------------------------------------------------

function Browser() {

  var ua, s, i;

  this.isIE = false;  // Internet Explorer
  this.isOP = false;  // Opera
  this.isNS = false;  // Netscape
  this.ua   = '';

  ua = navigator.userAgent;

  s = "Opera";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isOP = true;
    this.ua = s;
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.ua = s;
    return;
  }

  // Treat any other "Gecko" browser as Netscape 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.ua = s;
    return;
  }

  s = "MSIE";
  if ((i = ua.indexOf(s))) {
    this.isIE = true;
    this.ua = s;
    return;
  }
}

var browser = new Browser();


