//	Javascript for main page buttons
var hasImage = false;
// Check on Browser type
bName = navigator.appName;
bVer = parseInt(navigator.appVersion);
if ((bName == "Netscape" && bVer >= 3) ||
    (bName == "Mozilla" && bVer >= 5) ||
    (bName == "Microsoft Internet Explorer" && bVer >= 4)) {
    hasImage = true;
    // Create an associative array of buttons
    // new Array doesn't work in Netscape 2, so declare it here
    Buttons = new Array();
    crButton("accomm");
    crButton("eat");
    crButton("forsale");
    crButton("adverts");
    crButton("classifieds");
    crButton("gazetteer");
//    crButton("news");
    crButton("events");
    crButton("offers");
    crButton("shop");
    crButton("students");
    crButton("todo");
    crButton("about");
}	
// Create a button object
function Button(name) {
    this.off = new Image();
    this.off.src = "/gfx/buts/off/" + name + ".gif";
    this.on = new Image();
    this.on.src = "/gfx/buts/on/" + name + ".gif";
}
function crButton(name) {
    Buttons[name] = new Button(name);
}
function iOn(imgName) {
    if (hasImage == true) {
	document[imgName].src = Buttons[imgName].on.src;
    }
}
function iOff(imgName) {
    if (hasImage == true) {
	document[imgName].src = Buttons[imgName].off.src;
    }
}

function winLaunch(theURL,winName,targetName,features) { 
eval(winName+"=window.open('"+theURL+"','"+targetName+"','"+features+"')")
eval(winName+".focus()");
}

function cccdate()
{
	months = new Array();
	months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
	now = new Date;
	day = ordinal(now.getDate());
	return(day+" "+months[now.getMonth()]+" "+now.getFullYear());
}
function ordinal(i)
{ 
        suffix = "th";
        if (i == 1 || i == 21 || i == 31) {
                suffix = "st";
        }
        if (i == 2 || i == 22) {
                suffix = "nd";
        }
        if (i == 3 || i == 23) {
                suffix = "rd";
        }
        res = i + suffix;
        return (res);
}
