
function S7ConfigObject()
{  //Please host this file on your own web server (do not reference from s7testweb.adobe.com) and change the urls below to match your assigned image server urls
	this.contentRoot = "http://s7d5.scene7.com/";
	this.isViewerRoot	= this.contentRoot + "s7viewers/";
	this.isRoot		= this.contentRoot + "is/image/";
	this.skinsRoot = this.contentRoot + "skins/";
	this.staticRoot = this.contentRoot + "is/content/";
	this.videoRoot =  this.contentRoot + "e2/";
	//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) 
{
	var q = '';
	for (var i = 1; i < arguments.length; i = i + 2)
	{
		if (i + 1 < arguments.length) 
		{
			q += '&' + escape(arguments[i]) + '=' + escape(arguments[i + 1]);
		}
	}
	q = q.substr(1);

	if (this.divId > this.maxDivs)
	{
		this.divId = 1;
	}
	var divcontainer = "flash_setvariables_" + inId + "_" + this.divId;
	this.divId ++;
	
	if (!document.getElementById(divcontainer))
	{
		var divholder = document.createElement("div");
		divholder.id = divcontainer;
		document.body.appendChild(divholder);
	}
	document.getElementById(divcontainer).innerHTML = "";
	var divinfo;
		divinfo = "<embed src='" + this.isViewerRoot + "/flash/gateway.swf' FlashVars='lc=" + inId + "&fq=" + escape(q) + "' width='0' height='0' type='application/x-shockwave-flash'></embed>";
	document.getElementById(divcontainer).innerHTML = divinfo;
};



function docWrite(line) {
    document.write(line);
}

//Default variables required for viewer initilization

var S7ConfigClient		= new S7ConfigObject();

var root		= S7ConfigClient.isViewerRoot;
var imageServer		= S7ConfigClient.isRoot;              
	
			
//autoResize functions
function resizeStage(inWidth, inHeight, myName)
{
	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;
}

function genInstance(){
 var curDateTime = new Date();
 var curTime = 'ZoomMX' + curDateTime.getHours()+ curDateTime.getMinutes() + curDateTime.getSeconds();
  return curTime;
 }
 
 // added by dsweeney 7/7/2011
 function embed_SC_Vid(vidPath,htmlID,width,height, autoPlay) {
	var myName=genInstance();	//This needs to match the ID and NAME in the flash initialization below.  This is generated randomly dependant on curent time in order to prevent multiple page instances from interfering with each other by having the same instance name declared
	var viewerType = "Scene7SharedAssets/Scene7VideoAS3_i";  //this should be changed to reference the path of your AS3 viewer file, relative to the web root

	var videoName = vidPath;  //Image, ImageSet, or comma seperated list of Company/Image to pass to the viewer
	//var configName = "Scene7SharedAssets/eVideo_Below_PlayIcon";  //Viewer configuration settings to use at viewer initialization
	var configName = autoPlay==true ? "Scene7SharedAssets/eVideo_Floating" : "Scene7SharedAssets/eVideo_Floating_PlayIcon";  //Viewer configuration settings to use at viewer initialization
					
	var flashvars = {
		
		}; 

	var params = {     //Setup param tag elements for the flash object to embed in the page 
		allowScriptAccess:"Always",
		allowFullScreen:"true",
		menu:"false",
		quality:"high",
		scale:"showall",
		salign:"LT",
		bgcolor:"#FFFFFF",
		wmode:"transparent"
	};  

	var attributes = {  //Setup object tag elements for the flash object to embed in the page
		id: myName,
		name: myName
	};

	var viewerUrl = "";  //Build Viewer Path to Viewer swf
		viewerUrl += S7ConfigClient.staticRoot;
		viewerUrl += viewerType + "?";
		viewerUrl += "&contentroot=" + S7ConfigClient.skinsRoot;
		viewerUrl += "&instanceName=" + myName;
		viewerUrl += "&asset=" + videoName;
		viewerUrl += "&config=" + configName;
		viewerUrl += "&videoserverurl=rtmp://s7strmn2.scene7.com/s7strmn2/e2"; 				
		viewerUrl += "&vidServerUrl=/e2/"; 				
		viewerUrl += "&comServerUrl=rtmp://s7strmn2.scene7.com/s7strmn2/e2"; 				
		viewerUrl += "&serverUrl=" + S7ConfigClient.isRoot;
		viewerUrl += "&stageSize=" + width +"," + height;
	
	swfobject.embedSWF(viewerUrl, htmlID, width, height, "7.0.14.0", "../flash/expressInstall.swf", flashvars, params, attributes);
}
