/*------------------------------------------------------------------
*
* File:			Detectbrowser.js
* Description:	Utilities to determine the type of browser used and
*				to navigate between the pages
*
*	Ver	Date		Init	Comment
*-------------------------------------------------------------------	
*	d1	13-Mar-1999	KK		Created
-------------------------------------------------------------------*/

/////////////////////////////////////////////////////////////////
// Check that we are using above version 4 of Netscape or IE
/////////////////////////////////////////////////////////////////
var nav_iBrowserVer = parseInt(navigator.appVersion);

var nav_bVer4Browser = false;
var nav_bIsNS = navigator.appName == "Netscape";
var nav_bIsIE = navigator.appName == "Microsoft Internet Explorer";

if ( nav_bIsNS || nav_bIsIE )
{
	if (nav_iBrowserVer >= 4)
	{
		nav_bVer4Browser = true;
	}
}

/////////////////////////////////////////////////////////////////


function nav_isNS()
/*
	Returns true if browser used is Netscape
*/
{
	return (navigator.appName == "Netscape");
}

function nav_isIE()
/*
	Returns true if browser used is Netscape
*/
{
	return (navigator.appName == "Microsoft Internet Explorer");
}

//////////////////////////////////////////////////////////////
// Functions used to navigate between pages
//////////////////////////////////////////////////////////////

var nav_sCurDir="";

function nav_setCurDir(sURL)		
/*
	Takes a full URL and parses it to find the current directory.
	Whenever a page loads this function should be called with the URL
	of that page.
*/
{	
	//Set the current directory, to be the directory of the new page
	var i = sURL.lastIndexOf("/");
		
	if (i == -1)
	{
		nav_sCurDir = "";
	}
	else
	{
		nav_sCurDir = sURL.substring(0, i+1);
	}	
}	

function nav_GetRelativeURL(sURL)
/*
	Gets the relative URL from the current directory
*/
{
	//Get relative URL to the new file
	var sRelURL = "";
		
	var i = nav_sCurDir.indexOf("/");
		
	while (i != -1)
	{
		sRelURL += "../";
		
		i = nav_sCurDir.indexOf("/", ++i);
	} 
				
	sRelURL += sURL;
	
	return sRelURL;
}

function nav_GotoURL(sURL)
/*
	Gets the relative URL to sURL from the current directory 
	and goes to that URL.
*/
{
	var sRelURL = nav_GetRelativeURL(sURL);

	//Show the page
	window.location.href  = sRelURL;
}


//////////////////////////////////////////////////////////////
// Functions used to get the query string
//////////////////////////////////////////////////////////////

var nav_sQuery = "";

function nav_getQueryString()
/*
	gets hold of the querystring
*/
{
	nav_sQuery = window.location.search;
	
	if (nav_sQuery.length >1)
	{
		//Get rid of the leading '?'
		nav_sQuery = nav_sQuery.substr(1);
	}
}

function nav_getQueryStringValue(sParamName)
/*
	Takes a parameter to the querystring ang gets the value
*/
{
	if (nav_sQuery.length == 0)
	{
		nav_getQueryString();
	}
	
	var aParamValues = nav_sQuery.split("&");
	
	var sValue="";
	var sParamValue;
	
	//Get the string (parameter) we are searching for and its length
	var sParam = sParamName + "=";
	var iParamLen = sParam.length;
	
	for (var i = 0; i < aParamValues.length; i++)
	{
		sParamValue = aParamValues[i];
	
		if (sParamValue.substr(0, iParamLen).toLowerCase() 
							== sParam.toLowerCase())
		{
			sValue = sParamValue.substr(iParamLen);
			break;
		}
	}
	
	return sValue;
}

/////////////////////////////////////////////////////////////////////
// Function to write the page title
/////////////////////////////////////////////////////////////////////
function nav_WritePageTitle()
/*
	This writes out the title tag, ensuring that all the 
	pages have the same titlebar text, which is currently:
		'Exhibitor Manual Online'
*/
{
	document.write("<TITLE>Exhibitor Manual Online</TITLE>");
}

function nav_WritePageTitleSpecial(sTitle)
/*
	Some pages, most notably the admin pages will need a different 
	titlebar text from the rest of the pages.
*/
{
	document.write("<TITLE>Exhibitor Manual Online - " 
			+ sTitle + "</TITLE>");
}

function nav_WriteShoppingBasketTitle()
/*
	Writes out the titlebar text for the Shopping Basket
*/
{
	document.write("<TITLE>" + nav_GetShoppingBasketTitle() 
		+ "</TITLE>");
}

function nav_GetShoppingBasketTitle()
/*
	Returns the title of the shopping basket
*/
{
	return "Exhibitor Manual Online - Shopping Basket"
}

/////////////////////////////////////////////////////////////////////
// Functions used to write frequently used formatting
/////////////////////////////////////////////////////////////////////
/*
	These don't work in NS, so they're commented out for the moment

*/
//function nav_writePageHeaderTD(sDiv, sText)
/*
	Writes the page header
*/
/*{
	
	
	alert("Bungholio");

	var sHTML =	"<TD BGCOLOR='#008CAD' ALIGN=right>"
		+		"<TABLE BGCOLOR='#008CAD' WIDTH=100%>"
		+		"<TR><TD WIDTH=60px>"
		+		"<IMG SRC='../images/globeWhiteTrans.gif' WIDTH=60px>"
		+		"</TD><TD CLASS=PageHeader valign=top>"
		+		sText
		+		"</TD></TR></TABLE></TD>";

	nav_DocWrite(sDiv, sHTML);

}

//Store the HTML to write a redline here
var nav_sRedLine = "";

function nav_writeRedLine(sDiv)
*//*
	Writes the horizontal red line
*/
/*{
	if (nav_sRedLine.length == 0)
	{
		nav_sRedLine = 
			"<TD WIDTH=1px BGCOLOR='#ff0000'>"
		+	"<IMG SRC='../images/redpixel.gif' Height='100%' Width=1>"
		+	"</TD>";
	}
	
	nav_DocWrite(sDiv, nav_sRedLine);	
}

function nav_DocWrite(sDiv, sText)
{
	var sDoc = "document";
	
	if (nav_bIsNS)
	{
		//Have to get the NS layer's document
		
		if (sLayer)
		{
			sDoc += "." + sDiv + "document";
		}
	}
	
	alert(sDoc);
	
	var objDoc = eval(sDoc);
	objDoc.write(sText);
}
*/
