//Filename: functions.js
//Written by: Dave Dudman
//Description: This file contains javascript routines which are local to this application


//Specify Global variables

// used for Stripping out any spaces
  var noGSpace = /\s/g

  // used ofr add to favourites 
var ukpsurl="http://www.ukprivateschools.com/";
var ukpstitle="Ukprivateschools.com";

var strShortDate; //date in format nnth month 2006


//*********************************************************
function fncShowDate()
{
  var months=new Array(13);
  var strsuffix;
months[1]="January";
months[2]="February";
months[3]="March";
months[4]="April";
months[5]="May";
months[6]="June";
months[7]="July";
months[8]="August";
months[9]="September";
months[10]="October";
months[11]="November";
months[12]="December";
var days= new Array(8);
days[1]="Sunday";
days[2]="Monday";
days[3]="Tuesday";
days[4]="Wednesday";
days[5]="Thursday";
days[6]="Friday";
days[7]="Saturday";
var time=new Date();
var lmonth=months[time.getMonth() + 1];
var date=time.getDate();
var year=time.getYear();
var lday=days[time.getDay() + 1];
if ((navigator.appName == "Microsoft Internet Explorer") && (year < 2000))		
year="19" + year;
if (navigator.appName == "Netscape")
year=1900 + year;
//document.write("<center>" + lday + " " + lmonth + " ");
//document.write(date + ", " + year + "</center>");
document.write(lday + " " + lmonth + " ");
document.write(date + ", " + year );

//alert("date=" + date);
switch (date)
{
	case 1 :
	case 21:
	case 31:
	   strsuffix = "st";
	   break;
	case 2 :
	case 22 :
		   strsuffix = "nd";
		   break;
	case 3 :
	case 23:
		   strsuffix = "rd";
		   break;
	case 4:
	case 5:
	case 6:
	case 7:
	case 8:
	case 9:
	case 10:
	case 11:
	case 12:
	case 13:
	case 14:
	case 15:
	case 16:
	case 17:
	case 18:
	case 19:
	case 20:
	case 24:
	case 25:
	case 26:
	case 27:
	case 28:
	case 29:
	case 30:
		   strsuffix = "th";
		   break;
	default:
	   strsuffix = "what";
		   break;
}
strShortDate = date + "<sup>" + strsuffix + "</sup> " + lmonth + " " + year;
//alert("strShortDate=" + strShortDate);
}


//*********************************************************
function fncAddtoFavourites()
{

//Show 'add to favourite for IE'
//Show 'add bookmark' for firefox and Netscape 

  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4))
   {
    document.write('<a href="javascript:window.external.AddFavorite(ukpsurl,ukpstitle);" title="Add to  your favourites">');
    document.write("Add this site to your Favourites</a>");}
   else if (navigator.appName == "Netscape") {
    document.write('<a href="javascript:window.sidebar.addPanel(ukpstitle,ukpsurl,\'\');" title="Add to your bookmarks">');
	   document.write("Add this site to your Bookmarks</a>");
   } else
     {
       var msg = "<b>Add this site to your Bookmarks</b>";
       if(navigator.appName == "Netscape") msg += " <b> - press(Ctrl-D) on your keyboard.<br>Mac users press Command-D<br> or CTRL-T (Opera) to bookmark</b>";
        document.write(msg);
     }
}

