
function S7ConfigObject()
{
	this.isViewerRoot	= "http://s7d2.scene7.com/is-viewers/";
	this.isRoot		= "http://s7d2.scene7.com/is/image/";
        this.contentRoot = "http://s7d2.scene7.com/";
	this.skinsRoot = "http://s7d2.scene7.com/skins/";
	//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://s7d2.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;
};



function docWrite(line) {
    document.write(line);
}

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 isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
var flashDescription;

//
// This will likely fail on versions before flash 6, but since we don't 
// support versions before 6.0r65 it is ok.
//
function isFlashCurrent(versionMajorReq, versionMinorReq, versionRevisionReq) {
    var versionMajor;
    var versionMinor;
    var versionRevision;

    // NS/Opera version >= 3 check for Flash plugin in plugin array
    if (navigator.plugins != null && navigator.plugins.length > 0) {
        if (navigator.plugins["Shockwave Flash"]) {
            // parse the description to get the version
            flashDescription = navigator.plugins["Shockwave Flash"].description;
            var descArray = flashDescription.split(" ");
            var tempArrayMajor = descArray[2].split(".");
            versionMajor = tempArrayMajor[0];
            versionMinor = tempArrayMajor[1];
            if (descArray[3] != "") {
                tempArrayMinor = descArray[3].split("r");
            } else {
                tempArrayMinor = descArray[4].split("r");
            }
            versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;

        }
    } else if (isIE && isWin && !isOpera) {
        try {
            var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + versionMajorReq);

            // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
            // so be careful.  Of course we don't run those versions.
            axo.AllowScriptAccess = "always";
            // required for v6.x?
            var version = axo.GetVariable("$version");
            // safe to call for 6.0r47 or greater
            flashDescription = version;

            // parse the version data
            tempArray = version.split(" ");
            // ["WIN", "2,0,0,11"]
            tempString = tempArray[1];
            // "2,0,0,11"
            versionArray = tempString.split(",");
            // ['2', '0', '0', '11']

            versionMajor = versionArray[0];
            versionMinor = versionArray[1];
            versionRevision = versionArray[2];
            // should be 3???
        } catch (e) {
        }
    }

    // test version
    if (versionMajor > versionMajorReq) {
	// alerts are just for demonstration and testing, disable when in production
    	//alert("Flash Version: " + versionMajor + "," + versionMinor + "," + versionRevision + " detected");
        return true;
    }
    if (versionMajor == versionMajorReq
            && versionMinor > versionMinorReq) {
	// alerts are just for demonstration and testing, disable when in production
        //alert("Flash Version: " + versionMajor + "," + versionMinor + "," + versionRevision + " detected");
       	return true;
    }
    if (versionMajor == versionMajorReq
            && versionMinor == versionMinorReq
            && versionRevision >= versionRevisionReq) {
	// alerts are just for demonstration and testing, disable when in production
	//alert("Flash Version: " + versionMajor + "," + versionMinor + "," + versionRevision + " detected");
        return true;
    }

    // alerts are just for demonstration and testing, disable when in production
    //alert("Flash Version: " + versionMajor + "," + versionMinor + "," + versionRevision + " detected");
    return false;
}


