﻿<!-- 
/*
 File		: detect.js

 Purpose    : This javascript file contains the functions for checking browser version and flash version.
 
 Functions  : detectFlash()
              - check the version of the flash plugin, if the version of the flash plugins is lower than 5.0, a warning message will be displayed
              detectBrowser()
              - check the type and version of the browser
              Get_Cookie(name)
              - get the cookies
              Set_Cookie(name,value,expires,path,domain,secure)
              - set the cookies

 Modification History :
 Version    Date            By              Description
 -----------------------------------------------------------------------
 1st        2002-05-13     Vivian Au        First Version
 -----------------------------------------------------------------------
*/

//links for upgrading browsers and flash plugins
    var ielink = 'http://www.microsoft.com/windows/ie/downloads/default.asp';
    var nslink = 'http://home.netscape.com/computing/download/index.html?cp=hop04ft6';
    var flashlink = 'http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash';

    function detectFlash()
    {
    
    	if (navigator.appName.indexOf("Netscape") != -1 && navigator.appVersion.charAt(0) >= 3) {
            // Set these local variables to avoid the Netscape 4 crashing bug.
            thearray = navigator.plugins
            arraylen = thearray.length
    
            // Step through each plugin in the array.
            for (var i=0; i < arraylen; i++)
            {
              // Set these local variables to avoid the Netscape 4 crashing bug.
              theplugin = thearray[i]
              thename   = theplugin.name
              thedesc   = theplugin.description
              // If the plugin is Shockwave...
              if (thename == "Shockwave for Director")
              {
                // ...find the version number.
                var versionLoc = thedesc.indexOf("version ");
                var versionString = thedesc.substring(versionLoc + 8,thedesc.length);
    
                if (versionString == '7 .0.3')             { swVersion = 7.03000; }
                else if (versionString == '7.0.3')         { swVersion = 7.03000; }
                else if (versionString.indexOf('7.') > -1) { swVersion = 7.00000; }
                else if (versionString.indexOf('8.') > -1) { swVersion = 8.00000; }
                else if (versionString.indexOf('6.') > -1) { swVersion = 6.00000; }
                else { swVersion = integer(versionString) ; }
              }
    
              // If we're dealing with a Flash plugin...
              if (thedesc.indexOf("Shockwave Flash ") != -1)
              {
                // ...then find the version number.
                var versionLoc = thedesc.indexOf("Shockwave Flash ");
                var versionString = thedesc.substring(versionLoc + 16,thedesc.length);
                var minorVersion;
                var majorVersion;
    
                // Look for an " r".  Whatever's after the "r" is the minor version. For
                versionLoc = versionString.indexOf(" r");
                if (versionLoc != -1)
                {
                  // If there is an "r", then everything before the " r" is the major version...
                  majorVersion = versionString.substring(0,versionLoc);
    
                  // ...and everything after is the minor version.
                  minorVersion = versionString.substring(versionLoc + 2,versionString.length);
    
                  // Format the final version string as x.xyy where x.x is the major version
                  // and yy is the minor release version.
                  flashVersion = parseFloat(majorVersion + (minorVersion < 100 ? "0" : "") + (minorVersion < 10 ? "0" : "") + minorVersion);
                }
                else
                {
                  // If there is no "r", then set the version string to be all of the version info.
                  flashVersion = parseFloat(versionString);
                }
              }
         	}
            // check flash plugin for Netscape
    		if (flashVersion >= 5) {
    			flash = 1;
    		} else {
    			flash = 0;
    		}
    	} else if (navigator.appName.indexOf('Microsoft') != -1 && navigator.appVersion.indexOf('Mac') == -1 && navigator.appVersion.indexOf('3.1') == -1) {
        //checking flash plugin for internet explorer for Mac
    		flash = 1;
    
    	} else {
        //checking flash plugin for internet explorer for PC
    		if (navigator.appVersion.indexOf('MSIE')!=-1 && navigator.appVersion.indexOf('4.5') == -1)
    		{	
    			if (navigator.plugins["Shockwave Flash"]) 
    				flash = 1;
    			else
    				flash = 0;
    		}else
    			flash = 0;
    	}
    //getConMsg is declared in common.js
    	if (!flash && (!confirm(getConMsg('dlflash')))) {
            if (home){
        		window.location = "noflash.htm"; // no flash
            } else {    
// set the cookie if the user's browser was checked
// Set_cookie is declared in detect.js
//                Set_Cookie("checkedFlash", 1,"","\/" + curLang + "\/");
                Set_Cookie("checkedFlash", 1);
            }
        } else if (!flash) {
            window.open(flashlink, 'dlflash', "" , "\/");
        }
    }

    function detectBrowser(){
        // convert all characters to lowercase to simplify testing 
        var agt=navigator.userAgent.toLowerCase(); 

        // *** BROWSER VERSION *** 
        // check browser type (Internet Explorer)
        var is_major = parseInt(navigator.appVersion); 
        var is_minor = parseFloat(navigator.appVersion); 
        var ie_ver =  parseFloat(agt.substring(30, 33));

        // check browser type (netscape)
        var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1)); 
        var is_nav4up = (is_nav && (is_minor >= 4.76)); 
    
        var is_ie   = (agt.indexOf("msie") != -1); 
        var is_ie5up  = (is_ie  && ie_ver >= 5.5); 

        var dlbrowser = false;
        if (!is_nav4up && !is_ie5up) {
            dlbrowser = true;
        }
        
        if (dlbrowser) {
        //getConMsg is declared in common.js
            if (confirm(getConMsg('dlbrowser'))) {
                if (ns)
                    window.location = nslink; 
                 else 
                    window.location = ielink; 
            } else {
//                Set_Cookie("checkedBrowser", 1,"","\/" + curLang + "\/");
                Set_Cookie("checkedBrowser", 1, "" , "\/");
            }
        }
    }
    
    function Get_Cookie(name) {
        var start = document.cookie.indexOf(name+"=");
        var len = start+name.length+1;
        if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
        if (start == -1) return null;
        var end = document.cookie.indexOf(";",len);
        if (end == -1) end = document.cookie.length;
        return unescape(document.cookie.substring(len,end));
    }
 

    
    function Set_Cookie(name,value,expires,path,domain,secure) {
        document.cookie = name + "=" +escape(value) +
            ( (expires) ? ";expires=" + expires.toGMTString() : "") +
            ( (path) ? ";path=" + path : "") + 
            ( (domain) ? ";domain=" + domain : "") +
            ( (secure) ? ";secure" : "");
    }

    if (Get_Cookie("checkedBrowser") != 1)
        detectBrowser();
    if (Get_Cookie("checkedFlash") != 1)
        detectFlash();
//-->

