//-----------------------------------------------------------------------------
//
// This file provides common <head> content for all HTML browser dependent
// on the browser in use.
//
//-----------------------------------------------------------------------------

function IsIE55()
{
	var bRetVal = false;
	var appCodeIndex = navigator.appVersion.indexOf('MSIE ');
	
	// Is this IE?
	if (appCodeIndex != -1)
	{
		// Yes, which version is it?
		var fVersion = parseFloat(navigator.appVersion.substr(appCodeIndex+5));
		
		// Is the version larger than 5.5?
		bRetVal = (fVersion >= 5.5);		
	}
	
	return bRetVal;	
}

function IsIE4()
{
	var bRetVal = false;
	var appCodeIndex = navigator.appVersion.indexOf('MSIE ');
	
	// Is this IE?
	if (appCodeIndex != -1)
	{
		// Yes, which version is it?
		var fVersion = parseFloat(navigator.appVersion.substr(appCodeIndex+5));
		
		// Set the return value
		bRetVal = (fVersion >= 4.0);
	}
	
	return bRetVal;
}

function IsNetscape()
{
	// Is this NS 4?
	var bRetVal = document.layers;
		
	if (document.layers)
	{
		// Netscape 4.x
		bRetVal = true;
	}
	else
	{
		bRetVal = ((navigator.userAgent.indexOf('Netscape') != 0) || (navigator.userAgent.indexOf('Mozilla') != 0)) && navigator.appName != 'Microsoft Internet Explorer';
	}
	
	return bRetVal;
}

function IsOpera()
{
	return (navigator.userAgent.indexOf('Opera') != -1);
}

function IncludeHeaders(sRelUrl, sComScripts, sScripts)
{
	var sHeader = '';
	var sBasePath = '';

	// Is this a netscape browser?
	if (IsNetscape() == true)
	{
		// Netscapes stylesheet and DOM implementation
		document.writeln('<link href=\"netscape.css\" type=\"text\/css\" rel=\"STYLESHEET\">' + 
				'<script language=\"javascript\" src=\"netscape/dom.js\"></script>');
		
		// Set the script path
		sBasePath = sRelUrl + 'scripts/netscape/';
	}
	else if (IsOpera() == true)
	{
		// Opera stylesheet and DOM implementation
		document.writeln('<link href=\"opera.css\" type=\"text\/css\" rel=\"STYLESHEET\">' + 
				'<script language=\"javascript\" src=\"scripts/opera/dom.js\"></script>');
		
		// Set the script path
		sBasePath = sRelUrl + 'scripts/opera/';
	}
	else if (IsIE55() == true || IsIE4() == true)
	{
		// IE 4.0 or later
		document.writeln('<link href=\"ie.css\" type=\"text\/css\" rel=\"STYLESHEET\">' +
				'<link rel=\"SHORTCUT ICON\" HREF=\"http://www.michaelruck.de/favicon.ico\">' +
				'<meta http-equiv=\"imagetoolbar\" content=\"no\">' +
				'<script language=\"javascript\" src=\"ie/dom.js\"></script>');
	}
	
	// Load the common scripts
	var aScripts = sComScripts.split(':');
	if (aScripts.length > 0)
	{
		for (var sScript in aScripts)
		{
			if (aScripts[sScript].length != 0)
			{
				document.writeln('<script language=\"javascript\" src=\"' + aScripts[sScript] + '.js\"></script>');
			}
		}
	}
	
	// Iterate over all script files to load
	aScripts = sScripts.split(';');
	if (aScripts.length > 0)
	{
		// Now write a line for each script
		for (var sScript in aScripts)
		{
			if (aScripts[sScript].length != 0)
			{
				document.writeln('<script language=\"javascript\" src=\"' + aScripts[sScript] + '.js\"></script>');
			}
		}
	}
}