RFX_defaultFont='arialnarrow';RFX_embedWidth = {'high' : 1024, 'low' : 800};RFX_embedHeight = {'high' : 700, 'low' : 600};
RFX_Base = "http://meijer.richfx.com/catalog_meijer/MeijerBackyard/";
PassBack = escape("");
VersioningID = "";
VersioningName = "";
CatalogTotalPages = 32;
/* Function: DeclareCatalogObject
* Description: returns html code to embed the catalog
*/
function DeclareCatalogObject()
{
debugFunc('DeclareCatalogObject', arguments);
var buff="";
//get the event handlers, and the metrics code.
buff += declareScriptTag('version.txt'); //Sets the VERSION variable
buff += declareScriptTag('custom/flashevents.js');
buff += declareScriptTag('script/LoggingManager.js');
//declare the product iframe
buff += '
';
buff += '';
buff += EmbedCatalog();
//if debug variable is set via the querystring show a textbox showing the debug info
if (oSettings.debug)
{
buff += '
'
}
buff += "CatalogObjectReady()";
//adding 'showobjectdec=true', shows the declaration of the object in plain text.
if (_rfxGetUrlParam("RFX_showobjectdec"))
return ""
else
return buff
}
/* Function: GetUserVars
* Description: populates the user specific information.
*
*/
function GetUserVars()
{
debugFunc('GetUserVars', arguments);
oSettings.ViewID = GetViewId();
oSettings.sResolution=_rfxGetSubCookie('perm', 'res', oSettings.sResolution);
oSettings.iCurrentPage=_rfxGetSubCookie('temp', "page", oSettings.iCurrentPage);
if (oSettings.bShowSearch)
oSettings.searches=_rfxGetSubCookie('perm', "searches", oSettings.searches);
if (oSettings.iflagsEnabled)
oSettings.iflags=_rfxGetSubCookie('perm', 'iflags', oSettings.iflags);
if (oSettings.zoomMode == "arrows") //Arrow zoom mode.
oSettings.arrow_help=_rfxGetSubCookie('temp', 'arrow_help', oSettings.arrow_help);
//if (oSettings.zoomMode == "magnify") //Magnify mode.
// oSettings.mag_help=_rfxGetSubCookie('temp', 'mag_help', oSettings.mag_help);
}
/* Function: _rfxGetUrlParams
* Description: checks for parameters in the url that should override any cookie values.
*/
function _rfxGetUrlParams()
{
debugFunc('_rfxGetUrlParams', arguments);
oSettings.base=unescape(_rfxGetUrlParam("RFX_Base",oSettings.base));
oSettings.clientBase=unescape(_rfxGetUrlParam("RFX_URLBase",oSettings.clientBase));
oSettings.debug=_rfxGetUrlParam("RFX_Debug",oSettings.debug);
oSettings.showSearchBorders=_rfxGetUrlParam("RFX_SSB",oSettings.showSearchBorders);
oSettings.func_debug=_rfxGetUrlParam("RFX_Show_Internals",oSettings.func_debug);
oSettings.QAProjectID=_rfxGetUrlParam("RFX_QAProjectID",oSettings.QAProjectID);
oSettings.ViewID=_rfxGetUrlParam("RFX_ViewID",oSettings.ViewID);
oSettings.sResolution=_rfxGetUrlParam("RFX_Res", oSettings.sResolution);
oSettings.iCurrentPage=_rfxGetUrlParam("RFX_Page",oSettings.iCurrentPage);
oSettings.bDontCache=_rfxGetUrlParam("RFX_dontcache",oSettings.bDontCache);
oSettings.sViewMode=_rfxGetUrlParam("RFX_View",oSettings.sViewMode);
oSettings.sSearchTerm=unescape(_rfxGetUrlParam("RFX_SearchTerm",oSettings.sSearchTerm));
oSettings.iSearchOffset=_rfxGetUrlParam("RFX_SearchOffset",oSettings.iSearchOffset);
oSettings.bDisableLogging= _rfxGetUrlParam("RFX_disablelogging", oSettings.bDisableLogging);
oSettings.bDebugLogging= _rfxGetUrlParam("RFX_DebugLogging", oSettings.bDebugLogging);
oSettings.sOmnitureABTestName = _rfxGetUrlParam("RFX_ABTest", "");
oSettings.sOmnitureABSecondTestName = "";
oSettings.sOmnitureCampaignName = _rfxGetUrlParam("RFX_Campaign", "");
oSettings.VersioningID = _rfxGetUrlParam("RFX_VersioningID", VersioningID);
oSettings.isStaging = _rfxGetUrlParam("RFX_Staging", false);
oSettings.language = _rfxGetUrlParam("RFX_Lang", "en");
oSettings.integration = _rfxGetUrlParam("RFX_Int", oSettings.integration);
oSettings.bNoCheck = _rfxGetUrlParam("RFX_NoCheck", false);
if (!oSettings.isStaging)
oSettings.isStaging = !(location.hostname.match(/.*\.\D{2,4}$/) && location.hostname.indexOf('testny') < 0);
//for product page preview
oSettings.BorderClickGID = _rfxGetUrlParam("RFX_BorderClickGID", oSettings.BorderClickGID);
//for search result border blink
oSettings.BorderBlink = _rfxGetUrlParam("RFX_BorderBlink", oSettings.BorderBlink);
// QA mode
oSettings.QA = new Array();
var qa = unescape(_rfxGetUrlParam("RFX_QA", ""));
if( qa == "productpage" ) {
oSettings.QA.bShowProductPageInNewWindow = true;
}
}
/* Function: checkBaseForCache
* Description: checks if we need to make the base come from earthcache, our cache provider.
* if so changes the base
*/
function checkBaseForCache()
{
debugFunc('checkBaseForCache', arguments);
if (oSettings.bDontCache == "true")
return false;
//if location is a domain, and its not "testny" then use cache
if (oSettings.base.match(/\/\/([^\/]*)/))
{
hostname = RegExp.$1
//Earthcache
//if (hostname.match(/.*\.\D{2,4}$/) && hostname.indexOf("testny") < 0 && hostname.indexOf("earthcache") < 0)
// oSettings.base=oSettings.base.replace("http:\/\/","http://http.earthcache.net/")
//Akamai
if (!oSettings.isStaging &&
!oSettings.isOffline &&
hostname.indexOf("edgesuite") < 0)
oSettings.base=oSettings.base.replace("richfx.com","richfx.com.edgesuite.net")
}
}
/* Function: _rfxMain
* Description: entry point of the Catalog.
*/
function _rfxMain()
{
debugFunc('_rfxMain', arguments);
//start user specific code, only if cookies is supported.
if (CookiesEnabled())
GetUserVars()
//overrided user settings with url params
_rfxGetUrlParams();
if (!oSettings.base) oSettings.base = location.href.substr(0,location.href.lastIndexOf('/'));
//add a slash to the end of base url if there isnt one already.
oSettings.base+=(oSettings.base.charAt(oSettings.base.length-1)!='/')?"/":"";
oSettings.productbase=oSettings.base;
if (oSettings.iCurrentPage>oSettings.totalPages || oSettings.iCurrentPage<0)
oSettings.iCurrentPage=1;
//check if we should add caching.
checkBaseForCache()
//Initialize Catalog Settings depending on user settings.
setResolution(oSettings.sResolution)
oSettings.bCookiesEnabled = CookiesEnabled();
oSettings.version = (shouldShowHTML())?"HTML":"FLASH " + oSettings.flash_version;
oSettings.viewType = oSettings.isLowRes() ? "Small View" : "Large View";
//check to see if html version is requested or required
if (shouldShowHTML())
document.write(declareScriptTag('script/html_catalog.js'));
else
document.write(declareScriptTag('script/flash_catalog.js'));
}
/*
* Function: CatalogCodeLoaded()
* Description: call back after appropriate javascript code for the catalog has been loaded
*/
function CatalogCodeLoaded()
{
debugFunc('CatalogCodeLoaded', arguments);
//These are flash/HTML specific already
InitializeCatalog();
document.write(DeclareCatalogObject());
}
/* Function: detectFlash
* Description: returns true if minFlashVersion or greater is detected.
*/
function detectFlash(minFlashVersion)
{
debugFunc('detectFlash', arguments);
//dont bother detecting if already detect.
if (oSettings.flash_version)
return oSettings.flash_version >= minFlashVersion;
var plugin;
var flash_version=0;
document.write("\nfunction jCreateObject(progID)\nOn Error Resume Next\nset jCreateObject=CreateObject(progID)\nend function\n");
for (i=6;i<=12;i++)
{
plugin = false;
if( oSettings.ie && oSettings.windows ) { // MSIE on Windows, use ActiveX
plugin=typeof(jCreateObject("ShockwaveFlash.ShockwaveFlash." + i)) == "object";
}
else { // Otherwise, use Netscape plugin style detection
plugin = ((navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : false);
plugin = (plugin && plugin.description && parseInt(plugin.description.substring(plugin.description.indexOf(".")-2)) >= i) ? true : false;
}
if (plugin) flash_version = i;
}
oSettings.flash_version=flash_version;
return (flash_version > minFlashVersion)
}
/*
* Function: shouldShowHTML()
* Description: returns true if we should show html version.
*/
function shouldShowHTML()
{
debugFunc('shouldShowHTML', arguments);
return oSettings.htmlEnabled && (_rfxGetUrlParam("RFX_ver") == "html" || !detectFlash(6) || !oSettings.flashEnabled || (navigator.userAgent.toLowerCase().indexOf('mac') >= 0 && oSettings.flash_version <= 5))
}
/* Function: setResolution
* Description: populates a setting with the sizes of a certain resolution.
*/
function setResolution(index)
{
debugFunc('setResolution', arguments);
for (attrib in oSettings.Resolutions)
{
eval("oSettings." + attrib + "=oSettings.Resolutions[attrib][index];")
}
oSettings.embedWidth = RFX_embedWidth[index];
oSettings.embedHeight = RFX_embedHeight[index];
}
/* Function: CatalogVars
* Description: contains all catalog settings
*/
function CatalogVars()
{
debugFunc('CatalogVars', arguments);
this.bInitializing=true;
this.sCatalogMode;
this.defaultFont = RFX_defaultFont;
this.HIGHRES;
this.LOWBAND;
this.read_only=false;
this.base=(typeof(RFX_Base)=="string")?RFX_Base:"";
this.clientBase=location.href
this.clientBase=this.clientBase.replace(/\#$/, "");
this.clientBase=this.clientBase.replace(location.search,"") + "?";
this.showSearchBorders="false";
this.bShowModeMenu;
this.bShowHelp;
this.bShowTOC;
this.bShowPane;
this.showProdPopupAnim = 1;
this.totalPages=0;
this.sResolution;
this.ViewID;
this.searches="";
this.sLastSearchTerm = "";
this.arrow_help=0;
this.iflags="";
this.debug;
this.bCookiesEnabled;
this.viewType;
this.version;
this.bDisableLogging = false;
this.VersioningID="";
this.VersioningName="";
this.iCurrentPage = 1;
this.sViewMode = 'spread';
this.ua = navigator.userAgent.toLowerCase();
// Operating Systems
this.mac = this.ua.indexOf('mac') > -1;
this.windows = this.ua.indexOf('windows') > -1;
this.osX = this.mac && (this.ua.indexOf('os x') >= 0 );
this.win95 = this.ua.indexOf('win95') >= 0 || this.ua.indexOf('windows 95') >= 0;
this.winNT = this.ua.indexOf('winnt') >= 0 || this.ua.indexOf('windows nt 4') >= 0;
// Browsers
this.opera = this.ua.indexOf('opera') > -1;
this.ie = (this.ua.indexOf('msie') > -1) && !this.opera; // Opera can masquerade as IE
this.gecko = this.ua.indexOf('gecko') > -1;
this.safari = this.ua.indexOf('safari') > -1;
this.aol = this.ua.indexOf('aol') > -1;
this.isLowRes = function() {return this.sResolution=='low';}
this.isHighRes = function() {return this.sResolution=='high';}
this.isOffline = this.base.indexOf('127.0.0.1') > -1;
}
/* Function: product_details_close
* Description: closes the product window in response to the close click event in the flash
*/
function product_details_close()
{
var obj = document.getElementById('product_frame')
if (obj.style.display!="none")
{
obj.style.visibility='hidden';
obj.style.display = "none"
obj.src=oSettings.base+"html/ProductPageWait.html";
}
}
/////////////////////////////////////////////////////////////////////////////////////////
/* Function: GetViewId
* Description: returns the view (user) id, if none
* creates one and sets it in a persistent cookie
*/
function GetViewId()
{
debugFunc('GetViewId', arguments);
id = _rfxGetSubCookie('perm', 'viewid')
if (!id)
{
id = GenerateNewId();
_rfxSetSubCookie('perm', 'viewid', id);
}
return id
}
/* Function: GenerateNewId
* Description: Creates a random character string used for unique ids.
*/
function GenerateNewId()
{
debugFunc('GenerateNewId', arguments);
charList = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
//TODO: Add random number to shift the random iterator to.
uID = ""
for (i=0;i<32;i++)
uID+=charList.charAt(Math.random()*charList.length)
return uID;
}
/* Function: declareScriptTag
* Description: returns script tag with the scriptFile supplied.
*/
function declareScriptTag(scriptFile)
{
debugFunc('declareScriptTag', arguments);
return "" +(oSettings.safari ? "" : "")+"\n";
}
/* Function: ParseUrlEncodedString
* Description: parses a url encoded string and returns value if found
*/
function ParseUrlEncodedString(str,param)
{
//debugFunc('ParseUrlEncodedString', arguments);
if (!str)
return null;
re = new RegExp("(^|[?&])" + param + "=([^&=]*)(&|$)?","i")
//re = new RegExp(param + "=([^&=]*)(&|$)?","i")
if (str.match(re))
return RegExp.$2
return null;
}
/* Function: ReplaceUrlEncodedString
* Description: returns adds or replaces a query string param in a formatted string
*/
function ReplaceUrlEncodedString(queryStr, param)
{
debugFunc('ReplaceUrlEncodedString', arguments);
if (queryStr)
{
rep = /\&$/;
param=param.replace(rep, "");
var sPar = param.split("=")[0];
var sVal = param.split("=")[1];
re = new RegExp("(^|[?&])" + sPar + "=([^&=]*)(&|$)?","i")
if (queryStr.match(re))
{
if (sVal=="")
queryStr = queryStr.replace(re,RegExp.$1); //delete
else
queryStr = queryStr.replace(re,RegExp.$1+param+"&");
return queryStr;
}
if (sVal=="")
return queryStr;
queryStr=queryStr.replace(rep, "");
return queryStr+"&"+param;
}
return param;
}
/* Function: _rfxGetUrlParam
* Description: returns value of url param if found, or sDefValue if not
*/
function _rfxGetUrlParam(param, sDefValue)
{
debugFunc('_rfxGetUrlParam', arguments);
queryStr = location.search
if (!queryStr) return sDefValue; // if query string is empty return
sRet=ParseUrlEncodedString(queryStr,param);
return (sRet==null ? sDefValue : sRet);
}
/* Function: _rfxSetUrlParam
* Description: returns adds or replaces a query string param in a query string
*/
function _rfxSetUrlParam(queryStr, param)
{
debugFunc('_rfxSetUrlParam', arguments);
return ReplaceUrlEncodedString(queryStr, param);
}
/* Function: GetUrlParamState
* Description: returns the basic state of the catalog as a URL param string
*/
function GetUrlParamState()
{
debugFunc('GetUrlParamState', arguments);
var sParams=location.search;
sParams=sParams.replace(/^\?/, "");
sParams=sParams.replace(/\#$/, "");
sParams=_rfxSetUrlParam(sParams,"RFX_Ver=" + oSettings.sCatalogMode);
sParams=_rfxSetUrlParam(sParams,"RFX_Res=" + oSettings.sResolution);
sParams=_rfxSetUrlParam(sParams,"RFX_Base=" + escape(oSettings.base));
return sParams;
}
/* Function: StripUrlParamState
* Description: returns the URL string stripped of all rfx_ params that control state
*/
function StripUrlParamState(sURL)
{
debugFunc('StripUrlParamState', arguments);
sURL=_rfxSetUrlParam(sURL,"RFX_Ver=");
sURL=_rfxSetUrlParam(sURL,"RFX_Res=");
sURL=_rfxSetUrlParam(sURL,"RFX_Page=");
sURL=_rfxSetUrlParam(sURL,"RFX_Base=");
sURL=_rfxSetUrlParam(sURL,"RFX_ViewID=");
sURL=_rfxSetUrlParam(sURL,"RFX_Debug=");
return sURL;
}
/////////////////////////////////////////////////////////////////////////////////////////
/* Function: CookiesEnabled
* Description: returns true if Cookies is enabled.
*/
function CookiesEnabled()
{
debugFunc('CookiesEnabled', arguments);
_rfxSetSubCookie('temp', 'enabled', 'true')
return _rfxGetSubCookie('temp', 'enabled') == 'true';
}
/* Function: _rfxGetCookie
* Description: returns value of cookie specified in sName,
* null if not found.
*/
function _rfxGetCookie(sName)
{
debugFunc('_rfxGetCookie', arguments);
// cookies are separated by semicolons
var aCookie = document.cookie.split("; ");
for (var i=0; i < aCookie.length; i++)
{
// a name/value pair (a crumb) is separated by an equal sign
var aCrumb = aCookie[i].split("=");
if (sName == aCrumb[0])
return unescape(aCrumb[1]);
}
// a cookie with the requested name does not exist
return null;
}
/* Function: _rfxGetSubCookie
* Description: returns value of a sub cookie of sCookieName specified by sSubCookieName
* null if not found.
*/
function _rfxGetSubCookie(sCookieName, sSubCookieName, sDefValue)
{
debugFunc('_rfxGetSubCookie', arguments);
var sCrumb = _rfxGetCookie(oSettings.CatalogID+"_"+sCookieName);
var sVal=ParseUrlEncodedString(sCrumb, sSubCookieName);
return (sVal!=null ? unescape(sVal) : sDefValue);
}
function _rfxSetSubCookie(sCookieName, sSubCookieName, sSubCookieValue )
{
debugFunc('_rfxSetSubCookie', arguments);
var sCrumb = _rfxGetCookie(oSettings.CatalogID+"_"+sCookieName);
sCrumb = ReplaceUrlEncodedString(sCrumb,sSubCookieName+'='+sSubCookieValue);
var expires="";
if (sCookieName!='temp')
expires="expires=Mon, 31 Dec 2010 23:59:59 UTC;";
document.cookie=oSettings.CatalogID+"_"+sCookieName+"="+escape(sCrumb)+";"+expires;
}
/////////////////////////////////////////////////////////////////////////////////////////
/* Function: geturl_FSCommand
* Description: Flash event handler for Mozilla based browsers
* For Mozilla based browsers we send the event via a getUrl javascript:geturl_FSCommand
* to facilitate the problem of talking to the browser in netscape&mac.
*/
function geturl_FSCommand(command, args) {
main_DoFSCommand(command, args)
}
/* Function: main_FSCommand
* Description: Flash event handler for IExplorer
*/
if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0) {
document.write(' \n');
document.write('on error resume next \n');
document.write('Sub rfxmain_FSCommand(ByVal command, ByVal args)\n');
document.write(' call main_DoFSCommand(command, args)\n');
document.write('end sub\n');
document.write(' \n');
}
function baseSwitchCallStack(checkBox)
{
if (oSettings.mac && oSettings.gecko)
checkBox.checked = !checkBox.checked
oSettings.func_debug = checkBox.checked;
}
function debugFunc(funcName,args,stype)
{
if (oSettings && oSettings.func_debug == 1)
{
var sArgs=" ";
for (var i=0; i0)
{
fsw.value=sDebugBackLog;
sDebugBackLog="";
}
fsw.value+="\n"+args
if (!(oSettings.mac && oSettings.ie))
fsw.scrollTop=fsw.scrollHeight;
}
else
sDebugBackLog+="\n"+args;
}
catch (e) {}
}
return
}
if (oSettings.debug && command != "ShowStateWindow" && command != "DumpDebugWindow")
{
fsw.value+="\nFunction: " + func;
if (!(oSettings.mac && oSettings.ie))
fsw.scrollTop=fsw.scrollHeight;
}
try
{
eval(func);
}
catch(e)
{
if (oSettings.debug)
if (document.all)
fsw.value+="\nCall Failed! -- " + e.description;
else
fsw.value+="\nCall Failed! -- " + e.message;
}
}
/////////////////////////////////////////////////////////////////////////////////////////
var bflashEventsLoaded=false;
var bCatalogObjectReady=false;
var bLoggingLoaded=false;
/* Function: CallCatalogReady
* Description: checks is everything has loaded and calls CatalogReady()
*/
function CallCatalogReady()
{
debugFunc('CallCatalogReady', arguments);
if (bCatalogObjectReady && bflashEventsLoaded && bLoggingLoaded)
{
_rfxLoggingManager.logCatalog();
CatalogReady();
oSettings.bInitializing=false;
if (sDebugBackLog.length>0) _dfs(""); //flush whatever we accumulated if any
}
}
function LoggingLoaded()
{
debugFunc('LoggingLoaded', arguments);
bLoggingLoaded=true;
CallCatalogReady();
}
/* Function: CatalogObjectReady
* Description: called when the object has done writing to the document
*/
function CatalogObjectReady()
{
debugFunc('CatalogObjectReady', arguments);
bCatalogObjectReady=true;
CallCatalogReady();
}
/* Function: flashEventsLoaded
* Description: called after the flashevents.js is loaded.
*/
function flashEventsLoaded()
{
debugFunc('flashEventsLoaded', arguments);
bflashEventsLoaded=true;
CallCatalogReady();
}
/* Function: MagicVarsLoaded
* Description: called after the magic vars are loaded.
*/
function MagicVarsLoaded()
{
debugFunc('MagicVarsLoaded', arguments);
//populate template settings
PopulateMagicVariables(oSettings);
if( !oSettings.bNoCheck )
check_unsupported();
_rfxMain();
}
function check_unsupported()
{
var ua = navigator.userAgent.toLowerCase();
var msie, mozilla, opera;
var browserVersion=0;
if (opera = ua.indexOf("opera", 0) >= 0)
{
ver = parseFloat(ua.substr(ua.indexOf("opera")+6))
browserVersion = parseInt(ver);
}
else if (msie = ua.indexOf("msie", 0) >= 0)
{
ver = parseFloat(ua.substr(ua.indexOf("msie")+5))
browserVersion = parseInt(ver);
}
else if (mozilla = (ua.indexOf("mozilla") >= 0) && (ua.indexOf("compatible;") < 0))
{
ver = parseFloat(ua.substr(ua.lastIndexOf("/")+1))
browserVersion = parseInt(ua.substr(ua.indexOf("/")+1));
}
var has_flash = detectFlash(6);
if (
(oSettings.ie && browserVersion < 6) || // MSIE 6.0 or greater
(oSettings.mac && !oSettings.osX ) || // Only Mac OSX is supported
(oSettings.mac && oSettings.ie ) || // no Mac IE!
(oSettings.win95 || oSettings.winNT) || // no windows 95/NT
(!has_flash && oSettings.aol) || // no HTML on AOL
(!has_flash && oSettings.safari) || // no HTML on Safari (it seems to crash Safari 1.2)
(!has_flash && oSettings.mac) // no HTML on Mac
)
location.href=oSettings.base + "error/error.aspx";
// has no flash and no html version
if (!has_flash && oSettings.htmlEnabled==false && !oSettings.ie)
location.href = oSettings.base + "error/error.aspx?error_type=noflash_noie";
}
//objects holding settings
var oSettings = new CatalogVars();
//get magic variables function, call _rfxGetUrlParams to get base param
//magic.js then calls magic loaded, which eventually starts the catalog.
_rfxGetUrlParams();
checkBaseForCache();
document.write(declareScriptTag('script/magic.js'));
if (oSettings.debug)
document.write(declareScriptTag('script/debug_catalog.js'));