function S7ConfigObject()
{
    this.isVersion      = "2.8";
    this.isDomain       = "http://s7d2.scene7.com";
    this.isViewerRoot   = this.isDomain + "/is-viewers/";
    this.isRoot     = this.isDomain + "/is/image/";
    this.isContentRoot  = this.isDomain + "/skins/";
    
    this.isGenericBrochureViewer    = "flash/genericbrochure.swf";
    this.isGenericZoomViewer    = "flash/genericzoom.swf";
    
    this.searchEngineUrl    = "http://s7search1.scene7.com/s7search/search";


    this.codebase       = this.isViewerRoot + "/applets/" + this.isVersion + "/";
    this.archiveSuffix  = "";
    this.buttonPath     = this.isRoot + "/demo/buttons/";

    //used by js->flash communication.
    var ua        = navigator.userAgent.toLowerCase();
    this.isIeWin  = ua.indexOf('msie') != -1 && ua.indexOf('win') != -1 && ua.indexOf('opera') == -1 && ua.indexOf('webtv') == -1;
    this.isFsCommand = true;
}

S7ConfigObject.prototype.defaultInstanceName = function(img)
{
    var j = img.indexOf('?');
    var j1 = img.indexOf(',');
    if (j1 > 0 && (j < 0 || j > j1)) j = j1;
    j1 = img.indexOf(';');
    if (j1 > 0 && (j < 0 || j > j1)) j = j1;
    j1 = img.indexOf(':');
    if (j1 > 0 && (j < 0 || j > j1)) j = j1;
    j1 = img.indexOf('%3f');
    if (j1 > 0 && (j < 0 || j > j1)) j = j1;
    j1 = img.indexOf('%3F');
    if (j1 > 0 && (j < 0 || j > j1)) j = j1;
    if (j < 0) j = img.length;
    var i = img.lastIndexOf('/', j) + 1;
    return img.substring(i, j);
}

S7ConfigObject.prototype.setFlashParam = function(inId, inName, inVal) 
{
    if (this.isIeWin)
        document.getElementById(inId).SetVariable(inName, inVal);
    else 
    {
        var divcontainer = "flash_setvariables_" + inId;
        if (!document.getElementById(divcontainer))
        {
            var divholder = document.createElement("div");
            divholder.id = divcontainer;
            document.body.appendChild(divholder);
        }
        document.getElementById(divcontainer).innerHTML = "";
        var divinfo = "<embed src='../flash/gateway.swf' FlashVars='lc=" + inId + "&fq="+escape(inName + "=" + inVal)+"' width='0' height='0' type='application/x-shockwave-flash'></embed>";
        document.getElementById(divcontainer).innerHTML = divinfo;
    }
};

var flashOk = false;
S7ConfigObject.prototype.checkFlash = function()    //call this function and then test the flashOk variable
{
    if (S7Config.isIeWin)
    {
        document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
        document.write('on error resume next \n');
        document.write('flashOk = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7")) \n');
        document.write('if flashOk = false then \n');
        document.write('    flashOk = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6")) \n');
        document.write('end if \n');
        document.write('</SCR' + 'IPT\> \n');
    }
    else if (navigator.plugins && navigator.plugins["Shockwave Flash"])
    {
        var desc = navigator.plugins["Shockwave Flash"].description;
        var descArray = desc.split(" ");
        var majorVersionArray = descArray[2].split(".");     
        var majorVersion = majorVersionArray[0];        
        flashOk = majorVersion > 6;
    }
}

S7ConfigObject.prototype.fsCommand = function(instance)
{
    if (this.fsCommand)
    {
        document.write('<SCR'+'IPT LANGUAGE="VBScript"> Sub ' + instance + '_FSCommand(ByVal command, ByVal args)  call doFSCommand(command, args) end sub </SCR'+'IPT>');
        this.fsCommand = false;
    }
    return this.isIeWin ? 'fscommand:' : 'javascript:';
}

var S7Config        = new S7ConfigObject();

//backwards compatibility
var root            = S7Config.isViewerRoot;
var imageServer     = S7Config.isRoot;
var codebase        = S7Config.codebase;
var archiveSuffix   = S7Config.archiveSuffix;
var buttonPath      = S7Config.buttonPath;
function checkFlash() { S7Config.checkFlash(); }

function getParam(p,d)
{
    var str = "" + unescape(document.location);
    var i = Math.max( str.indexOf('?'+p+'='), str.indexOf('&'+p+'=') );
    if ( i < 0 )
        return d;
    i+=2+p.length;
    var i2 = str.indexOf('&',i);
    var returnstr = str.substring(i,(i2<0?str.length:i2));
    return (returnstr.indexOf(',')>0?returnstr.split(','):returnstr);
};

function doFSCommand(inCommand, inArgs)
{
    eval(inArgs);
}


function s7EmbedFlash(flashContainerId, url, instance, movieWidth, movieHeight, movieBgc) {
    
if (!flashOk)
    document.write('An update for the Flash player is required. <a href="http://www.macromedia.com/go/getflashplayer">Click here</a> to get a recent version and then try again<br><br><br>');
else
{
    // load flash
    var flashText = '';
    flashText = flashText + '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
    flashText = flashText + '  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,47,0" ';
    flashText = flashText + ' ID="'+instance+'" WIDTH="'+movieWidth+'" HEIGHT="'+movieHeight+'" ALIGN="">';
    flashText = flashText + ' <PARAM NAME=movie VALUE="' + url +'">' ;
    flashText = flashText + ' <PARAM NAME=menu VALUE=false> <PARAM NAME=quality VALUE=high> <PARAM NAME=scale VALUE=noscale> <PARAM NAME=salign VALUE=LT> <PARAM NAME=bgcolor VALUE=#'+movieBgc+'> <PARAM NAME="allowScriptAccess" VALUE="always"> ';
    flashText = flashText + ' <EMBED src="' + url+'"';
    flashText = flashText + ' NAME="'+instance+'" QUALITY="high" BGCOLOR="#'+movieBgc+'" WIDTH="'+movieWidth+'" HEIGHT="'+movieHeight+'" SWLIVECONNECT="true" allowScriptAccess="always"';
    flashText = flashText + ' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">';
    flashText = flashText + ' </EMBED></OBJECT>';
    
    document.getElementById(flashContainerId).innerHTML = flashText;
}



}

