var requiredVersion = 5;
var useRedirect = false; 
var flashPage = " " 
var noFlashPage = " " 
var upgradePage = " " 
var flash2Installed = false;            
var flash3Installed = false;            
var flash4Installed = false;            
var flash5Installed = false;            
var flash6Installed = false;            
var flash7Installed = false;            
var flash8Installed = false;            
var maxVersion = 8;                             
var actualVersion = 0;                          
var hasRightVersion = false;            
var jsVersion = 1.0;                    

var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;         
var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false; 
jsVersion = 1.1;
if(isIE && isWin){ // don't write vbscript tags on anything but ie win
        document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
        document.write('on error resume next \n');
        document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
        document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
        document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
        document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');     
        document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');     
        document.write('flash7Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');     
        document.write('flash8Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8"))) \n');     
        document.write('</SCR' + 'IPT\> \n'); // break up end tag so it doesn't end our script
}

function detectFlash(yesFlash,noFlash) {

	flashPage = yesFlash;
	noFlashPage = noFlash;
	flash_detect=false;

	if (navigator.plugins) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
                        var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
                        var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
                        var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
                        flash2Installed = flashVersion == 2;            
                        flash3Installed = flashVersion == 3;
                        flash4Installed = flashVersion == 4;
                        flash5Installed = flashVersion == 5;
                        flash6Installed = flashVersion == 6;
                        flash7Installed = flashVersion == 7;
                        flash8Installed = flashVersion == 8;
		}
	}
        for (var i = 2; i <= maxVersion; i++) { 
                if (eval("flash" + i + "Installed") == true) actualVersion = i;
        }
	if ( navigator.appName == 'Netscape' ) {
		var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
		if ( plugin && parseInt(plugin.description.substring(plugin.description.indexOf(".")-1)) >= 4 ) {
		    actualVersion = 4;
		} else {
		    actualVersion = 0;
		}
	}
        if (actualVersion >= requiredVersion) {                 
                hasRightVersion = true;                         
                if (useRedirect) {                                      
                        if(jsVersion > 1.0) {                           
                                window.location.replace(flashPage);     
                        } else {
                                window.location = flashPage;            
                        }
                }
                else flash_detect=true;
        } else {        
        
                if (useRedirect) {              
                        if(jsVersion > 1.0) {   
                                window.location.replace((actualVersion >= 2) ? upgradePage : noFlashPage);
                        } else {
                                window.location = (actualVersion >= 2) ? upgradePage : noFlashPage;
                        }
                }
        }
        return flash_detect;

}

function netaRandom(maxNumber) {

// returns random numbers between 0 and maxNumber -1
// (returns the rest of the division with maxNumber)
// e.g. netaRandom(5) could return values between 0 and 4
//
// anyway you'll get similar numbers if you call the function after very little
// time intervals because the function is based on the actual time
//
// by marco

	today = new Date();
	return Math.abs(today.getTime()) % maxNumber;
}

// redirect italien to default instance of page

function redirectURL() {

	var url = window.location.href;

	var urlRedirect = url;

	urlRedirect = urlRedirect.replace(/\/it\//i,"/");
	urlRedirect = urlRedirect.replace(/\/it\b/i,"");

	if (url != urlRedirect) {

		window.location.href = urlRedirect;
	}
}

