function S7ConfigObject()
{
	this.isVersion		= "2.8";
	this.isViewerRoot	= "/is-viewers";
	this.isRoot		= "/is/image/";

	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"])
	{
		desc = navigator.plugins["Shockwave Flash"].description;
		flashOk = desc.indexOf('6.') > 0 || desc.indexOf('7.') > 0 || desc.indexOf('8.') > 0 || desc.indexOf('9.') > 0 || desc.indexOf('10.') > 0 || desc.indexOf('11.') > 0;
	}
}

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);
}
