//
// inDuality.js
//
// Support routines for embedding inDuality into web pages
//


var iPosition, sTemp, gsBrowserName;

////////////////////////////////////////////////////////////
// Event Manager
////////////////////////////////////////////////////////////

//
// addEvent()
// 
function addEvent( elem, evtType, func, capture ) 
{
	capture = (capture) ? capture : false;
	
	if ( elem.addEventListener )
		elem.addEventListener( evtType, func, capture );
	else if ( elem.attachEvent ) 
		elem.attachEvent( "on" + evtType, func );
	else 
		elem[ "on" + evtType ] = func;
}

//
// removeEvent()
//
function removeEvent( elem, evtType, func, capture ) 
{
	capture = (capture) ? capture : false;
	
	if ( elem.removeEventListener )
		elem.removeEventListener( evtType, func, capture );
	else if ( elem.attachEvent )
		elem.detachEvent( "on" + evtType, func );
	else
		elem[ "on" + evtType ] = null;
}

//
// addOnLoadEvent()
//
function addOnLoadEvent( func ) 
{
	if (window.addEventListener || window.attachEvent)
		addEvent(window,"load", func, false);
	else
	{
		var oldQueue = (window.onload) ? window.onload : function() {};
		
		window.onload = function() 
		{
			oldQueue();
			func();
		}
	}
}


////////////////////////////////////////////////////////////
// Misc
////////////////////////////////////////////////////////////

//
// validateBrowserOS()
//
function validateBrowserOS()
{
	var sDetect = navigator.userAgent.toLowerCase();
	var sOS, sBrowser, sVersion;

	if ( checkIt( sDetect, 'konqueror' ))
	{
		sBrowser = 'Konqueror';
		sOS = 'Linux';
	}
	else if ( checkIt( sDetect, 'safari' ))
		sBrowser = 'Safari';
	else if ( checkIt( sDetect, 'omniweb' ))
		sBrowser = 'OmniWeb';
	else if ( checkIt( sDetect, 'opera' ))
		sBrowser = 'Opera';
	else if ( checkIt( sDetect, 'webtv' ))
		sBrowser = 'WebTV';
	else if ( checkIt( sDetect, 'icab' ))
		sBrowser = 'iCab';
	else if ( checkIt( sDetect, 'msie' ))
		sBrowser = 'Internet Explorer';
	else if ( !checkIt( sDetect, 'compatible' ))
	{
		sBrowser = 'Netscape Navigator';
		sVersion = sDetect.charAt( 8 );
	}
	else
		sBrowser = 'An unknown browser';

	if ( !sVersion )
		sVersion = sDetect.charAt( iPosition + sTemp.length );

	if ( !sOS )
	{
		if ( checkIt( sDetect, 'linux' ))
			sOS = 'Linux';
		else if ( checkIt( sDetect, 'x11' ))
			sOS = 'Unix';
		else if ( checkIt( sDetect, 'mac' ))
			sOS = 'Mac';
		else if ( checkIt(  sDetect,'win' ))
			sOS = 'Windows';
		else 
			sOS = 'an unknown operating system';
	}

	if ( (sBrowser != 'Internet Explorer' && sBrowser != 'Netscape Navigator' && sBrowser != 'Opera' && sBrowser != 'Safari') || sOS != 'Windows' )
	{
		document.write( 'This page uses the inDuality Plugin from Pelican Crossing (http://www.pelicancrossing.com) which requires Internet Explorer, Firefox. Chrome or Opera running on Windows.' );
		return false;		
	}
	else if ( sBrowser == 'Internet Explorer' && sOS == 'Windows' && parseInt( sVersion ) < 6 )
	{
		document.write( 'This page uses the inDuality Plugin from Pelican Crossing (http://www.pelicancrossing.com) which requires Internet Explorer Version 5.0 or above, you are using version '+sVersion+' of Internet Explorer.' );
		return false;		
	}
	else if ( sBrowser == 'Netscape Navigator' && sOS == 'Windows' && parseInt( sVersion ) < 1 )
	{
		document.write( 'This page uses the inDuality Plugin from Pelican Crossing (http://www.pelicancrossing.com) which requires Firefox Version 1.0 or above, you are using version '+sVersion+' of Firefox.' );
		return false;		
	}
	else if ( sBrowser == 'Opera' && sOS == 'Windows' && parseInt( sVersion ) < 9 )
	{
		document.write( 'This page uses the inDuality Plugin from Pelican Crossing (http://www.pelicancrossing.com) which requires Opera Version 9.0 or above, you are using version '+sVersion+' of Opera.' );
		return false;		
	}
	
	gsBrowserName = sBrowser;	
	return true;
}


//
// checkIt()
//
function checkIt( sDetect, sParam )
{
	iPosition = sDetect.indexOf( sParam ) + 1;
	sTemp = sParam;
	return ( iPosition );
}

//
// IsinDualityInstalled()
//
function IsinDualityInstalled() 
{
	if ( window.ActiveXObject )
	{
		if ( DetectinDualityActiveX() ) 
			return true;
		else
			return false;	
	}
	else 
	{
		if ( navigator.mimeTypes["application/x-induality"]  && navigator.mimeTypes["application/x-induality"].enabledPlugin )
			return true;	
	}
	
	return false;	
}


//
// AutoRefreshPage()
//
function AutoRefreshPage() 
{
	navigator.plugins.refresh();	

	if ( IsinDualityInstalled() )
	{
		window.location.reload();
		return;
	}

	setTimeout( "AutoRefreshPage()", 500 );
}



////////////////////////////////////////////////////////////
// inDualityControl
////////////////////////////////////////////////////////////

//
// inDualityControl Constructor
//
function inDualityControl()
{
	this.pluginVersion = '2,0,0,150';
	this.width = '100%';
	this.height = '100%';
	this.contentType = 'Blink3D';
	this.oProperties = new Object();
	this.oTheControl = null;
}


//
// inDualityControl.addProperty
//
inDualityControl.prototype.addProperty = function( sPropertyName, sValue )
{
	this.oProperties[sPropertyName] = sValue;
}


//
// inDualityControl.create
//
inDualityControl.prototype.create = function()
{
	if ( window.ActiveXObject )
	{	
		document.write( '<object id="inDualityCtl" classid="CLSID:65A0276F-A5C2-4BA2-82DA-BC4AF3250F9E"' );
		document.write( ' codebase=""' );
		document.write( ' width = "'+this.width+'"' );
		document.write( ' height = "'+this.height+'" class="Object">' );					
		
		for ( sPropertyName in this.oProperties )
		{
			document.write( ' <PARAM name="'+sPropertyName+'" value="'+this.oProperties[sPropertyName]+'">' );
		}

		document.write( '</object>' );
	}
	else
	{
		document.write( '<object id="inDualityCtl"' );
		document.write( ' type = "application/x-induality"' );
		document.write( ' codebase = ""' );
		document.write( ' width = "'+this.width+'"' );
		document.write( ' height = "'+this.height+'" class="Object">' );
		
		for ( sPropertyName in this.oProperties )
		{
			document.write( ' <PARAM name="'+sPropertyName+'" value="'+this.oProperties[sPropertyName]+'">' );
		}

		document.write( '</object>' );
	}
}

//
// inDualityControl.setControl
//
inDualityControl.prototype.setControl = function()
{
	this.oTheControl = this.getControl();
}

//
// inDualityControl.getControl
//
inDualityControl.prototype.getControl = function()
{
	if ( window.document["inDualityCtl"] )
		return window.document["inDualityCtl"];
	else if ( navigator.appName.indexOf( "Microsoft Internet" ) == -1 )
	{
		if ( document.embeds && document.embeds["inDualityCtl"] )
			return document.embeds["inDualityCtl"];
	}
	else // if ( navigator.appName.indexOf( "Microsoft Internet" ) != -1 )
	{
		return document.getElementById("inDualityCtl");
	}
}

//
// inDualityControl.sendCommand
//
inDualityControl.prototype.sendCommand = function( sCmd )
{
	this.getControl().PluginCommand( sCmd );
}


//
// inDualityControl.goHome
//
inDualityControl.prototype.goHome = function()
{
	this.getControl().PluginHome();
}


//
// inDualityControl.goBack
//
inDualityControl.prototype.goBack = function()
{
	this.getControl().PluginBack();
}


//
// inDualityControl.goForward
//
inDualityControl.prototype.goForward = function()
{
	this.getControl().PluginForward();
}

//
// inDualityControl.getInstallProgress
//
inDualityControl.prototype.getInstallProgress = function()
{
	return this.oTheControl.installProgress;
}

//
// inDualityControl.getIsExtInstalled
//
inDualityControl.prototype.getIsExtInstalled = function()
{
	return this.oTheControl.isExtInstalled;
}

//
// inDualityControl.show
//
inDualityControl.prototype.show = function()
{
	 this.oTheControl.setAttribute( "class", "Object" );
}

//
// inDualityControl.hide
//
inDualityControl.prototype.hide = function()
{	
 	 this.oTheControl.setAttribute( "class", "hiddenObject" );
}

////////////////////////////////////////////////////////////
// DHTML
////////////////////////////////////////////////////////////

var DHTMLAPI = 
{
    browserClass : new Object(),
    init : function () 
	 {
        this.browserClass.isCSS = ((document.body && document.body.style) ? true : false);
        this.browserClass.isW3C = ((this.browserClass.isCSS && document.getElementById) ? true : false),
        this.browserClass.isIE4 = ((this.browserClass.isCSS && document.all) ? true : false),
        this.browserClass.isNN4 = ((document.layers) ? true : false),
        this.browserClass.isIECSSCompat = ((document.compatMode && document.compatMode.indexOf("CSS1") >= 0) ? true : false)  
    },
    // Seek nested NN4 layer from string name
    seekLayer : function (doc, name) 
	 {
        var elem;
        for (var i = 0; i < doc.layers.length; i++) 
		  {
            if (doc.layers[i].name == name) 
				{
                elem = doc.layers[i];
                break;
            }
				
            // dive into nested layers if necessary
            if (doc.layers[i].document.layers.length > 0) 
				{
                elem = this.seekLayer(doc.layers[i].document, name);
                if (elem) {break;}
            }
        }
        return elem;
    },
  
    // Convert element name string or object reference
    // into a valid element object reference
    getRawObject : function (elemRef) 
	 {        var elem;
        if (typeof elemRef == "string") 
		  {
            if (this.browserClass.isW3C) 
                elem = document.getElementById(elemRef);
				else if (this.browserClass.isIE4) 
                elem = document.all(elemRef);
				else if (this.browserClass.isNN4) 
                elem = this.seekLayer(document, elemRef);
        } 
		  else 
		  {
            // pass through object reference
            elem = elemRef;
        }
		  
        return elem;
    },
    // Convert element name string or object reference
    // into a valid style (or NN4 layer) object reference
    getStyleObject : function (elemRef) 
	 {
        var elem = this.getRawObject(elemRef);
		  
        if (elem && this.browserClass.isCSS) 
            elem = elem.style;
		  
        return elem;
    },
  
    // Position an element at a specific pixel coordinate
    moveTo : function (elemRef, x, y) 
	 {
        var elem = this.getStyleObject(elemRef);
        if (elem) 
		  {
            if (this.browserClass.isCSS) 
				{
                // equalize incorrect numeric value type
                var units = (typeof elem.left == "string") ? "px" : 0; 
                elem.left = x + units;
                elem.top = y + units;
            } 
				else if (this.browserClass.isNN4) 
				{
                elem.moveTo(x,y);
            }
        }
    },
  
    // Move an element by x and/or y pixels
    moveBy : function (elemRef, deltaX, deltaY) 
	 {
        var elem = this.getStyleObject(elemRef);
        if (elem) 
		  {
            if (this.browserClass.isCSS) 
				{
                // equalize incorrect numeric value type
                var units = (typeof elem.left == "string") ? "px" : 0;
                if (!isNaN(this.getElementLeft(elemRef))) 
					 {
                    elem.left = this.getElementLeft(elemRef) + deltaX + units;
                    elem.top = this.getElementTop(elemRef) + deltaY + units;
                }
            } 
				else if (this.browserClass.isNN4) 
				{
                elem.moveBy(deltaX, deltaY);
            }
        }
    },
  
    // Set the z-order of an object
    setZIndex : function (obj, zOrder) 
	 {
        var elem = this.getStyleObject(obj);
        if (elem) 
            elem.zIndex = zOrder;
    },
  
    // Set the background color of an object
    setBGColor : function (obj, color) 
	 {
        var elem = this.getStyleObject(obj);
        if (elem) 
		  {
            if (this.browserClass.isCSS) 
                elem.backgroundColor = color;
				else if (this.browserClass.isNN4) 
                elem.bgColor = color;
        }
    },
  
    // Set the visibility of an object to visible
    show : function (obj) 
	 {
        var elem = this.getStyleObject(obj);
        if (elem) 
            elem.visibility = "visible";		
    },
  
    // Set the visibility of an object to hidden
    hide : function (obj) 
	 {
        var elem = this.getStyleObject(obj);
        if (elem) 
            elem.visibility = "hidden";
    },
	 
	  // Set the visibility of an object to hidden
    stripOffPX : function ( value ) 
	 {
		 return value.replace( /px/, "" );
    },
  
    // return computed value for an elementŐs style property
    getComputedStyle : function (elemRef, CSSStyleProp) 
	 {
        var elem = this.getRawObject(elemRef);
        var styleValue, camel;
		  
        if (elem) 
		  {
            if (document.defaultView && document.defaultView.getComputedStyle) 
				{
                // W3C DOM version
                var compStyle = document.defaultView.getComputedStyle(elem, "");
                styleValue = compStyle.getPropertyValue(CSSStyleProp);
            } 
				else if (elem.currentStyle) 
				{
                // make IE style property camelCase name from CSS version
                var IEStyleProp = CSSStyleProp;
                var re = /-\D/;
                while (re.test(IEStyleProp)) 
					 {
                    camel = IEStyleProp.match(re)[0].charAt(1).toUpperCase();
                    IEStyleProp = IEStyleProp.replace(re, camel);
                }
					 
                styleValue = elem.currentStyle[IEStyleProp];				
            }
        }
		  
        return (styleValue) ? styleValue : null;
    },

    // Retrieve the x coordinate of a positionable object
    getElementLeft : function (elemRef)  
	 {
        var elem = this.getRawObject(elemRef);
        var result = null;
		  
        if (this.browserClass.isCSS || this.browserClass.isW3C) 
            result = parseInt(this.getComputedStyle(elem, "left"));
		  else if (this.browserClass.isNN4) 
            result = elem.left;

			return result;
    },
  
    // Retrieve the y coordinate of a positionable object
    getElementTop : function (elemRef)  
	 {
        var elem = this.getRawObject(elemRef);
        var result = null;
        if (this.browserClass.isCSS || this.browserClass.isW3C) 
            result = parseInt(this.getComputedStyle(elem, "top"));
		  else if (this.browserClass.isNN4) 
            result = elem.top;

			return result;
    },
  
    // Retrieve the rendered width of an element
    getElementWidth : function (elemRef)  
	 {
        var result = null;
        var elem = this.getRawObject(elemRef);
        if (elem) {
            if (elem.offsetWidth) 
				{
                if (elem.scrollWidth && (elem.offsetWidth != elem.scrollWidth)) 
                    result = elem.scrollWidth;
					 else 
                    result = elem.offsetWidth;
            } 
				else if (elem.clip && elem.clip.width) 
				{
                // Netscape 4 positioned elements
                result = elem.clip.width;
            }
        }
        return result;
    },
  
    // Retrieve the rendered height of an element
    getElementHeight : function (elemRef)  
	 {
        var result = null;
        var elem = this.getRawObject(elemRef);
        if (elem) 
		  {
            if (elem.offsetHeight) 
                result = elem.offsetHeight;
				else if (elem.clip && elem.clip.height)
                result = elem.clip.height;
        }
        return result;
    },
  
    // Return the available content width space in browser window
    getInsideWindowWidth : function () 
	 {
        if (window.innerWidth) 
            return window.innerWidth;
		  else if (this.browserClass.isIECSSCompat) 
		  {
            // measure the html element's clientWidth
            return document.body.parentElement.clientWidth;
        } 
		  else if (document.body && document.body.clientWidth) 
            return document.body.clientWidth;

        return null;
    },

    // Return the available content height space in browser window
    getInsideWindowHeight : function () 
	 {
        if (window.innerHeight)
            return window.innerHeight;
		  else if (this.browserClass.isIECSSCompat) 
		  {
            // measure the html element's clientHeight
            return document.body.parentElement.clientHeight;
        } 
		  else if (document.body && document.body.clientHeight) 
            return document.body.clientHeight;

		return null;
    }
}

////////////////////////////////////////////////////////////
// Progress Bar
////////////////////////////////////////////////////////////


//
// initProgressBar()
//
function initProgressBar() 
{
    // create quirks object whose default (CSS-compatible) values
    // are zero; pertinent values for quirks mode filled in later 
	 if (navigator.appName == "Microsoft Internet Explorer" && navigator.userAgent.indexOf("Win") != -1 && 
        (typeof document.compatMode == "undefined" || document.compatMode == "BackCompat")) 
	 {
        document.getElementById("progressBar").style.height = "15px";
        document.getElementById("progressBar").style.width = "auto";
        document.getElementById("progressBar").style.fontSize = "12px";
        document.getElementById("progressBar").style.left = "0px";		  
        document.getElementById("progressBar").style.top = "0px";	   

        document.getElementById("slider").style.height = "15px";
        document.getElementById("slider").style.width = DHTMLAPI.getElementWidth( "progressBar" );
        document.getElementById("slider").style.fontSize = "12px";		  		  
        document.getElementById("slider").style.left = "0px";		  
        document.getElementById("slider").style.top = "0px";	   
    } 	
}

//
// showProgressBar()
//
function showProgressBar() 
{
	DHTMLAPI.show( "progressBar" );
}


//
// hideProgressBar()
//
function hideProgressBar() 
{	
	document.getElementById( "installVideo" ).innerHTML=''; 
	document.getElementById( "installImages" ).innerHTML=''; 
	
	DHTMLAPI.hide( "progressBar" );
	DHTMLAPI.hide( "installVideo" );
	DHTMLAPI.hide( "installImages" );
	
	document.getElementById( "installProgress" ).innerHTML='';
}


//
// showInDuality()
//
function showInDuality() 
{	
	loopObject.oCtrl.show();
}

//
// calcProgress()
//
function calcProgress( current, total ) 
{
	var temp;
	
	if ( current <= total ) 
	{
		var factor = current/total;
		var pct = Math.ceil(factor * 100);
		
		document.getElementById("progressBar").firstChild.nodeValue = loopObject.oCtrl.installMsg + " " + pct + "%";
		document.getElementById("slider").firstChild.nodeValue = loopObject.oCtrl.installMsg + " " + pct + "%";
		
		if ( document.defaultView && document.defaultView.getComputedStyle )
			temp = parseInt( factor * DHTMLAPI.stripOffPX( DHTMLAPI.getComputedStyle( "progressBar", "width" ) ));
		else
			temp = parseInt( factor * DHTMLAPI.getElementWidth( "progressBar" ) );
		
		document.getElementById("slider").style.clip = "rect(0px " + temp + "px 16px 0px)";
	}
}


// Loop variables
var loopObject = {end:100, current:0, interval:null, oCtrl:null, iCurrentImageNum:0, flashObj:null, firstTime:true };


//
// startProgressBar()
//
function startProgressBar() 
{
	if ( loopObject.oCtrl.getIsExtInstalled() == undefined || loopObject.current == Number.NaN )
	{
		loopObject.interval = setTimeout( "startProgressBar()", 500 );	
		return;
	}
	
	if ( parseInt(loopObject.current ) <= parseInt( loopObject.end ) && !loopObject.oCtrl.getIsExtInstalled() ) 
	{
		loopObject.current = parseInt( loopObject.oCtrl.getInstallProgress() );
		if ( loopObject.current == Number.NaN )
			loopObject.current = 1;
			
		if ( oCtrl.progressBarVisible )
			calcProgress( loopObject.current, loopObject.end );
			
		loopObject.interval = setTimeout( "startProgressBar()", 500 );
	} 
	else 
	{
		calcProgress( loopObject.end, loopObject.end );
		loopObject.interval = null;		
		hideProgressBar();		
		setTimeout( "showInDuality()", 750 );
	}
}

//
// showInstallProgress()
//
function showInstallProgress( oCtrl ) 
{
	
	if ( loopObject.firstTime )
	{
		loopObject.firstTime = false;
		loopObject.oCtrl = oCtrl;	
		DHTMLAPI.hide( "installInstructions" );
		setTimeout( "showInstallProgress()", 2000 );
		
		return;
	}
	
	loopObject.oCtrl.setControl();

	document.getElementById( "installInstructions" ).innerHTML = '';
		
	if ( !loopObject.oCtrl.getIsExtInstalled() )
	{
		DHTMLAPI.init();
		initProgressBar();

		if ( loopObject.oCtrl.progressBarVisible )
			showProgressBar();				
			
		startProgressBar();		

		if ( loopObject.oCtrl.installVideoURL != undefined && loopObject.oCtrl.installVideoURL != null && loopObject.oCtrl.installVideoURL != "" )
			startInstallVideo();
		else
			document.getElementById( "installImages" ).innerHTML = '';

		if ( loopObject.oCtrl.installImagesURL != undefined && loopObject.oCtrl.installImagesURL != null && loopObject.oCtrl.installImagesURL != "")
		{
			showInstallImages();				
			startInstallImages();		
		}			
	}
	else
	{
		document.getElementById( "installProgress" ).innerHTML='';	
	}
}

//
// showInstallImages()
//
function showInstallImages() 
{
	var n = document.getElementById( "installImages" ).innerHTML = '<img id="installImage" src="" height="0" width="0">';

	if ( typeof oCtrl.installImageWidth == "string" && (oCtrl.installImageWidth == "auto" || oCtrl.installImageWidth.indexOf( "%" ) != -1 ) )
	{
		if ( document.defaultView && document.defaultView.getComputedStyle )
			temp = DHTMLAPI.stripOffPX( DHTMLAPI.getComputedStyle( "wrapper", "width" ) );
		else
			temp = DHTMLAPI.getElementWidth( "wrapper" );		
			
		DHTMLAPI.getRawObject( "installImage" ).width = temp;	
	}
	else
		DHTMLAPI.getRawObject( "installImage" ).width = oCtrl.installImageWidth;
		
	if ( typeof oCtrl.installImageHeight == "string" && (oCtrl.installImageHeight == "auto" || oCtrl.installImageHeight.indexOf( "%" ) != -1) )
	{
		if ( document.defaultView && document.defaultView.getComputedStyle )
			temp = DHTMLAPI.stripOffPX( DHTMLAPI.getComputedStyle( "wrapper", "height" ) );
		else
			temp = DHTMLAPI.getElementHeight( "wrapper" );		
		
		DHTMLAPI.getRawObject( "installImage" ).height = temp;	
	}
	else
		DHTMLAPI.getRawObject( "installImage" ).height = oCtrl.installImageHeight;	
	
	changeImage();	
	DHTMLAPI.show( "installImages" );
}

//
// hideInstallImages()
//
function hideInstallImages() 
{
	DHTMLAPI.hide( "installImages" );
}

//
// startInstallImages()
//
function startInstallImages() 
{
	if ( parseInt(loopObject.current ) <= parseInt( loopObject.end ) && !loopObject.oCtrl.getIsExtInstalled() ) 
	{
		changeImage();
		setTimeout( "startInstallImages()", 500 );			
	} 
	else 
	{
		setTimeout( "hideInstallImages()", 500 );
	}
}

//
// changeImage()
//
function changeImage() 
{
	iSectionSize = loopObject.end/loopObject.oCtrl.numInstallImages;	

	iNewImageNum = parseInt( loopObject.current/iSectionSize )+1;	
	
	if ( iNewImageNum == loopObject.iCurrentImageNum || loopObject.iCurrentImageNum >= loopObject.oCtrl.numInstallImages )
		return;
		
	loopObject.iCurrentImageNum = iNewImageNum;
	
	iPos = oCtrl.installImagesURL.lastIndexOf( "." );
	if ( iPos == -1 )
		return;		

	var sTemp = oCtrl.installImagesURL.substr( 0, iPos );
	var sExt =  oCtrl.installImagesURL.substr( iPos );
	sTemp += String( loopObject.iCurrentImageNum );
	sTemp += sExt;
	
	DHTMLAPI.getRawObject( "installImage" ).src = sTemp;	
}

//
// startInstallVideo()
//
function startInstallVideo() 
{
	var iWidth;
	var iHeight;
	
	if ( typeof oCtrl.installImageVideoWidth == "string" && (oCtrl.installImageVideoWidth == "auto" || oCtrl.installImageVideoWidth.indexOf( "%" ) != -1) )
	{
		if ( document.defaultView && document.defaultView.getComputedStyle )
			iWidth = DHTMLAPI.stripOffPX( DHTMLAPI.getComputedStyle( "wrapper", "width" ) );
		else
			iWidth = DHTMLAPI.getElementWidth( "wrapper" );		
	}
	else
		iWidth = oCtrl.installImageVideoWidth;
		
		
	if (typeof oCtrl.installImageVideoHeight == "string" && ( oCtrl.installImageVideoHeight == "auto" || oCtrl.installImageVideoHeight.indexOf( "%" ) != -1) )
	{
		if ( document.defaultView && document.defaultView.getComputedStyle )
			iHeight = DHTMLAPI.stripOffPX( DHTMLAPI.getComputedStyle( "wrapper", "height" ) );
		else
			iHeight = DHTMLAPI.getElementHeight( "wrapper" );		
	}
	else
		iHeight = oCtrl.installImageVideoHeight;	
		
		
   loopObject.flashObj = new SWFObject( oCtrl.installVideoURL+"&autoplay=1&enablejsapi=1", "video", iWidth, iHeight, "8", "#ffffff");
	loopObject.flashObj.addParam("allowfullscreen", "true");
   loopObject.flashObj.addParam("allowscriptaccess", "always");
	loopObject.flashObj. addParam('flashvars','autostart=true');
   loopObject.flashObj.write("installVideo");
	if ( iWidth != 1 && iHeight != 1 )
		DHTMLAPI.show( "installVideo" );	
}


//
// showDownloadInstructions()
//
function showDownloadInstructions( sInstallerURL, sButtonURL ) 
{
	
	var temp = '<a href="'+sInstallerURL+'" target="_self"><img src="'+sButtonURL+'" border="0"/></a><br><br>';
	temp += 'The inDuality plugin is required to view the Virtual World on this page.<br>';
	temp += 'The plugin is small and will install quickly depending on your connection speed.';
	temp += '<ul style="text-align:left; list-style:none">';
	temp += '<li>1. Click on the button above and download the install to your desktop.</li>';
	temp += '<li>2. To run the instal, locate the file on your desktop and double click on it.</li>';
	temp += '<li>3. Accept the license agreement.</li>';
	temp += '<li>4. Return to this page and watch the informational messages while the install completes </li>';
	temp += '</ul>';
			
	document.getElementById( "installInstructions" ).innerHTML = temp;
	
	DHTMLAPI.init();
	DHTMLAPI.show( "installInstructions" );		

	AutoRefreshPage();
}

/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(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 _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=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;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;