function genInstance(){ var curDateTime = new Date(); var curTime = 'ZoomMX' + curDateTime.getHours()+ curDateTime.getMinutes() + curDateTime.getSeconds(); return curTime; } /* parseImageSets A function used to split a comma separated list of image sets into an array for reference to the viewer and json calls input: a comma seperated list of imagesets referencing only the set (not the company) output: none, this function writes to a globally defined object imagset_test */ function parseImageSets(sets) { var b = sets; b += ""; //for some reason JavaScript doesn't like splitting the return from getParam on a comma, but it works fine after performing a string operation on it. imagset_test = b.split(','); //split the list of imagesets on each comma and return each individual imagest to an index within the globally declared imagset_test Object return; } /* initializeJSON A function used to make the initial calls to load imageset properties via JSON from the image server and perform the necessary steps to parse that data into useful objects for reference by the page input: string of comma separated Image Sets output: imageName variable, a comma seperated list of company/imagesets to pass to the viewer at initialization usage notes: In this code the initializeJSON method should be called when declaring the image argument that will be passed to the viewer the function will return a comma separated list of company/imagesets that can then be passed to the viewer, and will as side effect perform the other necessary actions in order to initialize the page with JSON support */ function initializeJSON(set){ scene7Ready = 0; // reset scene7state. scene7Count = 0; // reset the count parseImageSets(set); //Break out comma seperated list of imagesets to the globally defined imagset_test object var setCount=imagset_test.length-1; //variable to store how many sets were passed to the viewer var imageName = ''; //This is the return of the initializeJSON function and represents a valid company/imageset comma seperated list that can be passed to the viewer for (var i = 0; i <= setCount; i++) { imageName += companyName + '/' + imagset_test[i] + ','; //append company name, the name of the current imageset and another comma until there are no more imagsets when the code kicks out of the for loop } for (var i = 0; i <= setCount; i++) { //this code makes JSON requests to the image server to retrieve the images for each set passed to the page and load them into the same array for reference by the viewer loadimagset(companyName + '/' + imagset_test[i],i); } return imageName; } //End Initialize JSON // onDemandServer should be changed to point to the appropriate server // For example, if you use s7d2.scene7.com for your requests, onDemandServer should be "s7d2.scene7.com" // var onDemandServer = "s7d1.scene7.com"; var onDemandServer = "http://s7d5.scene7.com"; var onDemandSkinServer = "http://www.express.com/"; // Function: S7ConfigObject() // Purpose: Constructor for the S7ConfigObject class // Param: None // Output: A new instantiated S7ConfigObject instance // Notes: No need to use this function explicitly function S7ConfigObject() { this.isViewerRoot = onDemandServer + "/is-viewers/"; this.isRoot = onDemandServer + "/is/image/"; this.contentRoot = onDemandSkinServer + "assets/s7/"; 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; } // Function: setFlashParam(int, string, int) // Purpose: Set the Flash parameter for the DOM // Param: inID ID number for the operation // Param: inNAme is the name of the inner HTML object // Param: inVale is the value of the inner HTML object // Output: None // Notes: No need to use this function explicitly 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 = ""; document.getElementById(divcontainer).innerHTML = divinfo; }; // Function: docWrite(string) // Purpose: Embeds lines directly into the document to work around the IE activeX protocols // Param: line is the string to embed in the document // Output: None function docWrite(line) { document.write(line); } var S7Config = new S7ConfigObject(); var root = S7Config.isViewerRoot; var imageServer = S7Config.isRoot; // Function: resiszeStage(int, int) // Purpose: Function to allow for automatic resizing of the stage // Param: inWidth is the new width of the stage // Param: inHeight is the new height of the stage // Output: None // Notes: No need to use this function explicitly 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(string) // Purpose: Function to extract the layer object from the DOM, used by setWidth() and setHeight() // Param: name is the name of the layer to extract // Output: None // Notes: No need to use this function explicitly 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, int) // Purpose: Function to automaticly set the width of a layer, used by resizeStage() // Param: layer is a pointer to the layer to alter // Output: None // Notes: No need to use this function explicitly 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, int) // Purpose: Function to automaticly set the height of a layer, used by resizeStage() // Param: layer is a pointer to the layer to alter // Output: None // Notes: No need to use this function explicitly 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; } // Variable definition for use in the isFlashCurrent function 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; // Function: isFlashCurrent(int, int, int) // Purpose: To check the installed version of Flash against the supplied requirement // Param: versionMajorReq is the integer value of the lowest allowed major version supported // Param: versionMinorReq is the integer value of the lowest allowed minor version supported // Param: versionRevisoinReq is the integer value of the lowest allowed revision version supported // Output: True if the installed version of Flash meets the supplied requirements, false otherwise // Notes: 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; // This If-else block captures the values of the Major, Minor and Revsion version numbers for the installed Flash plugin // First checks for Netscape, and Opera version 3 orlater 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; } } // Next checks Internet Explorer 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; } // zoom viewer arguments // Server is defined in the config.js file var companyName = "expressfashion"; var baseURL = S7Config.isRoot + '/' + companyName + '/'; var serverUrl = S7Config.isRoot; //declares the server root for all image serving related calls. Be sure to change this to the appropriately assigned domain before going live! var contentRootUrl = S7Config.contentRoot; //Same as above but has the skin root. var viewerUrl = S7Config.isViewerRoot; //same as above but referencing is-viewers for viewer context var configName = 'expressfashion/Basic_Config'; //This variable tells the viewer to pull configuration information associated to an IPS ID, uses same notation as above // s7 ---------------------------------------------- /* Note that in order for these functions to correctly affect the zoom viewer in your page that the instance name of the viewer needs to match the first parameter passed to the setFlashParam methods below. If you're using an instance name different from ZoomMX as specified in this set of sample code then you'll need to update the methods below to reference that instance name. */ function zoomRGN(instance, RGN){ S7Config.setFlashParam(instance, 'rgn',RGN); } function zoomRGNN(instance,RGNN){ S7Config.setFlashParam(instance, 'rgnn',RGNN); } function zoomRGNR(instance,RGNR){ S7Config.setFlashParam(instance, 'rgnr',RGNR); } function zoomCurrentFrame(instance,Frame){ S7Config.setFlashParam(instance, 'currentFrame',Frame); } //private functions and variables var sjCallbacks=new Object();//!global variable MUST be created ! var sjErrCallbacks=new Object();//!global variable MUST be created ! /*This function takes a single json imageset response for input and returns the total alternate images in the set for use by the flash viewer as an index Need to pass in a json imageset response information Input: JSON imageset response for one imageset, position of set within the list of image sets the viewer was initialized in (starting from 0) Output: retstr a string variable that is built to include all the necessary html code that embeds the child swatch grids into the page. */ function dumpAltsInSets(obj, iID, instanceName, imagset_index) { var i =""; //Iterator for the main for loop var x=0; // conditional variable for the while loop is always set as the index of the next semi colon (indicating another image in the image set) in the json response currently evaluated var y=0; // variable set to the index of the next comma in the json response evaluated var z=-1; for (i = 0 ; i < iID; i++){ z += imagset_index[i]; } var altView=""; var retstr=""; for (i in obj){ //Step through the imageset JSON array in a for loop x=obj[i].indexOf(";",0); // Look for the first occurence of ; which denotes a swatch image y=obj[i].indexOf(",",0); // Look for the first occurence of , which denotes an alternate image if (y==-1) { // If there are no specified swatch images y=obj[i].length; // Set the y index to the end of the array } zoomCurrentFrame(instanceName,z+1); //set the flash viewer to the first image of the new set through the javascript flash API while (x>0) //Start a while loop to go through each JSON response loop is active as long as there's a , in the json response { z++; //Increment the counter that's used to reference the position in the altImageUrl array altView=obj[i].substring(x+1,y); //take the first character after the comma up to the character before the semi colon in the json response altView=S7Config.isRoot + '/' +altView; //complete the image path with server url and company info altImageURL[z]=altView; //append this full url path to the alt view image to an array retstr=retstr + ''; //setup the response that would go into the page for the swatch images // need to have alt image be different sizes. if( document.getElementById("cat-prod-flash-alt-views") != null ) { retstr=retstr + ''; } else if( document.getElementById("cat-alt-alt-img-wrapper") != null ) { retstr=retstr + ''; } else if( document.getElementById("cat-ens-alt-img-con") != null) { retstr=retstr + ''; } else { retstr=retstr + ''; } retstr=retstr + ''; x=obj[i].indexOf(";",y); //x is incremented to the next occurence of a comma that comes after the occurence of a semi-colon. If there is no other comma then kick out of the while loop and return y=obj[i].indexOf(",",y+1); if (y==-1) { y=obj[i].length; } } } return retstr; } /*This function takes an Object of imageset JSON responses and steps through the whole set to count how many individual images are in each imageset Input: An Object type containing JSON imageset information for all sets in the page, in the order that they are passed to the viewer Output: temp_index an array of ints that correspond to how many images are in each imageset */ function countAltsinSets(obj) { var i =""; //Iterator for the main for loop var x=0; // conditional variable for the while loop is always set as the index of the next semi colon (indicating another image in the image set) in the json response currently evaluated var y=0; // variable set to the index of the next comma in the json response evaluated var z=-1; var temp_index = new Array(); for (var j=0; j <= obj.length; j++) { //for j loop stepping through each index in the Object for (i in obj[j]){ //for i loop stepping through each character in each index of the Object x=obj[j][i].indexOf(";",0); // Look for the first occurence of ; which denotes a swatch image y=obj[j][i].indexOf(",",0); // Look for the first occurence of , which denotes an alternate image if (y==-1) { //Conditional // If there are no specified swatch images y=obj[j][i].length; // Set the y index to the end of the array } //end conditional while (x>0) //Start a while loop to go through each imageset list loop is active as long as there's a , in the json response denoting that another image follows {//Begin While z++; //Increment the counter that's used to reference the position in the altImageUrl array x=obj[j][i].indexOf(";",y); //x is incremented to the next occurence of a comma that comes after the occurence of a semi-colon. If there is no other comma then kick out of the while loop and return y=obj[j][i].indexOf(",",y+1); if (y==-1) {//conditional y=obj[j][i].length; } //end conditional } //End while temp_index[j] = z +1; //after kicking out of the while loop (meaning there are no more alternate images) write the amount of iterations to an index in the returning array z=-1; //reset the iterator to proceed to the next index of the Object in the for loop } //end for i loop } //End for j loop return temp_index; } //End Function /*This function should be referenced whenever a primary swatch grid is clicked in the page as it references the appropriate function to change the secondary swatch grids to reflect the selected imageset, as well as update the main image view to the first image of the new set Input: Index referencing the position of the user selected set in the order to which they were passed to the viewer starting from 0 Output: None explicitly, actions are taken by subsequently referenced dumpAltsInSets function */ function setColor(iID, selector, instanceName, imagset_test, imagset_index) { $(selector + " *").remove(); $(selector).append(dumpAltsInSets(imagset_test[iID], iID, instanceName, imagset_index)); } /* Engineer provided code, do not modify without certainty of intent! */ function sjGetResponse(inReq, inImg, inCallback, inErrCallback) { var tempi = inImg.indexOf("?"); var tempmod = ""; if(tempi >= 0){ tempmod = inImg.substring(tempi+1); inImg = inImg.substring(0,tempi); } var urljson = imageServer + '/' + inImg + '?' + inReq; if (tempmod){ urljson += '&' + tempmod; } var id = inImg.split("/")[1].split("_").join("") urljson += '&id=' + id; if (typeof inCallback != 'undefined'){ sjCallbacks[id] = inCallback; } if (typeof inErrCallback != 'undefined'){ sjErrCallbacks[id] = inErrCallback; } $.getScript( urljson, function() { scene7Count++; if(scene7Count == scene7FinishCount) { appendS7(); } } ); } function s7jsonResponse(inArg, inId) { sjCallbacks[inId](inArg); } function s7jsonError(inArg, inId) { if (typeof sjErrCallbacks[inId] != 'undefined'){ sjErrCallbacks[inId](inArg); }else{ alert(inArg.message); } } function sjDebug(inPsResponse, inJsonResponse, inPsResponseParserName, inPsRequest) { } function loadimagset(inURL,isetid) { //alert(inURL + " , " + isetid); sjGetResponse( 'req=imageset,json', inURL, function(inArg) { imagset_test[isetid]=inArg; }, function(inArg) { alert('failed loading imageset for [' + inURL + ']: ' + inArg.message); } ); } // s7 stuff ------------------ var scene7Count = 0; var scene7FinishCount = 0; var imagesets; var imagset_test = new Object(); var altImageURL= new Object(); var parentSwatches; var imageName; var movieWidth; //Sets the width of the flash object embedded into the page var movieHeight; //Sets the height of the flash object embedded into the page var movieBgc; //Sets the background color (in RGB) of the flash object embedded into the page var viewer="genericzoom.swf"; //Use genericzoom.swf or basiczoom.swf, don't deviate from these two viewers unless using a custom loader or viewer var urlPassBack; //This string will be appended to all image map urls when an image map is clicked //var windowName; var windowFeatures; //This variable sets the features of the window opened from an image map, consult documentation for the window.open method and it's features for syntax and values var args; var imagset_index=new Array(); var flashOk;