////////////////////////////////////////////////////////////////// 
// get major Silverlight version 
// Return values: 
// 0 -> Silverlight not installed (at least not properly). 
// 1 -> Silverlight 1 installed 
// 2-> Silverlight 2 installed 
// 3-> Silverlight 3 installed 
// http://www.apijunkie.com/APIJunkie/blog/post/2009/04/How-to-programmatically-detect-Silverlight-version.aspx
////////////////////////////////////////////////////////////////// 

getSilverlightVersion = function() { 
    var SLVersion; 

    try {   

        try {             
            var control = new ActiveXObject('AgControl.AgControl'); 

            if (control.IsVersionSupported("3.0")) {
                SLVersion = 3;             
            }
            else if (control.IsVersionSupported("2.0")) {
                SLVersion = 2;             
            }
            else {
                SLVersion = 1;
            }

            control = null;       
        } 
        catch (e) {
            var plugin = navigator.plugins["Silverlight Plug-In"]; 

            if (plugin) {
                if (plugin.description === "1.0.30226.2") {
                    SLVersion = 2;
                }
                else {
                    SLVersion = parseInt(plugin.description[0]); 
                }
            } 
            else {
                SLVersion = 0; 
            }
        } 
    } 
    catch (e) {  
        SLVersion = 0; 
    } 

    return SLVersion; 
} 
