// AutoViewer 1.0
// PhotoWarp


var haveqt=false;
var haveflash=false;
var MM_contentVersion = 5;

var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");
	    for (var i = 0; i < words.length; ++i)
	    {
		if (isNaN(parseInt(words[i])))
		continue;
		var MM_PluginVersion = words[i]; 
	    }
	haveflash = MM_PluginVersion >= MM_contentVersion;
}

if (navigator.plugins) {
	for (i=0; i < navigator.plugins.length; i++ ) {
		if (navigator.plugins[i].name.indexOf("QuickTime") >= 0)
		{ haveqt = true; }
		
	}
}

function AutoViewer_displayMovie() 
{
	if (this.useqt) {
		document.writeln (this.qtcode);
	} else if (this.useflash) {
		document.writeln (this.flashcode);
	} else if (this.usejava) {
		document.writeln (this.javacode);
	} else {
		document.writeln (this.noviewercode);
	}
}

function AutoViewer($qtcode, $flashcode, $javacode, $noviewercode) 
{
	this.havejava=false;
	this.haveqt=haveqt;
	this.haveflash=haveflash;
	this.ismac=false;
	this.iswin=false;
	this.ismsie=false;
	this.useqt=false;
	this.useflash=false;
	this.usejava=false;
	this.qtcode = qtcode;
	this.flashcode = flashcode;
	this.javacode = javacode;
	this.noviewercode = noviewercode;
	
	if (navigator.userAgent.indexOf("Mac") >= 0) {
		this.ismac=true;
		this.haveqt=true;
	}
	
	if (navigator.userAgent.indexOf("Win") >= 0) {
		this.iswin=true;
	}
	
	if (navigator.userAgent.indexOf("MSIE") >= 0) {
		this.ismsie=true;
	}
	
    if (this.ismsie && this.iswin) {
    
        // Java detection
        // Java detection
        //MSJVMVersion = oClientCaps.getComponentVersion("{08B0E5C0-4FCB-11CF-AAA5-00401C608500}", "ComponentID");
        //SunJVMVersion = oClientCaps.getComponentVersion("{8AD9C840-044E-11D1-B3E9-00805F499D93}", "ComponentID");
        //this.havejava = ((MSJVMVersion) || (SunJVMVersion)) ? true : false;
          this.havejava=false;

        
        // Flash detection
        try {
            var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
            this.haveflash = true;
            delete flash;
        } catch(e) {
            this.haveflash = false;
        }
        
        // QT detection
        try {
            var qt = new ActiveXObject("QuickTimeCheckObject.QuickTimeCheck.1");
            if (qt && qt.IsQuickTimeAvailable(0)) {
                this.haveqt = true;
            }
            delete qt;
        } catch(e) {
            this.haveqt = false;
        }
        
    } else {
        this.havejava = true;
    }
			
	this.useqt = ((this.haveqt) && (this.qtcode));
	this.useflash = ((this.haveflash) && (this.flashcode));
	this.usejava = ((this.havejava) && (this.javacode));
	
	this.displayMovie = AutoViewer_displayMovie;
}

