//############################## FLASH LOADER ##############################//

function loadObj(obj){
  switch (obj){
    case "MDY":
       document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' height='303' width='375'><param name='movie' value='/webtemplate_flash/Norwich_MDY_Animation.swf'><param name='quality' value='best'><param name='play' value='true'><param name='wmode' value='transparent'><embed height='303' pluginspage='http://www.macromedia.com/go/getflashplayer' src='/webtemplate_flash/Norwich_MDY_Animation.swf' type='application/x-shockwave-flash' width='375' quality='best' play='true' wmode='transparent'></object>");
    break;
    default :
  }
}


//############################## FLASH DETECTOR ##############################//

var detectableWithVB = false;
var pluginFound = false;

function goURL(daURL){
    window.location = daURL;
}

function redirectCheck(pluginFound, redirectURL, redirectIfFound) {
    if(redirectURL && ((pluginFound && redirectIfFound) || (!pluginFound && !redirectIfFound))){
		goURL(redirectURL);
		return pluginFound;
    }else{
		return pluginFound;
    }	
}

function canDetectPlugins(){
    if(detectableWithVB || (navigator.plugins && navigator.plugins.length > 0)){
		return true;
    }else{
		return false;
    }
}

function detectFlash(redirectURL, redirectIfFound){
    pluginFound = detectPlugin('Shockwave','Flash'); 

    if(!pluginFound && detectableWithVB){
		pluginFound = detectActiveXControl('ShockwaveFlash.ShockwaveFlash.1');
    }

    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectPlugin() {

    var daPlugins = detectPlugin.arguments;
    var pluginFound = false;

    if (navigator.plugins && navigator.plugins.length > 0){
		var pluginsArrayLength = navigator.plugins.length;
		
			for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ){
	    		var numFound = 0;
	    		for(namesCounter=0; namesCounter < daPlugins.length; namesCounter++){

					if((navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) || (navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0)){
						numFound++;
					}   
	    		}
					
	    		if(numFound == daPlugins.length){
					pluginFound = true;
					break;
	    		}
			}
    }
    return pluginFound;
}

// VBSCRIPT FOR IE/WINDOWS
if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)){
    document.writeln('<script language="VBscript">');

    document.writeln('\'do a one-time test for a version of VBScript that can handle this code');
    document.writeln('detectableWithVB = False');
    document.writeln('If ScriptEngineMajorVersion >= 2 then');
    document.writeln('  detectableWithVB = True');
    document.writeln('End If');

    document.writeln('\'this next function will detect most plugins');
    document.writeln('Function detectActiveXControl(activeXControlName)');
    document.writeln('  on error resume next');
    document.writeln('  detectActiveXControl = False');
    document.writeln('  If detectableWithVB Then');
    document.writeln('     detectActiveXControl = IsObject(CreateObject(activeXControlName))');
    document.writeln('  End If');
    document.writeln('End Function');

    document.writeln('\'and the following function handles QuickTime');
    document.writeln('Function detectQuickTimeActiveXControl()');
    document.writeln('  on error resume next');
    document.writeln('  detectQuickTimeActiveXControl = False');
    document.writeln('  If detectableWithVB Then');
    document.writeln('    detectQuickTimeActiveXControl = False');
    document.writeln('    hasQuickTimeChecker = false');
    document.writeln('    Set hasQuickTimeChecker = CreateObject("QuickTimeCheckObject.QuickTimeCheck.1")');
    document.writeln('    If IsObject(hasQuickTimeChecker) Then');
    document.writeln('      If hasQuickTimeChecker.IsQuickTimeAvailable(0) Then ');
    document.writeln('        detectQuickTimeActiveXControl = True');
    document.writeln('      End If');
    document.writeln('    End If');
    document.writeln('  End If');
    document.writeln('End Function');

    document.writeln('</scr' + 'ipt>');
}


