// This object provides some useful debugging tools:
function log()
{
// Escape values
// Would be nice to sort it...
function print_debug()
{
function print_debug_var ( variable, value, indent )
{
for ( var i = 0; i < indent; i++ )
{ document.write ( " " ); }
document.write ( variable + " => " + value + "
" );
if ( typeof ( value ) == "object" && indent < 5 )
{
try
{
for ( var key in value )
{
print_debug_var ( key, value[key], indent + 1 );
}
} catch ( error ) {}
}
}
document.write ( "- DEBUG: ----------------------------------------
" );
for ( var i = 0; i < arguments.length; i += 2 )
{
document.write ( "
" );
print_debug_var ( arguments[i], arguments[i+1], 0 );
}
document.write ( "-------------------------------------------------
" );
}
this.print_debug = print_debug;
}
var log = new log();
// This object implements the global SESSION variable:
function SESSION()
{
function OBJECT(){}
this.REQUEST = new OBJECT();
var browser = new OBJECT();
browser.plugins = new OBJECT();
var userAgent = navigator.userAgent.toLowerCase();
var appVersion = navigator.appVersion.toLowerCase();
// Detect OS:
if ( userAgent.indexOf ( "mac" ) >= 0 )
{
browser.os = "Mac";
}
else if ( userAgent.indexOf ( "win" ) >= 0
|| userAgent.indexOf ( "16bit" ) >= 0 )
{
browser.os = "Windows";
}
else if ( userAgent.indexOf ( "unix" ) >= 0
|| userAgent.indexOf ( "x11" ) >= 0
|| userAgent.indexOf ( "linux" ) >= 0
|| userAgent.indexOf ( "bsd" ) >= 0
|| userAgent.indexOf ( "sunos" ) >= 0
|| userAgent.indexOf ( "irix" ) >= 0
|| userAgent.indexOf ( "lynx" ) >= 0
|| userAgent.indexOf ( "hp-ux" ) >= 0
|| userAgent.indexOf ( "aix" ) >= 0
|| userAgent.indexOf ( "sco" ) >= 0
|| userAgent.indexOf ( "ncr" ) >= 0
|| userAgent.indexOf ( "dec" ) >= 0
|| userAgent.indexOf ( "osf1" ) >= 0
|| userAgent.indexOf ( "ultrix" ) >= 0
|| userAgent.indexOf ( "sinix" ) >= 0 )
{
browser.os = "Unix";
}
// Detect Browser:
if ( userAgent.indexOf ( "opera" ) >= 0 )
{
browser.name = "Opera";
browser.version = parseFloat ( appVersion );
}
else if ( userAgent.indexOf ( "konqueror" ) >= 0 )
{
browser.name = "Konqueror";
var p = userAgent.indexOf ( "konqueror" );
browser.version = parseFloat ( appVersion.substring ( p + 10,
appVersion.indexOf ( ";", p ) ) );
}
else if ( browser.os == "Mac" && userAgent.indexOf ( "safari" ) >= 0 )
{
browser.name = "Safari";
browser.version = parseFloat ( appVersion );
}
else if ( appVersion.indexOf ( "msie" ) >= 0 )
{
browser.name = "Internet Explorer";
var p = appVersion.indexOf ( "msie" );
if ( browser.os == "Mac" )
{
browser.version = parseFloat ( userAgent.substring ( p + 5,
userAgent.indexOf ( ";", 5 ) ) );
}
else
{
browser.version = parseFloat ( appVersion.substring ( p + 5,
appVersion.indexOf ( ";", p ) ) );
}
}
else if ( userAgent.indexOf ( "mozilla" ) >= 0
&& userAgent.indexOf ( "spoofer" ) < 0
&& userAgent.indexOf ( "compatible" ) < 0
&& userAgent.indexOf ( "webtv" ) < 0
&& userAgent.indexOf ( "hotjava" ) < 0 )
{
if ( navigator.product.toLowerCase() == "gecko"
&& userAgent.indexOf ( "mozilla/5" ) >= 0
&& ( navigator.vendor == "Firefox"
|| userAgent.indexOf ( "firefox" ) >= 0 ) )
{
browser.name = "Firefox";
if ( navigator.vendorSub )
{
browser.version = navigator.vendorSub;
}
else
{
browser.version = parseFloat ( userAgent.substring
( userAgent.indexOf ( "firefox" ) + 8 ) );
}
}
else if ( navigator.product.toLowerCase() == "gecko"
&& userAgent.indexOf ( "mozilla/5" ) >= 0
&& ( navigator.vendor == "Firebird"
|| navigator.vendor == "Mozilla"
|| navigator.vendor == "Debian"
|| navigator.vendor == "" ) )
{
browser.name = "Other Browser";
browser.version = "";
}
else
{
browser.name = "Netscape";
if ( navigator.vendor == "Netscape" || navigator.vendor == "Netscape6" )
{
browser.version = parseFloat ( navigator.vendorSub );
}
else
{
browser.version = parseFloat ( appVersion );
}
}
}
else
{
browser.name = "Unknown";
browser.version = "";
}
// Detect Plug-ins:
function detect_plugin_pi()
{
var results = 0;
for ( var j = 0; j < navigator.plugins.length; j++ )
{
for ( var i = 0; i < arguments.length; i++ )
{
if ( navigator.plugins[j].name.indexOf ( arguments[i] ) >= 0
|| navigator.plugins[j].description.indexOf ( arguments[i] ) >= 0 )
{
results++;
if ( results == arguments.length ) return ( true );
}
}
}
return ( false );
}
// Can/should _mt be done the same way as _pt?
function detect_plugin_mt()
{
return ( navigator.mimeTypes[arguments[i]]
&& navigator.mimeTypes[arguments[i]].enabledPlugin
&& navigator.mimeTypes[arguments[i]].enabledPlugin.description );
}
if ( navigator.plugins && navigator.plugins.length > 0 )
{
browser.plugins.Flash = detect_plugin_pi ( "Shockwave", "Flash" );
browser.plugins.MediaPlayer = detect_plugin_pi ( "Windows Media" );
browser.plugins.QuickTime = detect_plugin_pi ( "QuickTime" );
browser.plugins.RealPlayer = detect_plugin_pi ( "RealPlayer" );
// browser.plugins.AcrobatReader = detect_plugin_mt ( "application/pdf" );
}
else if ( browser.os == "Windows" && browser.name == "Internet Explorer"
&& parseInt ( browser.version ) >= 4 )
{
// What's the deal with http://www.webreference.com/js/column55/activex.html?
document.write
( '\n'
+ 'Function detect_plugin_vb ( plugin )\n'
+ 'On Error Resume Next\n'
+ 'detect_plugin_vb = false\n'
+ 'If ScriptEngineMajorVersion >= 2 Then\n'
+ 'detect_plugin_vb = ( IsObject ( CreateObject ( plugin ) ) )\n'
+ 'If plugin = "QuickTimeCheckObject.QuickTimeCheck.1" Then\n'
+ 'detect_plugin_vb = detect_plugin_vb.IsQuickTimeAvailable(0)\n'
+ 'End If\n'
+ 'End If\n'
+ 'End Function\n'
+ '<\/sc' + 'ript>' );
browser.plugins.Flash = detect_plugin_vb ( "ShockwaveFlash.ShockwaveFlash.1" );
browser.plugins.MediaPlayer = detect_plugin_vb ( "MediaPlayer.MediaPlayer.1" );
browser.plugins.QuickTime = detect_plugin_vb ( "QuickTimeCheckObject.QuickTimeCheck.1" );
// This one crashes IE/XP?
// browser.plugins.RealPlayer = detect_plugin_vb ( "rmocx.RealPlayer G2 Control" );
// || detect_plugin_vb ( "RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)" )
// || detect_plugin_vb ( "RealVideo.RealVideo(tm) ActiveX Control (32-bit)" );
// browser.plugins.AcrobatReader = detect_plugin_vb ( "PDF.PdfCtrl.1" )
// || detect_plugin_vb ( "AcroExch.Document" );
}
else if ( navigator.mimeTypes && navigator.mimeTypes.length )
{
browser.plugins.Flash = detect_plugin_mt ( "application/x-shockwave-flash" );
browser.plugins.MediaPlayer = detect_plugin_mt ( "application/x-mplayer2" );
browser.plugins.QuickTime = detect_plugin_mt ( "video/quicktime" );
browser.plugins.RealPlayer = detect_plugin_mt ( "audio/x-pn-realaudio-plugin" );
// browser.plugins.AcrobatReader = detect_plugin_mt ( "application/pdf" );
}
this.REQUEST.BROWSER = browser;
}
var SESSION = new SESSION();
// This is only used by web::object(); move to web.js?
function document_write ( html )
{
document.write ( html );
}