//retrieve the browser name and the version

var browserName = navigator.appName;
var browserVersion = navigator.appVersion;
//var userAgent = navigator.userAgent;

//identify the broswer version
//whether they are IE or NS

var app_number = parseInt(browserVersion);

var IE4=false;
var IE4_UP=false;
var NS4=false;
var NS4_UP=false;
var NS6=false;

if (browserName.indexOf("Microsoft")!= -1 ) {

	if (app_number==4) {
		IE4=true;
	}
	if (app_number>=4) {
		IE4_UP=true;
	}

}
else if (browserName.indexOf("Netscape")!= -1) {
	
	if (app_number==4) {
		NS4=true;
	}
	if (app_number>=4) {
		NS4_UP=true;
	}
	if (app_number==5) {
		NS6=true;
	}

}

function getLocalDate(form_name,input_name)
{
	textmonth = new Array(12);
	textmonth[0] = "January"
	textmonth[1] = "February"
	textmonth[2] = "March"
	textmonth[3] = "April"
	textmonth[4] = "May"
	textmonth[5] = "June"
	textmonth[6] = "July"
	textmonth[7] = "August"
	textmonth[8] = "September"
	textmonth[9] = "October"
	textmonth[10] = "November"
	textmonth[11] = "December"

	dayofweek = new Array (7);
	dayofweek[0] = "Sunday"
	dayofweek[1] = "Monday"
	dayofweek[2] = "Tuesday"
	dayofweek[3] = "Wednesday"
	dayofweek[4] = "Thursday"
	dayofweek[5] = "Friday"
	dayofweek[6] = "Saturday"

	thedate = new Date();
	day_of_week = thedate.getDay();
	day = thedate.getDate();
	month = thedate.getMonth();
      	year = thedate.getFullYear();

	if (day > 9) {
		last = 1;
	}
	else {
		last = 0;
	}

	if (day.toString().charAt(last) == 1 && day != 11) {
		suffix = "st";
	}
	else if (day.toString().charAt(last) == 2 && day != 12) {
		suffix = "nd";
	}
	else if (day.toString().charAt(last) == 3 && day != 13) {
		suffix = "rd";
	}
	else {
		suffix = "th";	
	}

	concat_date = dayofweek[day_of_week] + ', ' + textmonth[month] + ' ' + day + suffix + ', ' + year;	

	modifyInputElementSize(form_name,input_name,concat_date.length);

	eval("document."+form_name+"."+input_name).value = concat_date;

}

function getLocalTime(form_name,input_name) 
{
	var today = new Date();

	localDate = forMat(today);

	modifyInputElementSize(form_name,input_name,localDate.length);

	eval("document."+form_name+"."+input_name).value = localDate;

	setTimeout("getLocalTime('" + form_name + "', '" + input_name + "')",100);
}


function getGMTTime(form_name, input_name, GMTOffset) 
{
	var today = new Date();

	today.setHours(today.getUTCHours());
	today.setMinutes(today.getUTCMinutes());
	today.setSeconds(today.getUTCSeconds());

	var timediff = (GMTOffset*60*60*1000);

	today.setTime(today.getTime()+timediff);

	eval("document."+form_name+"."+input_name).value = forMat(today);

	setTimeout("getLocalTime('" + form_name + "', '" + input_name + "', " + GMTOffset + ")",100);
}

//padout the number so it is always displays 2 digits. 
//If the number us "8", the padout would mean "08".

function padout(number) { 
	return (number < 10) ? '0' + number : number; 
}

//format the time so it is displayed with the " hour : minute : seconds " template.

function forMat(thetime)
{
	var th=padout(thetime.getHours());
	var tm=padout(thetime.getMinutes());
	var ts=padout(thetime.getSeconds());

	return (th+':'+tm+':'+ts);
}

//forward to another webpage.

function forwardPage(object) 
{
	var webpage;
	webpage = object.options[object.selectedIndex].value;
	window.location = webpage;
}

function getLastModified()
{
	document.write(document.lastModified);
}

/*
	modify the size of the form input elements.
	Include Text, Select, Check boxes, Radio

	@param	form_name	Form name inside the HTML page. <FORM>..</FORM>
	@param	input_name	Form elements inside the form of a HTML page. <INPUT>..<SELECT>
	@param	length		Length of Form elements inside the form of a HTML page.
*/

function modifyInputElementSize(form_name, input_name, length)
{
	eval("document."+form_name+"."+input_name).size = length;
}

/*
I have provided a sneak peek of 
  <a href="myimage.gif" 
  onClick="window.open('myimage.gif', 'myWin', 
  'toolbar=no, directories=no, location=no, 
  status=yes, menubar=no, resizable=no, scrollbars=no, 
  width=300, height=200'); 
  return false"
  >my image</a> for you to see.

*/
function openBrowserWindow(url, name, toolbar, directories, location, 
	status, menubar, resizable, scrollbars, width, height)
{
	var windowOptions;
	
	if (toolbar)
	{
		windowOptions+=" toolbar=yes, ";
	}
	if (directories)
	{
		windowOptions+=" directories=yes, ";
	}
	if (location)
	{
		windowOptions+=" location=yes, ";
	}
	if (status)
	{
		windowOptions+=" status=yes, ";
	}
	if (menubar)
	{	
		windowOptions+=" menubar=yes, ";
	}
	if (resizable)
	{
		windowOptions+=" resizable=yes, ";
	}
	if (scrollbars)
	{
		windowOptions+=" scrollbars=yes, ";
	}

	//width of the new window
	windowOptions+=" width="+width+", ";
	//height of the new window
	windowOptions+=" height="+height;

	window.open(url, name, windowOptions);

}

function modifyBrowserWindow(width, height)
{
	window.resizeTo(width, height);
}

function moveBrowserWindow(x, y)
{
	window.moveTo(x, y);
}