
function S7ConfigObject()
{
	this.isViewerRoot	= "http://sample.scene7.com/is-viewers/";
	this.isRoot		= "http://sample.scene7.com/is/image/";
        this.contentRoot 	= "http://sample.scene7.com/";

	//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.setFlashParam = function(inId, inName, inVal) 
{
		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='http://sample.scene7.com/is-viewers/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 S7Config		= new S7ConfigObject();

var root		= S7Config.isViewerRoot;
var imageServer		= S7Config.isRoot;

//autoResize functions
function resizeStage(inWidth, inHeight)
{
	var elementId = myName;
	var isSafari = ((navigator.appName=='Safari') || (navigator.userAgent.toLowerCase().indexOf('safari')>-1));
	var elm = null;
	if (!isSafari)
	{
		elm = document.embeds[elementId];
	}
	var checkElm = false;
	if (elm)
	{
		checkElm = true;
	}
	else
	{
		checkElm = false;
	}

	if (!isSafari && checkElm)
	{
		elm.width = inWidth;
		elm.height= inHeight;
	}
	else
	{
		setWidth(elementId, inWidth);
		setHeight(elementId, inHeight);
	}
}

function getLayer(name)
{
	if (document.getElementById)
		return document.getElementById(name).style;
	if (document.all)
		return document.all[name].style;
	if (document.layers)
		return document[name];
}

function setWidth(layer,w)
{
	layer=getLayer(layer);
	if (document.getElementById)
		layer.width=w;
	else if (document.all)
		layer.posWidth=w;
	else if (layer.clip)
		layer.clip.width=w;
}

function setHeight(layer,h)
{
	layer=getLayer(layer);
	if (document.getElementById)
		layer.height=h;
	else if (document.all)
		layer.posHeight=h;
	else if (layer.clip)
		layer.clip.height=h;
}



var flashOk = false;
var flashChecked = false;
function checkFlash()	//call this function and then test the flashOk variable
{
	if(flashChecked)
	{
		return;
	}
	else
	{
		flashChecked = true;
	}
    if (navigator.appVersion.indexOf("MSIE") >= 0 && navigator.appVersion.indexOf("Windows") >= 0)
    {
		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('if flashOk = false then \n');
		document.write('    flashOk = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8")) \n');
		document.write('end if \n');
		document.write('</SCR' + 'IPT\> \n');
    } else { // else part is added for Mozilla Firefox browser flash issue TD# 6048
		if( !navigator.plugins )
			return;
		flashPlugin = navigator.plugins["Shockwave Flash"];
		if( !flashPlugin )
			return;
		var desc = flashPlugin.description;
		var pluginIdent = desc.split(" ");
		//The Flash Player identification string is ([] = the array index) [0]Shockwave [1]Flash [2]6.0 [3]r21

		//if less than Flash Player 6 is detected, run this code.
		if(pluginIdent[0] == "Shockwave" && pluginIdent[1] == "Flash") {
			//set a toggle to show that some sort of Flash Player (of versions 1-5) was found
			var isSwfEnabled = true;

			//an array of the Flash version number (major.minor)
			var versionArray = pluginIdent[2].split(".");

			if(versionArray[0] < 6)	{
				flashOk=false;
			} else {
				 //Flash Player 6 or greater has been found, roll out the <object> tag.
				flashOk=true;
			}
		} else
			flashOk = false;
    }
}
