/* Version 1.
This file contains a set of standard javascript general functions. */

/* This function writes out the current date and time to the screen. This is output as: tuesday 15th april 2003, 11:27am. Later on move 
the date part of this function to the server side, so that it is not dependent on client side scripting being enabled. */
function write_current_date_and_time()
{
	var date_object,day,date,date_ending,month,year,the_24_hour,hour,minute,am_or_pm,second,day_array,month_array,output_date_time;

	new_date_object=new Date();
	day=new_date_object.getDay();
	date=new_date_object.getDate();
	month=new_date_object.getMonth();
	year=new_date_object.getFullYear();
	the_24_hour=new_date_object.getHours();
	minute=new_date_object.getMinutes();
	second=new_date_object.getSeconds();

	if(the_24_hour<12||the_24_hour==12){hour=the_24_hour;}
	else{hour=the_24_hour-12;}

	if(the_24_hour<12){am_or_pm='am';}
	else{am_or_pm='pm';}

	if(minute<10){minute='0'+minute;}
	if(second<10){second='0'+second;}

	day_array=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');

	if(date==1||date==21||date==31){date_ending='st';}
	else if(date==2||date==22){date_ending='nd';}
	else if(date==3||date==23){date_ending='rd';}
	else{date_ending='th';}

	month_array=new Array('January','February','March','April','May','June','July','August','September','October','November','December');

	output_date_time=day_array[day]+' '+date+'<span class=\'textSuper\'>'+date_ending+'</span> '+month_array[month]+' '+year+', '+hour+':'+minute+'<span class=\'textSmall\'>'+am_or_pm+'</span>';
	document.getElementById('output_current_date_and_time').innerHTML=output_date_time;
}

/* This function opens and populates a window with the required information. If later possible, get this function to resize the window on 
open to a different size (i.e. when the window has already been drawn). This window is intended for windows internal to the site. */
function window_open(url,height_and_width)
{
	var internal_link=window.open(url,'internal_link','left=10,top=10,scrollbars=yes,'+height_and_width+',resizable=yes');
	internal_link.focus();
	return false;
}