/*\
|*|  Dave Sugar
|*|
|*|  browser.js
|*|  9/12/2000
|*|  
|*|  This provides some JavaScript for determining the browser type and version
|*|  Please DON'T use this unless you REALLY REALLY REALLY have to.  You should
|*|  make every attempt to not worry about the browser version/type.  If there
|*|  is something you are trying to do that you think you need this see Dave
|*|  to try and make it work another way.  This is a last resort ONLY!!!  If you
|*|  really really really need to use this, please wrap all uses in other
|*|  java script functions (see javascript_util.js)
\*/

var coll = ""
var styleObj = ""

function isMacintosh ()
{
	return (navigator.platform.indexOf ('Mac') >= 0);
}

function isWindows ()
{
	return (navigator.platform.indexOf ('Win') >= 0);
}


function browserName ()
{	
	return (navigator.appName);
}

function browserVersion ()
{
	return (parseInt (navigator.appVersion));
}

function isNetscape ()
{
	return (navigator.appVersion.indexOf ('MSIE') == -1);
}	
	
function isInternetExplorer ()
{
	return (navigator.appVersion.indexOf ('MSIE') != -1);
}

if (isInternetExplorer ())
{
	coll = "all.";
	styleObj = ".style";	
}

function getObject (i_pObj)
{
	var pObj;
	if (typeof i_pObj == "string")
	{
		if (eval ("document." + coll + i_pObj))
			pObj = eval ("document." + coll + i_pObj + styleObj);
	}
	else
	{
		pObj = i_pObj;
	}

//	if (!pObj)
//		alert ("Invalid Object: " + i_pObj);
	return (pObj);
}

// shiftTo - move object to specified positin
function shiftTo (i_pObj, i_nX, i_nY)
{
	var pObj = getObject (i_pObj);	
	if (isNetscape ())
	{
		pObj.moveTo (i_nX, i_nY);
	}
	else
	{
		pObj.pixelLeft = i_nX;
		pObj.pixelTop = i_nY;
	}
}

// shiftBy - move object by specified offset
function shiftBy (i_pObj, i_nDeltaX, i_nDeltaY)
{
	var pObj = getObject (i_pObj);
	if (isNetscape ())
	{
		pObj.moveBy (i_nDeltaX, i_nDeltaY);
	}
	else
	{
		pObj.pixelLeft += i_nDeltaX;
		pObj.pixelTop += i_nDeltaY;	
	}
}

// setZIndex - set the zorder of an object
function setZIndex (i_pObj, i_nZOrder)
{
	var pObj = getObject (i_pObj);
	pObj.zIndex = i_nZOrder;
}

function getZIndex (i_pObj)
{
	var pObj = getObject (i_pObj);
	return (pObj.zIndex);
}

function setColor (i_pObj, i_nColor)
{
	var pObj = getObject (i_pObj);
	pObj.color = i_nColor;
}

function setBGColor (i_pObj, i_nColor)
{
	var pObj = getObject (i_pObj);
	if (isNetscape ())
	{
		pObj.bgColor = i_nColor;
	}
	else
	{
		pObj.backgroundColor = i_nColor;
	}
}

function getBGColor (i_pObj)
{
	var pObj = getObject (i_pObj);
	if (isNetscape ())
	{
		return (pObj.bgColor);
	}
	else
	{
		return (pObj.backgroundColor);
	}
}

// show - show the object
function show (i_pObj)
{
	var pObj = getObject (i_pObj);
	pObj.visibility = "visible";
}

// hide - hide the object
function hide (i_pObj)
{
	var pObj = getObject (i_pObj);
	pObj.visibility = "hidden";
}

function getObjectLeft (i_pObj)
{
	var pObj = getObject (i_pObj);
	if (isNetscape ())
	{
		return (pObj.left);
	}
	else
	{
		return (pObj.pixelLeft);
	}
}

function getObjectTop (i_pObj)
{
	var pObj = getObject (i_pObj);
	if (isNetscape ())
	{
		return (pObj.top);
	}
	else
	{
		return (pObj.pixelTop);
	}
}

function getObjectHeight (i_pObj)
{
	var pObj = getObject (i_pObj);
	if (isNetscape ())
	{
		return (pObj.clip.height);
	}
	else
	{
		return (pObj.clientHeight);
	}
}

function getObjectWidth (i_pObj)
{
	var pObj = getObject (i_pObj);
	if (isNetscape ())
	{
		return (pObj.clip.width);
	}
	else
	{
		return (pObj.clientWidth);
	}
}

function getInsideWindowWidth ()
{
	if (isNetscape ())
	{
		return (window.innerWidth);
	}
	else
	{
		return (document.body.clientWidth);
	}
}


function getInsideWindowHeight ()
{
	if (isNetscape ())
	{
		return (window.innerHeight);
	}
	else
	{
		return (document.body.clientHeight);
	}
}

var bAudioSetup = false;
//SetupAudio
// function to setup a page to play audio on command.  This function MUST
// be called while the page is loading.
// szAudioName - optional name of audio file to pre-load
function SetupAudio (i_szAudioName)
{
	var szEmbed = "";
	if (typeof i_szAudioName == "string")
		szEmbed = "<embed name='sound1' src='" + i_szAudioName + "' loop='false' autostart='false' hidden='true' mastersound>";
		
	if (isNetscape ())
		document.writeln ("<layer name='audio' height=0 width=0 visibility='hidden'>" + szEmbed + "</layer>");
	else
		document.writeln ("<div style='visibility:hidden' id='audio'>" + szEmbed + "</div>");
	bAudioSetup = true;
}

// PlayAudio
// play an audio clip - name is the path to the audio file (can be relative)
// You MUST call the function 'SetupAudio' on your page before calling this function
function PlayAudio (i_szAudioName)
{
	if (!bAudioSetup)
		return;

	var szEmbed = "<embed name='sound1' src='" + i_szAudioName + "' loop='false' autostart='true' hidden='true' mastersound>";
	if (isNetscape ())
	{
		document.layers["audio"].document.open ();
		document.layers["audio"].document.writeln ("<html><body>");
		document.layers["audio"].document.writeln (szEmbed);
		document.layers["audio"].document.writeln ("</body></html>");
		document.layers["audio"].document.close ();
	}
	else
	{
		document.all("audio").innerHTML = szEmbed;
	}
}
