FlashTour = new function()
{
    this.shim = document.getElementById("tourShim");
    this.shell = document.getElementById("tourShell");
    this.frame = document.getElementById("tourFrame");
    this.button = document.getElementById("tourClose");
        
    var self = this;
    this.button.onclick = function()
    {
        self.close();   
    };
}();

FlashTour.open = function(tourName, baseUrl, nextUrl)
{
    this.render(tourName, baseUrl, nextUrl);
    if(!(Ext.isMac && Ext.isGecko))
    {
    	// don't show this in FF for Mac
    	this.shim.style.display = "block";
    }
    this.shell.style.display = "block";
    
    
};

FlashTour.close = function()
{
    this.shim.style.display = "none";
    this.shell.style.display = "none";
};


/**
 * 
 */
FlashTour.render = function (tourName, baseUrl, nextUrl) 
{
    var flashVars = [];
    if (tourName) {
        flashVars[flashVars.length] = "slideShowName=" + tourName;
    }

    if (baseUrl) {
        flashVars[flashVars.length] = "baseUrl=" + baseUrl;
    }

    if (nextUrl) {
        flashVars[flashVars.length] = "nextUrl=" + nextUrl;
    }
    var html = this.createSwfHtml("/flashtour/tour_alt.swf?v=3", 640, 480, flashVars);
    this.frame.innerHTML = html;
}
/**
 * 
 */
FlashTour.createSwfHtml = function(swfUrl, width, height, flashVars)
{
    
    // set proto to existing protocol variable, or "http" if protocol is 
    // not set.  it is assumed the protocol variable is set outside the 
    // scope of this script file.
    var proto = "http";
    
    var flashVarsString = "";
    
    // build query string from array provided
    if(flashVars)
    {
        for(i=0; i<flashVars.length; i++)
        {
            flashVarsString += flashVars[i] + "&"; 
        }
    }   
    
    var html = "";
    html += "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' ";
    html += "codebase='" + proto + "://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0'  ";
    html += "width='" + width + "'  ";
    html += "height='" + height + "'  ";
    html += "align='middle'> ";
    html += "<param name='allowScriptAccess' value='always' /> ";
    html += "<param name='movie' value='" + swfUrl + "' /> ";
    html += "<param name='quality' value='high' /> ";
    html += "<param name='scale' value='noscale' /> ";
    html += "<param name='wmode' value='window' /> ";
    html += "<param name='salign' value='lt' /> ";
    html += "<param name='bgcolor' value='#ffffff' /> ";
    html += "<param name='FlashVars' value='" + flashVarsString + "' />";
    html += "<embed src='" + swfUrl + "'  ";
    html += "    quality='high'  ";
    html += "    scale='noscale'  ";
    html += "    wmode='window'  ";
    html += "    salign='lt'  ";
    html += "    bgcolor='#ffffff'  ";
    html += "    width='" + width + "'  ";
    html += "    height='" + height + "'  ";
    html += "    align='middle'  ";
    html += "    allowScriptAccess='always'  ";
    html += "    swLiveConnect='true'  ";
    html += "    type='application/x-shockwave-flash'  ";
    html += "    pluginspage='" + proto + "://www.macromedia.com/go/getflashplayer'  ";
    html += "    flashVars='" + flashVarsString + "'/>";
    html += "</object> ";
    
    return html;
};

