/*
        File: browser.js
     Version: 1.0

     Created: 02/05/05
    Modified: 08/02/06
   Copyright: Matthew Cassidy 2005
       Email: matt@afterglowmedia.com.au

     Purpose: Returns information about the client browser and performs browser functions
        Note: None

     License: For use solely by Afterglow Media. 
*/


/*----------------------------------------*/
/* Function: clientAppName()              */
/* Returns the name of the client browser */
/*----------------------------------------*/
function clientAppName() {
	return navigator.appName;
}


/*-------------------------------------------*/
/* Function: clientAppVer()                  */
/* Returns the version of the client browser */
/*-------------------------------------------*/
function clientAppVer() {
	return navigator.appVersion;
}


/*---------------------------------------------------------*/
/* Function: testClient(details, testCase)                 */
/* Returns true if the client details supplied are correct */
/*---------------------------------------------------------*/
function testClient(details, testCase) {
	if (details.indexOf(testCase) >= 0) { 
		return 1; 
	}
	return 0;
}


/*---------------------------------------------------------*/
/* Function: isIE()                                        */
/* Returns true if the client browser is Internet Explorer */
/*---------------------------------------------------------*/
function isIE() {
	return testClient(clientAppName(), "Internet Explorer");
}


/*-----------------------------------------------*/
/* Function: isMozilla()                         */
/* Returns true if the client browser is Mozilla */
/*-----------------------------------------------*/
function isMozilla() {
	return testClient(clientAppName(), "Netscape");
}


/*---------------------------------------------*/
/* Function: isWebTV()                         */
/* Returns true if the client browser is WebTV */
/*---------------------------------------------*/
function isWebTV() {
	return testClient(clientAppName(), "WebTV");
}


/*------------------------------------------*/
/* Function: isWindows()                    */
/* Returns true if the client OS is Windows */
/*------------------------------------------*/
function isWindows() {
	return testClient(clientAppVer(), "Win");
}


/*--------------------------------------*/
/* Function: isMac()                    */
/* Returns true if the client OS is Mac */
/*--------------------------------------*/
function isMac() {
	return testClient(clientAppVer(), "Mac");
}


/*-----------------------------------------*/
/* Function: isLinux()                    */
/* Returns true if the client OS is Linux */
/*----------------------------------------*/
function isLinux() {
	return testClient(clientAppVer(), "Linux");
}


/*---------------------------------------*/
/* Function: isUNIX()                    */
/* Returns true if the client OS is UNIX */
/*---------------------------------------*/
function isUNIX() {
	return testClient(clientAppVer(), "X11");
}


/*-----------------------------------*/
/* Function: bookmarkUrl(url, title) */
/* Bookmarks the URL provided        */
/*-----------------------------------*/
function bookmarkUrl(url, title) {
	/* Determine if this is IE and bookmark */
	if (isIE) {
		if (document.all) {
			window.external.AddFavorite(url, title);
		}
		else {
			bookmarkError();
		}
	}
	else {
		bookmarkError();
	}
}


/*----------------------------------------------------------------------------------*/
/* Function: bookmarkError()                                                        */
/* Displays the error message to present to users when auto bookmark is unavailable */
/*----------------------------------------------------------------------------------*/
function bookmarkError() {
	alert("Could not auto-bookmark. Please press CTRL+D to bookmark this page");
}


