/* THIS FILE NEEDS TO BE SAVED IN ANSI ENCODING OR IT WILL BREAK IN NS */

/* Check for plug-in based Helper control */
function detectPlugin() {
    // allow for multiple checks in a single pass
    var daPlugins = detectPlugin.arguments;
    // consider pluginFound to be false until proven true
    var pluginFound = false;
    // if plugins array is there and not fake
    if (navigator.plugins && navigator.plugins.length > 0) {
        var pluginsArrayLength = navigator.plugins.length;
        // for each plugin...
        for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) {
            // loop through all desired names and check each against the current plugin name
            var numFound = 0;
            for(namesCounter=0; namesCounter < daPlugins.length; namesCounter++) {
                // if desired plugin name is found in either plugin name or description
                if( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) || 
                    (navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) ) {
                    // this name was found
                    numFound++;
                }   
            }
            // now that we have checked all the required names against this one plugin,
            // if the number we found matches the total number provided then we were successful
            if(numFound == daPlugins.length) {
                pluginFound = true;
                // if we've found the plugin, we can stop looking through at the rest of the plugins
                break;
            }
        }
    }
    return pluginFound;
} // detectPlugin

function OSName()
{
	var uaString = navigator.userAgent.toLowerCase();
	var result;
	
    if (uaString.indexOf('windows 95') != -1 && uaString.indexOf('win95') != -1) {
        result = 'Windows 95';
    } else if (uaString.indexOf('windows 98') != -1 && uaString.indexOf('win98') != -1) {
        result = 'Windows 98';
    } else if (uaString.indexOf('windows me') != -1 && uaString.indexOf('winme') != -1) {
        result = 'Windows Me';
    } else if (uaString.indexOf('windows nt 4') != -1 && uaString.indexOf('winnt') != -1) {
        result = 'Windows NT';
    } else if (uaString.indexOf('windows nt 5.1') != -1) {
        result = 'Windows XP';
    } else if (uaString.indexOf('windows nt 5.2') != -1) {
        result = 'Windows 2003';
    } else if (uaString.indexOf('windows nt 5') != -1) {
        result = 'Windows 2000';
    } else if (uaString.indexOf('windows nt 6') != -1) {
        result = 'Windows Vista';
    } else if (uaString.indexOf('windows nt') != -1) {
        result = 'Windows NT';
    } else if (uaString.indexOf('mac os x') != -1) {
        result = 'Mac OS X';
    } else if (uaString.indexOf('mac os') != -1) {
        result = 'Mac OS';
    } else {
        result = 'Unknown';    
    }
	return result;
}

if (!helperInstalled)
{
    helperInstalled = detectPlugin('LAUNCH! Web Helper'); // Name of Helper Netscape style plug-in

    var osName = OSName().toLowerCase();
    if (!helperInstalled && osName != 'mac os x') {
        // Check cookies for all others 
        var cHELPER = 'Helper='; //'<%=Application("cHELPER")%>' + '='
        var allcookies = document.cookie;
        var pos = allcookies.indexOf(cHELPER);
        if (pos != -1) {
	        var cStart = pos + cHELPER.length
	        var cEnd = allcookies.indexOf(";", cStart);
	        if (cEnd == -1) cEnd = allcookies.length;
	        var cValue = allcookies.substring(cStart, cEnd);
	        cValue = unescape(cValue);
		    if (cValue != "") {
		        helperInstalled = true;
		        helperInstalledByCookie = true;
		    }
        }
    }
}
