/*	Copyright (c) 1996,2001 Picdar Technology Limited       All Rights Reserved
 *
 * 	This is UNPUBLISHED PROPRIETARY work of Picdar Technology Limited;
 * 	the contents of this file may not be disclosed to third parties, copied or
 * 	duplicated in any form, in whole or in part, without the prior written
 * 	permission of Picdar Technology Limited
 *
 *	Module   :	Browser001.js
 *
 *	Synopsis :	Javascript common code for Browser utilities.
 *
 *	Author   :	Adam Creeger
 *
 */

/*	Returns the appropriate true / false value to ensure the browser does nothing
 *	when javascript is run from a HREF (i.e. prevents the browser following the HREF)
 */
function ClickReturn()
	{
	theUA = window.navigator.userAgent;
	if (IsUsingIE() && (theUA.indexOf("Mozilla/3") >= 0) && IsUsingMac())
		return true;
	else
		return false;
	}

/* This function returns the name of the user's browser.
	It returns:
	IE if the user is using Internet Explorer.
	NS if the user is using Netscape Navigator.
	UNKNOWN if it is anything else.
*/
function GetBrowserName()
	{
	var result = "UNKNOWN";
	if (IsUsingIE())
		result = "IE";
	else if (IsUsingNS())
		result = "NS";
	return result;
	}

/* This function returns the version of the user's browser.
	It returns -1 if it is unknown.
*/
function GetBrowserVersion()
	{
	var findIndex;
	var browserVersion = -1;
	
	if (IsUsingIE())
		{
		browserVersion = navigator.userAgent.toLowerCase();
		findIndex = browserVersion.indexOf("msie") + 5;
		browserVersion = parseInt(browserVersion.substring(findIndex,findIndex + 1));
		}
	else if (IsUsingNS())
		browserVersion = parseInt(navigator.appVersion.substring(0,1));
	
	return browserVersion;
	}

/* This function returns the name of the OS of the user.
	It returns:
		win2k if the OS is Windows 2000
		winme if the OS is Windows ME
		win98 if the OS is Windows 98
		win95 if the OS is Windows 95
		winnt if the OS is Windows NT
		mac if the OS is Mac OS (any version).
		UNKNOWN if the OS is not recognised.
*/
function GetOS()
	{
	var strBrowser = navigator.userAgent.toLowerCase();
	var result = "UNKNOWN";
	if (strBrowser.indexOf("windows nt 5") != -1)
		result = "win2k";
	else if (strBrowser.indexOf("win 9x 4.9") != -1)
		result = "winme";
	else if (strBrowser.indexOf("win95") != -1 || strBrowser.indexOf("windows 95") != -1)
		result = "win95";
	else if (strBrowser.indexOf("win98") != -1 || strBrowser.indexOf("windows 98") != -1)
		result = "win98";
	else if (strBrowser.indexOf("winnt") != -1 || strBrowser.indexOf("windows nt") != -1)
		result = "winnt";
	else if (strBrowser.indexOf("win16") != -1)
		result = "win16";
	else if (strBrowser.indexOf("mac") != -1)
		result = "mac";
	else if (strBrowser.indexOf("inux") != -1)
		result = "linux";
	return result;
	}



/* This function returns true if the user's browser is Internet Explorer.
*/
function IsUsingIE()
	{
	var result = false;
	var strBrowser = navigator.appName;
	if (strBrowser.indexOf("Microsoft") != -1)
		result = true;
	return result;
	}

/* This function returns true if the user's browser is Netscape Navigator.
*/
function IsUsingNS()
	{
	var result = false;
	var strBrowser = navigator.appName;
	if (strBrowser.indexOf("Netscape") != -1)
		result = true;
	return result;
	}
	
/* This function returns true if the user is on a PC (with windows or Linux).
*/
function IsUsingPC()
	{
	var result = false;
	var strBrowser = navigator.userAgent.toLowerCase();
	if (strBrowser.indexOf("win") != -1)
		result = true;
	else if (strBrowser.indexOf("inux") != -1)
		result = true;
	return result;
	}
	
/* This function return true if the user is on a Mac (PowerPC or 68k).
*/
function IsUsingMac()
	{
	var result = false;
	var strBrowser = navigator.userAgent.toLowerCase();
	if (strBrowser.indexOf("mac") != -1)
		result = true;
	else if (strBrowser.indexOf("68k") != -1)
		result = true;
	return result;
	}
