var seoflash = function(ver){

    var PV = function(arrVersion){
        this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
        this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
        this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
        this.isValid = function(fv){
            if(this.major < fv.major) return false;
            if(this.major > fv.major) return true;
            if(this.minor < fv.minor) return false;
            if(this.minor > fv.minor) return true;
            if(this.rev < fv.rev) return false;
            return true;
        }
    }
        
    var pv = new PV([0,0,0]);
    if(navigator.plugins && navigator.mimeTypes.length){
        var x = navigator.plugins['Shockwave Flash'];
        if(x && x.description) {
            pv = new PV(x.description.replace(/([a-zA-Z]|\s)+/, '').replace(/(\s+r|\s+b[0-9]+)/, '.').split('.'));
        }
    } else if (navigator.userAgent && navigator.userAgent.indexOf('Windows CE') >= 0){
        var axo = 1;
        var counter = 6;
        while(axo) {
            try {
                counter++;
                axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.'+ counter);
                pv = new PV([counter,0,0]);
            } catch (e) {
                axo = null;
            }
        }
    } else {
        try {
            var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.7');
        } catch(e) {
            try {
                axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
            } catch(e) {}        
        }
        if (axo != null) {
            pv = new PV(axo.GetVariable('$version').split(' ')[1].split(','));
        }
    }
    
    return pv.isValid(new PV(ver.toString().split('.')));
}

var seo = function(swfaddress, base, ver) {
    var hash = location.href.indexOf('#');
    if (seoflash(ver)) {
        if (swfaddress != '/' && (hash == -1 || hash == location.href.length - 1)) {
            var xhr;
            if (window.XMLHttpRequest) {
                xhr = new XMLHttpRequest();
            } else if (window.ActiveXObject) {
                try {
                    xhr = new ActiveXObject('Msxml2.XMLHTTP');
                } catch(e) {
                    xhr = new ActiveXObject('Microsoft.XMLHTTP');
                }
            }
            location.replace(base + '#' + swfaddress);
            return;
            
            xhr.open('get', ((typeof base != 'undefined') ? base : '') + '/?' + swfaddress, false);                
            xhr.setRequestHeader('Content-Type', 'application/x-swfaddress');
            xhr.send('');
            eval(xhr.responseText);
        }
    } else if (hash != -1) {
        location.replace(location.href.replace(/#(\/)?/, ''));
    }
}