/* Function: detectFlash
* Description: returns true if minFlashVersion or greater is detected.
*/
function rfx_detectFlash (minFlashVersion) {
var flashinstalled = 0;
var flashversion = 0;
var x, y;
if (navigator.plugins && navigator.plugins.length) {
x = navigator.plugins["Shockwave Flash"];
if (x) {
flashinstalled = 2;
if (x.description) {
y = x.description;
flashversion = parseFloat( y.substr( y.indexOf('.') - 2 ) );
}
} else flashinstalled = 1;
if (navigator.plugins["Shockwave Flash 2.0"]) {
flashinstalled = 2;
flashversion = 2;
}
} else if (navigator.mimeTypes && navigator.mimeTypes.length) {
x = navigator.mimeTypes['application/x-shockwave-flash'];
if (x && x.enabledPlugin)
flashinstalled = 2;
else
flashinstalled = 1;
} else {
flashinstalled = 1;
for (var i=12; i>0; i--) {
flashversion = 0;
try {
var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
flashversion = i;
flashinstalled = 2;
break;
} catch(e) {}
}
}
return (flashinstalled == 2 && flashversion >= minFlashVersion);
}
// Override the default random number generator to fix Safari 3 bug.
Math.random = function() {
if ( typeof(Math.randomSeed) == "undefined" ) Math.randomSeed = (new Date()).getTime();
var a = 1664525;
var c = 1013904223;
var m = 4294967296;
return (Math.randomSeed = (Math.randomSeed * a + c) % m) / m;
}
// Search for and decode the script tag for load time parameters
function rfx_decodeScript (scriptName) {
// Search for the script element match specified script file name
var scriptElements = document.getElementsByTagName("script");
var scriptSrc = undefined;
var scripTagsObjects = new Array();
for ( var scriptID = 0; scriptID < scriptElements.length; scriptID++ ) {
if ( scriptElements[scriptID].src.toLowerCase().indexOf( scriptName.toLowerCase() ) != -1 ) {
scriptSrc = scriptElements[scriptID].src;
// Separate the document domain and URL path from the query parameters
var scriptVars = scriptSrc.split(scriptName);
// Add the host name and url path of parent document if none found in script path
if ( !scriptVars[0] ) {
var URLPath = document.location.pathname.split("/"); URLPath.pop();
scriptVars[0] = document.location.protocol + "//" + document.location.host + URLPath.join("/") + "/";
}
var hostVars = scriptVars.shift().split("://");
var queryVars = scriptVars.join(scriptName);
var host = undefined; var urlPath = undefined;
// Add the host name script path did not contain it
if ( !hostVars[1] ) {
host = document.location.host;
urlPath = hostVars[0];
} else {
var hostVarTmp = hostVars[1].split("/");
host = hostVarTmp.shift();
urlPath = "/" + hostVarTmp.join("/");
}
// Parse the query parameters
var queryVarObj = new Object();
var queryVarArray = queryVars.substring(1).split("&");
for ( var i = 0; i < queryVarArray.length; i++ ) {
var queryVariable = queryVarArray[i].split("=");
queryVarObj[ queryVariable[0].toLowerCase() ] = unescape( queryVariable[1] );
}
// Add the parent document's query parameters to list
queryVarArray = document.location.search.substring(1).split("&");
for ( var i = 0; i < queryVarArray.length; i++ ) {
var queryVariable = queryVarArray[i].split("=");
queryVarObj[ queryVariable[0].toLowerCase() ] = unescape( queryVariable[1] );
}
// Parse for the account name from the host
var accountVars = host.split(".");
var account = "";
if ( accountVars.length > 2 && accountVars[ accountVars.length - 2 ].toLowerCase() == "richfx" )
account = accountVars[ accountVars.length - 3 ].toLowerCase();
// Parse for the media name from the URL path
var urlVars = urlPath.split("/");
var mediaName = "";
for ( var i = 0; i < urlVars.length; i++ ) {
if ( urlVars[i] == "media" && urlVars.length > i + 1 ) {
mediaName = urlVars[i + 1];
break;
}
}
// Set default values
with ( queryVarObj ) {
if ( typeof(rfx_imageviewerbase) == "undefined" || !rfx_imageviewerbase ) queryVarObj.rfx_imageviewerbase = "http://" + host + urlPath + "viewers/base/";
if ( typeof(rfx_mediabase) == "undefined" || !rfx_mediabase ) queryVarObj.rfx_mediabase = "http://" + host + urlPath;
if ( typeof(rfx_client) == "undefined" || !rfx_client ) queryVarObj.rfx_client = account;
queryVarObj.rfx_int_default = "anyspot_onelevel";
queryVarObj.rfx_lang_default = "en";
}
// Populate the parsed script object
var scriptParsedObject = new Object();
scriptParsedObject.search = queryVars;
scriptParsedObject.host = scriptParsedObject.hostname = host;
scriptParsedObject.pathname = urlPath;
scriptParsedObject.href = scriptVars.join(scriptName);
scriptParsedObject.query = queryVarObj;
scriptParsedObject.account = account;
scriptParsedObject.medianame = mediaName;
// Identify client platform
scriptParsedObject.ua = navigator.userAgent.toLowerCase();
scriptParsedObject.mac = scriptParsedObject.ua.indexOf('mac') > -1;
scriptParsedObject.windows = scriptParsedObject.ua.indexOf('windows') > -1;
// Identify client browser
scriptParsedObject.opera = scriptParsedObject.ua.indexOf('opera') > -1;
scriptParsedObject.ie = ( scriptParsedObject.ua.indexOf('msie') > -1 ) && !scriptParsedObject.opera; // Opera can masquerade as IE
scriptParsedObject.safari = scriptParsedObject.ua.indexOf('safari') > -1;
scriptParsedObject.refid = scripTagsObjects.length;
scripTagsObjects.push(scriptParsedObject);
}
}
if ( !scripTagsObjects.length ) return;
var returnObject = scripTagsObjects[0];
returnObject.items = scripTagsObjects;
return returnObject;
}
// Check for a boolean true from a query param
function rfx_queryCheckBool( value ) {
var v = value;
if ( v == undefined ) return false;
v = v.toLowerCase();
if ( v == "1" || v == "true" || v == "on" )
return true;
else
return false;
}
//=========================================
//== FOR ActiveX Browswers
function routeDoFSCommand(command, args, flashObjectName) {
if ( typeof(flashObjectName) == "undefined" ) flashObjectName = "rfxmain";
if ( command == "call_alert" ) {
try { eval(args); } catch(e) {}
} else {
rfx_getFlashObject(flashObjectName).callJSFunction(command, args);
}
}
//=========================================
//== Form the flash embed code
function rfx_getFlashEmbedCode(embedID) {
if ( typeof(embedID) == "undefined" ) {
embedID = 0; elementID = ""
} else {
elementID = embedID;
}
if ( rfx_RequestParams.items[embedID].query.rfx_testimage ) {
var bgColor = rfx_RequestParams.items[embedID].query.rfx_testimage;
if ( !bgColor ) bgColor = "#FFFFFF";
var buf = '';
document.body.innerHTML = buf;
return false;
}
var rfx_movieSrc = rfx_RequestParams.items[embedID].query.rfx_imageviewerbase + "loader.swf";
if ( (elementID + "") != "" )
var rfx_movieElementID = "rfxmain_" + embedID;
else
var rfx_movieElementID = "rfxmain";
var rfx_fscommand = rfx_RequestParams.items[embedID].query.rfx_fscommand;
var bfsCommand = false;
if ( rfx_RequestParams.ie )
bfsCommand = true;
if ( typeof(rfx_fscommand) != "undefined" ) {
if ( rfx_fscommand == "0" )
bfsCommand = false;
else ( rfx_fscommand == "1" )
bfsCommand = false;
}
// check if using FSCommand
if ( bfsCommand ) {
// setup the FSCommand listener for the flash object
if ( rfx_RequestParams.ie ) {
//=============================================================
//For ActiveX Browsers; IE ===
rfx_CreateFSListener(rfx_movieElementID);
} else {
// for plugin based browsers
function rfx_tmpDoFSCommand(command, args) { routeDoFSCommand(command, args, rfx_movieElementID); }
eval ( rfx_movieElementID + '_DoFSCommand = rfx_tmpDoFSCommand' );
}
}
var rfx_flashVars = new Array();
rfx_flashVars.push( "name=" + rfx_movieElementID );
rfx_flashVars.push( "initCallBack=initCallBack" );
rfx_flashVars.push( "fs_command=" + (bfsCommand ? 1 : 0) ); //orig: "fs_command=0"
rfx_flashVars.push( "base=" + rfx_RequestParams.items[embedID].query.rfx_imageviewerbase );
rfx_flashVars.push( "mediaBase=" + rfx_RequestParams.items[embedID].query.rfx_mediabase );
rfx_flashVars.push( "sClientName=" + rfx_RequestParams.items[embedID].account );
rfx_flashVars.push( "sMediaName=" +rfx_RequestParams.items[embedID].medianame );
rfx_flashVars.push( "integration=" + rfx_RequestParams.items[embedID].query.rfx_int );
rfx_flashVars.push( "language=" + rfx_RequestParams.items[embedID].query.rfx_lang );
rfx_flashVars.push( "integration_default=" + rfx_RequestParams.items[embedID].query.rfx_int_default );
rfx_flashVars.push( "language_default=" + rfx_RequestParams.items[embedID].query.rfx_lang_default );
rfx_flashVars.push( "ZoomURL=" + rfx_RequestParams.items[embedID].query.rfx_mediabase + "zoom.info" );
rfx_flashVars.push( "AltURL=" + rfx_RequestParams.items[embedID].query.rfx_mediabase + "FirstFrame.jpg" );
rfx_flashVars.push( "queryStr" + escape( location.search.substring(1) ) );
var rfx_buff = "";
if ( !rfx_RequestParams.items[embedID].safari ) {
rfx_buff += '';
return rfx_buff;
}
//=========================================
// Parse script embed params
var rfx_RequestParams = rfx_decodeScript("rfxImageEmbed");
if ( typeof(rfx_RequestParams_itemID) == "undefined" )
var rfx_RequestParams_itemID = 0;
if ( typeof(rfx_RequestParams_renderID) == "undefined" )
var rfx_RequestParams_renderID = 0;
else
rfx_RequestParams_renderID++;
if ( rfx_RequestParams.ie ) {
var vbBuff = "";
vbBuff += '' + '\n';
vbBuff += '' + '\n';
vbBuff += '' + '\n';
document.write(vbBuff);
}
// Load the javascript sync code
document.write('');
// Show debug window if specified
if ( typeof(rfx_debugwindow) == "undefined" && rfx_queryCheckBool( rfx_RequestParams.items[rfx_RequestParams_renderID].query.rfx_debug ) ) {
var rfx_debugwindow = true;
document.write('');
}
// Load the embed code
document.write('');