//
/*
This has been slimed down to only the flash Detech functions, Check SVN for full version - /scripts/flash_detect.js
*/
var FlashDetect = new function(){
    var self = this;
    self.installed = false;
    var activeXDetectRules = [
        {
            "name":"ShockwaveFlash.ShockwaveFlash.7",
            "version":function(obj){
                return getActiveXVersion(obj);
            }
        },
        {
            "name":"ShockwaveFlash.ShockwaveFlash.6",
            "version":function(obj){
                var version = "6,0,21";
                try{
                    obj.AllowScriptAccess = "always";
                    version = getActiveXVersion(obj);
                }catch(err){}
                return version;
            }
        },
        {
            "name":"ShockwaveFlash.ShockwaveFlash",
            "version":function(obj){
                return getActiveXVersion(obj);
            }
        }
    ];
    
    var getActiveXVersion = function(activeXObj){
        var version = -1;
        try{
            version = activeXObj.GetVariable("$version");
        }catch(err){}
        return version;
    };

    var getActiveXObject = function(name){
        var obj = -1;
        try{
            obj = new ActiveXObject(name);
        }catch(err){
            obj = {activeXError:true};
        }
        return obj;
    };
    
    self.FlashDetect = function(){
        if(navigator.plugins && navigator.plugins.length>0){
            var type = 'application/x-shockwave-flash';
            var mimeTypes = navigator.mimeTypes;
            if(mimeTypes && mimeTypes[type] && mimeTypes[type].enabledPlugin && mimeTypes[type].enabledPlugin.description){
                var version = mimeTypes[type].enabledPlugin.description;
               self.installed = true;
            }
        }else if(navigator.appVersion.indexOf("Mac")==-1 && window.execScript){
            var version = -1;
            for(var i=0; i<activeXDetectRules.length && version==-1; i++){
                var obj = getActiveXObject(activeXDetectRules[i].name);
                if(!obj.activeXError){
                    self.installed = true;
                    version = activeXDetectRules[i].version(obj);
                    if(version!=-1){

                    }
                }
            }
        }
    }();
};

//

if(!FlashDetect.installed){
		//alert("Flash is required to enjoy this site."); 
		//This device has js but no flash - show html only
	}else{

		if(location.href.indexOf("#") == -1){
	if(location.pathname.length>1){
		var newURL = location.protocol + "//" + location.hostname + "/#" + location.pathname + location.search;
		location.replace(newURL);
	}
}else if(location.hash.length > 0 && location.pathname != "/"){
	var newURL = location.protocol + "//" + location.hostname + "/#" + location.pathname + location.hash.replace("#", "/");
	location.replace(newURL);
}
	}


function openURL(url)
{
	var referLink = document.createElement('a');
	referLink.href = url;
	referLink.target = "_blank";
	document.body.appendChild(referLink);
	//alert(document.body.innerHTML);
	referLink.click();
	document.body.removeChild(referLink);
	//alert(document.body.innerHTML);
}

