var ID_Unknown = 'UNKNOWN';
var ID_Firefox = 'FIREFOX';
var ID_IExplorer = 'MICROSOFT INTERNET EXPLORER';
var ID_Netscape = 'NETSCAPE';
var ID_Opera = 'OPERA';
var ID_Safari = 'SAFARI';
var ID_AOL = 'AOL';
var SaveBrowserID = null;

function isFF() {return (getBrowserID() == ID_Firefox);}
function isIE() {return (getBrowserID() == ID_IExplorer);}
function isNS() {return (getBrowserID() == ID_Netscape);}
function isOP() {return (getBrowserID() == ID_Opera);}
function isSA() {return (getBrowserID() == ID_Safari);}
function isAO() {return (getBrowserID() == ID_AOL);}

function getBrowserID() {
	if (SaveBrowserID) return SaveBrowserID;
	var appName = (navigator.appName) ? navigator.appName.toUpperCase() : '';
	if (appName != '') {
	  if (!SaveBrowserID) SaveBrowserID = appName.match(ID_IExplorer);
	  if (!SaveBrowserID) SaveBrowserID = appName.match(ID_Opera); 
	  if (SaveBrowserID) return SaveBrowserID;
	}
	var userAgent = (navigator.userAgent) ? navigator.userAgent.toUpperCase() : '';
	if (userAgent != '') {
	  if (!SaveBrowserID) SaveBrowserID = userAgent.match(ID_Firefox); 
	  if (!SaveBrowserID) SaveBrowserID = userAgent.match(ID_Opera); 
	  if (!SaveBrowserID) SaveBrowserID = userAgent.match(ID_Safari);
	  if (!SaveBrowserID) SaveBrowserID = userAgent.match(ID_AOL); 
	  if (SaveBrowserID) return SaveBrowserID;
	}
	var appVersion = (navigator.appVersion) ? navigator.appVersion.toUpperCase() : '';
	if (appVersion != '') {
	  if (!SaveBrowserID) SaveBrowserID = appVersion.match(ID_Safari); 
	  if (SaveBrowserID) return SaveBrowserID;
	}
	if (appName != '') {
	  if (!SaveBrowserID) SaveBrowserID = appName.match(ID_Netscape); 
	  if (SaveBrowserID) return SaveBrowserID;
	}
	SaveBrowserID = ID_Unknown; 
	return SaveBrowserID;
}

if (!document.getElementById) document.getElementById = document_getElementById;
function document_getElementById(aId) {
	return (document.all) ? document.all[aId] : document.layers[aId];
}

if (!window.innerHeight) window.innerHeight = window_innerHeight();
function window_innerHeight() {
	return (document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.clientHeight;
}

function setElementOpacity(aElement, aOpacity) {
	aOpacity = (aOpacity == 100) ? 99.999 : aOpacity;
	var style = aElement.style;
	style.filter = "alpha(opacity:" + aOpacity + ")"; // IE/Win
	aOpacity = aOpacity / 100;
	style.KHTMLOpacity = aOpacity; // Safari<1.2, Konqueror
	style.MozOpacity = aOpacity; // Older Mozilla and Firefox
	style.opacity = aOpacity; // Safari 1.2, newer Firefox and Mozilla, CSS3
}

function addBookmark(aURL, aTitle) {
	if (window.sidebar) { // Mozilla Firefox Bookmark
	  window.sidebar.addPanel(aTitle+'_false', aURL, false);
	} else 
	  if (window.external) { // IE Favorite
	    window.external.AddFavorite(aURL, aTitle); 
	  } else 
	    if (window.opera && window.print) { // Opera
	      var elem = document.createElement('a');
	      elem.setAttribute('href', aURL);
	      elem.setAttribute('title', aTitle);
	      elem.setAttribute('rel', 'sidebar');
	      elem.click();
	    }	
}

function NewXMLDoc() { // IE5+
	var xmlDoc = null;
	// IE
	if (window.ActiveXObject) { 
	  try { xmlDoc = new ActiveXObject('Msxml2.XMLDOM'); } 
	  catch (e) {
	    try { xmlDoc = new ActiveXObject('Microsoft.XMLDOM'); } 
	    catch (e) { xmlDoc = null; }
	  }
	}
	if (xmlDoc) return xmlDoc;
	// FF, OP etc.
	if (document.implementation) { if (document.implementation.createDocument) { xmlDoc = document.implementation.createDocument('','',null); } }
	return xmlDoc;
}