// Store the widgets in this code block
$.storeWidgets('547dc6e8|dfe9c83e|18f55887|1f42d7d2|a029b9cb|61875f15|d6b20e38|9ea9d7dc|dce3ea72|2cca1144|7e73e2c3|34b18901|1270d21a|270947b2|787eddcf|bdee4fa4|f4df7906|94a6e46|2dba4b83|2250f2b0|50395b73|d0d7ef21|34b18902|9a15cb48|4b1cd925|e55a6dff|ddb25bfa|9c4edb33|8aa38db3|b81ca720|4af14c4c|fd39e5f2');

/**
 * @fileoverview The javascript that runs the common-button.jsp widget.
*/
if (typeof ButtonWidget == "undefined")
{
	/**
	 * @class Handles the execution for {@link com.fry.ocpsdk.widget.common.ButtonWidget}
	 *        objects within the DOM.
	 */
	var ButtonWidget = BaseWidget.extend({

		/**
		 * Initialize a DOM element to represent a ButtonWidget.  When a DOM element
		 * is made into a button, the element will be assigned an <tt>enabled</tt> method.
		 * This method is a quick way to either set, or access, the enabled state of the
		 * button.  Setting the enabled state to <tt>false</tt> will assign the <tt>disabled</tt>
		 * CSS class to the parent container.  You can apply this style via the descendent
		 * selector:
		 * <pre>
		 *    .someWidget .common-button #myButton { color: black; }
		 *    .someWidget .disabled .common-button #myButton { color: gray; }
		 * </pre>
		 * Working with the enabled method is as simple as:
		 * <pre>
		 *    $("#myButton").enabled(true);   // Sets the button to the enabled state
		 *    if ($("#myButton").enabled()) {
		 *       // The button is enabled, do something
		 *       ...
		 *    }
		 * </pre>
		 * A button will also be assigned a hover state where it's parent container will have
		 * the <tt>mouseover</tt> CSS class when the mouse is over the button.  The class will
		 * be absent when the mouse is <i>not over</i> the button.
		 * <p/>
		 *
		 * @param widget {String} The unique selector for a button, or a jQuery object representing
		 *                        the DOM element of the button.
		 * @param settings {Object} The widget state
		 */
		create: function(widget, settings) {
			var jQ = this.base(widget, settings);
			var s = jQ.widgetState();

			// Convert the click function string into a function
			var fn = s.clickFunction;
			if (fn) {
				jQ.widgetData({ clickFunction:
						eval("(function(){ var f=" + fn + "; return f;})()")
				});
				delete s.clickFunction;
			}

			jQ.click(function() {
					if (this.enabled())
					{
						var f = $(this).widgetData().clickFunction;
						if (f) {
							f();
						}
					}
				})
				.mousedown(function() {
					if (this.enabled()) {
						$(this).parent(".Button.widget-root").addClass("mousedown");
						if ($(this).parent(".Button.widget-root").hasClass("mouseover")) {
							this.mOver = true;
							$(this).parent(".Button.widget-root").removeClass("mouseover");
						}
					}
				})
				.mouseup(function() {
					$(this).parent(".Button.widget-root").removeClass("mousedown");
					if (this.mOver) {
						this.mOver = false;
						$(this).parent(".Button.widget-root").addClass("mouseover");
					}
				});

			jQ.widgetElement().enabled = function(state) {
				// Adds a function that either sets or gets the enabled state of the button object
				if (state != null)
				{
					if (state)
					{
						ButtonWidget.enable($(this));
					}
					else
					{
						ButtonWidget.disable($(this));
					}

					return true;
				}
				else
				{
					return ButtonWidget.isEnabled($(this));
				}
			};

			jQ.widgetElement().selected = function(state) {
				// Adds a function that either sets or gets the selected state of the button object
				if (state != null)
				{
					if (state)
					{
						ButtonWidget.select($(this));
					}
					else
					{
						ButtonWidget.unselect($(this));
					}

					return true;
				}
				else
				{
					return ButtonWidget.isSelected($(this));
				}
			};

			return jQ;
		},

		/**
		 * Determine if a button is enabled.
		 *
		 * @param selector {String} The CSS selector for the element
		 * @return {Boolean} <tt>true</tt> if the button is enabled
		 */
		isEnabled: function(selector) {
			return !$(selector).parent(".Button.widget-root").is(".disabled");
		},

		/**
		 * Set the button to the enabled state.  Removes the <tt>disabled</tt> CSS
		 * class from the parent container.
		 *
		 * @param selector {String} The CSS selector for the element
		 */
		enable: function(selector) {
			$(selector).parent(".Button.widget-root").removeClass("disabled");
		},

		/**
		 * Set the button to the disabled state.  Applies the <tt>disabled</tt> CSS
		 * class to the parent container.
		 *
		 * @param selector {String} The CSS selector for the element
		 */
		disable: function(selector) {
			$(selector).parent(".Button.widget-root").addClass("disabled").removeClass("mouseover").removeClass("mousedown");
		},

		/**
		 * Determine if a button is selected.
		 *
		 * @param selector {String} The CSS selector for the element
		 * @return {Boolean} <tt>true</tt> if the button is selected
		 */
		isSelected: function(selector) {
			return $(selector).parent(".Button.widget-root").is(".selected");
		},

		/**
		 * Set the button to the selected state.  Applies the <tt>selected</tt> CSS
		 * class to the parent container.
		 *
		 * @param selector {String} The CSS selector for the element
		 */
		select: function(selector) {
			$(selector).parent(".Button.widget-root").addClass("selected");
		},

		/**
		 * Set the button to the default state.  Removes the <tt>selected</tt> CSS
		 * class from the parent container.
		 *
		 * @param selector {String} The CSS selector for the element
		 */
		unselect: function(selector) {
			$(selector).parent(".Button.widget-root").removeClass("selected");
		}
		
	});
}

// Initialize all common buttons with hover
// states if they don't already have it
$(document).ready(function() {
	$(".common-button").each(function() {
		if (!$(this).get(0).hoverState)
		{
			$(this).hover(
				function() {
					if (!$(this).parent(".Button.widget-root").is(".disabled"))
					{
						$(this).parent(".Button.widget-root").addClass("mouseover");
					}
				},
				function() {
					$(this).parent(".Button.widget-root").removeClass("mouseover");
				}
			).get(0).hoverState = true;
		}
	});
});
;if (typeof ScrollerWidget == "undefined") {

	/**
	 * @class Handles the execution for {@link com.fry.ocpsdk.widget.common.container.ScrollerWidget}
	 *        objects within the DOM.
	 */
	var ScrollerWidget = BaseWidget.extend({

		/**
		 * Initialize a DOM element to represent a ScrollerWidget.  A simple scroller
		 * displays the contents within an area that can be scrolled left and right by
		 * a defined amount.
		 *
		 * @param selector {String} The unique selector for a simple scroller, or a jQuery object representing
		 *                        the DOM element of the simple scroller.
		 * @param settings {Object} Model parameters you want the simple scroller to retain, such as scroll amount.
		 */
		create: function(selector, settings) {
			var jQ = this.base(selector, settings);

			// If there were parts, remove them
			var s = jQ.widgetState();
			delete s.parts;

			var d = jQ.widgetData();
			if (s.beforeScroll) {
				// Convert to a function
				var fn = "var v = " + s.beforeScroll + "; return v(selector,cb);";
				d.beforeScroll = new Function("selector,cb", fn);
				delete s.beforeScroll;
			}

			if (s.afterScroll) {
				// Convert to a function
				var fn = "var v = " + s.afterScroll + "; return v(selector);";
				d.afterScroll = new Function("selector", fn);
				delete s.afterScroll;
			}

			// Set a class if the developer wants to show a different state when
			// the mouse is over the scroller
			var self = this;
			jQ.hover(function() {
				var p = self.findParts(jQ);
				if (p.bodyMax > p.areaMax) {
					$(".mouseState", this).addClass("mouseoverscroller");
				}
			}, function() {
				$(".mouseState", this).removeClass("mouseoverscroller");
			});

			// This check needs to be static for all scroller types, otherwise we get
			// multiple event handlers per widget type (Scroller, SnapToScroller, etc...)
			if(ScrollerWidget.initInterval) {
				clearTimeout(ScrollerWidget.initInterval);
			}
			ScrollerWidget.initInterval = setTimeout(function() {
				self.checkInitialButtonStates();
			}, 50);

			// We need a function we can call when scrolling is complete
			d.finishCallback = function() {
				arguments.callee.thisObj.finishScroll(arguments.callee.selector);
			};
			d.finishCallback.thisObj = this;
			d.finishCallback.selector = selector;

			return jQ;
		},

		/**
		 * Find the parts of a simple scroller to speed up execution.  The parts are:
		 * <table border='1'><tr><td><b>Part</b></td><td><b>Description</b></td></tr>
		 * <tr><td>area</td><td>The area DIV element where the items will be displayed</td></tr>
		 * <tr><td>body</td><td>The table element where the items will be displayed</td></tr>
		 * <tr><td>areaMax</td><td>The size (height or width) of the visible window over the items</td></tr>
		 * <tr><td>bodyMax</td><td>The size (height or width) of the entire collection of items</td></tr>
		 * <tr><td>prevButton</td><td>The button widget that moves to previous items</td></tr>
		 * <tr><td>nextButton</td><td>The button widget that moves to later items</td></tr>
		 * </table>
		 *
		 * @param selector {String} The CSS selector for the element
		 * @return {Object} An object that contains the different parts of a scroller
		 */
		findParts: function(selector) {
			var jQ = $(selector);
			var s = jQ.widgetState();

			if (s.parts == null)
			{
				s.parts = {};
				s.parts.area = $("div.area", jQ);
				s.parts.body = $("div.area table.body", jQ);
				s.parts.areaMax = s.direction == "horizontal" ? s.parts.area.width() : s.parts.area.height();
				s.parts.bodyMax = s.direction == "horizontal" ? s.parts.body.width() : s.parts.body.height();
				s.parts.prevButton = jQ.widgetChild(".scroller-layout .button-previous");
				s.parts.nextButton = jQ.widgetChild(".scroller-layout .button-next");
         }

			return s.parts;
		},

		/**
		 * Calculate the actual scroll to position based on the provided position.
		 * The widget will adjust the position by determining the available scroll area size,
		 * enable/disable buttons, and trigger events.
		 *
		 * @param selector {String} The CSS selector for the element
		 * @param position {Object} The position to scroll to.  Can be either a String with the
		 *                          unit defined (percent: "%" or pixels: "px"), or a Number.
		 * @return {Number} The amount to scroll the area by
		 */
		calcScroll: function(selector, position, animate) {
			var jQ = $(selector);
			var s = jQ.widgetState();
			var parts = this.findParts(selector);

			// If the position is already a number, this won't matter...
			var pixelPos = Number(position);

			if (typeof position == "string") {
				// Check the unit type
				if (position.indexOf("%") == position.length - 1) {
					// Calculate a position from the total area width
					pixelPos = Math.floor(parts.bodyMax * (Number(position.substring(0, position.length - 1)) / 100));
				} else if (position.indexOf("px") == position.length - 2) {
					// Just eliminate the "px" unit
					pixelPos = Number(position.substring(0, position.length - 2));
				} else {
					// Let 'em know we don't like what they gave us...
					throw new Error("You passed an invalid position value to Scroller.scrollTo for object " + jQ.attr("id"));
				}
			}

			// TODO: We should try to short circuit the long calculations when we're not using animation [BF : 08/12/2008]

			// Determine where the start is, and what the change will be
			var start = (s.direction == "horizontal" ?  parts.area.scrollLeft() : parts.area.scrollTop());
			var delta = pixelPos - start;
			var max = (delta <= 0 ? 0 : parts.areaMax);
			var maxMove = (delta <= 0 ? 0 : parts.bodyMax - parts.areaMax);

			// Determine if the move is possible
			if(start >= 0 && start <= parts.bodyMax) {
				// We may need to adjust the delta due to us not being able
				// to move an entire "scrollAmount"
				if (delta < 0 && start + delta < 0) {
					delta = -start;
				} else if (delta > 0 && start + delta > maxMove) {
					delta = maxMove - start;
				}

				// Find out if we're going to hit a stop
				var hitStop = (delta > 0 ? (start + delta >= maxMove) : (start + delta <= 0));

				// Enable and disable buttons
				if (hitStop && delta <= 0) {
					parts.prevButton.widgetElement().enabled(false);
					s.prevStop = true;
				} else if (hitStop && delta >= 0) {
					parts.nextButton.widgetElement().enabled(false);
					s.nextStop = true;
				}

				if (delta < 0) {
					parts.nextButton.widgetElement().enabled(true);
					s.nextStop = false;
				} else if (delta > 0) {
					parts.prevButton.widgetElement().enabled(true);
					s.prevStop = false;
				}

				// Final pixel position
				return (hitStop ? maxMove : start + delta);
			}

			return 0;
		},

		/**
		 * Scroll to a specified position, handling whether an animation should
		 * be used.
		 *
		 * @param selector {String} The CSS selector for the element
		 * @param position {Object} The position to scroll to.  Can be either a String with the
		 *                          unit defined (percent: "%" or pixels: "px"), or a Number.
		 * @param animate {Boolean} <tt>true</tt> to use animation (smooth scrolling) to move
		 *                          to the specified position.
		 */
		scrollTo: function(selector, position, animate) {
			var jQ = $(selector);
			if (jQ[0].inmotion) {
				return;
			}

			var s = jQ.widgetState();
			var parts = this.findParts(selector);
			var start = (s.direction == "horizontal" ? parts.area.scrollLeft() : parts.area.scrollTop());

			// Calculate the scroll amount
			var scrollPos = this.calcScroll(selector, position, animate);
			if (start == scrollPos) {
				// No scroll is occurring
				return;
			}

			// Do they want a callback executed?
			var d = jQ.widgetData();
			if (d.beforeScroll) {
				// We'll hand the callback a function that they need to call when their
				// interrupt completes.  If they don't call it -- well, it's not our fault
				var cb = function() {
					arguments.callee.thisObj.startScroll(arguments.callee.selector, arguments.callee.scrollPos, arguments.callee.animate);
				};
				cb.thisObj = this;
				cb.selector = selector;
				cb.scrollPos = scrollPos;
				cb.animate = animate;

				// Call their method...
				d.beforeScroll(selector, cb);
			} else {
				this.startScroll(selector, scrollPos, animate);
			}
		},

		/**
		 * Called before starting the scroll.  The <tt>scrollstart</tt> event will be triggered,
		 * passing along the position where scrolling will finish and a boolean value indicating
		 * if one of the borders has been hit.
		 *
		 * @param selector {String} The CSS selector for the element
		 * @param scrollPos {Number} The position to scroll to
		 * @param animate {Boolean} <tt>true</tt> to animate the scroll.  <tt>false</tt> to jump to
		 *                the new position.
		 */
		startScroll: function(selector, scrollPos, animate) {
			var jQ = $(selector);
			if (jQ[0].inmotion) {
				return;
			}

			var s = jQ.widgetState();
			var d = jQ.widgetData();
			var parts = this.findParts(selector);
			var start = (s.direction == "horizontal" ? parts.area.scrollLeft() : parts.area.scrollTop());

			var anim="scroll";
			anim += (s.direction == "horizontal" ? "Left" : "Top");

			var hitStop = this.isAtStop(jQ);

			// Trigger the starting event, we're moving
			jQ.widgetTrigger("scrollstart", [scrollPos, hitStop]);

			// We would also like to know which way we're going to scroll
			var eventName = scrollPos < start ? "scrollprevious" : "scrollnext";
			jQ.widgetTrigger(eventName, [scrollPos, hitStop]);

			// Add a class to mirror the scroll direction
			$(".mouseState", jQ).addClass(eventName);
			if (s.scrollEvent && s.scrollEvent != eventName) {
				$(".mouseState", jQ).removeClass(s.scrollEvent);
			}
			s.scrollEvent = eventName;

         // Show the overlay
         $(".area .overlay", jQ).css("display", "block");

         jQ[0].inmotion = true;

			// Do the deed...
			if (animate) {
				var parms = {};
				var self = this;
				parms[anim] = scrollPos;
				parts.area.animate(parms, s.scrollSpeed, null, function() {
					self.finishScroll(selector);
				});
			} else {
				var self = this;
				parts.area[0][anim] = scrollPos;
				jQ[0].inmotion = false;
				if (s.finishTimer) {
					window.clearTimeout(s.finishTimer);
				}

				s.finishTimer = window.setTimeout(d.finishCallback, 250);
			}
		},

		/**
		 * Called after a scroll has finished.  The <tt>scrollend</tt> event contains the
		 * page number that the scroll ended on.  The page may contain a fractional portion
		 * which represents how far into the page the scroll ended.
		 *
		 * @param selector {String} The CSS selector for the element
		 */
		finishScroll: function(selector) {
			var jQ = $(selector);
			var s = jQ.widgetState();
			var parts = this.findParts(selector);

			s.finishTimer = null;
			jQ[0].inmotion = false;

         // Hide the overlay
         $(".area .overlay", jQ).css("display", "none");

         // Which page are we on?
			var scroll = (s.direction == "horizontal" ? parts.area.scrollLeft() : parts.area.scrollTop());
			var page = Number(Number(scroll / s.scrollAmount).toFixed(1));
			jQ.widgetTrigger("scrollend", [page]);

			// Clear the event class
			if (s.scrollEvent) {
				$(".mouseState", jQ).removeClass(s.scrollEvent);
				delete s.scrollEvent;
			}

			// If they specified a callback, call it now...
			var d = jQ.widgetData();
			if (d.afterScroll) {
				d.afterScroll(selector);
			}
		},

		/**
		 * Returns <tt>true</tt> if the scroller is in motion.
		 * @return {Boolean} <tt>true</tt> if the scroller is currently in motion
		 */
		isInMotion: function(selector) {
			return $(selector)[0].inmotion;
		},

		/**
		 * Scroll the area to the right or down, depending on the configured direction of the scroller.
		 *
		 * @param selector {String} The CSS selector for the element
		 */
		scrollNext: function(selector) {
			var jQ = $(selector);
			var s = jQ.widgetState();
			var parts = this.findParts(jQ);
			var amt = (s.direction == "horizontal" ? parts.area.scrollLeft() + s.scrollAmount : parts.area.scrollTop() + s.scrollAmount);
			this.scrollTo(selector, amt, s.animateScroll);
		},

		/**
		 * Scroll the area to the left or up, depending on the configured direction of the scroller.
		 *
		 * @param selector {String} The CSS selector for the element
		 */
		scrollPrevious: function(selector) {
			var jQ = $(selector);
			var s = jQ.widgetState();
			var parts = this.findParts(jQ);
			var amt = (s.direction == "horizontal" ? parts.area.scrollLeft() - s.scrollAmount : parts.area.scrollTop() - s.scrollAmount);
			this.scrollTo(selector, amt, s.animateScroll);
		},

		/**
		 * Scroll to a logical page by number.  The position is determined using the
		 * scroll amount set during creation of the widget.
		 *
		 * @param selector {String} The CSS selector for the element
		 * @param pageNumber {Number} Logical page number within the defined range of pages for the scroller
		 * @param animate {Boolean} <tt>true</tt> to animate the scroll to the position
		 */
		scrollToPage: function(selector, pageNumber, animate) {
			var jQ = $(selector);
			var s = jQ.widgetState();
			var pos = pageNumber * parseInt(s.scrollAmount);
			this.scrollTo(selector, pos, animate);
		},

		/**
		 * Returns <tt>true</tt> if the scroller is at either stop, or will arrive at one
		 * if it is in motion.
		 * @return {Boolean} <tt>true</tt> if the scroller is at either the beginning or end.
		 */
		isAtStop: function(selector) {
			var s = $(selector).widgetState();
			return (s.nextStop || s.prevStop);
		},

		/**
		 * Returns <tt>true</tt> if the scroller can move to no more previous pages.
		 * @return {Boolean} <tt>true</tt> if the scroller cannot move to the left, or up
		 */
		isPrevStop: function(selector) {
			var s = $(selector).widgetState();
			return s.prevStop;
		},

		/**
		 * Returns <tt>true</tt> if the scroller can move to no more next pages.
		 * @return {Boolean} <tt>true</tt> if the scroller cannot move to the right, or down
		 */
		isNextStop: function(selector) {
			var s = $(selector).widgetState();
			return s.nextStop;
		},

		/**
		 * Executed during initial initialization to set the buttons accordingly.
		 * @private
		 */
		checkInitialButtonStates: function() {
         // This would be slightly cleaner if we used the Scroller.findParts() method here as well,
			// but this method needs to be optimized completely for speed...
			$(".Scroller").each(function() {
				var jQ = $(this);
				var s = jQ.widgetState();

				// Set up the stops
				s.prevStop = true;
				s.nextStop = true;

				var jq = jQ.find("div.area");
				var bodyTable = jq.find("table.body");
				var areaMax = parseInt(jq.css(s.direction == "horizontal" ? "width" : "height").replace("px"));
				var bodyMax = s.direction == "horizontal" ? bodyTable.width() : bodyTable.height();

            $(".overlay", jq).width(bodyMax);

            if (bodyMax - 1 > areaMax) {
					$(this).find(".scroller-layout .button-next").widgetElement().enabled(true);
					s.nextStop = false;

					if (s.linkSlider) {
						// Link the slider to the scroller
                  SliderWidget.create("#" + s.linkSlider, { maxValue: bodyMax - areaMax, pageWidth: areaMax });
					}
				} else {
					if (s.linkSlider) {
						// Hide the slider if no need to scroll
						//$(".thumb", "#" + s.linkSlider).css("display", "none");
                  $("#" + s.linkSlider).css("display", "none");
					}

					$(this).find(".scroller-layout .scroll-button").css("display", "none");
				}
			});
			clearTimeout(this.initInterval);
			this.initInterval = null;
		}

	});
}
;if (typeof SnapToScrollerWidget == "undefined") {

	/**
	 * @class Handles the execution for {@link com.fry.ocpsdk.widget.common.container.ScrollerWidget}
	 *        objects within the DOM.
	 */
	var SnapToScrollerWidget = ScrollerWidget.extend({

      findParts: function(selector) {
         var jQ = $(selector);
         var s = jQ.widgetState();

         if (s.parts == null)
         {
            parts = this.base(selector);
            parts.areaMax = (Math.round(parts.areaMax / s.unitSize) * s.unitSize);
         }
         return s.parts;
      },

      /**
		 * Calculate the actual scroll to position based on the provided position.
		 * The widget will adjust the position by determining the available scroll area size,
		 * enable/disable buttons, and trigger events.
		 *
		 * @param selector {String} The CSS selector for the element
		 * @param position {Object} The position to scroll to.  Can be either a String with the
		 *                          unit defined (percent: "%" or pixels: "px"), or a Number.
		 * @return {Number} The amount to scroll the area by
		 */
		calcScroll: function(selector, position, animate) {
			var jQ = $(selector);
			var s = jQ.widgetState();
			var parts = this.findParts(selector);

			var actualPos = this.base(selector, position);
			if (animate) {
				var stepSize = (s.unitSize != null ? Number(s.unitSize) : Number(s.scrollAmount));
				actualPos = Math.round(actualPos / stepSize) * stepSize;
			}
			return actualPos;
		},

      /**
       * We can more efficiently calculate the scroller window size due to having
       * the unit size available.
       * @private
       */
      checkInitialButtonStates: function() {
         $(".Scroller").each(function() {
            var jQ = $(this);
            var s = jQ.widgetState();

            // Set up the stops
            s.prevStop = true;
            s.nextStop = true;

            var jq = $("div.area", jQ);
            var bodyTable = $("table.body", jq);
            var areaMax = parseInt(jq.css(s.direction == "horizontal" ? "width" : "height").replace("px"));
            areaMax = (Math.round(areaMax / s.unitSize) * s.unitSize);
            var bodyMax = s.direction == "horizontal" ? bodyTable.width() : bodyTable.height();

            $(".overlay", jq).width(bodyMax);

            if (bodyMax > areaMax) {
               $(this).find(".scroller-layout .button-next").widgetElement().enabled(true);
               s.nextStop = false;

               if (s.linkSlider) {
                  // Link the slider to the scroller
                  SliderWidget.create("#" + s.linkSlider, { maxValue: bodyMax - areaMax, pageWidth: areaMax });
               }
            } else {
               if (s.linkSlider) {
                  // Hide the slider if no need to scroll
                  //$(".thumb", "#" + s.linkSlider).css("display", "none");
                  $("#" + s.linkSlider).css("display", "none");
               }

               $(this).find(".scroller-layout .scroll-button").css("display", "none");
            }
         });
         clearTimeout(ScrollerWidget.initInterval);
         ScrollerWidget.initInterval = null;
      }
		
	});
}
;

		if (typeof PagedDataSetFilmstripLoaderWidget == "undefined") {

			/**
			 * @class Controls the com.fry.ocpsdk.widget.browsers.PagedDataSetFilmstripLoaderWidget
			 *        display which has a scrolling filmstrip per category.
			 *
			 * @author Brett Fattori (bfattori@fry.com)
			 */
			var PagedDataSetFilmstripLoaderWidget = BaseWidget.extend({

				/**
				 * Create an instance of a PagedDataSetFilmstripLoaderWidget by linking a
				 * DOM element to the class via its jQuery selector.
				 *
				 * @param selector {String} A jQuery selector for the widget root
				 * @param settings {Object} Any settings you wish to persist in the widget as its state
				 */
				create: function(selector, settings) {
					var jQ = this.base(selector, settings);
					var s = jQ.widgetState();

					if (jQ.elementData().entityCount == 0) {
                  jQ.hide();
                  return jQ;
               }

					// Read the total entity count off the filmstrip
					var data = jQ.elementData();
					s.totalEntityCount = data.entityCount;
					s.totalPages = Math.floor(s.totalEntityCount / s.pageSize);

					// Remember which pages are loaded
					s.loadedItems = $.fillArr((s.totalEntityCount), false);
					var x = s.pages * s.pageSize;
					while (x-- > 0) {
						s.loadedItems[x] = true;
					}

					s.currentPage = 0;

					// Fill in the widget with empty table cells
					var cT, sel, ev;

					// We'll let them specify an entity viewer to display when the entity
					// isn't yet loaded.
					if (s.emptyItemViewer) {
					   ev = "<div class='entity-viewer'>" + s.emptyItemViewer + "</div>";
					} else {
						ev = "<div class='entity-viewer'><!-- --></div>";
					}

					if (s.direction == "horizontal") {
						cT = ".filmstrip-table TR";
						sel = "<td class='item empty col cell'>" + ev + "</td>";
					} else {
						cT = ".filmstrip-table";
						sel = "<tr class='item empty row'><td class='cell'>" + ev + "</td></tr>";
					}

               var loadedEntities = s.totalEntityCount - (s.pageSize * s.pages);
					var t = $(cT, jQ);
					while (loadedEntities-- > 0) {
						t.append($(sel));
					}

					return jQ;
				},

				/**
				 * Returns the count of entities that will be displayed by this widget.
				 *
				 * @param selector {String} A jQuery selector for the widget root
				 * @return {Number} The number of entities to be displayed
				 */
				getEntityCount: function(selector) {
					return $(selector).elementData().entityCount;
				},

				/**
				 * Clamp the range of items to return based on the page number requested and
				 * the min and max range around that page.  Min and max are specified as items
				 * before and after, respectively.  The min and max will be adjusted to the
				 * nearest min and max item number based on what is already loaded.
				 *
				 * @param selector {String} A jQuery selector for the widget root
				 * @param pageNumber {Number} The page, within the range, to start with
				 * @param min {Number} The items before the page number, or the number of
				 *                     initial items loaded divided in half.
				 * @param max {Number} The items after the page number, or the number of
				 *                     initial items loaded divided in half.
				 * @return An array with two elements specifying the actual min and max range.
				 * @return {Array} An array of two elements: the min and max index
				 */
				clampRange: function(selector, pageNumber, min, max) {
					var jQ = $(selector);
					var s = jQ.widgetState();

					// Determine the buffer size to load
					var itemNum = pageNumber * s.pageSize;
					var buf = Math.floor((s.pages * s.pageSize) / 2) + 1;
					var minP = min || itemNum - buf;
					var maxP = max || itemNum + buf;

					// Normalize
					minP = minP < 0 ? 0 : minP;
					maxP = maxP > s.totalEntityCount ? s.totalEntityCount : maxP;

					// Determine which items before and after the page are loaded and
					// set a min/max to load around our current page
					while (s.loadedItems[minP] && minP < maxP) {
						minP++;
					}
					while (s.loadedItems[max] && maxP > minP) {
						maxP--;
					}

					// Return the array sorted numerically in case we get a wierd situation
					return [minP, maxP].sort(function(a,b) {
						return a - b;
					});
				},

				/**
				 * Called when navigating to the previous page, will determine items
				 * that need to be loaded to fill in the set.
				 *
				 * @param selector {String} A jQuery selector for the widget root
				 */
				previousPage: function(selector) {
					var jQ = $(selector);
					var s = jQ.widgetState();
					s.currentPage--;

					// Are there more pages to go?
					if (s.currentPage - s.loadThreshold > 0) {
						// Are the pages beyond at threshold not currently loaded?
						if (!s.loadedPages[s.currentPage - s.loadThreshold]) {
							// Load up the previous pages
							this.loadItems(selector, s.currentPage - s.loadThreshold, 0, s.pages);
						}
					}
				},

				/**
				 * Called when navigating to the next page, will determine items
				 * that need to be loaded to fill in the set.
				 *
				 * @param selector {String} A jQuery selector for the widget root
				 */
				nextPage: function(selector) {
					var jQ = $(selector);
					var s = jQ.widgetState();
					s.currentPage++;

					// Are there more pages to go?
					if (s.currentPage + s.loadThreshold < s.totalPages) {
						// Are the pages beyond at threshold not currently loaded?
						if (!s.loadedPages[s.currentPage + s.loadThreshold]) {
							// Load up the next pages
							this.loadItems(selector, s.currentPage + s.loadThreshold, s.pages, 0);
						}
					}
				},

				/**
				 * Set the page that should be scrolled to. The method will
				 * determine the items that need to be loaded to fill in the set.
				 *
				 * @param selector {String} A jQuery selector for the widget root
				 * @param pageNumber {Number} The page number to jump to
				 */
				setPage: function(selector, pageNumber) {
					var jQ = $(selector);
					var s = jQ.widgetState();

					if (pageNumber > 0 && pageNumber < s.totalPages) {
						// Do the scroll
						ScrollerWidget.scrollToPage($(".Scroller", jQ), pageNumber, true);
						this.loadPage(selector, pageNumber);
					}
				},

				/**
				 * Load the designated page and surrounding pages.  Using the starting count of
				 * pages, divided by two and adding one, that many pages will be loaded to each
				 * side of the designated page.  So, if you specified four pages to intially
				 * load, 3 pages to each side of the specified page will be loaded (if they
				 * aren't already loaded).
				 *
				 * @param selector {String} A jQuery selector for the widget root
				 * @param pageNumber {Number} The page number load around
				 */
				loadPage: function(selector, pageNumber) {
					var jQ = $(selector);
					var s = jQ.widgetState();

					// Load up the pages surrounding the specified page
					s.currentPage = Number(pageNumber);
					this.loadItems(selector, s.currentPage);
				},

				/**
				 * Load a set of items, as determined by the starting page and the number of
				 * pages after the starting page.  Optionally the starting page can be modified
				 * by specifying the pages to load before the starting page.  After the items
				 * have been loaded, the <tt>itemsLoaded</tt> event will be triggered, passing
				 * the set of elements that were loaded from the server.
				 *
				 * @param selector {String} A jQuery selector for the widget root
				 * @param startPage {Number} The page at which to start loading items
				 * @param pagesAfter {Number} The number of pages to load beyond the starting page
				 * @param [pagesBefore=0] {Number} The number of pages to load before the starting page
				 */
				loadItems: function(selector, startPage) {
					var jQ = $(selector);
					var s = jQ.widgetState();

					// Clamp the range
					var clamp = this.clampRange(selector, startPage);

					// Are we already loaded?
					if (s.loadedItems[clamp[0]] && s.loadedItems[clamp[1]]) {
						return;
					}

					// Mark the items as loaded
					for (var p = clamp[0]; p < clamp[1]; p++) {
						s.loadedItems[p] = true;
					}

					// Do the load
					var startIndex = clamp[0];
					var endIndex = clamp[1];
					endIndex = endIndex > startIndex ? endIndex : startIndex;

					var d, type, marker;
					if (s.direction == "horizontal") {
						d = $("<tr>");
						type = "TD.item";
						marker = "TD";
					} else {
						d = $("<table>");
						type = "TR.item";
						marker = "TR";
					}

					d.widgetAjax(jQ, "com.fry.ocpsdk.widget.browsers.PagedDataSetFilmstripWidget", type, "dataModel",
							{
								"startIndex": startIndex,
								"endIndex": endIndex
							},
							function() {

								var fn = function() {
									var aC = arguments.callee;
									if (aC.scroller.inmotion) {
										window.setTimeout(aC, 100);
										return;
									}

									/* Remove empty cells from the table row */
									$(".filmstrip-table " + aC.type + ":in(" + aC.startIndex + "-" + aC.endIndex + ")", aC.jQ).remove();

									/* Insert new cells into the table */
									var itemCount = $(aC.marker, aC.thisObj).length;
									$(".filmstrip-table " + aC.type + ":eq(" + (aC.startIndex - 1) + ")", aC.jQ).after($(aC.marker, aC.thisObj));

									/* Get our new items */
									var newItems = $(".filmstrip-table " + aC.type + ":in(" + aC.startIndex + "-" + aC.endIndex + ")", aC.jQ);

									/* Maybe this should be lower level? */
									$.initElementData(newItems);
									$.initWidgets(newItems);

									/* Trigger an event, passing the insert index and number of items */
									aC.jQ.widgetTrigger("itemsloaded", [(aC.startIndex - 1), itemCount, newItems]);
								};
								fn.scroller = $(".Scroller", jQ)[0];
								fn.thisObj = this;
								fn.marker = marker;
								fn.type = type;
								fn.startIndex = startIndex;
								fn.endIndex = endIndex;
								fn.jQ = jQ;

								window.setTimeout(fn, 100);
							}
					);

				}

			});
		}

	eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(3(C){C.a={1L:{P:3(E,F,H){6 G=C.a[E].i;17(6 D 1M H){G.q[D]=G.q[D]||[];G.q[D].1N([F,H[D]])}},1l:3(D,F,E){6 H=D.q[F];5(!H){4}17(6 G=0;G<H.1m;G++){5(D.8[H[G][0]]){H[G][1].w(D.b,E)}}}},o:{},c:3(D){5(C.a.o[D]){4 C.a.o[D]}6 E=C(\'<1O 1K="a-1J">\').1g(D).c({1F:"1G",X:"-1o",1H:"-1o",1I:"1P"}).1E("1d");C.a.o[D]=!!((!(/1X|1Y/).h(E.c("1Z"))||(/^[1-9]/).h(E.c("1W"))||(/^[1-9]/).h(E.c("1V"))||!(/1u/).h(E.c("1R"))||!(/1S|1T\\(0, 0, 0, 0\\)/).h(E.c("1U"))));20{C("1d").19(0).1D(E.19(0))}1y(F){}4 C.a.o[D]},1z:3(D){C(D).p("l","14").c("1k","1u")},1A:3(D){C(D).p("l","1C").c("1k","")},1x:3(G,E){6 D=/X/.h(E||"X")?"1B":"1w",F=7;5(G[D]>0){4 f}G[D]=1;F=G[D]>0?f:7;G[D]=0;4 F}};6 B=C.Q.u;C.Q.u=3(){C("*",2).P(2).1Q("u");4 B.w(2,1t)};3 A(E,F,G){6 D=C[E][F].2q||[];D=(N D=="O"?D.x(/,?\\s+/):D);4(C.2l(G,D)!=-1)}C.n=3(E,D){6 F=E.x(".")[0];E=E.x(".")[1];C.Q[E]=3(J){6 H=(N J=="O"),I=2n.i.2m.1l(1t,1);5(H&&A(F,E,J)){6 G=C.M(2[0],E);4(G?G[J].w(G,I):2j)}4 2.2k(3(){6 K=C.M(2,E);5(H&&K&&C.2o(K[J])){K[J].w(K,I)}2p{5(!H){C.M(2,E,2r C[F][E](2,J))}}})};C[F][E]=3(I,H){6 G=2;2.e=E;2.1f=F+"-"+E;2.8=C.1c({},C.n.r,C[F][E].r,H);2.b=C(I).g("m."+E,3(L,J,K){4 G.m(J,K)}).g("z."+E,3(K,J){4 G.z(J)}).g("u",3(){4 G.1a()});2.1b()};C[F][E].i=C.1c({},C.n.i,D)};C.n.i={1b:3(){},1a:3(){2.b.2h(2.e)},z:3(D){4 2.8[D]},m:3(D,E){2.8[D]=E;5(D=="j"){2.b[E?"1g":"27"](2.1f+"-j")}},28:3(){2.m("j",7)},21:3(){2.m("j",f)}};C.n.r={j:7};C.a.13={2i:3(){6 D=2;2.b.g("25."+2.e,3(E){4 D.1s(E)});5(C.y.R){2.1j=2.b.p("l");2.b.p("l","14")}2.22=7},23:3(){2.b.10("."+2.e);(C.y.R&&2.b.p("l",2.1j))},1s:3(F){(2.d&&2.k(F));2.t=F;6 E=2,G=(F.24==1),D=(N 2.8.V=="O"?C(F.1p).29().P(F.1p).2a(2.8.V).1m:7);5(!G||D||!2.16(F)){4 f}2.v=!2.8.W;5(!2.v){2.2f=2g(3(){E.v=f},2.8.W)}5(2.Y(F)&&2.S(F)){2.d=(2.Z(F)!==7);5(!2.d){F.2e();4 f}}2.11=3(H){4 E.1n(H)};2.12=3(H){4 E.k(H)};C(1e).g("1r."+2.e,2.11).g("1h."+2.e,2.12);4 7},1n:3(D){5(C.y.R&&!D.2d){4 2.k(D)}5(2.d){2.U(D);4 7}5(2.Y(D)&&2.S(D)){2.d=(2.Z(2.t,D)!==7);(2.d?2.U(D):2.k(D))}4!2.d},k:3(D){C(1e).10("1r."+2.e,2.11).10("1h."+2.e,2.12);5(2.d){2.d=7;2.1i(D)}4 7},Y:3(D){4(T.2b(T.1q(2.t.15-D.15),T.1q(2.t.1v-D.1v))>=2.8.18)},S:3(D){4 2.v},Z:3(D){},U:3(D){},1i:3(D){},16:3(D){4 f}};C.a.13.r={V:2c,18:1,W:0}})(26);',62,152,'||this|function|return|if|var|false|options||ui|element|css|_mouseStarted|widgetName|true|bind|test|prototype|disabled|mouseUp|unselectable|setData|widget|cssCache|attr|plugins|defaults||_mouseDownEvent|remove|_mouseDelayMet|apply|split|browser|getData|||||||||||||data|typeof|string|add|fn|msie|mouseDelayMet|Math|mouseDrag|cancel|delay|top|mouseDistanceMet|mouseStart|unbind|_mouseMoveDelegate|_mouseUpDelegate|mouse|on|pageX|mouseCapture|for|distance|get|destroy|init|extend|body|document|widgetBaseClass|addClass|mouseup|mouseStop|_mouseUnselectable|MozUserSelect|call|length|mouseMove|5000px|target|abs|mousemove|mouseDown|arguments|none|pageY|scrollLeft|hasScroll|catch|disableSelection|enableSelection|scrollTop|off|removeChild|appendTo|position|absolute|left|display|gen|class|plugin|in|push|div|block|triggerHandler|backgroundImage|transparent|rgba|backgroundColor|width|height|auto|default|cursor|try|disable|started|mouseDestroy|which|mousedown|jQuery|removeClass|enable|parents|filter|max|null|button|preventDefault|_mouseDelayTimer|setTimeout|removeData|mouseInit|undefined|each|inArray|slice|Array|isFunction|else|getter|new'.split('|'),0,{}));
;eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(c(A){A.2I("g.i",A.2c({},A.g.2L,{2G:c(){a B=4.9;7(B.d=="24"&&!(/(l|V|13)/).1h(4.j.e("m"))){4.j.e("m","l")}4.j.1M("g-i");(B.1O&&4.j.1M("g-i-1O"));4.2M()},2n:c(F){a H=4.9;7(4.d||H.1O||A(F.2a).2A(".g-2F-1G")){n 15}a C=!4.9.1G||!A(4.9.1G,4.j).1C?v:15;A(4.9.1G,4.j).2C("*").2E().1d(c(){7(4==F.2a){C=v}});7(!C){n 15}7(A.g.1b){A.g.1b.2Z=4}4.d=A.2P(H.d)?A(H.d.30(4.j[0],[F])):(H.d=="28"?4.j.28():4.j);7(!4.d.31("12").1C){4.d.1u((H.1u=="k"?4.j[0].1t:H.1u))}7(4.d[0]!=4.j[0]&&!(/(13|V)/).1h(4.d.e("m"))){4.d.e("m","V")}4.S={6:(o(4.j.e("33"),10)||0),5:(o(4.j.e("2S"),10)||0)};4.z=4.d.e("m");4.8=4.j.8();4.8={5:4.8.5-4.S.5,6:4.8.6-4.S.6};4.8.r={6:F.1r-4.8.6,5:F.1s-4.8.5};4.p=4.d.p();a B=4.p.8();7(4.p[0]==f.12&&A.2V.2Y){B={5:0,6:0}}4.8.k={5:B.5+(o(4.p.e("1N"),10)||0),6:B.6+(o(4.p.e("1T"),10)||0)};a E=4.j.m();4.8.l=4.z=="l"?{5:E.5-(o(4.d.e("5"),10)||0)+4.p[0].q,6:E.6-(o(4.d.e("6"),10)||0)+4.p[0].s}:{5:0,6:0};4.1g=4.1S(F);4.w={t:4.d.26(),u:4.d.1Q()};7(H.16){7(H.16.6!=1A){4.8.r.6=H.16.6+4.S.6}7(H.16.2s!=1A){4.8.r.6=4.w.t-H.16.2s+4.S.6}7(H.16.5!=1A){4.8.r.5=H.16.5+4.S.5}7(H.16.2k!=1A){4.8.r.5=4.w.u-H.16.2k+4.S.5}}7(H.h){7(H.h=="k"){H.h=4.d[0].1t}7(H.h=="f"||H.h=="1o"){4.h=[0-4.8.l.6-4.8.k.6,0-4.8.l.5-4.8.k.5,A(H.h=="f"?f:1o).t()-4.8.l.6-4.8.k.6-4.w.t-4.S.6-(o(4.j.e("2i"),10)||0),(A(H.h=="f"?f:1o).u()||f.12.1t.2u)-4.8.l.5-4.8.k.5-4.w.u-4.S.5-(o(4.j.e("2h"),10)||0)]}7(!(/^(f|1o|k)$/).1h(H.h)){a D=A(H.h)[0];a G=A(H.h).8();4.h=[G.6+(o(A(D).e("1T"),10)||0)-4.8.l.6-4.8.k.6,G.5+(o(A(D).e("1N"),10)||0)-4.8.l.5-4.8.k.5,G.6+T.2g(D.2U,D.1U)-(o(A(D).e("1T"),10)||0)-4.8.l.6-4.8.k.6-4.w.t-4.S.6-(o(4.j.e("2i"),10)||0),G.5+T.2g(D.2u,D.1V)-(o(A(D).e("1N"),10)||0)-4.8.l.5-4.8.k.5-4.w.u-4.S.5-(o(4.j.e("2h"),10)||0)]}}4.19("18",F);4.w={t:4.d.26(),u:4.d.1Q()};7(A.g.1b&&!H.2m){A.g.1b.2Q(4,F)}4.d.1M("g-i-2p");4.2d(F);n v},X:c(C,D){7(!D){D=4.m}a B=C=="V"?1:-1;n{5:(D.5+4.8.l.5*B+4.8.k.5*B-(4.z=="13"||(4.z=="V"&&4.p[0]==f.12)?0:4.p[0].q)*B+(4.z=="13"?A(f).q():0)*B+4.S.5*B),6:(D.6+4.8.l.6*B+4.8.k.6*B-(4.z=="13"||(4.z=="V"&&4.p[0]==f.12)?0:4.p[0].s)*B+(4.z=="13"?A(f).s():0)*B+4.S.6*B)}},1S:c(E){a F=4.9;a B={5:(E.1s-4.8.r.5-4.8.l.5-4.8.k.5+(4.z=="13"||(4.z=="V"&&4.p[0]==f.12)?0:4.p[0].q)-(4.z=="13"?A(f).q():0)),6:(E.1r-4.8.r.6-4.8.l.6-4.8.k.6+(4.z=="13"||(4.z=="V"&&4.p[0]==f.12)?0:4.p[0].s)-(4.z=="13"?A(f).s():0))};7(!4.1g){n B}7(4.h){7(B.6<4.h[0]){B.6=4.h[0]}7(B.5<4.h[1]){B.5=4.h[1]}7(B.6>4.h[2]){B.6=4.h[2]}7(B.5>4.h[3]){B.5=4.h[3]}}7(F.1a){a D=4.1g.5+T.2l((B.5-4.1g.5)/F.1a[1])*F.1a[1];B.5=4.h?(!(D<4.h[1]||D>4.h[3])?D:(!(D<4.h[1])?D-F.1a[1]:D+F.1a[1])):D;a C=4.1g.6+T.2l((B.6-4.1g.6)/F.1a[0])*F.1a[0];B.6=4.h?(!(C<4.h[0]||C>4.h[2])?C:(!(C<4.h[0])?C-F.1a[0]:C+F.1a[0])):C}n B},2d:c(B){4.m=4.1S(B);4.1j=4.X("V");4.m=4.19("1c",B)||4.m;7(!4.9.1w||4.9.1w!="y"){4.d[0].1x.6=4.m.6+"1J"}7(!4.9.1w||4.9.1w!="x"){4.d[0].1x.5=4.m.5+"1J"}7(A.g.1b){A.g.1b.1c(4,B)}n 15},2b:c(C){a D=15;7(A.g.1b&&!4.9.2m){a D=A.g.1b.34(4,C)}7((4.9.1m=="2N"&&!D)||(4.9.1m=="2D"&&D)||4.9.1m===v){a B=4;A(4.d).2B(4.1g,o(4.9.1m,10)||2O,c(){B.19("1k",C);B.22()})}1y{4.19("1k",C);4.22()}n 15},22:c(){4.d.2o("g-i-2p");7(4.9.d!="24"&&!4.1z){4.d.2e()}4.d=2K;4.1z=15},2H:{},23:c(B){n{d:4.d,m:4.m,1P:4.1j,9:4.9}},19:c(C,B){A.g.17.2t(4,C,[B,4.23()]);7(C=="1c"){4.1j=4.X("V")}n 4.j.2z(C=="1c"?C:"1c"+C,[B,4.23()],4.9[C])},2T:c(){7(!4.j.U("i")){n}4.j.3d("i").3x(".i").2o("g-i");4.35()}}));A.2c(A.g.i,{3l:{1u:"k",1w:15,3r:":3p",3q:0,3n:1,d:"24"}});A.g.17.1e("i","1p",{18:c(D,C){a B=A("12");7(B.e("1p")){C.9.21=B.e("1p")}B.e("1p",C.9.1p)},1k:c(C,B){7(B.9.21){A("12").e("1p",B.9.21)}}});A.g.17.1e("i","Z",{18:c(D,C){a B=A(C.d);7(B.e("Z")){C.9.1W=B.e("Z")}B.e("Z",C.9.Z)},1k:c(C,B){7(B.9.1W){A(B.d).e("Z",B.9.1W)}}});A.g.17.1e("i","1l",{18:c(D,C){a B=A(C.d);7(B.e("1l")){C.9.1X=B.e("1l")}B.e("1l",C.9.1l)},1k:c(C,B){7(B.9.1X){A(B.d).e("1l",B.9.1X)}}});A.g.17.1e("i","1K",{18:c(C,B){A(B.9.1K===v?"3v":B.9.1K).1d(c(){A(\'<1Y 3y="g-i-1K" 1x="3t: #3u;"></1Y>\').e({t:4.1U+"1J",u:4.1V+"1J",m:"V",1l:"0.3a",Z:3k}).e(A(4).8()).1u("12")})},1k:c(C,B){A("1Y.37").1d(c(){4.1t.3c(4)})}});A.g.17.1e("i","1v",{18:c(D,C){a E=C.9;a B=A(4).U("i");E.14=E.14||20;E.11=E.11||20;B.W=c(F){2f{7(/1D|1v/.1h(F.e("1L"))||(/1D|1v/).1h(F.e("1L-y"))){n F}F=F.k()}2j(F[0].1t);n A(f)}(4);B.Y=c(F){2f{7(/1D|1v/.1h(F.e("1L"))||(/1D|1v/).1h(F.e("1L-x"))){n F}F=F.k()}2j(F[0].1t);n A(f)}(4);7(B.W[0]!=f&&B.W[0].1F!="1E"){B.1Z=B.W.8()}7(B.Y[0]!=f&&B.Y[0].1F!="1E"){B.25=B.Y.8()}},1c:c(D,C){a E=C.9;a B=A(4).U("i");7(B.W[0]!=f&&B.W[0].1F!="1E"){7((B.1Z.5+B.W[0].1V)-D.1s<E.14){B.W[0].q=B.W[0].q+E.11}7(D.1s-B.1Z.5<E.14){B.W[0].q=B.W[0].q-E.11}}1y{7(D.1s-A(f).q()<E.14){A(f).q(A(f).q()-E.11)}7(A(1o).u()-(D.1s-A(f).q())<E.14){A(f).q(A(f).q()+E.11)}}7(B.Y[0]!=f&&B.Y[0].1F!="1E"){7((B.25.6+B.Y[0].1U)-D.1r<E.14){B.Y[0].s=B.Y[0].s+E.11}7(D.1r-B.25.6<E.14){B.Y[0].s=B.Y[0].s-E.11}}1y{7(D.1r-A(f).s()<E.14){A(f).s(A(f).s()-E.11)}7(A(1o).t()-(D.1r-A(f).s())<E.14){A(f).s(A(f).s()+E.11)}}}});A.g.17.1e("i","1R",{18:c(D,C){a B=A(4).U("i");B.1i=[];A(C.9.1R===v?".g-i":C.9.1R).1d(c(){a F=A(4);a E=F.8();7(4!=B.j[0]){B.1i.2x({2q:4,t:F.26(),u:F.1Q(),5:E.5,6:E.6})}})},1c:c(J,N){a I=A(4).U("i");a L=N.9.3j||20;a D=N.1P.6,C=D+I.w.t,P=N.1P.5,O=P+I.w.u;3s(a H=I.1i.1C-1;H>=0;H--){a E=I.1i[H].6,B=E+I.1i[H].t,R=I.1i[H].5,M=R+I.1i[H].u;7(!((E-L<D&&D<B+L&&R-L<P&&P<M+L)||(E-L<D&&D<B+L&&R-L<O&&O<M+L)||(E-L<C&&C<B+L&&R-L<P&&P<M+L)||(E-L<C&&C<B+L&&R-L<O&&O<M+L))){3w}7(N.9.2w!="3b"){a K=T.1f(R-O)<=20;a Q=T.1f(M-P)<=20;a G=T.1f(E-C)<=20;a F=T.1f(B-D)<=20;7(K){N.m.5=I.X("l",{5:R-I.w.u,6:0}).5}7(Q){N.m.5=I.X("l",{5:M,6:0}).5}7(G){N.m.6=I.X("l",{5:0,6:E-I.w.t}).6}7(F){N.m.6=I.X("l",{5:0,6:B}).6}}7(N.9.2w!="36"){a K=T.1f(R-P)<=20;a Q=T.1f(M-O)<=20;a G=T.1f(E-D)<=20;a F=T.1f(B-C)<=20;7(K){N.m.5=I.X("l",{5:R,6:0}).5}7(Q){N.m.5=I.X("l",{5:M-I.w.u,6:0}).5}7(G){N.m.6=I.X("l",{5:0,6:E}).6}7(F){N.m.6=I.X("l",{5:0,6:B-I.w.t}).6}}}}});A.g.17.1e("i","2v",{18:c(D,C){a B=A(4).U("i");B.1H=[];A(C.9.2v).1d(c(){7(A.U(4,"27")){a E=A.U(4,"27");B.1H.2x({b:E,2y:E.9.1m});E.3g();E.19("39",D,B)}})},1k:c(D,C){a B=A(4).U("i");A.1d(B.1H,c(){7(4.b.1q){4.b.1q=0;B.1z=v;4.b.1z=15;7(4.2y){4.b.9.1m=v}4.b.2b(D);4.b.j.2z("3f",[D,A.2c(4.b.g(),{3e:B.j})],4.b.9.3h);4.b.9.d=4.b.9.29}1y{4.b.19("3i",D,B)}})},1c:c(F,E){a D=A(4).U("i"),B=4;a C=c(K){a H=K.6,J=H+K.t,I=K.5,G=I+K.u;n(H<(4.1j.6+4.8.r.6)&&(4.1j.6+4.8.r.6)<J&&I<(4.1j.5+4.8.r.5)&&(4.1j.5+4.8.r.5)<G)};A.1d(D.1H,c(G){7(C.2t(D,4.b.3o)){7(!4.b.1q){4.b.1q=1;4.b.1I=A(B).28().1u(4.b.j).U("27-2q",v);4.b.9.29=4.b.9.d;4.b.9.d=c(){n E.d[0]};F.2a=4.b.1I[0];4.b.3m(F,v);4.b.2n(F,v,v);4.b.8.r.5=D.8.r.5;4.b.8.r.6=D.8.r.6;4.b.8.k.6-=D.8.k.6-4.b.8.k.6;4.b.8.k.5-=D.8.k.5-4.b.8.k.5;D.19("2J",F)}7(4.b.1I){4.b.2d(F)}}1y{7(4.b.1q){4.b.1q=0;4.b.1z=v;4.b.9.1m=15;4.b.2b(F,v);4.b.9.d=4.b.9.29;4.b.1I.2e();7(4.b.2r){4.b.2r.2e()}D.19("32",F)}}})}});A.g.17.1e("i","1n",{18:c(D,B){a C=A.2X(A(B.9.1n.2W)).2R(c(F,E){n(o(A(F).e("Z"),10)||B.9.1n.1B)-(o(A(E).e("Z"),10)||B.9.1n.1B)});A(C).1d(c(E){4.1x.Z=B.9.1n.1B+E});4[0].1x.Z=B.9.1n.1B+C.1C}})})(38);',62,221,'||||this|top|left|if|offset|options|var|instance|function|helper|css|document|ui|containment|draggable|element|parent|relative|position|return|parseInt|offsetParent|scrollTop|click|scrollLeft|width|height|true|helperProportions|||cssPosition|||||||||||||||||||margins|Math|data|absolute|overflowY|convertPositionTo|overflowX|zIndex||scrollSpeed|body|fixed|scrollSensitivity|false|cursorAt|plugin|start|propagate|grid|ddmanager|drag|each|add|abs|originalPosition|test|snapElements|positionAbs|stop|opacity|revert|stack|window|cursor|isOver|pageX|pageY|parentNode|appendTo|scroll|axis|style|else|cancelHelperRemoval|undefined|min|length|auto|HTML|tagName|handle|sortables|currentItem|px|iframeFix|overflow|addClass|borderTopWidth|disabled|absolutePosition|outerHeight|snap|generatePosition|borderLeftWidth|offsetWidth|offsetHeight|_zIndex|_opacity|div|overflowYOffset||_cursor|clear|uiHash|original|overflowXOffset|outerWidth|sortable|clone|_helper|target|mouseStop|extend|mouseDrag|remove|do|max|marginBottom|marginRight|while|bottom|round|dropBehaviour|mouseStart|removeClass|dragging|item|placeholder|right|call|scrollHeight|connectToSortable|snapMode|push|shouldRevert|triggerHandler|is|animate|find|valid|andSelf|resizable|init|plugins|widget|toSortable|null|mouse|mouseInit|invalid|500|isFunction|prepareOffsets|sort|marginTop|destroy|scrollWidth|browser|group|makeArray|mozilla|current|apply|parents|fromSortable|marginLeft|drop|mouseDestroy|outer|DragDropIframeFix|jQuery|activate|001|inner|removeChild|removeData|sender|sortreceive|refreshItems|receive|deactivate|snapTolerance|1000|defaults|mouseCapture|distance|containerCache|input|delay|cancel|for|background|fff|iframe|continue|unbind|class'.split('|'),0,{}))
;;(function(j){j.effects=j.effects||{};j.extend(j.effects,{save:function(b,a){for(var c=0;c<a.length;c++){if(a[c]!==null)j.data(b[0],"ec.storage."+a[c],b[0].style[a[c]])}},restore:function(b,a){for(var c=0;c<a.length;c++){if(a[c]!==null)b.css(a[c],j.data(b[0],"ec.storage."+a[c]))}},setMode:function(b,a){if(a=='toggle')a=b.is(':hidden')?'show':'hide';return a},getBaseline:function(b,a){var c,e;switch(b[0]){case'top':c=0;break;case'middle':c=0.5;break;case'bottom':c=1;break;default:c=b[0]/a.height};switch(b[1]){case'left':e=0;break;case'center':e=0.5;break;case'right':e=1;break;default:e=b[1]/a.width};return{x:e,y:c}},createWrapper:function(b){if(b.parent().attr('id')=='fxWrapper')return b;var a={width:b.outerWidth({margin:true}),height:b.outerHeight({margin:true}),'float':b.css('float')};b.wrap('<div id="fxWrapper" style="font-size:100%;background:transparent;border:none;margin:0;padding:0"></div>');var c=b.parent();if(b.css('position')=='static'){c.css({position:'relative'});b.css({position:'relative'})}else{var e=b.css('top');if(isNaN(parseInt(e)))e='auto';var d=b.css('left');if(isNaN(parseInt(d)))d='auto';c.css({position:b.css('position'),top:e,left:d,zIndex:b.css('z-index')}).show();b.css({position:'relative',top:0,left:0})}c.css(a);return c},removeWrapper:function(b){if(b.parent().attr('id')=='fxWrapper')return b.parent().replaceWith(b);return b},setTransition:function(c,e,d,g){g=g||{};j.each(e,function(b,a){unit=c.cssUnit(a);if(unit[0]>0)g[a]=unit[0]*d+unit[1]});return g},animateClass:function(f,i,h,k){var o=(typeof h=="function"?h:(k?k:null));var p=(typeof h=="object"?h:null);return this.each(function(){var b={};var a=j(this);var c=a.attr("style")||'';if(typeof c=='object')c=c["cssText"];if(f.toggle){a.hasClass(f.toggle)?f.remove=f.toggle:f.add=f.toggle}var e=j.extend({},(document.defaultView?document.defaultView.getComputedStyle(this,null):this.currentStyle));if(f.add)a.addClass(f.add);if(f.remove)a.removeClass(f.remove);var d=j.extend({},(document.defaultView?document.defaultView.getComputedStyle(this,null):this.currentStyle));if(f.add)a.removeClass(f.add);if(f.remove)a.addClass(f.remove);for(var g in d){if(typeof d[g]!="function"&&d[g]&&g.indexOf("Moz")==-1&&g.indexOf("length")==-1&&d[g]!=e[g]&&(g.match(/color/i)||(!g.match(/color/i)&&!isNaN(parseInt(d[g],10))))&&(e.position!="static"||(e.position=="static"&&!g.match(/left|top|bottom|right/))))b[g]=d[g]}a.animate(b,i,p,function(){if(typeof j(this).attr("style")=='object'){j(this).attr("style")["cssText"]="";j(this).attr("style")["cssText"]=c}else j(this).attr("style",c);if(f.add)j(this).addClass(f.add);if(f.remove)j(this).removeClass(f.remove);if(o)o.apply(this,arguments)})})}});j.fn.extend({_show:j.fn.show,_hide:j.fn.hide,__toggle:j.fn.toggle,_addClass:j.fn.addClass,_removeClass:j.fn.removeClass,_toggleClass:j.fn.toggleClass,effect:function(b,a,c,e){return j.effects[b]?j.effects[b].call(this,{method:b,options:a||{},duration:c,callback:e}):null},show:function(){if(!arguments[0]||(arguments[0].constructor==Number||/(slow|normal|fast)/.test(arguments[0])))return this._show.apply(this,arguments);else{var b=arguments[1]||{};b['mode']='show';return this.effect.apply(this,[arguments[0],b,arguments[2]||b.duration,arguments[3]||b.callback])}},hide:function(){if(!arguments[0]||(arguments[0].constructor==Number||/(slow|normal|fast)/.test(arguments[0])))return this._hide.apply(this,arguments);else{var b=arguments[1]||{};b['mode']='hide';return this.effect.apply(this,[arguments[0],b,arguments[2]||b.duration,arguments[3]||b.callback])}},toggle:function(){if(!arguments[0]||(arguments[0].constructor==Number||/(slow|normal|fast)/.test(arguments[0]))||(arguments[0].constructor==Function))return this.__toggle.apply(this,arguments);else{var b=arguments[1]||{};b['mode']='toggle';return this.effect.apply(this,[arguments[0],b,arguments[2]||b.duration,arguments[3]||b.callback])}},addClass:function(b,a,c,e){return a?j.effects.animateClass.apply(this,[{add:b},a,c,e]):this._addClass(b)},removeClass:function(b,a,c,e){return a?j.effects.animateClass.apply(this,[{remove:b},a,c,e]):this._removeClass(b)},toggleClass:function(b,a,c,e){return a?j.effects.animateClass.apply(this,[{toggle:b},a,c,e]):this._toggleClass(b)},morph:function(b,a,c,e,d){return j.effects.animateClass.apply(this,[{add:a,remove:b},c,e,d])},switchClass:function(){return this.morph.apply(this,arguments)},cssUnit:function(c){var e=this.css(c),d=[];j.each(['em','px','%','pt'],function(b,a){if(e.indexOf(a)>0)d=[parseFloat(e),a]});return d}});jQuery.each(['backgroundColor','borderBottomColor','borderLeftColor','borderRightColor','borderTopColor','color','outlineColor'],function(a,c){jQuery.fx.step[c]=function(b){if(b.state==0){b.start=m(b.elem,c);b.end=l(b.end)}b.elem.style[c]="rgb("+[Math.max(Math.min(parseInt((b.pos*(b.end[0]-b.start[0]))+b.start[0]),255),0),Math.max(Math.min(parseInt((b.pos*(b.end[1]-b.start[1]))+b.start[1]),255),0),Math.max(Math.min(parseInt((b.pos*(b.end[2]-b.start[2]))+b.start[2]),255),0)].join(",")+")"}});function l(b){var a;if(b&&b.constructor==Array&&b.length==3)return b;if(a=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(b))return[parseInt(a[1]),parseInt(a[2]),parseInt(a[3])];if(a=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(b))return[parseFloat(a[1])*2.55,parseFloat(a[2])*2.55,parseFloat(a[3])*2.55];if(a=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(b))return[parseInt(a[1],16),parseInt(a[2],16),parseInt(a[3],16)];if(a=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(b))return[parseInt(a[1]+a[1],16),parseInt(a[2]+a[2],16),parseInt(a[3]+a[3],16)];if(a=/rgba\(0, 0, 0, 0\)/.exec(b))return q['transparent'];return q[jQuery.trim(b).toLowerCase()]}function m(b,a){var c;do{c=jQuery.curCSS(b,a);if(c!=''&&c!='transparent'||jQuery.nodeName(b,"body"))break;a="backgroundColor"}while(b=b.parentNode);return l(c)};var q={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]};jQuery.easing['jswing']=jQuery.easing['swing'];jQuery.extend(jQuery.easing,{def:'easeOutQuad',swing:function(b,a,c,e,d){return jQuery.easing[jQuery.easing.def](b,a,c,e,d)},easeInQuad:function(b,a,c,e,d){return e*(a/=d)*a+c},easeOutQuad:function(b,a,c,e,d){return-e*(a/=d)*(a-2)+c},easeInOutQuad:function(b,a,c,e,d){if((a/=d/2)<1)return e/2*a*a+c;return-e/2*((--a)*(a-2)-1)+c},easeInCubic:function(b,a,c,e,d){return e*(a/=d)*a*a+c},easeOutCubic:function(b,a,c,e,d){return e*((a=a/d-1)*a*a+1)+c},easeInOutCubic:function(b,a,c,e,d){if((a/=d/2)<1)return e/2*a*a*a+c;return e/2*((a-=2)*a*a+2)+c},easeInQuart:function(b,a,c,e,d){return e*(a/=d)*a*a*a+c},easeOutQuart:function(b,a,c,e,d){return-e*((a=a/d-1)*a*a*a-1)+c},easeInOutQuart:function(b,a,c,e,d){if((a/=d/2)<1)return e/2*a*a*a*a+c;return-e/2*((a-=2)*a*a*a-2)+c},easeInQuint:function(b,a,c,e,d){return e*(a/=d)*a*a*a*a+c},easeOutQuint:function(b,a,c,e,d){return e*((a=a/d-1)*a*a*a*a+1)+c},easeInOutQuint:function(b,a,c,e,d){if((a/=d/2)<1)return e/2*a*a*a*a*a+c;return e/2*((a-=2)*a*a*a*a+2)+c},easeInSine:function(b,a,c,e,d){return-e*Math.cos(a/d*(Math.PI/2))+e+c},easeOutSine:function(b,a,c,e,d){return e*Math.sin(a/d*(Math.PI/2))+c},easeInOutSine:function(b,a,c,e,d){return-e/2*(Math.cos(Math.PI*a/d)-1)+c},easeInExpo:function(b,a,c,e,d){return(a==0)?c:e*Math.pow(2,10*(a/d-1))+c},easeOutExpo:function(b,a,c,e,d){return(a==d)?c+e:e*(-Math.pow(2,-10*a/d)+1)+c},easeInOutExpo:function(b,a,c,e,d){if(a==0)return c;if(a==d)return c+e;if((a/=d/2)<1)return e/2*Math.pow(2,10*(a-1))+c;return e/2*(-Math.pow(2,-10*--a)+2)+c},easeInCirc:function(b,a,c,e,d){return-e*(Math.sqrt(1-(a/=d)*a)-1)+c},easeOutCirc:function(b,a,c,e,d){return e*Math.sqrt(1-(a=a/d-1)*a)+c},easeInOutCirc:function(b,a,c,e,d){if((a/=d/2)<1)return-e/2*(Math.sqrt(1-a*a)-1)+c;return e/2*(Math.sqrt(1-(a-=2)*a)+1)+c},easeInElastic:function(b,a,c,e,d){var g=1.70158;var f=0;var i=e;if(a==0)return c;if((a/=d)==1)return c+e;if(!f)f=d*.3;if(i<Math.abs(e)){i=e;var g=f/4}else var g=f/(2*Math.PI)*Math.asin(e/i);return-(i*Math.pow(2,10*(a-=1))*Math.sin((a*d-g)*(2*Math.PI)/f))+c},easeOutElastic:function(b,a,c,e,d){var g=1.70158;var f=0;var i=e;if(a==0)return c;if((a/=d)==1)return c+e;if(!f)f=d*.3;if(i<Math.abs(e)){i=e;var g=f/4}else var g=f/(2*Math.PI)*Math.asin(e/i);return i*Math.pow(2,-10*a)*Math.sin((a*d-g)*(2*Math.PI)/f)+e+c},easeInOutElastic:function(b,a,c,e,d){var g=1.70158;var f=0;var i=e;if(a==0)return c;if((a/=d/2)==2)return c+e;if(!f)f=d*(.3*1.5);if(i<Math.abs(e)){i=e;var g=f/4}else var g=f/(2*Math.PI)*Math.asin(e/i);if(a<1)return-.5*(i*Math.pow(2,10*(a-=1))*Math.sin((a*d-g)*(2*Math.PI)/f))+c;return i*Math.pow(2,-10*(a-=1))*Math.sin((a*d-g)*(2*Math.PI)/f)*.5+e+c},easeInBack:function(b,a,c,e,d,g){if(g==undefined)g=1.70158;return e*(a/=d)*a*((g+1)*a-g)+c},easeOutBack:function(b,a,c,e,d,g){if(g==undefined)g=1.70158;return e*((a=a/d-1)*a*((g+1)*a+g)+1)+c},easeInOutBack:function(b,a,c,e,d,g){if(g==undefined)g=1.70158;if((a/=d/2)<1)return e/2*(a*a*(((g*=(1.525))+1)*a-g))+c;return e/2*((a-=2)*a*(((g*=(1.525))+1)*a+g)+2)+c},easeInBounce:function(b,a,c,e,d){return e-jQuery.easing.easeOutBounce(b,d-a,0,e,d)+c},easeOutBounce:function(b,a,c,e,d){if((a/=d)<(1/2.75)){return e*(7.5625*a*a)+c}else if(a<(2/2.75)){return e*(7.5625*(a-=(1.5/2.75))*a+.75)+c}else if(a<(2.5/2.75)){return e*(7.5625*(a-=(2.25/2.75))*a+.9375)+c}else{return e*(7.5625*(a-=(2.625/2.75))*a+.984375)+c}},easeInOutBounce:function(b,a,c,e,d){if(a<d/2)return jQuery.easing.easeInBounce(b,a*2,0,e,d)*.5+c;return jQuery.easing.easeOutBounce(b,a*2-d,0,e,d)*.5+e*.5+c}})})(jQuery);(function(k){k.effects.blind=function(h){return this.queue(function(){var b=k(this),a=['position','top','left'];var c=k.effects.setMode(b,h.options.mode||'hide');var e=h.options.direction||'vertical';k.effects.save(b,a);b.show();var d=k.effects.createWrapper(b).css({overflow:'hidden'});var g=(e=='vertical')?'height':'width';var f=(e=='vertical')?d.height():d.width();if(c=='show')d.css(g,0);var i={};i[g]=c=='show'?f:0;d.animate(i,h.duration,h.options.easing,function(){if(c=='hide')b.hide();k.effects.restore(b,a);k.effects.removeWrapper(b);if(h.callback)h.callback.apply(b[0],arguments);b.dequeue()})})}})(jQuery);(function(m){m.effects.bounce=function(l){return this.queue(function(){var b=m(this),a=['position','top','left'];var c=m.effects.setMode(b,l.options.mode||'effect');var e=l.options.direction||'up';var d=l.options.distance||20;var g=l.options.times||5;var f=l.duration||250;if(/show|hide/.test(c))a.push('opacity');m.effects.save(b,a);b.show();m.effects.createWrapper(b);var i=(e=='up'||e=='down')?'top':'left';var h=(e=='up'||e=='left')?'pos':'neg';var d=l.options.distance||(i=='top'?b.outerHeight({margin:true})/3:b.outerWidth({margin:true})/3);if(c=='show')b.css('opacity',0).css(i,h=='pos'?-d:d);if(c=='hide')d=d/(g*2);if(c!='hide')g--;if(c=='show'){var k={opacity:1};k[i]=(h=='pos'?'+=':'-=')+d;b.animate(k,f/2,l.options.easing);d=d/2;g--};for(var o=0;o<g;o++){var p={},j={};p[i]=(h=='pos'?'-=':'+=')+d;j[i]=(h=='pos'?'+=':'-=')+d;b.animate(p,f/2,l.options.easing).animate(j,f/2,l.options.easing);d=(c=='hide')?d*2:d/2};if(c=='hide'){var k={opacity:0};k[i]=(h=='pos'?'-=':'+=')+d;b.animate(k,f/2,l.options.easing,function(){b.hide();m.effects.restore(b,a);m.effects.removeWrapper(b);if(l.callback)l.callback.apply(this,arguments)})}else{var p={},j={};p[i]=(h=='pos'?'-=':'+=')+d;j[i]=(h=='pos'?'+=':'-=')+d;b.animate(p,f/2,l.options.easing).animate(j,f/2,l.options.easing,function(){m.effects.restore(b,a);m.effects.removeWrapper(b);if(l.callback)l.callback.apply(this,arguments)})};b.queue('fx',function(){b.dequeue()});b.dequeue()})}})(jQuery);(function(o){o.effects.clip=function(k){return this.queue(function(){var b=o(this),a=['position','top','left','height','width'];var c=o.effects.setMode(b,k.options.mode||'hide');var e=k.options.direction||'vertical';o.effects.save(b,a);b.show();var d=o.effects.createWrapper(b).css({overflow:'hidden'});var g=b[0].tagName=='IMG'?d:b;var f={size:(e=='vertical')?'height':'width',position:(e=='vertical')?'top':'left'};var i=(e=='vertical')?g.height():g.width();if(c=='show'){g.css(f.size,0);g.css(f.position,i/2)}var h={};h[f.size]=c=='show'?i:0;h[f.position]=c=='show'?0:i/2;g.animate(h,{queue:false,duration:k.duration,easing:k.options.easing,complete:function(){if(c=='hide')b.hide();o.effects.restore(b,a);o.effects.removeWrapper(b);if(k.callback)k.callback.apply(b[0],arguments);b.dequeue()}})})}})(jQuery);(function(k){k.effects.drop=function(h){return this.queue(function(){var b=k(this),a=['position','top','left','opacity'];var c=k.effects.setMode(b,h.options.mode||'hide');var e=h.options.direction||'left';k.effects.save(b,a);b.show();k.effects.createWrapper(b);var d=(e=='up'||e=='down')?'top':'left';var g=(e=='up'||e=='left')?'pos':'neg';var f=h.options.distance||(d=='top'?b.outerHeight({margin:true})/2:b.outerWidth({margin:true})/2);if(c=='show')b.css('opacity',0).css(d,g=='pos'?-f:f);var i={opacity:c=='show'?1:0};i[d]=(c=='show'?(g=='pos'?'+=':'-='):(g=='pos'?'-=':'+='))+f;b.animate(i,{queue:false,duration:h.duration,easing:h.options.easing,complete:function(){if(c=='hide')b.hide();k.effects.restore(b,a);k.effects.removeWrapper(b);if(h.callback)h.callback.apply(this,arguments);b.dequeue()}})})}})(jQuery);(function(k){k.effects.explode=function(h){return this.queue(function(){var b=h.options.pieces?Math.round(Math.sqrt(h.options.pieces)):3;var a=h.options.pieces?Math.round(Math.sqrt(h.options.pieces)):3;h.options.mode=h.options.mode=='toggle'?(k(this).is(':visible')?'hide':'show'):h.options.mode;var c=k(this).show().css('visibility','hidden');var e=c.offset();e.top-=parseInt(c.css("marginTop"))||0;e.left-=parseInt(c.css("marginLeft"))||0;var d=c.outerWidth(true);var g=c.outerHeight(true);for(var f=0;f<b;f++){for(var i=0;i<a;i++){c.clone().appendTo('body').wrap('<div></div>').css({position:'absolute',visibility:'visible',left:-i*(d/a),top:-f*(g/b)}).parent().addClass('effects-explode').css({position:'absolute',overflow:'hidden',width:d/a,height:g/b,left:e.left+i*(d/a)+(h.options.mode=='show'?(i-Math.floor(a/2))*(d/a):0),top:e.top+f*(g/b)+(h.options.mode=='show'?(f-Math.floor(b/2))*(g/b):0),opacity:h.options.mode=='show'?0:1}).animate({left:e.left+i*(d/a)+(h.options.mode=='show'?0:(i-Math.floor(a/2))*(d/a)),top:e.top+f*(g/b)+(h.options.mode=='show'?0:(f-Math.floor(b/2))*(g/b)),opacity:h.options.mode=='show'?1:0},h.duration||500)}}setTimeout(function(){h.options.mode=='show'?c.css({visibility:'visible'}):c.css({visibility:'visible'}).hide();if(h.callback)h.callback.apply(c[0]);c.dequeue();k('.effects-explode').remove()},h.duration||500)})}})(jQuery);(function(l){l.effects.fold=function(j){return this.queue(function(){var b=l(this),a=['position','top','left'];var c=l.effects.setMode(b,j.options.mode||'hide');var e=j.options.size||15;var d=!(!j.options.horizFirst);l.effects.save(b,a);b.show();var g=l.effects.createWrapper(b).css({overflow:'hidden'});var f=((c=='show')!=d);var i=f?['width','height']:['height','width'];var h=f?[g.width(),g.height()]:[g.height(),g.width()];var k=/([0-9]+)%/.exec(e);if(k)e=parseInt(k[1])/100*h[c=='hide'?0:1];if(c=='show')g.css(d?{height:0,width:e}:{height:e,width:0});var o={},p={};o[i[0]]=c=='show'?h[0]:e;p[i[1]]=c=='show'?h[1]:0;g.animate(o,j.duration/2,j.options.easing).animate(p,j.duration/2,j.options.easing,function(){if(c=='hide')b.hide();l.effects.restore(b,a);l.effects.removeWrapper(b);if(j.callback)j.callback.apply(b[0],arguments);b.dequeue()})})}})(jQuery);(function(i){i.effects.highlight=function(f){return this.queue(function(){var b=i(this),a=['backgroundImage','backgroundColor','opacity'];var c=i.effects.setMode(b,f.options.mode||'show');var e=f.options.color||"#ffff99";var d=b.css("backgroundColor");i.effects.save(b,a);b.show();b.css({backgroundImage:'none',backgroundColor:e});var g={backgroundColor:d};if(c=="hide")g['opacity']=0;b.animate(g,{queue:false,duration:f.duration,easing:f.options.easing,complete:function(){if(c=="hide")b.hide();i.effects.restore(b,a);if(c=="show"&&jQuery.browser.msie)this.style.removeAttribute('filter');if(f.callback)f.callback.apply(this,arguments);b.dequeue()}})})}})(jQuery);(function(g){g.effects.pulsate=function(d){return this.queue(function(){var b=g(this);var a=g.effects.setMode(b,d.options.mode||'show');var c=d.options.times||5;if(a=='hide')c--;if(b.is(':hidden')){b.css('opacity',0);b.show();b.animate({opacity:1},d.duration/2,d.options.easing);c=c-2}for(var e=0;e<c;e++){b.animate({opacity:0},d.duration/2,d.options.easing).animate({opacity:1},d.duration/2,d.options.easing)};if(a=='hide'){b.animate({opacity:0},d.duration/2,d.options.easing,function(){b.hide();if(d.callback)d.callback.apply(this,arguments)})}else{b.animate({opacity:0},d.duration/2,d.options.easing).animate({opacity:1},d.duration/2,d.options.easing,function(){if(d.callback)d.callback.apply(this,arguments)})};b.queue('fx',function(){b.dequeue()});b.dequeue()})}})(jQuery);(function(i){i.effects.fade=function(f){return this.queue(function(){var b=i(this),a=['opacity'];var c=i.effects.setMode(b,f.options.mode||'effect');if(c=='toggle')c=b.is(':hidden')?'show':'hide';var e=f.options.opacity||0;var d=b.css('opacity');i.effects.save(b,a);b.show();if(c=='show')b.css({opacity:0});var g={opacity:c=='show'?d:e};b.animate(g,{queue:false,duration:f.duration,easing:f.options.easing,complete:function(){if(c=='hide')b.hide();if(c=='hide')i.effects.restore(b,a);if(f.callback)f.callback.apply(this,arguments);b.dequeue()}})})}})(jQuery);(function(n){n.effects.puff=function(f){return this.queue(function(){var b=n(this);var a=n.extend(true,{},f.options);var c=n.effects.setMode(b,f.options.mode||'hide');var e=parseInt(f.options.percent)||150;a.fade=true;var d={height:b.height(),width:b.width()};var g=e/100;b.from=(c=='hide')?d:{height:d.height*g,width:d.width*g};a.from=b.from;a.percent=(c=='hide')?e:100;a.mode=c;b.effect('scale',a,f.duration,f.callback);b.dequeue()})};n.effects.scale=function(h){return this.queue(function(){var b=n(this);var a=n.extend(true,{},h.options);var c=n.effects.setMode(b,h.options.mode||'effect');var e=parseInt(h.options.percent)||(parseInt(h.options.percent)==0?0:(c=='hide'?0:100));var d=h.options.direction||'both';var g=h.options.origin;if(c!='effect'){a.origin=g||['middle','center'];a.restore=true}var f={height:b.height(),width:b.width()};b.from=h.options.from||(c=='show'?{height:0,width:0}:f);var i={y:d!='horizontal'?(e/100):1,x:d!='vertical'?(e/100):1};b.to={height:f.height*i.y,width:f.width*i.x};if(h.options.fade){if(c=='show'){b.from.opacity=0;b.to.opacity=1};if(c=='hide'){b.from.opacity=1;b.to.opacity=0}};a.from=b.from;a.to=b.to;a.mode=c;b.effect('size',a,h.duration,h.callback);b.dequeue()})};n.effects.size=function(q){return this.queue(function(){var a=n(this),c=['position','top','left','width','height','overflow','opacity'];var e=['position','top','left','overflow','opacity'];var d=['width','height','overflow'];var g=['fontSize'];var f=['borderTopWidth','borderBottomWidth','paddingTop','paddingBottom'];var i=['borderLeftWidth','borderRightWidth','paddingLeft','paddingRight'];var h=n.effects.setMode(a,q.options.mode||'effect');var k=q.options.restore||false;var o=q.options.scale||'both';var p=q.options.origin;var j={height:a.height(),width:a.width()};a.from=q.options.from||j;a.to=q.options.to||j;if(p){var l=n.effects.getBaseline(p,j);a.from.top=(j.height-a.from.height)*l.y;a.from.left=(j.width-a.from.width)*l.x;a.to.top=(j.height-a.to.height)*l.y;a.to.left=(j.width-a.to.width)*l.x};var m={from:{y:a.from.height/j.height,x:a.from.width/j.width},to:{y:a.to.height/j.height,x:a.to.width/j.width}};if(o=='box'||o=='both'){if(m.from.y!=m.to.y){c=c.concat(f);a.from=n.effects.setTransition(a,f,m.from.y,a.from);a.to=n.effects.setTransition(a,f,m.to.y,a.to)};if(m.from.x!=m.to.x){c=c.concat(i);a.from=n.effects.setTransition(a,i,m.from.x,a.from);a.to=n.effects.setTransition(a,i,m.to.x,a.to)}};if(o=='content'||o=='both'){if(m.from.y!=m.to.y){c=c.concat(g);a.from=n.effects.setTransition(a,g,m.from.y,a.from);a.to=n.effects.setTransition(a,g,m.to.y,a.to)}};n.effects.save(a,k?c:e);a.show();n.effects.createWrapper(a);a.css('overflow','hidden').css(a.from);if(o=='content'||o=='both'){f=f.concat(['marginTop','marginBottom']).concat(g);i=i.concat(['marginLeft','marginRight']);d=c.concat(f).concat(i);a.find("*[width]").each(function(){child=n(this);if(k)n.effects.save(child,d);var b={height:child.height(),width:child.width()};child.from={height:b.height*m.from.y,width:b.width*m.from.x};child.to={height:b.height*m.to.y,width:b.width*m.to.x};if(m.from.y!=m.to.y){child.from=n.effects.setTransition(child,f,m.from.y,child.from);child.to=n.effects.setTransition(child,f,m.to.y,child.to)};if(m.from.x!=m.to.x){child.from=n.effects.setTransition(child,i,m.from.x,child.from);child.to=n.effects.setTransition(child,i,m.to.x,child.to)};child.css(child.from);child.animate(child.to,q.duration,q.options.easing,function(){if(k)n.effects.restore(child,d)})})};a.animate(a.to,{queue:false,duration:q.duration,easing:q.options.easing,complete:function(){if(h=='hide')a.hide();n.effects.restore(a,k?c:e);n.effects.removeWrapper(a);if(q.callback)q.callback.apply(this,arguments);a.dequeue()}})})}})(jQuery);(function(m){m.effects.shake=function(l){return this.queue(function(){var b=m(this),a=['position','top','left'];var c=m.effects.setMode(b,l.options.mode||'effect');var e=l.options.direction||'left';var d=l.options.distance||20;var g=l.options.times||3;var f=l.duration||l.options.duration||140;m.effects.save(b,a);b.show();m.effects.createWrapper(b);var i=(e=='up'||e=='down')?'top':'left';var h=(e=='up'||e=='left')?'pos':'neg';var k={},o={},p={};k[i]=(h=='pos'?'-=':'+=')+d;o[i]=(h=='pos'?'+=':'-=')+d*2;p[i]=(h=='pos'?'-=':'+=')+d*2;b.animate(k,f,l.options.easing);for(var j=1;j<g;j++){b.animate(o,f,l.options.easing).animate(p,f,l.options.easing)};b.animate(o,f,l.options.easing).animate(k,f/2,l.options.easing,function(){m.effects.restore(b,a);m.effects.removeWrapper(b);if(l.callback)l.callback.apply(this,arguments)});b.queue('fx',function(){b.dequeue()});b.dequeue()})}})(jQuery);(function(k){k.effects.slide=function(h){return this.queue(function(){var b=k(this),a=['position','top','left'];var c=k.effects.setMode(b,h.options.mode||'show');var e=h.options.direction||'left';k.effects.save(b,a);b.show();k.effects.createWrapper(b).css({overflow:'hidden'});var d=(e=='up'||e=='down')?'top':'left';var g=(e=='up'||e=='left')?'pos':'neg';var f=h.options.distance||(d=='top'?b.outerHeight({margin:true}):b.outerWidth({margin:true}));if(c=='show')b.css(d,g=='pos'?-f:f);var i={};i[d]=(c=='show'?(g=='pos'?'+=':'-='):(g=='pos'?'-=':'+='))+f;b.animate(i,{queue:false,duration:h.duration,easing:h.options.easing,complete:function(){if(c=='hide')b.hide();k.effects.restore(b,a);k.effects.removeWrapper(b);if(h.callback)h.callback.apply(this,arguments);b.dequeue()}})})}})(jQuery);(function(f){f.effects.transfer=function(g){return this.queue(function(){var b=f(this);var a=f.effects.setMode(b,g.options.mode||'effect');var c=f(g.options.to);var e=b.offset();var d=f('<div class="ui-effects-transfer"></div>').appendTo(document.body);if(g.options.className)d.addClass(g.options.className);d.addClass(g.options.className);d.css({top:e.top,left:e.left,height:b.outerHeight()-parseInt(d.css('borderTopWidth'))-parseInt(d.css('borderBottomWidth')),width:b.outerWidth()-parseInt(d.css('borderLeftWidth'))-parseInt(d.css('borderRightWidth')),position:'absolute'});e=c.offset();animation={top:e.top,left:e.left,height:c.outerHeight()-parseInt(d.css('borderTopWidth'))-parseInt(d.css('borderBottomWidth')),width:c.outerWidth()-parseInt(d.css('borderLeftWidth'))-parseInt(d.css('borderRightWidth'))};d.animate(animation,g.duration,g.options.easing,function(){d.remove();if(g.callback)g.callback.apply(b[0],arguments);b.dequeue()})})}})(jQuery);;                                                                  
		if (typeof OverlayWidget == "undefined") {
			var OverlayWidget = Base.extend({
				constructor: null,

				create: function(selector, settings) {
					$(selector).widgetState(settings).widgetClass(OverlayWidget);
				},

				
				getWidgetClassName: function() {
					return "OverlayWidget";
				},

				lazyload: function(selector, event) {
					var jQ = $(selector);
					var s = jQ.widgetState();
					this.createBackground(selector);
					this.createOverlay(selector);
					this.assignEvents(selector);
				},

				assignEvents: function(selector) {
					var jQ = $(selector);
					var s = jQ.widgetState();
					var self = this;
					var bg = $(s.bg);
					var ov = $(s.ov);
					
					$(".close", ov).hover(
						  function() {
							  $(this).addClass("close-mouseover");
						  },
						  function() {
							  $(this).removeClass("close-mouseover");
							  $(".quicklook-button", this).hide();
						  }
					  );
					$(".close", ov).click(function(e) {
						self.hide(selector);
					});
					if (s.closeOnBackgroundClick) {
						bg.click( function(e) {
							if(e.target == bg.get(0)) {
								self.hide(selector);
							}							
						});
					}

				},

				createBackground: function(selector) {
				
					var jQ=$(selector);
					var s = jQ.widgetState();
					var x = s.cssSelector;
					if (s.captureClicks) $("body").append('<div class="OverlayScreen ' + $(selector).widgetId() + '-screen"><!-- --></div>');
					
					if (x) {
						if (x.charAt(0) == "#") {
							$("body").append('<div id="' + x.substring(1,x.length) + '"><div class="OverlayBackground ' + $(selector).widgetId() + '-bg"><!-- --></div></div>');
						} else {
							$("body").append('<div class="' + s.cssSelector + '"><div class="OverlayBackground ' + $(selector).widgetId() + '-bg"><!-- --></div></div>');
						}
					} else {
						$("body").append('<div class="' + $(selector).widgetId() + '-bg"><!-- --></div>');
					}
					s.bg = "." + $(selector).widgetId() + "-bg";
					s.screen = ".OverlayScreen";
					if (s.captureClicks) {
						$(s.screen).css("opacity", "0.0").add(s.bg).css("width", document.body.clientWidth).css("height", $(document).height());
					} else {
						$(s.bg).css("width", 0).css("height", 0);
					}
				},

				createOverlay: function(selector) {
					var jQ = $(selector);
					var s = jQ.widgetState();
					
					$(s.bg).append('<div class="Overlay"><iframe src="about:blank" scrolling="no" frameborder="0" width="100%"></iframe><div class="handle"><div class="close"></div></div><div class="overlay-body"></div><div class="overlay-loading"><!-- --></div></div>');
					s.ov = s.bg + " .Overlay";
					s.ovbody = s.bg + " .Overlay .overlay-body";
					s.ovloading = s.bg + " .overlay-loading";
					var ov = $(s.ov);
					ov.css("position", "absolute");
					
					var options = {};
					// Safari has an issue with select dropdown boxes inside of draggable areas, so we need to explicitly
					// disable dragging on the body of the overlay in Safari only 
					if($.browser.safari) {
						$.extend(options, { cancel:'.overlay-body'});
					}
					if (s.dragByBody) {
						ov.draggable(options);
					}
					if (s.dragByHandle) {
						$.extend(options, { handle:'.handle'});
						ov.draggable(options);
					}
				},

				getBody: function(selector, source) {
	      		var s = $(selector).widgetState();
					var b = $(s.ovbody);
					if (source.sourceURL) {
						
						b.widgetAjax(selector, "path:" + source.sourceURL, null, null, null, function() {
							$(s.ovloading).hide();
							var ov =$(s.ov);
							$("iframe", ov).attr("height",ov.height() + "px");
						});
					} else if (source.sourceSelector) {
						b.html("").append($(source.sourceSelector).html());
					}
				},

				hideAll: function() {
					$(".Overlay-stub").each(function(){
						OverlayWidget.hide(this);
					});	
				},
				
				hide: function(selector) {
					var jQ = $(selector);
					var s = jQ.widgetState();
					if (jQ[0].inProgress) return;
					if (!s.ov) return;
					var ov = $(s.ov);
					$("iframe", ov).hide();
					if (s.effectOnHide) {
						$(s.ov)
							  .hide(s.effectOnHide, {}, s.effectOnHideSpeed, function() {$(s.bg).hide();$(s.screen).hide();})
							  .find(s.ovbody).html("");
					} else {
							$(s.ov).hide().find(s.ovbody).html("");
							$(s.bg).hide();
							$(s.screen).hide();
					}
				},

				setShowEffect: function(selector, effect, options, speed) {
					var s = $(selector).widgetState();
					s.effectOnShow = effect;
					s.effectOnShowOptions = options;
					s.effectOnShowSpeed = speed;
				},

				setHideEffect: function(selector, effect, options, speed) {
					var s = $(selector).widgetState();
					s.effectOnHide = effect;
					s.effectOnHideOptions = options;
					s.effectOnHideSpeed = speed;
				},

				show: function(selector, event, source, x, y) {
					var jQ = $(selector);
					var s = jQ.widgetState();
					if (jQ[0].inProgress) return;
					jQ[0].inProgress = true;
					if (!s.created) {
						this.lazyload(selector, event);
						s.created = true;
					}

					$(s.bg).show();
					$(s.screen).show();
					$("iframe", ov).show();
					var ov = $(s.ov);
					var ovl = $(s.ovloading);
					ov.show();
					ovl.show();
					this.getBody(selector, source);

					if (!x) {
						
						x = document.body.parentNode.clientWidth / 2;
						}
					if (!y) {
						y = document.body.parentNode.clientHeight /2;
					}

					var ovx = x - (ov.width() / 2);
					var ovy = y - (ov.height() / 2);


					if (!s.allowOffScreenOverlay) {
					
						var st = $(window).scrollTop();
						var sl = $(window).scrollLeft();
						if (ovx < sl) {
							ovx = s.onScreenPadding + sl;
						} else if (ovx + ov.width() > $(window).width()) {
							ovx = $(window).width() - ov.width() - s.onScreenPadding + sl;
						}

						if (ovy < st) {
							ovy = s.onScreenPadding + st;
						} else if (ovy + ov.height() > ($(window).height() + st)) {
							ovy = $(window).height() - ov.height() - s.onScreenPadding + st;
						}
					}
					ov.css("top", ovy + "px").css("left", ovx + "px");
					if (s.effectOnShow) {
						ov.show(s.effectOnShow, {}, s.effectOnShowSpeed, function() {
							jQ[0].inProgress = false;
							if (source.sourceSelector) {
								ovl.hide();
							}
						});
					} else {
						ov.show();
						jQ[0].inProgress = false;
						ovl.hide();
					}
				}
			});
		}
	

		function openBasketPage()
		{
			window.location = '/checkout/basket.jsp';
		}
	
   	$(function(){
			$("#widget-but-ucart").click(function(){
			  openBasketPage();
			});

			$(".cart-search-keyword-container .search-button").click(function(){
				submitSearchForm(document.searchForm);
			});

			if ($(".keyword-text").height() < 16) {
				$(".keyword-text").height("16px");
			}
		});
	
		$(function(){
		   var ucartTimer;
		
		   $("#widget-but-ucart").hover(function(){
		      ucartTimer = setTimeout(function() { showBasket('show',''); }, 500);
		   },function(ev) {
		      if( typeof ucartTimer != undefined ) { clearTimeout(ucartTimer); }
		   });
		});

		// When the Universal Cart layer opens 
		// it will close if the user clicks on anything in the main browser window
		$(document).click(function(event) {
			var posX = event.clientX;
			var posY = event.clientY;
			var miniCart = $('#widget-ucart');
			var miniCartPos = miniCart.offset();
			if(isShowingBasket())
			{
				// If user click to background, close the mini cart
				if(!(posX >= miniCartPos.left && posX <= (miniCartPos.left + miniCart.width())
					&& posY >= miniCartPos.top && posY <= (miniCartPos.top + miniCart.height()))) {
					hideBasket();
				}
			}
		});
		/**
 * @fileoverview The javascript that runs the common-image.jsp widget.

 @author: $Author: bfattori $
 @version: $Revision: 1.5 $
 */
if (typeof ImageWidget == "undefined")
{
	/**
	 * @class Handles the execution for {@link com.fry.ocpsdk.widget.common.ImageWidget}
	 *        objects within the DOM.
	 */
	var ImageWidget = BaseWidget.extend({

		/**
		 * Returns the state of the image widget. If an ImageWidget was not initialized with
		 * the <tt>create()</tt> method, check for elementData.  If the elementData is defined,
		 * assign it to the ImageWidget's <tt>widgetState</tt> and return that.
		 * @return {Object} The ImageWidget's widgetState.
		 */
		getState: function(selector)
		{
			var jQ = $(selector);
			var s = jQ.widgetState();
			if (!s.layers && jQ.elementData())
			{
				jQ.widgetState(jQ.elementData()).widgetClass(ImageWidget);
				s = jQ.widgetState();
			}
			return s;
		},

		/**
		 * Convenience method for working with a two layer image background.
		 * Retrieves the background layer, or returns an empty string if no background
		 * was supplied.
		 *
		 * @param selector {String} The CSS selector for the element
		 * @return {String} The source of the background layer
		 */
		getBackgroundSrc: function(selector)
		{
			var s = this.getState(selector);
			var layers = s.layers.split(",");
			return (layers.length == 2 ? layers[0] : "");
		},

		/**
		 * Convenience method for working with a two layer image foreground.
		 * Retrieves the foreground layer.
		 *
		 * @param selector {String} The CSS selector for the element
		 * @return {String} The source of the foreground layer
		 */
		getImageSrc: function(selector)
		{
			var s = this.getState(selector);
			var layers = s.layers.split(",");
			return (layers.length == 2 ? layers[1] : layers[0]);
		},

		/**
		 * Get the src for the layer number specified.
		 *
		 * @param selector {String} The CSS selector for the element
		 * @return {String} The image source for the layer specified
		 */
		getLayerSrc: function(selector, layer)
		{
			var s = this.getState(selector);
			return s.layers.split(",")[layer];
		},

		/**
		 * Set a layer's src based on the layer number.
		 *
		 * @param selector {String} The CSS selector for the element
		 * @param layer {number} The layer number to set
		 * @param newImage {String} The name of the new image (without the path)
		 */
		setLayerSrc: function(selector, layer, newImage)
		{

			//if (newImage.indexOf(".") != -1)
			//{
				// Remove any extension information
			//	newImage = newImage.substring(0, newImage.indexOf("."));
			//}

			var s = this.getState(selector);
			var oldSrc = $(selector).widgetChild("img").attr("src");
			var layerSrc = s.layers.split(",")[layer];
            var temp = oldSrc.substring(oldSrc.lastIndexOf("/")+1,oldSrc.length);
            var newSrc = oldSrc.replace(temp, newImage);

			// Replace the layer in the stored layers
			var stack = s.layers.split(",");
			stack[layer] = newImage;
			s.layers = stack.join(",");
			// Swap the layer's image
			$(selector).widgetChild("img").attr("src", newSrc);
		},

		/**
		 * Set a layer's src based on the image src in the layer.  The
		 * old image should exist in one of the layers of the image.  As
		 * long as it does, it will be replaced with the new image.  With this
		 * method you don't need to know what layer the image source is specified
		 * for, only the source itself.
		 *
		 * @param selector {String} The CSS selector for the element
		 * @param oldImage {String} The name of the old image (without the path)
		 * @param newImage {String} The name of the new image (without the path)
		 */
		setImageSrc: function(selector, oldImage, newImage)
		{
			// Figure out which layer is the old image
			var s = this.getState(selector);
			var layers = s.layers.split(",");
			for (var i in layers)
			{
				if (oldImage == layers[i])
				{
					this.setLayerSrc(selector, parseInt(i), newImage);
					break;
				}
			}
		},

		/**
		 * Set the size of the image.
		 *
		 * @param selector {String} The CSS selector for the element
		 * @param width {Number} The new width of the image, in pixels
		 * @param height {Number} The new height of the image, in pixels
		 */
		setImageSize: function(selector, width, height)
		{
			// This works for simple one-layer Scene7 urls only!
			var img = $("img", selector);
			var src = img.attr("src")
					.replace(/wid=[0-9]+/g, "wid=" + width)
					.replace(/hei=[0-9]+/g, "hei=" + height)
					.replace(/size=[0-9,\.]+/g, "size=" + width + "," + height);
			img.attr("width", width).attr("height", height).attr("src", src);
		},

		/**
		 * Get the widget class name.  Every widget in the DOM has an associated
		 * widget class.  Access the class with the <tt>widgetClass()</tt> method.
		 *
		 * @return {String} The string "ImageWidget"
		 */
		getWidgetClassName: function()
		{
			return "ImageWidget";
		}
	});
}
;
         if (typeof sj_resource == "undefined")
         {
            var sj = {};
            // The "code path" where we'll find the "spacer.gif" image
            sj.path = '/assets/oneill/assets/motif/ocpsdk/generic/scene7/';

            var sj_resource = new Object();
            sj_resource.getResource  = function(inString){
               var res = inString;
               for (var key in this) {
                  if (typeof key == 'string') {
                     var old;
                     do {
                        old = res;
                        res = res.replace('%' + key + '%', this[key]);
                     } while (old != res);
                  }
               }

               return res;
            };
         }
      /*
ADOBE CONFIDENTIAL
Copyright 2005 Adobe Systems Incorporated
All Rights Reserved.

NOTICE:  All information contained herein is, and remains the property of Adobe Systems Incorporated and its suppliers,
if any.  The intellectual and technical concepts contained herein are proprietary to Adobe Systems Incorporated and its
suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret or 
copyright law. Dissemination of this information or reproduction of this material is strictly forbidden unless prior 
written permission is obtained from Adobe Systems Incorporated.
*/

if (typeof S7ConfigMain == "undefined") {

   var S7ConfigMain = {};

   var S7ConfigObject = function(inVersion,inViewerRoot,inRoot)
   {
      this.isVersion		= inVersion || "2.8";
      this.isViewerRoot	= inViewerRoot || "/is-viewers";
      this.isRoot		= inRoot || "/is/image/";
   };

   var S7Config		= new S7ConfigObject();

   var sjroot		= S7Config.isViewerRoot;
   var sjimageServer	= S7Config.isRoot;

}
;/*
ADOBE CONFIDENTIAL
Copyright 2005 Adobe Systems Incorporated
All Rights Reserved.

NOTICE:  All information contained herein is, and remains the property of Adobe Systems Incorporated and its suppliers,
if any.  The intellectual and technical concepts contained herein are proprietary to Adobe Systems Incorporated and its
suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret or 
copyright law. Dissemination of this information or reproduction of this material is strictly forbidden unless prior 
written permission is obtained from Adobe Systems Incorporated.
*/

if (typeof S7Browser == "undefined") {

   var S7Browser = {};

   function SjDetectBrowser() {
      var ua = navigator.userAgent.toLowerCase();

      // browser engine name
      this.isGecko       = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
      this.isAppleWebKit = (ua.indexOf('applewebkit') != -1);

      // browser name
      this.isKonqueror   = (ua.indexOf('konqueror') != -1);
      this.isWebTV       = (ua.indexOf('webtv') != -1);
      this.isSafari      = (ua.indexOf('safari') != - 1);
      this.isOmniweb     = (ua.indexOf('omniweb') != - 1);
      this.isOpera       = (ua.indexOf('opera') != -1);
      this.isIcab        = (ua.indexOf('icab') != -1);
      this.isAol         = (ua.indexOf('aol') != -1);
      this.isIE          = (ua.indexOf('msie') != -1 && !this.isOpera && (ua.indexOf('webtv') == -1) );
      this.isMozilla     = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
      this.isFirebird    = (ua.indexOf('firebird/') != -1);
      this.isNS          = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) :
                           ( (ua.indexOf('mozilla') != -1) &&
               !this.isOpera &&
               !this.isSafari &&
               (ua.indexOf('spoofer') == -1)
               && (ua.indexOf('compatible') == -1)
               && (ua.indexOf('webtv') == -1)
               && (ua.indexOf('hotjava') == -1) ) );

      // spoofing and compatible browsers
      this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
      this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);

      // rendering engine versions
      this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
      this.equivalentMozilla = ( (this.isGecko) ? parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) ) : -1 );
      this.appleWebKitVersion = ( (this.isAppleWebKit) ? parseFloat( ua.substring( ua.indexOf('applewebkit/') + 12) ) : -1 );

      // browser version
      this.versionMinor = parseFloat(navigator.appVersion);

      // correct version number
      if (this.isGecko && !this.isMozilla) {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('/', ua.indexOf('gecko/') + 6) + 1 ) );
      }
      else if (this.isMozilla) {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
      }
      else if (this.isIE && this.versionMinor >= 4) {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
      }
      else if (this.isKonqueror) {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
      }
      else if (this.isSafari) {
         this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('safari/') + 7 ) );
      }
      else if (this.isOmniweb) {
         this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('omniweb/') + 8 ) );
      }
      else if (this.isOpera) {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera') + 6 ) );
      }
      else if (this.isIcab) {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab') + 5 ) );
      }

      this.versionMajor = parseInt(this.versionMinor);

      // dom support
      this.isDOM1 = (document.getElementById);
      this.isDOM2Event = (document.addEventListener && document.removeEventListener);

      // css compatibility mode
      this.mode = document.compatMode ? document.compatMode : 'BackCompat';

      // platform
      this.isWin    = (ua.indexOf('win') != -1);
      this.isWin32  = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
      this.isMac    = (ua.indexOf('mac') != -1);
      this.isUnix   = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1);
      this.isLinux  = (ua.indexOf('linux') != -1);

      // specific browser shortcuts
      this.isNS4x = (this.isNS && this.versionMajor == 4);
      this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
      this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
      this.isNS4up = (this.isNS && this.versionMinor >= 4);
      this.isNS6x = (this.isNS && this.versionMajor == 6);
      this.isNS6up = (this.isNS && this.versionMajor >= 6);
      this.isNS7x = (this.isNS && this.versionMajor == 7);
      this.isNS7up = (this.isNS && this.versionMajor >= 7);

      this.isIE4x = (this.isIE && this.versionMajor == 4);
      this.isIE4up = (this.isIE && this.versionMajor >= 4);
      this.isIE5x = (this.isIE && this.versionMajor == 5);
      this.isIE55 = (this.isIE && this.versionMinor == 5.5);
      this.isIE5up = (this.isIE && this.versionMajor >= 5);
      this.isIE6x = (this.isIE && this.versionMajor == 6);
      this.isIE6up = (this.isIE && this.versionMajor >= 6);

      this.isIE4xMac = (this.isIE4x && this.isMac);

      this.hasAll					= (document.all)		     ? true : false;	// document.all
      this.hasAnchors				= (document.anchors)		 ? true : false;	// document.anchors
      this.hasCookies				= (document.cookie)			 ? true : false;	// cookies enabled
      this.hasDocumentElement		= (document.documentElement) ? true : false;	// document.documentElement
      this.hasForms				= (document.forms)			 ? true : false;	// document.forms
      this.hasFrames	   			= (window.frames)			 ? true : false;	// window.frames
      this.hasGetElementById  		= (document.getElementById)	 ? true : false;	// document.getElementById
      this.hasGetElementsByTagName	= (document.getElementsByTagName) ? true : false;	// document.getElementsByTagName
      this.hasImages	   			= (document.images)			 ? true : false;	// document.images
      this.hasJava		   			= navigator.javaEnabled();						// Java enabled
      this.hasLayers	   			= (document.layers)			 ? true : false;	// document.layers
      this.hasLinks	   			= (document.links)		     ? true : false;	// document.links
      this.hasOption	   			= (window.Option)		     ? true : false;	// window.Option
      this.hasRegexp	   			= (window.RegExp)		     ? true : false;	// window.RegExp
      this.hasScreen	   			= (window.screen)		     ? true : false;	// window.screen

   }

   // utility function called by getCookie( )
   SjDetectBrowser.prototype.getCookieVal=function(offset){
      var endstr = document.cookie.indexOf (";", offset);
       if (endstr == -1) {
           endstr = document.cookie.length;
       }
       return unescape(document.cookie.substring(offset, endstr));
   };

   SjDetectBrowser.prototype.fixCookieDate=function(date){
      var base=new Date(0);
      var skew=base.getTime();
      if(skew>0)date.setTime(date.getTime()-skew);
   };

   // primary function to retrieve cookie by name
   SjDetectBrowser.prototype.getCookie=function(name){
     var arg = name + "=";
       var alen = arg.length;
       var clen = document.cookie.length;
       var i = 0;
       while (i < clen) {
           var j = i + alen;
           if (document.cookie.substring(i, j) == arg) {
               return this.getCookieVal(j);
           }
           i = document.cookie.indexOf(" ", i) + 1;
           if (i == 0) break;
       }
       return "";
   };

   // store cookie value with optional details as needed
   SjDetectBrowser.prototype.setCookie=function (name,value,expires,path,domain,secure){
      document.cookie = name + "=" + escape (value) +
           ((expires) ? "; expires=" + expires : "") +
           ((path) ? "; path=" + path : "") +
           ((domain) ? "; domain=" + domain : "") +
           ((secure) ? "; secure" : "");
   };

   // remove the cookie by setting ancient expiration date
   SjDetectBrowser.prototype.deleteCookie=function (name,path,domain){
       if (this.getCookie(name)) {
           document.cookie = name + "=" +
               ((path) ? "; path=" + path : "") +
               ((domain) ? "; domain=" + domain : "") +
               "; expires=Thu, 01-Jan-70 00:00:01 GMT";
       }
   };

   var sjIS = new SjDetectBrowser();
   var sjDetectBrowserIncluded = true;
};/*
ADOBE CONFIDENTIAL
Copyright 2005 Adobe Systems Incorporated
All Rights Reserved.

NOTICE:  All information contained herein is, and remains the property of Adobe Systems Incorporated and its suppliers,
if any.  The intellectual and technical concepts contained herein are proprietary to Adobe Systems Incorporated and its
suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret or 
copyright law. Dissemination of this information or reproduction of this material is strictly forbidden unless prior 
written permission is obtained from Adobe Systems Incorporated.
*/

if (typeof S7Core == "undefined") {

   var S7Core = {};

   if(Array.prototype.push && ([0].push(true)==true))
      Array.prototype.push = null;

   if(!Array.prototype.push) {
      function array_push() {
         for(var i=0;i<arguments.length;i++){
            this[this.length]=arguments[i];
         };
         return this.length;
      }
      Array.prototype.push = array_push;
   }

   if(!Array.prototype.pop) {
      function array_pop(){
          lastElement = this[this.length-1];
         this.length = Math.max(this.length-1,0);
          return lastElement;
      }
      Array.prototype.pop = array_pop;
   }


   String.prototype.doubleNewlines = function() {
      return this.replace( /(\r?\n|\r){1,2}/g, '\n\n' );
   };

   function sjPBreak(str) {
      return( (str.indexOf("?")>=0?"&":"?") );
   };

   sjDelimList = [' ', '\n', '\r'];

   function sjGetKeyValue(inS, inKey) {
      var keyIdx = inS.indexOf(inKey);
      if (keyIdx == -1) {
         return null;
      }
      var eqIdx = inS.indexOf('=', keyIdx + inKey.length);
      if (eqIdx == -1) {
         return null;
      }
      var valStartIdx = eqIdx + 1;
      while ((valEndIdx < inS.length) && (inS.charAt(valStartIdx) == ' ')) {
         valStartIdx ++;
      }
      if (valStartIdx >= inS.length - 1) {
         return null;
      }
      var valEndIdx = valStartIdx + 1;
      while ((valEndIdx < inS.length) && !sjIsLineDelim(inS.charAt(valEndIdx))) {
         valEndIdx ++;
      }
      return inS.substring(valStartIdx+1, valEndIdx);
   };

   function sjIsLineDelim(inChar) {
      for (var i = 0; i < sjDelimList.length; i ++) {
         if (inChar == sjDelimList[i]) {
            return true;
         }
      }
      return false;
   };

   function sjGetElement(name) {
      if(typeof(name)!='string') return name;
      if (document.getElementById)
         return document.getElementById(name);
      else if (document.all)
         return document.all[name];
      else if (document.layers)
         return document[name];
      else name=null;
      return name;
   }

   function sjGetElementDoc(name) {
      if (document.getElementById)
         return document.getElementById(name).ownerDocument;
      else if (document.all)
         return document.all[name].document;
      else if (document.layers)
         return document[name].document;
      else name=null;
      return name;
   }

   function sjGetElementStyle(name) {
      if (document.getElementById)
         return document.getElementById(name).style;
      if (document.all)
         return document.all[name].style;
      if (document.layers)
         return document[name];
   }

   function sjGetObj(name){
     if (document.getElementById){
      this.obj = document.getElementById(name);
      this.style = document.getElementById(name).style;
     }else if (document.all){
      this.obj = document.all[name];
      this.style = document.all[name].style;
     }else if (document.layers){
         this.obj = document.layers[name];
         this.style = document.layers[name];
     }
   }

   function sjGetTextContent(inNode) {
      var s = '';
      var children = inNode.childNodes;
      for(var i = 0; i < children.length; i++) {
         var child = children[i];
         if (child.nodeType == 3 /*Node.TEXT_NODE*/) s += child.data;
         else s += sjGetTextContent(child);
      }
      return s;
   }

   function sjCreateDiv(parentId,divId) {
      var parentElm = null;
         if (parentId != null)
          parentElm = sjGetElement(parentId);
      if (document.all) {
         if (parentElm == null)
           parentElm = document.body;
          parentElm.insertAdjacentHTML('afterBegin',' <div unselectable="on" id="' + divId +
                                       '" style="position:absolute;text-align:left;overflow:hidden;">'+' '+'</div> ');
      }
      else if (document.layers) {
         if (parentElm == null){
            document.layers[divId] = new Layer(0);
            } else {
            parentElm.document.layers[divId] = new Layer(0,parentElm);
            }
      }
      else if (document.getElementById) {
         if (parentElm == null)
           parentElm = document.body;
         var tempLayer = document.createElement('div');
         tempLayer.setAttribute('id',divId);
         tempLayer.setAttribute('style','position:absolute;text-align:left;overflow:hidden;');
         parentElm.appendChild(tempLayer);
      }
   }

   function sjGetWidth(name) {
      if (document.getElementById)
         return document.getElementById(name).style.width;
      if (document.all)
         return document.all[name].offsetWidth;
      if (document.layers)
         return document[name].document.width;
   }

   function sjGetHeight(name) {
      if (document.getElementById)
         return document.getElementById(name).style.height;
      if (document.all)
         return document.all[name].offsetHeight;
      if (document.layers)
         return document[name].document.height;
   }


   function sjGetX(layer) {
      layer=sjGetElementStyle(layer);
      if (document.getElementById)
         return parseInt(layer.left);
      if (document.all)
         return layer.pixelLeft;
      if (document.layers)
         return layer.x;
   }

   function sjGetY(layer) {
      layer=sjGetElementStyle(layer);
      if (document.getElementById)
         return parseInt(layer.top);
      if (document.all)
         return layer.pixelTop;
      if (document.layers)
         return layer.y;
   }

   function sjSetClip(layer,x,y,t,r,b,l) {
      layer=sjGetElementStyle(layer);
      if (document.getElementById) {
         //layer.clip='rect('+t+' '+r+' '+b+' '+l+')';
         layer.clip='rect('+t+'px '+r+'px '+b+'px '+l+'px)';
      } else if (document.all) {
         layer.clip='rect('+t+'px '+r+'px '+b+'px '+l+'px)';
         layer.pixelLeft=x;
         layer.pixelTop=y;
         layer.overflow='hidden';
      } else if (document.layers) {
         layer.clip.top=t;
         layer.clip.right=r;
         layer.clip.bottom=b;
         layer.clip.left=l;
         layer.moveTo(x,y);
      }
   }

   function sjSetWidth(layer,w) {
      layer=sjGetElementStyle(layer);
      if (document.getElementById)
         layer.width=parseInt(w)+'px';
      else if (document.all)
         layer.posWidth=parseInt(w)+'px';
      else if (layer.clip)
         layer.clip.width=w;
   }

   function sjSetHeight(layer,h) {
      layer=sjGetElementStyle(layer);
      if (document.getElementById)
         layer.height=parseInt(h)+'px';
      else if (document.all)
         layer.posHeight=parseInt(h)+'px';
      else if (layer.clip)
         layer.clip.height=h;
   }

   function sjZoomMap (inMapName, inXfactor, inYfactor) {
      if(inMapName){
        if (document.all) {
         var map = document.all[inMapName];
         if (map){
            var areas = map.all.tags('AREA');
         }
        } else if (document.getElementsByName) {
         var map = document.getElementsByName(inMapName)[0];
         if (map){
            var areas = map.getElementsByTagName('AREA');
         }
        }
        if (areas) {
         for (var a = 0; a < areas.length; a++) {
           //var coords = areas[a].getAttribute('origcoords').split(/\s*,\s*/);
           var coords = areas[a].getAttribute('coords').split(/\s*,\s*/);
           if (areas[a].getAttribute('shape').toLowerCase() == 'rect' || areas[a].getAttribute('shape').toLowerCase() == 'poly') {
            for (var p = 0; p < coords.length; p += 2) {
              coords[p] = Math.round(coords[p] * inXfactor);
              coords[p + 1] = Math.round(coords[p + 1] * inYfactor);
            }
           } else if (areas[a].getAttribute('shape').toLowerCase() == 'circle') {
            coords[0] = Math.round(coords[0] * inXfactor);
            coords[1] = Math.round(coords[1] * inYfactor);
            coords[2] = Math.round(coords[2] * (inXfactor < inYfactor ? inXfactor : inYfactor));
           }
           //areas[a].coords = coords.join(', ');
           areas[a].setAttribute('coords',coords.join(', '));
         }
        }
      }
   }

   function sjResetMap (inMapName) {
      if(inMapName){
        if (document.all) {
         var map = document.all[inMapName];
         if (map){
            var areas = map.all.tags('AREA');
         }
        } else if (document.getElementsByName) {
         var map = document.getElementsByName(inMapName)[0];
         if (map){
            var areas = map.getElementsByTagName('AREA');
         }
        }
        if (areas) {
         for (var a = 0; a < areas.length; a++) {
           var coords = areas[a].getAttribute('origcoords').split(/\s*,\s*/);
           areas[a].setAttribute('coords',coords.join(', '));
         }
        }
      }
   }

   function sjSetLayerHTML(layer,html) {
      if (navigator.userAgent.indexOf('MSIE 5.0') && navigator.userAgent.indexOf('Mac') != -1) html += '\n';
      if (document.getElementById){
         document.getElementById(layer).innerHTML=html;
      } else if (document.all) {
         layer=eval(layer);
         layer.innerHTML=html;
      } else if (document.layers) {
         var doc=sjGetElementDoc(layer);
         doc.open();
         doc.writeln(html);
         doc.close();
      }
   }

   function sjGetLayerHTML(layer) {
      if (document.getElementById){
         return document.getElementById(layer).innerHTML;
      } else if (document.all) {
         layer=eval(layer);
         return layer.innerHTML;
      }
   }

   function sjSetXY(layer,x,y) {
      layer=sjGetElementStyle(layer);
      if (document.getElementById) {
         layer.left=parseInt(x)+'px';
         layer.top=parseInt(y)+'px';
      } else if (document.all) {
         layer.pixelLeft=parseInt(x)+'px';
         layer.pixelTop=parseInt(y)+'px';
      } else if (document.layers)
         layer.moveTo(x,y);
   }

   function sjCenter(layer,y) {
      sjSetXY(layer,Math.round((width-getWidth(layer)-leftMargin-rightMargin)/2)+leftMargin,y);
   }

   function sjSetCursor(curtype) {
      var ua = navigator.userAgent.toLowerCase();
      var isIE = (ua.indexOf('msie') != -1);
      var isMAC = (ua.indexOf('mac') != -1);
      document.body.style.cursor = ((!isIE || isMAC) && curtype == 'hand')? 'pointer' : curtype;
      //if (document.all) document.body.style.cursor=curtype;
   }

   // value must be "visible", "hidden", or "inherit".
   function sjSetVisibility (layer, value){
      layer=sjGetElementStyle(layer);
      if (document.layers)
        layer.visibility = value;
      else if (layer)
        layer.visibility = value;
   }

   // return values as strings "visible", "hidden", or "inherit".
   function sjGetVisibility (layer){
      layer=sjGetElementStyle(layer);
      if (document.layers){
       var value = layer.visibility;
       if (value == "show")
         return "visible";
       else if (value == "hide")
         return "hidden";
       else return value;
      }
      else if (layer)
       return layer.visibility;
   }

   function sjGetZIndex (layer){
      layer=sjGetElementStyle(layer);
     if (document.layers)
        return(layer.zIndex);
     else if (layer)
        return (layer.zIndex);
   }

   function sjSetZIndex (layer, z){
      layer=sjGetElementStyle(layer);
      if (document.layers)
         layer.zIndex = z;
      else if (layer)
         layer.zIndex = z;
   }

   function sjSetBackColor (layer, color){
      if (color.toLowerCase() == "transparent"){
         color = "";
      }
      layer=sjGetElementStyle(layer);
      if(layer.background)
         layer.background = color;
      else if (document.layers)
         layer.bgColor = color;
      else if(document.all || document.getElementById)
         layer.backgroundColor = color;
   }

   sjSetBackImage = function (layer, imageURL) {
      layer=sjGetElementStyle(layer);
      if(layer.background)
         layer.background.src = imageURL == 'none' ? null : imageURL;
      else if (document.layers)
         layer.background.src = imageURL == 'none' ? null : imageURL;
      else if (document.all || document.getElementById)
         layer.backgroundImage = imageURL == 'none' ? 'none' : 'url(' + imageURL + ')';
   };

   function sjSetBorder (layer, width,style,color){
      stl=sjGetElementStyle(layer);
      stl.borderWidth = width + "px" || 0;
      stl.borderStyle = style || 'solid';
      stl.borderColor = color || 'black';
   }

   function sjOpacity (layer,inOpacity) {
      if (inOpacity != null) {
         stl=sjGetElementStyle(layer);
          if(inOpacity < 0) inOpacity = 0;
         if(inOpacity > 99) inOpacity = 99;
         stl.opacity = (inOpacity / 100);
         stl.MozOpacity = (inOpacity / 100);
         stl.KhtmlOpacity = (inOpacity / 100);
         stl.filter = "alpha(opacity=" + inOpacity + ")";
         return stl.opacity;
      }
   }

   function sjGetMouseXY(e){
     var mousePos = {x: 0, y: 0};
      if (document.all) {
         mousePos.x = event.clientX + document.body.scrollLeft;
          mousePos.y = event.clientY + document.body.scrollTop;
      } else {
           mousePos.x = e.pageX;
             mousePos.y = e.pageY;
      }
     return mousePos;
   }

   function sjGetPageCoords (element) {
     var coords = {x: 0, y: 0};
     while (element) {
       coords.x += element.offsetLeft;
       coords.y += element.offsetTop;
       element = element.offsetParent;
     }
     return coords;
   }

   function sjGetOffsets (evt) {
    if(evt){
     if (typeof evt.offsetX != 'undefined')
       return { x: evt.offsetX, y: evt.offsetY };
     else if (evt.target) {
       if (window.opera)
         var element = evt.target;
       else
         var element = evt.target.nodeType == 1 ? evt.target : evt.target.parentNode;
       var eventCoords = {
         x: evt.clientX + window.pageXOffset,
         y: evt.clientY + window.pageYOffset
       };
       var elCoords = sjGetPageCoords(element);
       return {x: eventCoords.x - elCoords.x, y: eventCoords.y - elCoords.y};
     }
    }
   }


   function sjAddObjectEvent(inObject, evType, handler, useCapture){
    var  inObject = sjGetElement(inObject.getElementId());
     if (inObject.addEventListener){
         inObject.addEventListener(evType, handler, useCapture);
       return true;
     } else if (inObject.attachEvent){
       var res = inObject.attachEvent("on"+evType, handler);
       return res;
     } else {
         //alert("Handler could not be attached");
         alert(sj_resource.getResource('%HANDLER_COULD_NOT_BE_ATTACHED%'));
     }
   }

   function sjRemoveObjEvent(inObject, evType, handler, useCapture){
    var  inObject = sjGetElement(inObject.getElementId());
     if (inObject.removeEventListener){
         inObject.removeEventListener(evType, handler, useCapture);
       return true;
     } else if (inObject.detachEvent){
       var res = inObject.detachEvent("on"+evType, handler);
       return res;
     } else {
         //alert("Handler could not be removed");
         alert(sj_resource.getResource('%HANDLER_COULD_NOT_BE_REMOVED%'));
     }
   }

   // usage :
   //   addKeyHandler(document.body);
   //     document.body.addKeyPress(32, function(){alert("You pressed Space");});
   //or  document.body.addKeyDown(65, function(){alert('a pressed');})
   //    document.body.removeKeyDown(65)
   //or var counter = 0;
   //   function increaseCounter() {
   //     window.status = "counter = " + counter++;
   //   }
   //
   //   document.body.addKeyPress(13, increaseCounter);document.body.addKeyPress(13, increaseCounter);
   // or document.body.addKeyDown(67, function() {if (window.event.ctrlKey) alert("CTRL + C");});
   // or
   //	var w, q;
   //	document.body.addKeyDown(81, function() {q = true; if (q && w) window.status = "q and w is pressed";});
   //	document.body.addKeyUp(81, function() {q = false; window.status = "";});
   //	document.body.addKeyDown(87, function() {w = true; if (q && w) window.status = "q and w is pressed";});
   //	document.body.addKeyUp(87, function() {w = false; window.status = "";});
   sjAddKeyHandler = function sjAddKeyHandler(element) {
      element._keyObject = new Array();
      element._keyObject["keydown"] = new Array();
      element._keyObject["keyup"] = new Array();
      element._keyObject["keypress"] = new Array();

      element.addKeyDown = function (keyCode, action) {
         element._keyObject["keydown"][keyCode] = action;
      };

      element.removeKeyDown = function (keyCode) {
         element._keyObject["keydown"][keyCode] = null;
      };

      element.addKeyUp = function (keyCode, action) {
         element._keyObject["keyup"][keyCode] = action;
      };

      element.removeKeyUp = function (keyCode) {
         element._keyObject["keyup"][keyCode] = null;
      };

      element.addKeyPress = function (keyCode, action) {
         element._keyObject["keypress"][keyCode] = action;
      };

      element.removeKeyPress = function (keyCode) {
         element._keyObject["keypress"][keyCode] = null;
      };

      function handleEvent() {
         var type = window.event.type;
         var code = window.event.keyCode;

         if (element._keyObject[type][code] != null)
            element._keyObject[type][code]();
      };

      element.onkeypress = handleEvent;
      element.onkeydown = handleEvent;
      element.onkeyup = handleEvent;
   };

   /////////////
   function sjGetKey(obj,evt) {
      var key=document.all?event.keyCode:
         evt.keyCode?evt.keyCode:
         evt.charCode?evt.charCode:
         evt.which?evt.which:void 0;
     return key;
   };

   /////////////
   //	reading the scrollBars width (depending on the OS settings).
   function getScrollBarWidth (){
      try{
         var elem = document.createElement("DIV");
         elem.id = "asdf";
         elem.style.width = 100;
         elem.style.height = 100;
         elem.style.overflow = "scroll";
         elem.style.position = "absolute";
         elem.style.visibility = "hidden";
         elem.style.top = "0";
         elem.style.left = "0";
         document.body.appendChild (elem);
         scrollWidth = sjGetElement('asdf').offsetWidth - sjGetElement('asdf').clientWidth;
         document.body.removeChild (elem);
         delete elem;
      }catch (ex){
         return false;
      }
      return scrollWidth;
   };
   ///////////
   function getRowIndex (cell) {
     return document.all ? cell.parentElement.rowIndex : cell.parentNode.rowIndex;
   };

};/*
ADOBE CONFIDENTIAL
Copyright 2005 Adobe Systems Incorporated
All Rights Reserved.

NOTICE:  All information contained herein is, and remains the property of Adobe Systems Incorporated and its suppliers,
if any.  The intellectual and technical concepts contained herein are proprietary to Adobe Systems Incorporated and its
suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret or 
copyright law. Dissemination of this information or reproduction of this material is strictly forbidden unless prior 
written permission is obtained from Adobe Systems Incorporated.
*/

if (typeof S7TextLoader == "undefined") {

   var S7TextLoader = {};

   var SjTextLoader = function() {
      this._id = SjTextLoader._cnt ++;
      this.req = null;
      this.tid=null;
      this.text=null;
      this.IFrameDoc=null;
      this.first = false;
      this.json = false;
      this.counter = 0;
      SjTextLoader.all[this._id] = this;
      if( document.childNodes && document.createElement ) {
         sjCreateDiv(null,"datadiv"+this._id);
         var dname="datadiv"+this._id;
         var lname="loader"+this._id;
         var str=' <div id='+dname+' style="position:absolute;visibility:hidden"><iframe src="about:blank" id='+lname+' name='+lname+' onload=""></iframe> </div> ';
         sjSetLayerHTML("datadiv"+this._id,str);
      }
   };

   SjTextLoader.prototype.load = function(inURL,firstLoading) {
      if (inURL.indexOf("json") >= 0){
         this.json = true;
         tljson = this;
         //inURL = inURL.substring(inURL.indexOf(S7Config.isRoot)+S7Config.isRoot.length,inURL.indexOf("?"));
         loadCtx(tljson,inURL);
         this.counter = 0;
         clearInterval(this.tid);
      }else{
         this.json = false;
         if (!firstLoading){
            if (window.XMLHttpRequest) {//native XMLHttpRequest object
               this.req = new XMLHttpRequest();
               eval('this.req.onreadystatechange = function() { SjTextLoader.all[' + this._id + ']._onLoadText(); }');
               this.req.open("GET", inURL, true);
               this.req.send(null);
            }/* else if ((window.ActiveXObject) &&
                     (!(navigator.userAgent.indexOf('MSIE 5.0') &&
                        navigator.userAgent.indexOf('Mac') != -1))){//IE/Windows ActiveX version
               this.req = new ActiveXObject("Microsoft.XMLHTTP");
               if (this.req) {
                  eval('this.req.onreadystatechange = function() { SjTextLoader.all[' + this._id + ']._onLoadText(); }');
                  this.req.open("GET", inURL, true);
                  this.req.send();
               }
            }*/ else {
               var elm=sjGetElement("loader" + this._id);
               if (elm){
                  if (typeof elm.src != 'undefined')
                     elm.src = inURL;
                  else if (typeof elm.location != 'undefined')
                     elm.location = inURL;
                  this.tid=setInterval(this+'.checkLoad()', 100);
               }
            }
         }else{
            image = new Object;
            metadata = new Object;//for future
            protocol = new Object;//for future
            context = new Object;//for future
            this.first = true;
            document.write("<script language='javascript' src='" + inURL+  ",javascript'></" + "script>");
            this.tid=setInterval(this+'.checkLoad()', 100);
         }
      }
   };

   SjTextLoader.prototype._onLoadText = function() {
      if (this.req.readyState == 4) {//"loaded";0 = uninitialized 1 = loading 2 = loaded 3 = interactive 4 = complete
         if (this.req.status == 200) {//"OK" Numeric code returned by server, such as 404 for "Not Found" or 200 for "OK"
            this.text = this.req.responseText;
            if (this.onLoadText){
               this.onLoadText();
            }
           } else {
               //alert("There was a problem retrieving data:\n" + this.req.statusText);
               alert(sj_resource.getResource("%THERE_WAS_A_PROBLEM_RETRIEVING_DATA%:\n") + this.req.statusText);
           }
       }
   };

   function dumpProps(obj,obj_name) {
      var str = "", i ="";
      for (i in obj)
      str += obj_name +"."+ i +" = "+ obj[i] +"\n";
      return str;
   }

   SjTextLoader.prototype.checkLoad = function() {
      if (this.first == true){
         if (image.rect) {
            this.text = dumpProps(image,"image");
            if (metadata){
               this.text += dumpProps(metadata,"metadata");
            }
            if (protocol){
               this.text += dumpProps(protocol,"protocol");
            }
            if (context){
               this.text += dumpProps(context,"context");
            }
            if (this.onLoadText){
               this.onLoadText();
            }
            this.counter = 0;
            clearInterval(this.tid);
         }else{
            if (this.counter < 100){
               this.counter++;
               //window.status = 'Loading context...'+this.counter+' attempt.';
            }else{
               //window.status = 'Error loading context!';
               //alert('Error loading context!');
               alert(sj_resource.getResource('%ERROR_LOADING_CONTEXT%!'));
               this.counter = 0;
               clearInterval(this.tid);
            }
         }
      }else{
         var elm=sjGetElement("loader" + this._id);
         if (elm != null)
         if(document.frames){
          if(document.frames[elm.name]) { this.IFrameDoc=document.frames[elm.name].document; } // For IE5
         }else if (elm.contentDocument) { this.IFrameDoc=elm.contentDocument; } //For NS6
          else if (elm.contentWindow) { this.IFrameDoc=elm.contentWindow.document; } //For IE5.5
         else{
            //alert('Problems.....');
            alert(sj_resource.getResource('%PROBLEMS%.....'));
            clearInterval(this.tid);
            return true;
         }
         var inf = sjGetTextContent(this.IFrameDoc);
         if (inf){
            this.text = inf;
            if (this.onLoadText){
               this.onLoadText();
            }
            clearInterval(this.tid);
         }
      }
   };

   SjTextLoader.prototype.clearText = function(txt) {
      var testText = txt;
      if ((testText != null) && (testText != '')) {
          var result = testText;
          var teg=testText.substring(testText.indexOf("<"),testText.indexOf(">")+1);
         var idx = testText.indexOf(teg);
         while (idx != -1) {
            result = result.substring(0, idx) + '' + result.substring(idx + teg.length);
            testText=result;
             idx=-1;
            teg=testText.substring(testText.indexOf("<"),testText.indexOf(">")+1);
            if (teg!=''){
              idx = testText.indexOf(teg);
             result=testText;
            }
         }

         testText=testText.replace("&lt;","<");
         testText=testText.replace("&gt;",">");
         this.text = testText;
      }
      return this.text;
   };

   SjTextLoader.prototype.toString = function() {
      return 'SjTextLoader.all[' + this._id + ']';
   };

   SjTextLoader.all = [];
   SjTextLoader._cnt = 0;

   //private functions and variables
   var sjCallbacks=new Object();//!global variable MUST be created !
   var sjErrCallbacks=new Object();//!global variable MUST be created !

   function sjGetResponse(inReq, inImg, inCallback, inErrCallback) {
      var urljson = "";
      var tempi = inImg.indexOf("?");
      if(tempi >= 0){
         urljson = inImg + '&' + inReq;
      }else{
         urljson = inImg + '?' + inReq;
      }
      var id = sjHashCode(urljson);
      urljson += '&id=' + id;
      if (typeof inCallback != 'undefined'){
         sjCallbacks[id] = inCallback;
      }
      if (typeof inErrCallback != 'undefined'){
         sjErrCallbacks[id] = inErrCallback;
      }
       var oScript = document.getElementById('sjScript_'+id);
       if (oScript) {
         document.getElementsByTagName("head")[0].removeChild(oScript);
      }
       oScript = document.createElement('script');
      oScript.type = 'text/javascript';
      oScript.id= 'sjScript_'+id;
       oScript.src= urljson;
      if (typeof oScript!="undefined"){
         document.getElementsByTagName("head")[0].appendChild(oScript);
      }
   }

   function s7jsonResponse(inArg, inId) {
      inId = decodeURIComponent(inId);
      sjCallbacks[inId](inArg);
   }

   function s7jsonError(inArg, inId) {
      inId = decodeURIComponent(inId);
      if (typeof sjErrCallbacks[inId] != 'undefined'){
         sjErrCallbacks[inId](inArg);
      }else{
         alert(inArg.message);
      }
   }

   function sjDebug(inPsResponse, inJsonResponse, inPsResponseParserName, inPsRequest) {
   }

   function sjHashCode(d) {//unix style
      if (!d || d=="") return 1;
      var h=0,g=0;
      for (var i=d.length-1;i>=0;i--) {
         var c=parseInt(d.charCodeAt(i));
         h=((h << 6) & 0xfffffff) + c + (c << 14);
         if ((g=h & 0xfe00000)!=0) h=(h ^ (g >> 21));
      }
      return h;
   }

   function loadCtx(tl,inURL) {
      sjGetResponse(
         'req=ctx,json&scl=1',
         inURL,
         function(inArg) {
            tl.text = dumpProps(inArg,"");
            if (tl.onLoadText){
               tl.onLoadText();
            }
         },
         function(inArg) {
            alert('failed loading ctx for image [' + inURL + ']: ' + inArg.message);
         }
      );
   }

   function addAreaToMAp(inMap,inShape,inCoords, inHREF,inAlt) {
       var oMap = document.getElementById(inMap);
      if (typeof oMap != "undefined"){
         var oArea = document.createElement('area');
         oArea.shape = inShape;
         oArea.coords = inCoords;
         oArea.href = inHREF;
         oArea.alt = inAlt;
         oArea.title = inAlt;
         oArea.setAttribute("origcoords",oArea.coords);
         if (typeof oArea != "undefined"){
            oMap.appendChild(oArea);
         }
      }
   }

   function loadMap(inImage,inSclX,inSclY,inId) {
      sjGetResponse(
         'req=map,json&scl=1',
         inImage,
         function(inArg) {
            var oMap = document.getElementById("s7map_"+inId);
            if (inArg != null) {
                  if ((typeof oMap != "undefined")&&(oMap != null)){
                     for (var k = oMap.childNodes.length-1; k >= 0 ; k--) {
                        oMap.removeChild(oMap.childNodes[k]);
                     }
                     for (var i = 0; i < inArg.length; i ++) {
                        addAreaToMAp("s7map_"+inId,inArg[i].shape,inArg[i].coords,inArg[i].href,inArg[i].alt);
                     }
                     sjResetMap("s7map_"+inId);
                     sjZoomMap ("s7map_"+inId,inSclX,inSclY);
                  }
               } else {
                  if (typeof oMap != "undefined"){
                     for (var k = oMap.childNodes.length-1; k >= 0 ; k--) {
                        oMap.removeChild(oMap.childNodes[k]);
                     }
                  }
               }
         },
         function(inArg) {
            alert('failed loading map for image [' + inImage + ']: ' + inArg.message);
         }
      );
   }
};/*
ADOBE CONFIDENTIAL
Copyright 2005 Adobe Systems Incorporated
All Rights Reserved.

NOTICE:  All information contained herein is, and remains the property of Adobe Systems Incorporated and its suppliers,
if any.  The intellectual and technical concepts contained herein are proprietary to Adobe Systems Incorporated and its
suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret or 
copyright law. Dissemination of this information or reproduction of this material is strictly forbidden unless prior 
written permission is obtained from Adobe Systems Incorporated.
*/

if (typeof S7Hashtable == "undefined") {

   var S7Hashtable = {};

   //String key, Object value
   var SjHashtable = function(){
       this.hashtable = new Array();
   };

   SjHashtable.prototype.clear = function (){
       this.hashtable = new Array();
      for (var key in this.hashtable){
         this.remove(key);
      }
   };

   SjHashtable.prototype.containsKey = function(key){
       var exists = false;
       for (var i in this.hashtable) {
           if (i == key && this.hashtable[i] != null) {
               exists = true;
               break;
           }
       }
       return exists;
   };

   SjHashtable.prototype.indexOfKey = function(key){
      var result = -1;
       var exists = false;
       for (var i in this.hashtable) {
         result++;
         if (i == key){
            if( this.hashtable[i] != null) {
               exists = true;
               break;
            }
           }
       }
       return exists ? result:-1;
   };

   SjHashtable.prototype.containsValue = function(value){
       var contains = false;
       if (value != null) {
           for (var i in this.hashtable) {
               if (this.hashtable[i] == value) {
                   contains = true;
                   break;
               }
           }
       }
       return contains;
   };

   SjHashtable.prototype.indexOfValue = function(value){
      var result = -1;
      var contains = false;
       if (value != null) {
           for (var i in this.hashtable) {
            result++;
               if (this.hashtable[i] == value) {
                   contains = true;
                   break;
               }
           }
       }
       return contains ? result : -1;
   };

   SjHashtable.prototype.get = function(key){
       return this.hashtable[key];
   };

   SjHashtable.prototype.isEmpty = function(){
       return (this.size == 0) ? true : false;
   };

   SjHashtable.prototype.keys = function(){
       var keys = new Array();
       for (var i in this.hashtable) {
           if (this.hashtable[i] != null)
               keys.push(i);
       }
       return keys;
   };

   SjHashtable.prototype.put = function(key, value){
       if (key == null || value == null) {
           throw "NullPointerException {" + key + "},{" + value + "}";
       }else{
           this.hashtable[key] = value;
       }
   };

   SjHashtable.prototype.remove = function(key){
       var rtn = this.hashtable[key];
       this.hashtable[key] = null;
       return rtn;
   };

   SjHashtable.prototype.size = function(){
       var size = 0;
       for (var i in this.hashtable){
           if (this.hashtable[i] != null)
               size ++;
       }
       return size;
   };

   SjHashtable.prototype.toString = function(){
       var result = "";
       for (var i in this.hashtable){
           if (this.hashtable[i] != null)
               result += "{" + i + "},{" + this.hashtable[i] + "}\n";
       }
       return result;
   };

   SjHashtable.prototype.values = function(){
       var values = new Array();
       for (var i in this.hashtable) {
           if (this.hashtable[i] != null)
               values.push(this.hashtable[i]);
       }
       return values;
   };

};/*
ADOBE CONFIDENTIAL
Copyright 2005 Adobe Systems Incorporated
All Rights Reserved.

NOTICE:  All information contained herein is, and remains the property of Adobe Systems Incorporated and its suppliers,
if any.  The intellectual and technical concepts contained herein are proprietary to Adobe Systems Incorporated and its
suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret or 
copyright law. Dissemination of this information or reproduction of this material is strictly forbidden unless prior 
written permission is obtained from Adobe Systems Incorporated.
*/
if (typeof S7Element == "undefined") {
   var S7Element = {};

   var SjElement = function(inParent, inElementId) {
      if (arguments[0] == 'empty') {
         return;
      }
       this._parent = inParent || self;
       this.window = (inParent && inParent.window) || self;
       this.document = (inParent && inParent.document) || self.document;
      this.name=this._elementId = inElementId || 'SjElement'+parseInt(SjElement.Count++);
       this.tag = null;
      this._x = 0;
      this._y = 0;
      this._z = 0;
      this._width = 0;
      this._height = 0;
      this._visible = false;
      this._opacity = 100;
      this._fadeTime = 2000;
      this._color = '';
      this._backColor = '';
      this._backImage = '';
      this._fadeid = null;
      this._content = sjGetElement(this._elementId);
      if (this._content){
         this._content._draggable = false;
      }
      SjElement.all[this._elementId] = this;
   };

   SjElement.prototype.getParent = function() {
      return this._parent;
   };

   SjElement.prototype.getElementId = function() {
      return this._elementId;
   };

   SjElement.prototype.getElement = function() {
      return sjGetElement(this._elementId);
   };

   SjElement.prototype.toString = function () {
      return 	'SjElement.all["'+this._elementId+'"]';
   };

   SjElement.prototype.visible = function(inVisible) {
      var the_element = sjGetElementStyle(this._elementId);
      if (inVisible != null && the_element) {
         this._visible = inVisible;
         if (inVisible) {
            //the_element.visibility = 'visible';
            the_element.visibility = 'inherit';
         } else {
            the_element.visibility = 'hidden';
         }
      }
      return this._visible;
   };

   SjElement.prototype.pageXY = function() {
         return sjGetPageCoords (sjGetElement(this._elementId));
   };

   SjElement.prototype.left = function(inX) {
      if (inX == null) {
         return this._x;
      } else {
      if (document.getElementById) {
         this._content.style.left=parseInt(inX)+'px';
      } else if (document.all) {
         this._content.style.pixelLeft=parseInt(inX)+'px';
      } else if (document.layers)
         this._content.moveTo(parseInt(inX),parseInt(inY));
         this._x = parseInt(inX);
         return this._x;
      }
   };

   SjElement.prototype.top = function (inY) {
      if (inY == null) {
         return this._y;
      } else {
      if (document.getElementById) {
         this._content.style.top=parseInt(inY)+'px';
      } else if (document.all) {
         this._content.style.pixelTop=parseInt(inY)+'px';
      } else if (document.layers)
         this._content.moveTo(parseInt(inX),parseInt(inY));
         this._y = parseInt(inY);
         return this._y;
      }
   };

   SjElement.prototype.toXY = function(inX,inY) {
      var xy={x:this.left(inX),y:this.top(inY)};
      this.fireEvent('setXY');
      return xy;
   };

   SjElement.prototype.width = function (inWidth) {
      if (inWidth == null) {
         return this._width;
      } else {
         if (document.getElementById)
           this._content.style.width=inWidth+'px';
         else if (document.all)
           this._content.style.posWidth=inWidth+'px';
         else if (layer.clip)
           this._content.clip.width=inWidth;
         this._width = inWidth;
         return this._width;
      }
   };

   SjElement.prototype.height = function (inHeight) {
      if (inHeight == null) {
         return this._height;
      } else {
         if (document.getElementById)
           this._content.style.height=inHeight+'px';
         else if (document.all)
           this._content.style.posHeight=inHeight+'px';
         else if (layer.clip)
           this._content.clip.height=inHeight;
         this._height = inHeight;
         return this._height;
      }
   };

   SjElement.prototype.setSize = function (inWidth,inHeight) {
      var size={w:this.width(inWidth),h:this.height(inHeight)};
      this.fireEvent('setSize');
      return size;
   };

   SjElement.prototype.clip = function (inLeft,inTop,inRight,inBottom) {
         var the_element = sjGetElementStyle(this._elementId);
         var bw=parseInt(the_element.borderWidth);
         if (bw){
            sjSetClip(this._elementId,this._x,this._y,inTop,inRight+2*bw,inBottom+2*bw,inLeft);
         }else{
            sjSetClip(this._elementId,this._x,this._y,inTop,inRight,inBottom,inLeft);
         }
   };

   SjElement.prototype.setBorder = function (width,style,color){
      stl=sjGetElementStyle(this._elementId);
      stl.borderWidth = width + "px" || 0;
      stl.borderStyle = style || 'solid';
      stl.borderColor = color || '#000000';
   };

   SjElement.prototype.getBorder = function (){
      stl=sjGetElementStyle(this._elementId);
      return parseInt(stl.borderWidth);
   };

   SjElement.prototype.opacity = function (inOpacity) {
      if (inOpacity != null) {
         var e = sjGetElement(this._elementId);
          if(inOpacity < 0) inOpacity = 0;
         if(inOpacity > 99) inOpacity = 99;
         e.style.opacity = (inOpacity / 100);
         e.style.MozOpacity = (inOpacity / 100);
         e.style.KhtmlOpacity = (inOpacity / 100);
         e.style.filter = "alpha(opacity=" + inOpacity + ")";
         this._opacity = inOpacity;
      }
   };

   SjElement.prototype.zIndex = function (inZ) {
      if (inZ == null) {
         return this._z;
      } else {
         sjSetZIndex(this._elementId,inZ);
         this._z = inZ;
         return sjGetZIndex(this._elementId);
      }
   };

   SjElement.prototype.setFadeTime = function(inFadeTime) {
      this._fadeTime = inFadeTime;
   };

   SjElement.prototype.fadeIn = function(inFadeTime){
       if (this._fadeid) {
         clearTimeout(this._fadeid);
         this._fadeid = null;
      }
      this._opacity=0;
      this.fadeStartTime = new Date().getTime();
      this.fadeStartOpacity = this._opacity;
      this.fadeTo(99,inFadeTime);
   };

   SjElement.prototype.fadeOut = function(inFadeTime){
       if (this._fadeid) {
         clearTimeout(this._fadeid);
         this._fadeid = null;
      }
      this._opacity=99;
      this.fadeStartTime = new Date().getTime();
      this.fadeStartOpacity = this._opacity;
      this.fadeTo(0,inFadeTime);
   };

   SjElement.prototype.fadeTo = function(inOpacity,inFadeTime){
      if(this._opacity==null) return;

      var dt = new Date().getTime() - this.fadeStartTime;
      if (dt >= inFadeTime) {
          this.opacity(inOpacity);
          this.visible((this._opacity > 0)? true:false);
         clearTimeout(this._fadeid);
         this._fadeid = null;
         if (this.afterFade){
            this.afterFade();
         }
         return;
      } else {
         var newOpacity = Math.round(this.fadeStartOpacity + (inOpacity - this.fadeStartOpacity) * dt / inFadeTime);
          this.opacity(newOpacity);
          this.visible((this._opacity > 0)? true:false);
         this._fadeid=setTimeout(this+'.fadeTo('+inOpacity+','+inFadeTime+')',5);
      }
   };

   SjElement.prototype.color = function (inColor) {
      if (inColor == null) {
         return this._color;
      } else {
         sjSetBackColor(this._elementId,inColor);
         this._color=inColor;
         return this._color;
      }
   };

   SjElement.prototype.background = function (inBackColor,inBackImage) {
       if (inBackColor)
         this._backColor = inBackColor;
       if (inBackImage)
         this._backImage = inBackImage;
   };

   //System Event
   //event{type,x,y,button,keyCode,shiftKey,ctrlKey,altKey}
   SjElement.prototype.addEventHandler = function(eventName, handler){
      var obj = this;
      var x = 0;
      var y = 0;
      this._content = sjGetElement(this._elementId);
      this._content["on"+eventName.toLowerCase()] = function(event){
         if (!event) var event = window.event;
         var target = null;
         if (event.target) {
            target = (event.target.nodeType == 3) ? event.target.parentNode : event.target;
          } else {
             target = event.srcElement;
         }

         if (event.modifiers){
            event.shiftKey = ((event.modifiers & Event.SHIFT_MASK) != 0);
            event.altKey = ((event.modifiers & Event.ALT_MASK) != 0);
            event.ctrlKey = ((event.modifiers & Event.CONTROL_MASK) != 0);
            event.button	= event.which;
            event.keyCode	= event.which;
         }
         if (event.pageX || event.pageY){
            event.posx = event.pageX;
            event.posy = event.pageY;
         } else if (event.clientX || event.clientY){
            event.posx = event.clientX + document.body.scrollLeft;
            event.posy = event.clientY + document.body.scrollTop;
         }

               return handler(obj, event , target);
      };
   };

   SjElement.prototype.removeEventHandler = function(eventName, handler){
      if (document.layers){
         this.releaseEvents(Event[eventName.toUpperCase()]);
         delete this._content[Event[eventName.toUpperCase()]];
      }
      this._content["on"+eventName.toLowerCase()] = null;
   };

   //Event
   SjElement.prototype.makeEventObject = function(inAarguments){
      var eventobject = new Object();
      eventobject["type"] = inAarguments[0];
      eventobject["target"] = this;
      for (i = 1; i < inAarguments.length; i+=2){
         eventobject[inAarguments[i]] = inAarguments[i+1];
      }
      return eventobject;
   };

   SjElement.prototype.addEventListener = function(inType, inHandler){
      inType = inType.toLowerCase();
      if (!this.hashtable_eventlisteners){
         this.hashtable_eventlisteners = new SjHashtable();
      }
      var arrListeners = this.hashtable_eventlisteners.get(inType);
      if (!arrListeners){
         arrListeners = new Array();
         this.hashtable_eventlisteners.put(inType, arrListeners);
      }
      var index = this.indexOfEventListener(inType, inHandler);
      if (index == -1){
         arrListeners.push(inHandler);
      }
   };

   SjElement.prototype.removeEventListener = function(inType, inHandler){
      inType = inType.toLowerCase();
      if (this.hashtable_eventlisteners){
         var arrListeners = this.hashtable_eventlisteners.get(inType);
         if (arrListeners){
            //arrListeners.remove(inHandler);
            var index = this.indexOfEventListener(inType, inHandler);
            if (index != -1){
               var arrListeners_temp = new Array();
               for (var i = 0; i < arrListeners.length; i++){
                  if (arrListeners[i] != inHandler){
                     arrListeners_temp.push(arrListeners[i]);
                  }
               }
               this.hashtable_eventlisteners.put(inType, arrListeners_temp);
            }
         }
      }
   };

   SjElement.prototype.fireEventObject = function(inEvent){
      if (this.hashtable_eventlisteners && this.hashtable_eventlisteners.size() > 0){
         var arrListeners = this.hashtable_eventlisteners.get(inEvent.type.toLowerCase());
         if (arrListeners){
            var index;
            for (index = 0; index < arrListeners.length; index++){
               arrListeners[index](inEvent);
            }
         }
      }
   };


   SjElement.prototype.fireEvent = function(){
      var eventobject = this.makeEventObject(arguments);
      this.fireEventObject(eventobject);
   };

   SjElement.prototype.indexOfEventListener = function(inType, inHandler){
      var result = -1;
      inType = inType.toLowerCase();
      var index;
      if (this.hashtable_eventlisteners){
         var arrListeners = this.hashtable_eventlisteners.get(inType);
         if (arrListeners){
            //result = this.hashtable_eventlisteners.indexOfValue(inHandler);//arrListeners.indexOf(inListener);
            for (index = 0; index < arrListeners.length; index++){
               if (arrListeners[index] == inHandler){
                  result = index;
                  break;
               }
            }
         }
      }
      return result;
   };


   SjElement.Count = 0;
   SjElement.all = [];
};/*
ADOBE CONFIDENTIAL
Copyright 2005 Adobe Systems Incorporated
All Rights Reserved.

NOTICE:  All information contained herein is, and remains the property of Adobe Systems Incorporated and its suppliers,
if any.  The intellectual and technical concepts contained herein are proprietary to Adobe Systems Incorporated and its
suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret or 
copyright law. Dissemination of this information or reproduction of this material is strictly forbidden unless prior 
written permission is obtained from Adobe Systems Incorporated.
*/

if (typeof S7Layer == "undefined") {

   var S7Layer = {};

   var SjLayer = function(inParent, inElementId) {
      if (arguments[0] == 'empty') {
         return;
      }
      this.SjElement = SjElement;
      this.SjElement(inParent, inElementId);
      if (this._parent && this._parent._elementId){
         sjCreateDiv(this._parent._elementId , this._elementId);
      }else{
         sjCreateDiv(null , this._elementId);
      }
      this._content = sjGetElement(this._elementId);
   };

   SjLayer.prototype = new SjElement('empty');
}
;/*
ADOBE CONFIDENTIAL
Copyright 2005 Adobe Systems Incorporated
All Rights Reserved.

NOTICE:  All information contained herein is, and remains the property of Adobe Systems Incorporated and its suppliers,
if any.  The intellectual and technical concepts contained herein are proprietary to Adobe Systems Incorporated and its
suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret or 
copyright law. Dissemination of this information or reproduction of this material is strictly forbidden unless prior 
written permission is obtained from Adobe Systems Incorporated.
*/

if (typeof S7Picture == "undefined") {

   var S7Picture = {};

   var SjPicture = function(inParent, inElementId,inWidth,inHeight,transparency) {
      if (arguments[0] == 'empty') {
         return;
      }
      this.SjElement = SjElement;
      this.SjElement(inParent, inElementId);
      if (this._parent && this._parent._elementId){
         sjCreateDiv(this._parent._elementId , this._elementId);
      }else{
         sjCreateDiv(null , this._elementId);
      }
      if (typeof tsj != 'undefined'){
         this.codePath		= tsj.path;
      }else if(typeof sj != 'undefined'){
         this.codePath		= sj.path;
      }else{
         this.codePath		= '../dhtml/';
      }

      this.transparency = transparency || false;
      this._imageWidth = 0;
      this._imageHeight = 0;
      this._stretch = false;
      this.scale = 1;
      this.loaded = false;
      this.img = new Image();
      this.img._uId = this._elementId + '_img';
      this.img.src = this.codePath+"images/spacer.gif";
       this.img.str = ' <img';
      this.img.str += ' id=' + this.img._uId;
      this.img.str += ' name=' + this.img._uId;
      this.img.str += ' border=' + 0;
      this.img.str += ' style="position:absolute;left:0;top:0;"';
      this.img.str += '> ';
       sjSetLayerHTML(this._elementId,this.img.str);
      this._content = sjGetElement(this._elementId);
      this.imageElm = sjGetElement(this.img._uId);
      this.imageElm._parent = this;
      this.useMap='';
      this.imageElm.useMap='';
      this.img._parent = this;
   };

   SjPicture.prototype = new SjElement('empty');

   SjPicture.prototype.load = function(inURL) {
      if (inURL == this.img.src) {
         if (this.loaded == true){
            eval('document.' + this.img._uId + '.onload=this.onLoad;');//?????????/
            eval('document.' + this.img._uId + '.style.width=this._imageWidth;');
            eval('document.' + this.img._uId + '.style.height=this._imageHeight;');
            eval('document.' + this.img._uId + '.onload();');
         }
         return;
      }
      this.loaded = false;
      if (document.all) {
         sjGetElement(this.img._uId).outerHTML=this.img.str;
         this.imageElm = sjGetElement(this.img._uId);
         this.imageElm._parent = this;
         this.img._parent = this;
      }else{
         eval('document.' + this.img._uId + '.style.width=null;');
         eval('document.' + this.img._uId + '.style.height=null;');
      }
      this.img.src = inURL;
      eval('document.' + this.img._uId + '.onload=this.onLoad;');
      eval('document.' + this.img._uId + '.onerror=this.onError;');
      eval('document.' + this.img._uId + '.onabort=this.onAbort;');
       eval('document.' + this.img._uId + '.src = inURL;');
      this.imageElm.useMap = this.useMap;
   };


   SjPicture.prototype.onLoad = function() {
      this._parent.loaded = true;
      this._parent._imageWidth = this.width;
      this._parent._imageHeight = this.height;
      //this._parent.setSize(this.width,this.height);//set size of conteiner div !!!
      this._parent.stretch(this._parent.stretch());
      //////
      var version = parseFloat(navigator.appVersion.split("MSIE")[1]);
      var haveFilters = null;
      if ((version >= 5.5) && (version < 8)){
            try {
               haveFilters = document.body.filters;
            }catch(e){
               //alert();
            }
      }
   //	if ((version >= 5.5) && (version < 8) && (document.body.filters)){
      if ((version >= 5.5) && (version < 8) && (haveFilters != null)){
         var img = this;
         var imgName = this.src.toUpperCase();
   //		if (imgName.indexOf("PNG-ALPHA") != -1){
         if (this._parent.transparency){
            var imgID = (img.id) ? "id='" + img.id + "' " : "";
            var imgName = (img.name) ? "name='" + img.name + "' " : "";
            var imgBorder = (img.border) ? "border='" + img.border + "' " : "";
            var imgStyle = "display:inline-block;" + img.style.cssText;
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
            var imgAlt = (img.alt) ? "alt='" + img.alt + "' " : "alt='" + img.alt + "' ";
            if (img.useMap){
               strAddMap = "<img style=\"position:relative; left:-" + img.width + "px;"
               + "height:" + img.height + "px;width:" + img.width +"\" "
               + "src=\"" + this._parent.codePath+"images/spacer.gif" + "\" usemap=\"" + img.useMap
               + "\" border=\"" + img.border + "\">";
             }
             var strNewHTML = "<img " + imgID + imgName + imgTitle + imgAlt + imgBorder
                         + ' src='+this._parent.codePath+"images/spacer.gif"
                         + " style=\"" + imgStyle + ";"
                         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                         + "(src=\'" + img.src + "\', sizingMethod='scale');"
                         + "\">";
            if (img.useMap){
               strNewHTML += strAddMap;
            }
            img.outerHTML = strNewHTML;
          }
      }
      /////////
      this._parent.fireEvent('load');
   };

   SjPicture.prototype.onError = function() {
      this._parent.loaded = false;
      this._parent.fireEvent('error');
   };

   SjPicture.prototype.onAbort = function() {
      this._parent.loaded = false;
      this._parent.fireEvent('abort');
   };

   SjPicture.prototype.stretch = function(inStretch) {
      if (inStretch != null) {
         this._stretch = inStretch;
         var w = this.width();
         var h = this.height();
         if (this._stretch) {
            sjSetWidth(this.img._uId, this._width);
            sjSetHeight(this.img._uId, this._height);
         } else {
            sjSetWidth(this.img._uId, this._imageWidth);
            sjSetHeight(this.img._uId, this._imageHeight);
         }
            sjZoomMap (this.imageElm.useMap.substring(1), this.width()/w, this.height()/h);
      }
      return this._stretch;
   };

   SjPicture.prototype.super_width = SjPicture.prototype.width;
   SjPicture.prototype.width = function(inWidth) {
      var w = this.super_width();
      var h = this.super_height();
      var ret = this.super_width(inWidth);
      if (inWidth != null) {
            if (this._stretch) {
               sjSetWidth(this.img._uId, this._width);
               sjSetHeight(this.img._uId, this._height);
            }
            sjZoomMap (this.imageElm.useMap.substring(1), this.width()/w, this.height()/h);
      }
      return ret;
   };

   SjPicture.prototype.super_height = SjPicture.prototype.height;
   SjPicture.prototype.height = function(inHeight) {
      var w = this.super_width();
      var h = this.super_height();
      var ret = this.super_height(inHeight);
      if (inHeight != null) {
            if (this._stretch) {
               sjSetWidth(this.img._uId, this._width);
               sjSetHeight(this.img._uId, this._height);
            }
            sjZoomMap (this.imageElm.useMap.substring(1), this.width()/w, this.height()/h);
      }
      return ret;
   };

   SjPicture.prototype.map = function(inMap) {
      if (inMap!= null){
        this.imageElm.useMap=this.useMap='#'+inMap;
      }else
      return this.imageElm.useMap;
   };

   SjPicture.prototype.clearMap = function() {
        this.imageElm.useMap=this.useMap='';
   };
}
;/*
ADOBE CONFIDENTIAL
Copyright 2005 Adobe Systems Incorporated
All Rights Reserved.

NOTICE:  All information contained herein is, and remains the property of Adobe Systems Incorporated and its suppliers,
if any.  The intellectual and technical concepts contained herein are proprietary to Adobe Systems Incorporated and its
suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret or 
copyright law. Dissemination of this information or reproduction of this material is strictly forbidden unless prior 
written permission is obtained from Adobe Systems Incorporated.
*/

if (typeof S7ZoomMain == "undefined") {

   var S7ZoomMain = {};

   /////////////////////////////////SjZoomNav
   var SjZoomNav = function(inObj,inWidth,inHeight,inPosition,inNav,transparency){
      this.SjElement = SjElement;
   ///////
      if ((typeof inNav == 'undefined')) {
         inNav = 'izNav';
      }
       if (sjGetElement(inNav)){
         this.SjElement(sjGetElement(inNav), null);
         if (this._parent){
            sjCreateDiv(sjGetElement(inNav), this._elementId);
         }else{
            sjCreateDiv(null , this._elementId);
         }
         this.elem=sjGetElement(this._elementId);
         this.elem._elementId = this._elementId;
         this._content		= sjGetElement(this._elementId);

         this.setSize(sjGetElement(inNav).offsetWidth || 50,sjGetElement(inNav).offsetHeight || 50);
         sjSetWidth(inNav, this.width());
         sjSetHeight(inNav, this.height());
          this.toXY(0,0);
      }else{
         this.SjElement(inObj, null);
         if (this._parent && this._parent._elementId){
            sjCreateDiv(this._parent._elementId , this._elementId);
         }else{
            sjCreateDiv(null , this._elementId);
         }
         this.elem=sjGetElement(this._elementId);
         this.elem._elementId = this._elementId;
         this._content		= sjGetElement(this._elementId);

         this.setSize(inWidth || 50,inHeight || 50);
      }
   /////////

      this.transparency = transparency;
      this.navObj = null;

      this.dblnavImage = new SjPicture(this.elem,null,null,null,this.transparency);
      this.dblnavImage.setSize(inWidth || 50,inHeight || 50);
      this.dblnavImage.visible(false);

      this.navImage = new SjPicture(this.elem,null,null,null,this.transparency);
      this.navImage.visible(false);
      sjSetBorder(this._elementId,1,'solid',"#666666");
      this.navImage.setSize(inWidth || 50,inHeight || 50);
      this.dragImage = new SjLayer(this);
      this.dragImage.zIndex(100);
      this.dragImage.visible(false);
      this.dragImage.setSize(inWidth || 50,inHeight || 50);

   //	this.d = new SjLayer(this);
   //	this.d.setSize(inWidth || 50,inHeight || 50);
   //	this.d.setBorder(2,'solid','#ff0000');
   //	this.d.zIndex(100);

      this.borderWidth  = 2;
      this.borderColor = '#ff0000';
      //var str='<img id='+this.dragImage._elementId+'_img  src="../dhtml/images/blankimg.gif" style="left:2px;top:2px;width:'+this.dragImage.width()+';height:'+this.dragImage.height()+';">';
      var str='<img id='+this.dragImage._elementId+'_img  src="" style="left:2px;top:2px;width:'+this.dragImage.width()+'px;height:'+this.dragImage.height()+'px;">';
      sjSetLayerHTML(this.dragImage._elementId,str);
      sjGetElementStyle(this.dragImage._elementId+'_img').border='#ff0000 2px solid';
      this.visible(false);
      this.position = inPosition || 'absolute';
      if (this.position == 'absolute'){
         sjGetElementStyle(this._elementId).position='absolute';
      }else{
         //sjGetElementStyle(this._elementId).position ='relative';//relative - not work!
      }
      this.initialLoading	= true;
      //for future this.changingImage	= false;
   };

   SjZoomNav.prototype = new SjElement();

   SjZoomNav.prototype.setViewer = function(inObj){
      this.navObj = inObj;
      if (this.navObj){
         this.navObj.navLayer = this;
         //sjGetElement(this.dragImage._elementId+'_img').src = this.navObj.codePath+"images/blankimg.gif";
         sjGetElement(this.dragImage._elementId+'_img').src = this.navObj.codePath+"images/spacer.gif";
         this.initHandlers();
         if ((this.navObj.navloadURL) && (this.navObj.imgServerWidth) && (this.navObj.imgServerHeight)){
            this.navObj.navDefaultScl = Math.max(Math.max(this.navObj.imgServerWidth / (this.width()-5), this.navObj.imgServerHeight / (this.height()-5)), 1.0);
            //this.navObj.navloadURL +='&scl='+(this.navObj.navDefaultScl)+'&fmt=jpeg'+this.navObj.idStr;
            //this.navObj.navloadURL +='&scl='+(this.navObj.navDefaultScl)+'&fmt='+this.navObj.format+this.navObj.idStr;
            this.navObj.navloadURL +='&scl='+(this.navObj.navDefaultScl)+this.navObj.idStr;
            //??this.navImage.load(this.navObj.navloadURL);
            this.dblnavImage.load(this.navObj.navloadURL);
         }
      }
   };

   SjZoomNav.prototype.update = function(x,y,w,h){
      if(this.navObj){
         this.navObj.navigatorScl= Math.max(w/this.navImage.width(),h/this.navImage.height());
         var fixedX = Math.max(-x/this.navObj.navigatorScl,0);
         var fixedY = Math.max(-y/this.navObj.navigatorScl,0);
         this.dragImage.toXY(fixedX+this.navImage.left(),fixedY+this.navImage.top());
   //		this.d.toXY(fixedX+this.navImage.left(),fixedY+this.navImage.top());
         var fixedWidth = Math.min(this.navObj.width()/this.navObj.navigatorScl, this.navImage.width());
         var fixedHeight = Math.min(this.navObj.height()/this.navObj.navigatorScl, this.navImage.height());
         this.dragImage.setSize(fixedWidth,fixedHeight);
   //		this.d.setSize(fixedWidth,fixedHeight);
         sjGetElementStyle(this.dragImage._elementId+'_img').width = parseInt(((this.dragImage.width()-this.borderWidth*2)<1?1:(this.dragImage.width()-this.borderWidth*2)))+"px";
         sjGetElementStyle(this.dragImage._elementId+'_img').height = parseInt(((this.dragImage.height()-this.borderWidth*2)<1?1:(this.dragImage.height()-this.borderWidth*2)))+"px";
   //		sjGetElementStyle(this.d._elementId).width = parseInt(((this.d.width()-this.borderWidth*2)<1?1:(this.d.width()-this.borderWidth*2)))+"px";
   //		sjGetElementStyle(this.d._elementId).height = parseInt(((this.d.height()-this.borderWidth*2)<1?1:(this.d.height()-this.borderWidth*2)))+"px";
      }
   };

   SjZoomNav.prototype.moving=false;
   SjZoomNav.prototype.startDrag=false;


   SjZoomNav.prototype.initHandlers = function(){
      var obj = this;
      var objNav = this.navObj;
      this.dblnavImage.addEventListener("load",
         function (){
            var scl = 1;//Math.min((obj.width()-5)/obj.dblnavImage._imageWidth,(obj.height()-5)/obj.dblnavImage._imageHeight);
            obj.dblnavImage.stretch(true);
            //obj.dblnavImage.setSize(obj.dblnavImage._imageWidth*scl,obj.dblnavImage._imageHeight*scl);
            obj.dblnavImage.setSize(obj.dblnavImage.img.width*scl,obj.dblnavImage.img.height*scl);
            obj.dblnavImage.toXY((obj.width() - obj.dblnavImage.width())/2,(obj.height() - obj.dblnavImage.height())/2);
            obj.dblnavImage.visible(true);
            obj.navImage.load(obj.dblnavImage.img.src);//??
            return false;
         }
      );
      this.navImage.addEventListener("load",
         function (){
            var scl = 1;//Math.min((obj.width()-5)/obj.navImage._imageWidth,(obj.height()-5)/obj.navImage._imageHeight);
            obj.navImage.stretch(true);
            //obj.navImage.setSize(obj.navImage._imageWidth*scl,obj.navImage._imageHeight*scl);
            obj.navImage.setSize(obj.navImage.img.width*scl,obj.navImage.img.height*scl);
            obj.navImage.toXY((obj.width() - obj.navImage.width())/2,(obj.height() - obj.navImage.height())/2);
            obj.dragImage.setSize(obj.navImage.width(),obj.navImage.height());
   //			obj.d.setSize(obj.navImage.width(),obj.navImage.height());
            var newx =(obj.navImage.width() - obj.dragImage.width())/2;
            var newy =(obj.navImage.height() - obj.dragImage.height())/2;
   //			var newx =(obj.navImage.width() - obj.d.width())/2;
   //			var newy =(obj.navImage.height() - obj.d.height())/2;
            obj.dragImage.toXY(newx+obj.navImage.left(),newy+obj.navImage.top());
   //			obj.d.toXY(newx+obj.navImage.left(),newy+obj.navImage.top());
            sjGetElementStyle(obj.dragImage._elementId+'_img').width = parseInt(((obj.dragImage.width()-obj.borderWidth*2)<1?1:(obj.dragImage.width()-obj.borderWidth*2)))+"px";
            sjGetElementStyle(obj.dragImage._elementId+'_img').height = parseInt(((obj.dragImage.height()-obj.borderWidth*2)<1?1:(obj.dragImage.height()-obj.borderWidth*2)))+"px";
            obj.dragImage.visible(true);
   //			sjGetElementStyle(obj.d._elementId).width = parseInt(((obj.d.width()-obj.borderWidth*2)<1?1:(obj.d.width()-obj.borderWidth*2)))+"px";
   //			sjGetElementStyle(obj.d._elementId).height = parseInt(((obj.d.height()-obj.borderWidth*2)<1?1:(obj.d.height()-obj.borderWidth*2)))+"px";
            if(obj.navObj){
               if (!obj.initialLoading){
                  if (obj.dblnavImage.loaded){
                     obj.dblnavImage.fadeOut(obj.navObj.turnTime/2);
                  }
                  obj.navImage.fadeIn(obj.navObj.turnTime/2);
                  obj.navImage.visible(true);
               }else{
                  obj.navImage.visible(true);
                  obj.dblnavImage.visible(false);
               }
            }
            obj.initialLoading	= false;
            return false;
         }
      );
      this.dragImage.addEventHandler('mousedown',
   //	this.navImage.addEventHandler('mousedown',
   //	this.d.addEventHandler('mousedown',
         function (o,evt){
            objNav.storeImagesXY();
            ex = evt.posx;
            ey = evt.posy;
            obj.startDrag=true;
            sjSetCursor('hand');
            return false;
         }
      );
      this.dragImage.addEventHandler('mousemove',
   //	this.navImage.addEventHandler('mousemove',
   //	this.d.addEventHandler('mousemove',
         function (o,evt){
            if (obj.startDrag){
               obj.moving=true;
               var diffX = evt.posx - ex;
               var diffY = evt.posy - ey;
               objNav.setPosition(objNav.backImage,objNav.bx - diffX*objNav.navigatorScl,objNav.by - diffY*objNav.navigatorScl,objNav.currentScl);
               objNav.foreImage.left(objNav.currentX-objNav.bx+objNav.fx);
               objNav.foreImage.top(objNav.currentY-objNav.by+objNav.fy);
            }
            return false;
         }
      );
      this.dragImage.addEventHandler('mouseup',
   //	this.navImage.addEventHandler('mouseup',
   //	this.d.addEventHandler('mouseup',
         function (o,evt){
            if(obj.moving){
               obj.moving=false;
               objNav.updateForeImage();
            }else{
               if (evt.ctrlKey){
               } else {
               }
            }
            obj.startDrag=false;
            sjSetCursor('default');
            return false;
         }
      );
   //
      this.navImage.addEventHandler('mousedown',
         function (o,evt){
            objNav.storeImagesXY();
            ex = evt.posx;
            ey = evt.posy;
            obj.startDrag=true;
            sjSetCursor('hand');
            return false;
         }
      );
      this.navImage.addEventHandler('mousemove',
         function (o,evt){
            if (obj.startDrag){
               obj.moving=true;
               var diffX = evt.posx - ex;
               var diffY = evt.posy - ey;
               objNav.setPosition(objNav.backImage,objNav.bx - diffX*objNav.navigatorScl,objNav.by - diffY*objNav.navigatorScl,objNav.currentScl);
               objNav.foreImage.left(objNav.currentX-objNav.bx+objNav.fx);
               objNav.foreImage.top(objNav.currentY-objNav.by+objNav.fy);
            }
            return false;
         }
      );
      this.navImage.addEventHandler('mouseup',
         function (o,evt){
            if(obj.moving){
               obj.moving=false;
               objNav.updateForeImage();
            }else{
               if (evt.ctrlKey){
               } else {
               }
            }
            obj.startDrag=false;
            sjSetCursor('default');
            return false;
         }
      );

   //
      this.addEventHandler('mouseout',
         function (o,evt){
            if(obj.moving){
               obj.moving=false;
               objNav.updateForeImage();
            }else{
               if (evt.ctrlKey){
               } else {
               }
            }
            obj.startDrag=false;
            sjSetCursor('default');
            return false;
         }
      );
   };

   SjZoomNav.prototype.setBorder = function(sz,inColor) {
      if ((inColor.indexOf("#") == -1) && ((inColor.indexOf("0x") == -1))) {
         inColor = "#"+inColor;
      }else if (inColor.indexOf("0x") != -1) {
         inColor = inColor.replace("0x","#");
      }
      this.borderColor = inColor || "#ff0000";
      this.borderWidth = parseInt(sz) || 2;
      sjGetElementStyle(this.dragImage._elementId+'_img').border=""+this.borderColor+" "+parseInt(this.borderWidth)+"px solid";
      sjGetElementStyle(this.dragImage._elementId+'_img').width = parseInt(((this.dragImage.width()-this.borderWidth*2)<1?1:(this.dragImage.width()-this.borderWidth*2)))+"px";
      sjGetElementStyle(this.dragImage._elementId+'_img').height = parseInt(((this.dragImage.height()-this.borderWidth*2)<1?1:(this.dragImage.height()-this.borderWidth*2)))+"px";
   //	this.d.setBorder(this.borderWidth,'solid',this.borderColor);
   //	sjGetElementStyle(this.d._elementId).width = parseInt(((this.d.width()-this.borderWidth*2)<1?1:(this.d.width()-this.borderWidth*2)))+"px";
   //	sjGetElementStyle(this.d._elementId).height = parseInt(((this.d.height()-this.borderWidth*2)<1?1:(this.d.height()-this.borderWidth*2)))+"px";
   };

   /////////////////////////////////SjZoom

   var SjZoom = function(inParent,inBaseImage,inWidth,inHeight,withNav,withMagnifier,inPosition,inTransparency){
      this.SjElement = SjElement;
      this.SjElement(inParent, null);
      if (this._parent && this._parent._elementId){
         sjCreateDiv(this._parent._elementId , this._elementId);
      }else{
         sjCreateDiv(null , this._elementId);
      }
      this._content		= sjGetElement(this._elementId);
      if (typeof tsj != 'undefined'){
         this.codePath		= tsj.path;
      }else if(typeof sj != 'undefined'){
         this.codePath		= sj.path;
      }else{
         this.codePath		= '../dhtml/';
      }
   //	this.mainURL		= inBaseImage || this.codePath+"images/blankimg.gif";
      this.mainURL		= inBaseImage || this.codePath+"images/spacer.gif";
      this.foreURL		= null;
      this.loadURL		= null;
      this.waitIconURL	= null;
      this.imgFolder		= this.codePath+"images/default/";
      // viewer arguments
      this.viewSize		= {width: inWidth || 200, height: inHeight || 200};
      this.currentX		= null;//x;
      this.currentY		= null;//y;
      this.initialScl		= 1;//s;
      this.defaultScl		= 1;//s;
      this.currentScl		= 1;//s;
      this.lastScl		= 1;//s;
      this.nextScl		= 1;//s;
      this.prevScl		= 1;//s;
      this.imgServerWidth	= null; //server image size
      this.imgServerHeight= null;
      this.prevImgServerWidth	= null; //previuos server image size
      this.prevImgServerHeight= null;
      this.initialLoading	= true;
      this.changingImage	= false;
      this.initRGNZone	= null;
      this.RGNtype		= "rgna";
      this.format			= "jpeg";			// jpeg
      this.cachingModel	= "on,off";	// server side caching off, client side caching on
      this.infotxt		= "";
      this.buttonSpace	= 0;
      this.buttonOffset	= 0;
      this.imgBorder		= 0;
      // tiled zoom viewer arguments
      this.tileSize		= {width:128,height:128};
      this.panStep		= 128;
      this.maxWait		= 15000;
      this.max_zoom		= 100;//5;//some trick's;))
      this.zoom_factor	= 2;
      this.transitionTime	= 500;//msec
      this.fadeTime		= 150;// msec
      this.magnifier		= {width:150,height:150,factor:2,st:true};
      this.navInfo		= {pos:1,x:5,y:5,width:75,height:75};
      this.spinnerCou=0;
      this.orig_max_zoom	= 5;
      this.totalzoom		= 1;
      this.zoom_factor_limit = 0.0;
      this.waitIconTimer	= {showDelay: 3000, hideDelay: 100};
      this.waitIconTimerId= null;
      this.panPercision	= 3;
      this.curZoomPower	= 0;
      //navigator
      this.navigatorScl;
      this.withNav		= withNav || false;
      this.withMagnifier	= withMagnifier || false;
   //closebutton???????
      this.closebutton_w	= 20;
      this.closebutton_h	= 20;
      this.closebutton_x	= 5;
      this.closebutton_y	= 5;
      this.closebutton_pos = 0;
   //resizing
      this.setSize(this.viewSize.width,this.viewSize.height);
      this.clip(0,0,this.viewSize.width+2,this.viewSize.height+2);
   /////////////////
      this.transparency		= inTransparency || false;
      this.navLayer = null;
      this.foreImage = new SjPicture(this,'foreImage'+this._elementId,null,null,this.transparency);
      this.foreImage.visible(false);
      this.foreImage.setSize(this.viewSize.width,this.viewSize.height);
      this.foreImage.stretch(true);
      this.foreImage.zIndex(this.zIndex()+1);
      //XXX01 avu 22.09.2005: fixed issue #4696 - DHTML generic zoom - clicking swatch sometimes doesn't update main image.
      this.foreImage.afterFade = function() {
         this._parent.checkPendingChangeContext();
      };

      this.backImage = new SjPicture(this,'backImage'+this._elementId,null,null,this.transparency);
      this.backImage.visible(false);
      this.backImage.setSize(this.viewSize.width,this.viewSize.height);
      this.backImage.stretch(true);

      this.mapImage = new SjPicture(this,'mapImage'+this._elementId);
      this.mapImage.visible(false);
      this.mapImage.setSize(this.viewSize.width,this.viewSize.height);
      this.mapImage.stretch(true);
      this.mapImage.zIndex(this.foreImage.zIndex()+1);
      //this.mapImage.load(this.codePath+"images/blankimg.gif");
      this.mapImage.load(this.codePath+"images/spacer.gif");//????crazy!!!!
      this.waitIcon = new SjPicture(this,'waitIcon'+this._elementId);
      this.waitIcon.visible(false);
      this.waitIcon.zIndex(this.foreImage.zIndex()+1);
      this.waitIcon.setSize(10,10);
   ////////////////buttons
      this.closeButton = new SjPicture(this._parent,'closeButton'+this._elementId);
      this.plusButton = new SjPicture(this._parent,'plusButton'+this._elementId);
      this.minusButton = new SjPicture(this._parent,'minusButton'+this._elementId);
      this.resetButton = new SjPicture(this._parent,'resetButton'+this._elementId);
      this.infoButton = new SjPicture(this._parent,'infoButton'+this._elementId);
      this.closeButton.zIndex(this.foreImage.zIndex()+10);
      this.plusButton.zIndex(this.foreImage.zIndex()+10);
      this.minusButton.zIndex(this.foreImage.zIndex()+10);
      this.resetButton.zIndex(this.foreImage.zIndex()+10);
      this.infoButton.zIndex(this.foreImage.zIndex()+10);
      this.closeButton.setSize(20,20);
      this.plusButton.setSize(20,20);
      this.minusButton.setSize(20,20);
      this.resetButton.setSize(20,20);
      this.infoButton.setSize(20,20);
      this.closeButton.visible(false);
      this.plusButton.visible(false);
      this.minusButton.visible(false);
      this.resetButton.visible(false);
      this.infoButton.visible(false);
   //??	this.color('#ffffff');
      this.visible(true);
      this.stack = null;
      this.state = "create";
      this.oldImage = null;
      this.currentRGN = null;
      //XXX01 avu 22.09.2005: fixed issue #4696 - DHTML generic zoom - clicking swatch sometimes doesn't update main image.
      this.pendingChangeContext = null;
   /////////////////
      this.currentCrop = null;
      this.alignX = 0;
      this.alignY = 0;
      this.broshure = null;
      this.navloadURL	= null;
      this.navDefaultScl = 1;
   /////////////////
      this.clickToZoom = true;
      this.zoomSclArray = new Array();
      this.zoomIdx = null; //reset state
      this.zoomScl = false;
      this.enableZoom = true;
   /////////////////
      this.hotSpotEnable = false;
      this.oimgLabel = '';
      this.imgLabel = '';
   /////////////////
      this.turnTime		= 150;// msec
   };

   SjZoom.prototype = new SjElement();

   SjZoom.prototype.initialising = function (x,y,scale,defaultScl) {
      this.defaultScl = this.initialScl = Math.max(Math.max(this.imgServerWidth / this.viewSize.width, this.imgServerHeight / this.viewSize.height), 1.0);//ss
       if (defaultScl != null){
         this.defaultScl = this.initialScl = defaultScl;
        }
       this.bgImgScl = this.defaultScl;
       if (scale == null){
         this.currentScl = this.defaultScl;
        } else {
         var resetScl = scl1 = Math.max(this.imgServerWidth / this.viewSize.width,
                                 this.imgServerHeight / this.viewSize.height);
         var prevResetScl = scl0 = Math.max(this.prevImgServerWidth / this.viewSize.width,
                                    this.prevImgServerHeight / this.viewSize.height);
         resetScl = Math.max(resetScl,1.0);
         prevResetScl = Math.max(prevResetScl,1.0);

         var maxScaleChange = Math.pow(this.zoom_factor , this.max_zoom);
         //minimum allowed scale value.
         var minScale = resetScl / maxScaleChange;
         var prevminScale = prevResetScl / maxScaleChange;
         scale = scale * minScale / prevminScale;
         this.currentScl = scale;
       }

      //set position
      this.defaultX = (this.viewSize.width - this.imgServerWidth/this.defaultScl)/2;
       if (x == null){
         this.currentX = (this.viewSize.width - this.imgServerWidth/this.currentScl)/2;
        } else {
         this.currentX = x;
       }
      this.defaultY = (this.viewSize.height - this.imgServerHeight/this.defaultScl)/2;
       if (y == null){
         this.currentY = (this.viewSize.height - this.imgServerHeight/this.currentScl)/2;
        } else {
         this.currentY = y;
       }

      if (!this.zoomScl){
         this.zoomSclArray = new Array();
         for(var i=0;i<=this.max_zoom;i++){
            this.zoomSclArray.push(this.defaultScl/Math.pow(this.zoom_factor , i));
         }
      }
      //create url
         this.idStr="";
         if (this.imageVersion){
            this.idStr = '&id='+this.imageVersion;
         }
         this.loadURL = this.navloadURL = this.mainURL+sjPBreak(this.mainURL)+'rgn='+
                        Math.round(0)+','+
                        Math.round(0)+','+
                        Math.round(this.imgServerWidth)+','+
                        Math.round(this.imgServerHeight);
         //this.loadURL +=	'&scl='+(this.bgImgScl)+'&fmt=jpeg'+this.idStr;//jpeg-format
         //this.loadURL +=	'&scl='+(this.bgImgScl)+'&fmt='+this.format+this.idStr;
         this.loadURL +=	'&scl='+(this.bgImgScl)+this.idStr;
      //load image
         this.backImage.visible(false);
         this.backImage.load(this.loadURL);
         if (this.navLayer){
            this.navDefaultScl = Math.max(Math.max(this.imgServerWidth / (this.navLayer.width()-5), this.imgServerHeight / (this.navLayer.height()-5)), 1.0);
            //this.navloadURL +=	'&scl='+(this.navDefaultScl)+'&fmt=jpeg'+this.idStr;//jpeg-format
            //this.navloadURL +=	'&scl='+(this.navDefaultScl)+'&fmt='+this.format+this.idStr;
            this.navloadURL +=	'&scl='+(this.navDefaultScl)+this.idStr;
            this.navLayer.navImage.visible(false);
            this.navLayer.dblnavImage.visible(false);
            this.navLayer.dblnavImage.load(this.navloadURL);
         }
   };

   SjZoom.prototype.changeContext = function (inURL,x,y,scale,defaultScl,imgWidth,imgHeight,imgVersion,pageId){
      this.oldImage = this.mainURL;
      this.currentHost = location.host;
      var tempURL=new SjURL(inURL);
      if (!this.initialLoading) {
         if (this.changingImage || (!this.foreImage.loaded) ||(this.foreImage._fadeid != null) || (this._animeid)){
            //XXX01 avu 22.09.2005: fixed issue #4696 - DHTML generic zoom - clicking swatch sometimes doesn't update main image.
            this.pendingChangeContext = {
               url : inURL,
               x : x,
               y : y,
               scale : scale,
               defaultScl:defaultScl,
               width : imgWidth,
               height : imgHeight,
               version : imgVersion,
               pageId : pageId
            };
            return;
         }else{
            //same image - no change.
            if (inURL == this.mainURL) {
               return;
            }
            tTime = (new Date()).getTime();
            this.changingImage = true;
         }
      }
      //if((imgWidth)&&(imgHeight)&&(imgVersion)){
      if((imgWidth)&&(imgHeight)){
         this.prevImgServerWidth	= this.imgServerWidth; //previuos server image size
         this.prevImgServerHeight = this.imgServerHeight;
         this.imgServerWidth=imgWidth;
         this.imgServerHeight=imgHeight;
         if (imgVersion){
            this.imageVersion=imgVersion;
         }else{
            this.imageVersion=null;
         }
         if (pageId){
            this.pageId=pageId;
         }else{
            this.pageId='page0';
         }
         this.mainURL=mainURL=inURL;
         this.initialising(x,y,scale,defaultScl);
         this.state = "changeContext";
         this.fireEvent('endZoom');
      }else if ((this.currentHost != (tempURL.host+''+tempURL.port)) && (tempURL.host !='') && (!this.initialLoading)){
         this.prevImgServerWidth	= this.imgServerWidth; //previuos server image size
         this.prevImgServerHeight = this.imgServerHeight;
         if (imgVersion){
            this.imageVersion=imgVersion;
         }else{
            this.imageVersion=null;
         }
         if (pageId){
            this.pageId=pageId;
         }else{
            this.pageId='page0';
         }
         this.mainURL=mainURL=inURL;
         this.initialising(x,y,scale,defaultScl);
         this.state = "changeContext";
         this.fireEvent('endZoom');
      }else{
         if (pageId){
            this.pageId=pageId;
         }else{
            this.pageId='page0';
         }
         var ltURL = inURL+sjPBreak(inURL)+ 'req=ctx,json';
         var lt = null;
            lt = new SjTextLoader();
            lt.parent = this;
            lt.onLoadText = function() {
               if (lt.clearText(lt.text) != null) {
                  var imageRectStr = sjGetKeyValue(lt.text, 'image.rect');
                  var rectTokenList = imageRectStr.split(',');
                  var imageWidth = rectTokenList[2];
                  var imageHeight = rectTokenList[3];
                  var imageVersion = sjGetKeyValue(lt.text, 'image.version');
                  var metaVersion = sjGetKeyValue(lt.text, 'metadata.version');
                  this.parent.prevImgServerWidth	= this.parent.imgServerWidth; //previuos server image size
                  this.parent.prevImgServerHeight = this.parent.imgServerHeight;
                  this.parent.imgServerWidth=imageWidth;
                  this.parent.imgServerHeight=imageHeight;
                  if (imageVersion){
                     this.parent.imageVersion=imageVersion;
                  }else{
                     this.parent.imageVersion=null;
                  }
                  if (metaVersion){
                     this.parent.metaVersion=metaVersion;
                  }else{
                     this.parent.metaVersion=null;
                  }
                  this.parent.mainURL=mainURL=inURL;
                  this.parent.initialising(x,y,scale,defaultScl);
                  this.parent.state = "changeContext";
                  this.parent.fireEvent('endZoom');
               }
               return false;
            };
         if (this.initialLoading){
            lt.load(ltURL,true);
         }else{
            lt.load(ltURL,false);
         }
      }
   };

   SjZoom.prototype.checkPosition = function (x,y,scale){
      var newx = x;
      var newy = y;
      var shiftX = this.imgServerWidth/scale/2;
      var shiftY = this.imgServerHeight/scale/2;
      if (newx < (this.viewSize.width-this.imgServerWidth/scale))
         newx = (this.viewSize.width-this.imgServerWidth/scale);
      if (newy < (this.viewSize.height-this.imgServerHeight/scale))
         newy = (this.viewSize.height-this.imgServerHeight/scale);
      if (this.viewSize.width > this.imgServerWidth/scale){
         newx = (this.viewSize.width - this.imgServerWidth/scale)/2+(this.alignX*shiftX);
         if (newx+this.imgServerWidth/scale > this.viewSize.width){
            newx = (this.viewSize.width - this.imgServerWidth/scale);
         }
         if (newx < 0){
            newx = 0;
         }
      } else if (newx > 0)
         newx=0;
      if (this.viewSize.height > this.imgServerHeight/scale){
         newy = (this.viewSize.height - this.imgServerHeight/scale)/2+(this.alignY*shiftY);
         if (newy+this.imgServerHeight/scale > this.viewSize.height){
            newy = (this.viewSize.height - this.imgServerHeight/scale);
         }
         if (newy < 0){
            newy = 0;
         }
      } else if (newy > 0)
         newy=0;
      return ({nx:newx,ny:newy});
   };

   SjZoom.prototype.setPosition = function (img,x,y,scale){
      var oldx = img.left();
      var oldy = img.top();

      var newx = this.checkPosition(x,y,scale).nx;
      var newy = this.checkPosition(x,y,scale).ny;
      this.currentX = img.left(newx);
      this.currentY = img.top(newy);
      this.fireEvent('setPosition');

      //set navigator
      if (this.navLayer)
         this.navLayer.update(this.currentX,this.currentY,this.backImage.width(),this.backImage.height());

      sjResetMap("s7map_"+this._elementId);////map
      sjZoomMap ("s7map_"+this._elementId, 1/this.currentScl, 1/this.currentScl);
      return ({ox:oldx,oy:oldy,nx:newx,ny:newy});
   };

   SjZoom.prototype._animeid=null;
   SjZoom.prototype.func=new Function();
   SjZoom.prototype.animFix = function (img,x,y,inFinScale,inZoomTime,inAfterFn){
       if (this._animeid){
         clearTimeout(this._animeid);
         this._animeid = null;
      }
      var startScale	= this.currentScl;
      var startPosX	= parseInt(this.currentX);
      var startPosY	= parseInt(this.currentY);
      var finPosX		= parseInt(this.checkPosition(x,y,inFinScale).nx);
      var finPosY		= parseInt(this.checkPosition(x,y,inFinScale).ny);
      this.zoomStartTime	= new Date().getTime();
      if ((startPosX != finPosX) || (startPosY != finPosY) || (startScale != inFinScale) || (!this.foreImage.loaded)){//!!!!!!!!!
          if (this.foreImage._fadeid) {
            clearTimeout(this.foreImage._fadeid);
            this.foreImage._fadeid = null;
            //XXX01 avu 22.09.2005: fixed issue #4696 - DHTML generic zoom - clicking swatch sometimes doesn't update main image.
            this.checkPendingChangeContext();
         }
         this.foreImage.visible(false);
         this.mapImage.visible(false);//??
         sjSetCursor('wait');
         this.requestShowWaitIcon();
         this.animFixTo(img,startPosX,startPosY,finPosX,finPosY,startScale,inFinScale,inZoomTime,inAfterFn);
      }else{
          if (this.foreImage._fadeid) {
            clearTimeout(this.foreImage._fadeid);
            this.foreImage._fadeid = null;
            //XXX01 avu 22.09.2005: fixed issue #4696 - DHTML generic zoom - clicking swatch sometimes doesn't update main image.
            this.checkPendingChangeContext();
         }
         this.foreImage.visible(true);
         this.mapImage.visible(true);//??
         sjSetCursor('default');
         this.requestHideWaitIcon();
      }
   };

   SjZoom.prototype.animFixTo = function (img,startPosX,startPosY,finPosX,finPosY,startScale,finScale,inZoomTime,inAfterFn){
      var dt = new Date().getTime() - this.zoomStartTime;
      if (dt >= inZoomTime) {
         this.currentScl = finScale;
         this.setPosition(img,finPosX,finPosY,this.currentScl);
         img.setSize(this.imgServerWidth / this.currentScl,this.imgServerHeight / this.currentScl);
         if (this._animeid){
            clearTimeout(this._animeid);
            this._animeid = null;
         }
         if (inAfterFn){
            this.fireEvent('endZoom');
            this.fireEvent('setPosition');
            this.updateForeImage();
         }
         sjSetCursor('default');
         this.requestHideWaitIcon();
         return;
      } else {
         var startZoom = 1 / startScale;
         var finZoom = 1 / finScale;
         var newZoom = startZoom + (finZoom - startZoom) * dt / inZoomTime;
         var newScl = 1 / newZoom;
         this.currentScl = newScl;
         var newx = (startPosX + (finPosX - startPosX) * dt / inZoomTime);
         var newy = (startPosY + (finPosY - startPosY) * dt / inZoomTime);
         this.currentX = newx;
         this.currentY = newy;
         img.setSize(this.imgServerWidth / newScl,this.imgServerHeight / newScl);
         img.toXY(newx,newy);
         this.fireEvent('setPosition');
         //set navigator
         if (this.navLayer)
            this.navLayer.update(this.currentX,this.currentY,this.backImage.width(),this.backImage.height());
         sjResetMap("s7map_"+this._elementId);////map
         sjZoomMap ("s7map_"+this._elementId, 1/this.currentScl, 1/this.currentScl);
         this._animeid=setTimeout(this+'.animFixTo('+img+','+startPosX+','+startPosY+','+finPosX+','+finPosY+','+startScale+','+finScale+','+inZoomTime+','+this.func+')',25);
         return;
      }
   };

   SjZoom.prototype.ZoomAt = function (img,x,y,factor) {
   //this.max_zoom				: max number of zoom levels
   //this.defaultScl			: server scale at reset state
   //this.currentScl			: current server scale
   //this.zoom_factor			: step of zooming (by default = 2)
   //this.zoom_factor_limit	: by default = 0(without restrictions) if >0 ,value in % of max zooming
   //							1.0 ->> 100%,2.2 ->> 220%, 0.47 ->> 47%
   //zoom		scl		zoom_factor_limit
   //25%		4		0.25
   //33%		3		0.33
   //100%		1		1
   //200%		0.5		2.0
   /*
   if "factor" >1 - zoomOut "factor" <1 - zoomIn "factor" == 1 - may be "panning"
   */
      var nothing = false;

      if (!this.zoomScl){
         nothing = false;
      }else{
         if (factor > 1){
            if (this.zoomIdx == 0){//?? reseting
               nothing = false;
            }else{
                  for (var i=this.zoomSclArray.length-1;i>=0;i--){
                     if ((this.zoomSclArray[i] - this.currentScl)>0){
                        factor = this.zoomSclArray[i] / this.currentScl;
                        nothing = false;
                        break;
                     }else{
                        nothing = true;
                     }
                  }
            }
         }else if (factor < 1){
               for (var i=0;i<this.zoomSclArray.length;i++){
                  if ((this.zoomSclArray[i] - this.currentScl)<0){
                     factor = this.zoomSclArray[i] / this.currentScl;
                     nothing = false;
                     break;
                  }else{
                     nothing = true;
                  }
               }
         };
      }

      var newScl = this.currentScl*factor;
      if (this.zoom_factor_limit != 0) {
         newScl = Math.max(newScl, 1 / this.zoom_factor_limit);
      }
      newScl = Math.min(this.defaultScl,newScl);
      //maximum relative scale change, starting from 'reset' state.
      var maxScaleChange = Math.pow(this.zoom_factor , this.max_zoom);
      //minimum allowed scale value.
      var minScale = this.defaultScl / maxScaleChange;
      newScl = Math.max(newScl, minScale);
      //check for scale changing and panning
         var newx = this.viewSize.width/2-x/(newScl/this.currentScl);
         var newy = this.viewSize.height/2-y/(newScl/this.currentScl);
         var neww=this.imgServerWidth/newScl;
         var newh=this.imgServerHeight/newScl;
   //window.status = 'currentScl->'+this.currentScl+' factor->'+factor+' newScl->'+newScl+' zoomSclArray->'+this.zoomSclArray;
      if (!nothing){
            if ((newScl != this.currentScl) || (factor == 1) || (Math.round(newx) != Math.round(this.currentX)) || (Math.round(newy) != Math.round(this.currentY))){
            //this.state = "zoomAt";
            //this.fireEvent('zoomAt','image',img,'currentScl',this.currentScl,'newScl',newScl,'factor',factor);
            if (!this.initialLoading){
               this.animFix(img,newx,newy,newScl,this.transitionTime,this.updateForeImage);
            }else{
               this.animFix(img,newx,newy,newScl,0,this.updateForeImage);
            }
            if (newScl < this.currentScl){
               if (this.zoomScl){
                  if (this.zoomIdx < this.zoomSclArray.length){
                     this.zoomIdx++;
                  }
               }else{
                  this.zoomIdx++;
               }
            }else if (newScl > this.currentScl){
               if (this.zoomIdx > 0){
                  this.zoomIdx--;
               }
            }
         }else{
            sjSetCursor('default');
         }
      }
   //window.status = 'currentScl->'+this.currentScl+' factor->'+factor+' newScl->'+newScl+' zoomIdx->'+this.zoomIdx;
   };

   SjZoom.prototype.ZoomIn = function (img){
      var newx = this.viewSize.width/2-this.currentX;
      var newy = this.viewSize.height/2-this.currentY;
      this.ZoomAt(img,newx,newy,1/this.zoom_factor);
      this.state = "zoomIn";
      this.fireEvent('zoomIn','image',img,'currentScl',this.currentScl,'factor',1/this.zoom_factor);
   };

   SjZoom.prototype.ZoomOut = function (img){
      var newx = this.viewSize.width/2-this.currentX;
      var newy = this.viewSize.height/2-this.currentY;
      this.ZoomAt(img,newx,newy,this.zoom_factor);
      this.state = "zoomOut";
      this.fireEvent('zoomOut','image',img,'currentScl',this.currentScl,'factor',this.zoom_factor);
   };

   SjZoom.prototype.pan = function (img,directionX,directionY,amount){
      this.panStep = Math.sqrt(this.viewSize.width * this.viewSize.width + this.viewSize.height * this.viewSize.height) / 2;
      var newx = this.viewSize.width/2-this.currentX+directionX*amount*this.panStep;
      var newy = this.viewSize.height/2-this.currentY+directionY*amount*this.panStep;
      this.ZoomAt(img,newx,newy,1);
      this.state = "zoomPan";
      this.fireEvent('zoomPan','image',img,'directionX',directionX,'directionY',directionY,'amount',amount);
   };
   SjZoom.prototype.PanLeft = function (img){
      this.pan(img,-1,0,1);
   };
   SjZoom.prototype.PanUp = function (img){
      this.pan(img,0,-1,1);
   };
   SjZoom.prototype.PanDown = function (img){
      this.pan(img,0,1,1);
   };
   SjZoom.prototype.PanRight = function (img){
      this.pan(img,1,0,1);
   };
   SjZoom.prototype.PanLeftUp = function (img){
      this.pan(img,-1,-1,1);
   };
   SjZoom.prototype.PanRightUp = function (img){
      this.pan(img,1,-1,1);
   };
   SjZoom.prototype.PanLeftDown = function (img){
      this.pan(img,-1,1,1);
   };
   SjZoom.prototype.PanRightDown = function (img){
      this.pan(img,1,1,1);
   };

   SjZoom.prototype.ResetView = function (img){
      this.state = "reset";
      if(this.initRGNZone){
         this.ZoomSet(this.initRGNZone,this.RGNtype);
      }else{
         this.zoomIdx = 0;
         this.ZoomAt(img,this.defaultX,this.defaultY,this.defaultScl/this.currentScl);
      }
      this.fireEvent('zoomReset','image',img);
   };

   SjZoom.prototype.xImageToScreen = function (imgX){
      return imgX/this.currentScl+this.currentX;
   };
   SjZoom.prototype.yImageToScreen = function (imgY){
      return imgY/this.currentScl+this.currentY;
   };
   SjZoom.prototype.widthImageToScreen = function (imgW){
      return this.xImageToScreen(imgW) - this.xImageToScreen(0);
   };
   SjZoom.prototype.heightImageToScreen = function (imgH){
      return this.yImageToScreen(imgH) - this.yImageToScreen(0);
   };

   SjZoom.prototype.xScreenToImage = function (scrX){
      return (scrX-this.currentX) * this.currentScl;
   };
   SjZoom.prototype.yScreenToImage = function (scrY){
      return (scrY-this.currentY) * this.currentScl;
   };
   SjZoom.prototype.widthScreenToImage = function (scrW){
      return this.xScreenToImage(scrW) - this.xScreenToImage(0);
   };
   SjZoom.prototype.heightScreenToImage = function (scrH){
      return this.yScreenToImage(scrH) - this.yScreenToImage(0);
   };

   SjZoom.prototype.ZoomSet = function (rgn,type) {
      if (!this.changingImage){
        var rgnArray = rgn.split(",");
        if( rgnArray.length == 4 ) {
           var aspect = this.imgServerWidth/this.imgServerHeight;
           if( type=="rgnn" ) {
            rgnArray[0] = rgnArray[0] * this.imgServerWidth;
            rgnArray[1] = rgnArray[1] * this.imgServerHeight;
            rgnArray[2] = rgnArray[2] * this.imgServerWidth;
            rgnArray[3] = rgnArray[3] * this.imgServerHeight;
         }else if( type=="rgn" ){
            rgnArray[0] = rgnArray[0]/aspect*this.imgServerWidth;
            rgnArray[1] = rgnArray[1]*this.imgServerHeight;
            rgnArray[2] = rgnArray[2]/aspect*this.imgServerWidth;
            rgnArray[3] = rgnArray[3]*this.imgServerHeight;
         }
            var newx=this.xImageToScreen(rgnArray[0]);
            var newy=this.yImageToScreen(rgnArray[1]);
            var neww=this.widthImageToScreen(rgnArray[2]);
            var newh=this.heightImageToScreen(rgnArray[3]);
            var scl = Math.max(neww / this.viewSize.width, newh / this.viewSize.height);
             if (this.foreImage._fadeid) {
               clearTimeout(this.foreImage._fadeid);
               this.foreImage._fadeid = null;
               //XXX01 avu 22.09.2005: fixed issue #4696 - DHTML generic zoom - clicking swatch sometimes doesn't update main image.
               this.checkPendingChangeContext();
            }
            var nx = newx+neww/2-this.currentX;
            var ny = newy+newh/2-this.currentY;
            this.currentRGN = rgnArray;
            this.state = "setRGN";
            this.ZoomAt(this.backImage,nx,ny,scl);
        };
      }else{
         this.state = "setRGN";
         var stack ={name:"ZoomSet",args:arguments};
         this.stack = stack;
      }
   };

   SjZoom.prototype.checkRect = function (x,y,w,h){
      var res={x:0,y:0,w:0,h:0,scl:null,url:null};
      var scl=this.currentScl;
         if (scl <= 1){
            scl=1;
         }
      res.x = Math.max(0,-x);
      res.w = Math.min(this.viewSize.width, w);
      res.y = Math.max(0,-y);
      res.h = Math.min(this.viewSize.height, h);
      if ((res.h <= 0) || (res.w <= 0)) {
         return null;
      } else {
      //fix tile coordinates so that it will always be align to tileSize.width.
      var tsize = this.tileSize.width*Math.ceil(Math.round(this.tileSize.width * this.currentScl)/this.tileSize.width);
      var img_x_old = res.x*this.currentScl;
      var img_y_old = res.y*this.currentScl;
      var img_w_old = res.w*this.currentScl;
      var img_h_old = res.h*this.currentScl;
      img_x = tsize * Math.floor(img_x_old / tsize);
      img_w = tsize * Math.ceil((img_x_old + img_w_old) / tsize) - img_x;
      img_y = tsize * Math.floor(img_y_old/ tsize);
      img_h = tsize * Math.ceil((img_y_old + img_h_old) / tsize) - img_y;
      //fix out of image bounds.
      img_x = Math.max(img_x, 0);
      img_y = Math.max(img_y, 0);

      if ((img_x + img_w) > this.imgServerWidth) {
         img_w = this.imgServerWidth - img_x;
      }
      if ((img_y + img_h) > this.imgServerHeight) {
         img_h = this.imgServerHeight - img_y;
      }

      //find shift screen position of the image.
         var c1x=img_x+img_w/2;
         var c1y=img_y+img_h/2;
         var c2x=img_x_old+img_w_old/2;
         var c2y=img_y_old+img_h_old/2;
         this.shiftX = (c2x - c1x);
         this.shiftY = (c2y - c1y);
         this.lastScl = scl;//s;
         res.url = this.mainURL;
         res.scl = scl;
         res.x =	Math.round(img_x);
         res.y =	Math.round(img_y);
         res.w =	Math.round(img_w);
         res.h =	Math.round(img_h);
         this.currentCrop = res;
         return res;
      }
   };

   SjZoom.prototype.getRect = function (x,y,w,h){
      var res={x:0,y:0,w:0,h:0,url:null};
      var scl=this.currentScl;
         if (scl <= 1){
            scl=1;
         }
      res.x = Math.max(0,-x);
      res.w = Math.min(this.viewSize.width, w);
      res.y = Math.max(0,-y);
      res.h = Math.min(this.viewSize.height, h);
      if ((res.h <= 0) || (res.w <= 0)) {
         return null;
      } else {
      //fix tile coordinates so that it will always be align to tileSize.width.
      var tsize = this.tileSize.width*Math.ceil(Math.round(this.tileSize.width * this.currentScl)/this.tileSize.width);
      var img_x_old = res.x*this.currentScl;
      var img_y_old = res.y*this.currentScl;
      var img_w_old = res.w*this.currentScl;
      var img_h_old = res.h*this.currentScl;
      img_x = tsize * Math.floor(img_x_old / tsize);
      img_w = tsize * Math.ceil((img_x_old + img_w_old) / tsize) - img_x;
      img_y = tsize * Math.floor(img_y_old/ tsize);
      img_h = tsize * Math.ceil((img_y_old + img_h_old) / tsize) - img_y;
      //fix out of image bounds.
      img_x = Math.max(img_x, 0);
      img_y = Math.max(img_y, 0);

      if ((img_x + img_w) > this.imgServerWidth) {
         img_w = this.imgServerWidth - img_x;
      }
      if ((img_y + img_h) > this.imgServerHeight) {
         img_h = this.imgServerHeight - img_y;
      }

      //find shift screen position of the image.
         var c1x=img_x+img_w/2;
         var c1y=img_y+img_h/2;
         var c2x=img_x_old+img_w_old/2;
         var c2y=img_y_old+img_h_old/2;
         this.shiftX = (c2x - c1x);
         this.shiftY = (c2y - c1y);
         this.lastScl = scl;//s;
         this.idStr="";
         if (this.imageVersion){
            this.idStr = '&id='+this.imageVersion;
         }
         res.url = this.mainURL+sjPBreak(this.mainURL)+'rgn='+
                        Math.round(img_x)+','+
                        Math.round(img_y)+','+
                        Math.round(img_w)+','+
                        Math.round(img_h)+
                        //'&scl='+(scl)+'&fmt=jpeg'+this.idStr;
                        //'&scl='+(scl)+'&fmt='+this.format+this.idStr;
                        '&scl='+(scl)+this.idStr;
         this.foreURL = this.mainURL+sjPBreak(this.mainURL)+'rgn='+
                        Math.round(img_x)+','+
                        Math.round(img_y)+','+
                        Math.round(img_w)+','+
                        Math.round(img_h)+
                        //'&scl='+(scl)+'&fmt=jpeg'+this.idStr;
                        //'&scl='+(scl)+'&fmt='+this.format+this.idStr;
                        '&scl='+(scl)+this.idStr;
         this.foreMagURL = this.mainURL+sjPBreak(this.mainURL)+'rgn='+
                        Math.round(img_x)+','+
                        Math.round(img_y)+','+
                        Math.round(img_w)+','+
                        Math.round(img_h)+
                        //'&scl='+(scl/this.magnifier.factor)+'&fmt=jpeg'+this.idStr;
                        //'&scl='+(scl/this.magnifier.factor)+'&fmt='+this.format+this.idStr;
                        '&scl='+(scl/this.magnifier.factor)+this.idStr;
         return res;
      }
   };

   SjZoom.prototype.updateForeImage = function (inURL){
   var res={x:0,y:0,w:0,h:0,scl:null,url:null};
      res=this.checkRect(this.backImage.left(),this.backImage.top(),this.backImage.width(),this.backImage.height());
      this.mapImage.toXY(this.backImage.left(),this.backImage.top());
      this.mapImage.setSize(this.backImage.width(),this.backImage.height());
      this.idStr="";
      if (this.imageVersion){
         this.idStr = '&id='+this.imageVersion;
      }
      var tempURL = res.url + sjPBreak(res.url)+'rgn='+(res.x)+','+(res.y)+','+(res.w)+','+(res.h)+
                        //'&scl='+(res.scl)+'&fmt=jpeg'+this.idStr;
                        //'&scl='+(res.scl)+'&fmt='+this.format+this.idStr;
                        '&scl='+(res.scl)+this.idStr;
         if (this.foreImage._fadeid) {
            clearTimeout(this.foreImage._fadeid);
            this.foreImage._fadeid = null;
            //XXX01 avu 22.09.2005: fixed issue #4696 - DHTML generic zoom - clicking swatch sometimes doesn't update main image.
            this.checkPendingChangeContext();
         }
         this.foreImage.visible(false);
         this.mapImage.visible(false);//??
         sjSetCursor('wait');
         this.requestShowWaitIcon();
         //??this.foreURL = tempURL;
         //06-02-2007//??
         var offsetX = this.currentCrop.x/this.currentScl;
         var offsetY = this.currentCrop.y/this.currentScl;
         this.foreImage.toXY(this.backImage.left()+offsetX,this.backImage.top()+offsetY);
         //
      if (((typeof inURL != 'undefined') && ((inURL != tempURL) || (inURL != this.foreURL))) || (tempURL != this.foreURL)){
         this.foreImage.load(inURL || tempURL);
      }else{
         this.foreImage.load(this.foreURL);//??
      }
   };

   SjZoom.prototype.bx = 0;
   SjZoom.prototype.by = 0;
   SjZoom.prototype.fx = 0;
   SjZoom.prototype.fy = 0;
   SjZoom.prototype.ex = 0;
   SjZoom.prototype.ey = 0;
   SjZoom.prototype.moving=false;
   SjZoom.prototype.startDrag=false;

   SjZoom.prototype.storeImagesXY = function(){
      this.bx = this.backImage.left();
      this.by = this.backImage.top();
      this.fx = this.foreImage.left();
      this.fy = this.foreImage.top();
   };

   function sjCrossEvent(event){
      if (!event) var event = window.event;
      if (event.pageX || event.pageY){
         event.posx = event.pageX;
         event.posy = event.pageY;
      } else if (event.clientX || event.clientY){
         event.posx = event.clientX + document.body.scrollLeft;
         event.posy = event.clientY + document.body.scrollTop;
      }
         event.returnValue = false;
      event.stopPropagation = function() {this.propagate = false;};
      event.preventBubble = function() {this.bubble = false;};
      event.preventDefault = function() {this.defaultValue = false;};
      event.preventDefault();
      event.preventBubble();
      event.stopPropagation();
      return event;
   }

   SjZoom.prototype.initHandlers = function(){
      var obj = this;

   function toStandardMouse(){
      document.onmousemove=null;
      document.onmouseup=null;
   };

   function initMouse(o,evt){
      obj.storeImagesXY();
      obj.ex = evt.posx;
      obj.ey = evt.posy;
      obj.startDrag=true;
      sjSetCursor('hand');
         document.onmousemove = function(event){
            moveMouse(o,sjCrossEvent(event));
            return false;
         };
         document.onmouseup = function(event){
            finishMouse(o,sjCrossEvent(event));
            return false;
         };
         //document.onmouseout = function(event){
         //	finishMouse(o,sjCrossEvent(event));
         //	return false;
         //};
        if (document.all) {
         var map = document.all[obj.pageId];
         if (map){
            var areas = map.all.tags('AREA');
         }
        } else if (document.getElementsByName) {
         var map = document.getElementsByName(obj.pageId)[0];
         if (map){
            var areas = map.getElementsByTagName('AREA');
         }
        }
        if (areas) {
         for (var a = 0; a < areas.length; a++) {
           areas[a].onmousedown=function(event){
                           obj.storeImagesXY();
                           obj.ex = sjCrossEvent(event).posx;
                           obj.ey = sjCrossEvent(event).posy;
                           obj.startDrag=true;
                           return false;
                          };
           areas[a].onmouseup=document.onmouseup;
   /*		  areas[a].onmouseup=function(event){
                           finishMouse(o,sjCrossEvent(event));
                           return false;
                          };*/
           areas[a].onmousemove=document.onmousemove;
   /*		  areas[a].onmousemove=function(event){
            moveMouse(o,sjCrossEvent(event));
            window.status="x:"+sjCrossEvent(event).posx+" y:"+sjCrossEvent(event).posy;
                           return false;
                          };
   */

         }
        }	return false;
   };

   function moveMouse(o,evt){
      if (obj.startDrag){
         obj.moving=true;
         var diffX = evt.posx - obj.ex;
         var diffY = evt.posy - obj.ey;
         obj.setPosition(obj.backImage,obj.bx + diffX,obj.by + diffY,obj.currentScl);
         var x=obj.currentX-obj.bx+obj.fx;
         var y=obj.currentY-obj.by+obj.fy;
         obj.foreImage.toXY(x,y);
      }
      return false;
   };

   function finishMouse(o,evt){
      if(obj.moving){
         obj.moving=false;
         obj.state = "endPan";
         obj.fireEvent('endZoom');
         obj.updateForeImage();
      }else if (obj.startDrag){
         var x =sjGetPageCoords (sjGetElement(obj._elementId)).x;
         var y =sjGetPageCoords (sjGetElement(obj._elementId)).y;
         var newx=evt.posx-obj.currentX-x;
         var newy=evt.posy-obj.currentY-y;
         if ((obj.clickToZoom) && (obj.enableZoom)){
            if (evt.ctrlKey){
               obj.state = "zoomOut";
               obj.ZoomAt(obj.backImage,newx,newy,obj.zoom_factor);
            } else if (!evt.altKey){
               var minScale = Math.max(1 / obj.zoom_factor_limit, obj.defaultScl / Math.pow(obj.zoom_factor , obj.max_zoom));
               if (Math.abs(minScale - obj.currentScl) > 0.000001) {
                  obj.state = "zoomIn";
                  obj.ZoomAt(obj.backImage,newx,newy,1/obj.zoom_factor);
               }
            } else if (evt.altKey){
               obj.ResetView(obj.backImage);
            }
         }
      }
      obj.startDrag=false;
      sjSetCursor('default');
      toStandardMouse();
      return false;
   };
      ////////////////waitIcon
      this.waitIcon.addEventListener("load",
         function (){
            obj.waitIcon.setSize(obj.waitIcon._imageWidth,obj.waitIcon._imageHeight);
            var newx =(obj.viewSize.width - obj.waitIcon.width())/2;
            var newy =(obj.viewSize.height - obj.waitIcon.height())/2;
            obj.waitIcon.toXY(newx,newy);
            return false;
         }
      );
      this.waitIcon.addEventHandler('mousedown',initMouse);
      //this.waitIcon.addEventHandler('mousemove',moveMouse);
      this.waitIcon.addEventHandler('mouseup',finishMouse);
      ////////////////mapImage
      this.mapImage.addEventListener("load",
         function (){
            obj.mapImage.visible(true);
            return false;
         }
      );
      this.mapImage.addEventHandler('mousedown',initMouse);
      this.mapImage.addEventHandler('mousemove',moveMouse);
      this.mapImage.addEventHandler('mouseup',finishMouse);
      ////////////////backImage
      this.backImage.addEventListener("load",
         function (){
            obj.setPosition(obj.backImage,obj.currentX,obj.currentY,obj.currentScl);
            obj.backImage.setSize(obj.imgServerWidth / obj.currentScl,obj.imgServerHeight / obj.currentScl);
            obj.setPosition(obj.mapImage,obj.currentX,obj.currentY,obj.currentScl);
            obj.mapImage.setSize(obj.imgServerWidth / obj.currentScl,obj.imgServerHeight / obj.currentScl);
            obj.backImage.visible(true);
            obj.mapImage.visible(false);
            if(obj.initRGNZone){
               obj.changingImage=false;
               //XXX01 avu 22.09.2005: fixed issue #4696 - DHTML generic zoom - clicking swatch sometimes doesn't update main image.
               obj.checkPendingChangeContext();
               obj.ZoomSet(obj.initRGNZone,obj.RGNtype);
               if (!obj.initialLoading){
                  obj.foreImage.fadeOut(obj.turnTime/2);
               }
            }else{
               if (!obj.initialLoading){
                  obj.foreImage.fadeOut(obj.turnTime/2);
                  setTimeout(obj+'.updateForeImage()',obj.turnTime/2);
               }else{
                  obj.updateForeImage(obj.backImage.img.src);
               }
            }
                  obj.initialLoading	= false;
            return false;
         }
      );

      ////////////////foreImage
      this.foreImage.addEventListener("load",
         function (){
         var offsetX = obj.currentCrop.x/obj.currentScl;
         var offsetY = obj.currentCrop.y/obj.currentScl;
            var scl=obj.currentScl;
            if (scl < 1){
               scl/=obj.lastScl;
               obj.foreImage.height(obj.foreImage._imageHeight/scl);
               obj.foreImage.width(obj.foreImage._imageWidth/scl);
            }else{
               obj.foreImage.height(obj.foreImage._imageHeight);
               obj.foreImage.width(obj.foreImage._imageWidth);
            }
            var fadeTime;
            if (obj.changingImage){
               fadeTime = obj.turnTime/2;
               //XXX01 avu 22.09.2005: fixed issue #4696 - DHTML generic zoom - clicking swatch sometimes doesn't update main image.
               setTimeout(obj+'.changingImage=false;'+obj+'.checkPendingChangeContext();'+obj+'.callStack();',fadeTime);
            }else{
               fadeTime = obj.fadeTime;
            }
            if (!obj._animeid){//??26-01-2007??issue 6476
               obj.foreImage.fadeIn(fadeTime);
               obj.foreImage.visible(true);////??11-04-2007??issue 6755 - for IE
               obj.mapImage.visible(true);//??
            }
            sjSetCursor('default');
            obj.requestHideWaitIcon();
            //set navigator
            if (obj.navLayer){
               obj.navLayer.update(obj.currentX,obj.currentY,obj.backImage.width(),obj.backImage.height());
            }
            var metaStr = "";
            if (obj.metaVersion){
               metaStr = '&id='+obj.metaVersion;
            }
            if (obj.hotSpotEnable){
               loadMap(obj.mainURL+metaStr,1/obj.currentScl, 1/obj.currentScl,obj._elementId);
               obj.mapImage.map("s7map_"+obj._elementId);
               obj.setMapper("s7map_"+obj._elementId,
                     function (){
                        obj.enableZoom = false;
                        return false;
                     },
                     function (){
                        obj.enableZoom = true;
                        return false;
                     }
                  );
            }
            obj.state = "zoomForeImageLoad";
            //obj.fireEvent('zoomForeImageLoad','viewer',obj);
            obj.fireEvent('endZoom');
            //XXX01 avu 22.09.2005: fixed issue #4696 - DHTML generic zoom - clicking swatch sometimes doesn't update main image.
            obj.checkPendingChangeContext();
            return false;
         }
      );
      this.foreImage.addEventHandler('mousedown',initMouse);
      //this.foreImage.addEventHandler('mousemove',moveMouse);
      this.foreImage.addEventHandler('mouseup',finishMouse);
      ////////////////buttons
      this.closeButton.addEventHandler('click',
         function (o,evt){
            //window.open( '../dhtml/window_closer.html','DHTMLZoomCloser','width=300,height=300');
            var reply = confirm("The Web page you are viewing is trying to close the window" +
               "\n \nDo you want to close this DHTMLZoomViewer window?");
            if (reply) {
               top.close();
            }
            return false;
         }
      );
      this.plusButton.addEventHandler('click',
         function (o,evt){
            obj.ZoomIn(obj.backImage);
            return false;
         }
      );
      this.minusButton.addEventHandler('click',
         function (o,evt){
            obj.ZoomOut(obj.backImage);
            return false;
         }
      );
      this.resetButton.addEventHandler('click',
         function (o,evt){
            obj.ResetView(obj.backImage);
            return false;
         }
      );
      this.infoButton.addEventHandler('click',
         function (o,evt){
            obj.showInformation();
            return false;
         }
      );
   };

   //////////////////////////////////
   SjZoom.prototype.ZoomInit = function(rgn,type) {
      if(( type=="rgnn" ) || (type == 'rgna') || (type == 'rgn')){
         if( type == "rgnn" ){
            this.RGNtype = "rgnn";
         }else if( type == "rgn" ){
            this.RGNtype = "rgn";
         }else  if( type == "rgna" ){
            this.RGNtype = "rgna";
         }
         this.initRGNZone = rgn;
      }
   };

   SjZoom.prototype.setMaxZoom = function(numZoomLevels, amount,limit) {
      if( ""+amount == "undefined" || amount==null ) amount=2;
      if( amount <= 1 ) amount = 1.1;
   //	if( amount > 3 ) amount = 3;
      this.zoom_factor = amount;
      this.max_zoom = numZoomLevels;
      this.orig_max_zoom = numZoomLevels;
      this.zoom_factor_limit = limit || 0.0;
   };

   SjZoom.prototype.advanced = function( zoomAmount,tiles,percision, transitionLoops, buf_size ) {
      this.zoom_factor = Math.max(1.1,zoomAmount);
      this.panPercision = Math.max(1,parseInt(percision));
      if( buf_size || buf_size == 0 ) this.tileSize.width = Math.max(0,buf_size);
   };

   SjZoom.prototype.enableNav = function(position,inX,inY,inWidth,inHeight) {
      if (this.navLayer == null){
         var tszoom_nav = null;
         if( position >= 1 && position <= 4 ) {
            tszoom_nav = new SjZoomNav(this._parent,null,null,'absolute',null,this.transparency);
         }else if( position > 4 ) {
            tszoom_nav = new SjZoomNav(this._parent,inWidth || null,inHeight || null,'absolute',null,this.transparency);
         }
         tszoom_nav.setViewer(this);
         //??tszoom_nav.initHandlers();
         //??tszoom_nav.navImage.load(this.navloadURL);
         if (this.navloadURL){
            tszoom_nav.dblnavImage.load(this.navloadURL);
         }
      }
      var x =this.left();
      var y =this.top();
      this.navInfo.width = inWidth || this.navInfo.width;
      this.navInfo.height = inHeight || this.navInfo.height;
      if( position >= 1 && position <= 4 ) {
         this.navInfo.pos = position;
         switch(position){
            case 1:	this.navInfo.x = x + 5;
                  this.navInfo.y = y  + 5;
                  break;
            case 2:	this.navInfo.x = x + this.width() - this.navLayer.width() - 5;
                  this.navInfo.y = y  + 5;
                  break;
            case 3:	this.navInfo.x = x + this.width() - this.navLayer.width() - 5;
                  this.navInfo.y = y  + this.height() - this.navLayer.height() - 5;
                  break;
            case 4:	this.navInfo.x = x + 5;
                  this.navInfo.y = y  + this.height() - this.navLayer.height() - 5;
                  break;
         }
      }else if( position > 4 ) {
         this.navInfo.x = x+inX || 0;
         this.navInfo.y = y+inY || 0;
      };

      if (this.navLayer){
         this.navLayer.setSize(this.navInfo.width,this.navInfo.height);
         this.navLayer.toXY(this.navInfo.x,this.navInfo.y);
         this.navLayer.visible(true);
         this.navLayer.zIndex(this.foreImage.zIndex()+10);
      }
      return (this.navLayer);
   };

   SjZoom.prototype.NavigBox = function(){
      if (this.navLayer)
         this.navLayer.visible(!this.navLayer.visible());
   };

   SjZoom.prototype.setFormat = function(str) {
      this.format = str;
   };

   SjZoom.prototype.setCachingModel = function(str) {
      this.cachingModel = str;
   };

   SjZoom.prototype.addInformation = function(str) {
      this.infotxt = "alert('"+str+"')";
   };

   SjZoom.prototype.showInformation = function() {
      if( this.infotxt.length != 0 )	{
         eval(this.infotxt);
      }
      else{
         window.open( '../dhtml/helppage.html','DHTMLZoomInfo','width=300,height=400' );
      };
   };

   SjZoom.prototype.setHelpPage = function(str,w,h) {
      if( ""+str == "undefined" )
         this.infotxt = "window.open('../dhtml/helppage.html','DHTMLZoomInfo','width="+w+",height="+h+"')";
      else
         this.infotxt = "window.open('"+str+"','DHTMLZoomInfo','width="+w+",height="+h+"')";
   };

   SjZoom.prototype.enableUI = function(imgFolder,offset,spacing) {
      if( ""+this.imgFolder == "undefined" ) this.imgFolder= null;
      this.imgFolder	= imgFolder || "../dhtml/images/default/";
      if( this.imgFolder.substring(this.imgFolder.length-1,this.imgFolder.length) != "/" ) this.imgFolder+="/";
      if( ""+offset == "undefined" ) offset=0;
      if( ""+spacing == "undefined" ) spacing=0;

      this.buttonOffset = 0 || offset;
      this.buttonSpace = 0 || spacing;

         if( this.imgFolder != null ) {
            var infoShift = (this.infotxt!=""?1:0);
            var buttonSize = new Array(20,20);

            this.plusButton.toXY(this.viewSize.width-1-(3+infoShift)*(buttonSize[0]+this.buttonSpace),
                            this.viewSize.height-this.buttonOffset);
            this.minusButton.toXY( this.viewSize.width-1-(2+infoShift)*(buttonSize[0]+this.buttonSpace),
                           this.viewSize.height-this.buttonOffset);

            this.resetButton.toXY( this.viewSize.width-1-(1+infoShift)*(buttonSize[0]+this.buttonSpace),
                           this.viewSize.height-this.buttonOffset);

            if( this.infotxt != "" ) {
               this.infoButton.toXY( this.viewSize.width-1-infoShift*(buttonSize[0]+this.buttonSpace),
                              this.viewSize.height-this.buttonOffset);
            };

            //this.closeButton.load(this.imgFolder+'close.gif');
            this.plusButton.load(this.imgFolder+'zoomin.gif');
            this.minusButton.load(this.imgFolder+'zoomout.gif');
            this.resetButton.load(this.imgFolder+'reset.gif');
            this.infoButton.load(this.imgFolder+'info.gif');
            //this.closeButton.visible(false);
            this.plusButton.visible(true);
            this.minusButton.visible(true);
            this.resetButton.visible(true);
            if( this.infotxt != "" ) {
               this.infoButton.visible(true);
            }
         };
   };

   SjZoom.prototype.setWaitIconURL = function(inURL){
      if (this.waitIcon){
         this.waitIconURL = inURL || null;
         this.waitIcon.load(this.waitIconURL);
      }
   };

   SjZoom.prototype.setWaitIconTimer = function(inShowDelay, inHideDelay){
         this.waitIconTimer.showDelay = inShowDelay || 500;
         this.waitIconTimer.hideDelay = inHideDelay || 100;
   };

   SjZoom.prototype.requestHideWaitIcon = function(){
      if (this.waitIconTimerId){
         clearTimeout(this.waitIconTimerId);
         this.waitIconTimerId = null;
      }
      if (this.waitIconURL)
         this.waitIconTimerId = setTimeout(this+".waitIcon.visible(false)", this.waitIconTimer.hideDelay);
   };

   SjZoom.prototype.requestShowWaitIcon = function(){
         if (this.waitIconTimerId){
            clearTimeout(this.waitIconTimerId);
            this.waitIconTimerId = null;
         }
      if (this.waitIconURL)
          this.waitIconTimerId = setTimeout(this+".waitIcon.visible(true)", this.waitIconTimer.showDelay);
   };

   SjZoom.prototype.enableCloseButton = function(position){
      this.closebutton_pos = position;
         if( this.closebutton_pos >= 1 && this.closebutton_pos <= 4 ) {
            this.closeButton.load(this.imgFolder+'close.gif');
            this.closebutton_x = 5; this.closebutton_y = 5;
            if( this.closebutton_pos == 2 || this.closebutton_pos == 3 ) this.closebutton_x = this.viewSize.width-this.closebutton_w-5;
            if( this.closebutton_pos == 3 || this.closebutton_pos == 4 ) this.closebutton_y = this.viewSize.height-this.closebutton_h-5;
            this.closeButton.toXY(this.closebutton_x,this.closebutton_y);
            this.closeButton.visible(true);
         };
   };

   SjZoom.prototype.callStack = function(){
      if (this.stack){
         var str="";
         for (var i=0;i<this.stack.args.length;i++){
            if (i>0){
               str += ","+this+".stack.args["+i+"]";
            }else{
               str += this+".stack.args["+i+"]";
            }
         }
         eval(this+"."+this.stack.name+"("+str+")");
         this.stack = null;
      }
   };

   //XXX01 avu 22.09.2005: fixed issue #4696 - DHTML generic zoom - clicking swatch sometimes doesn't update main image.
   SjZoom.prototype.checkPendingChangeContext = function(){
      if (this.pendingChangeContext != null) {
         var url = this.pendingChangeContext.url;
         var x = this.pendingChangeContext.x;
         var y = this.pendingChangeContext.y;
         var scale = this.pendingChangeContext.scale;
         var defaultScl = this.pendingChangeContext.defaultScl;
         var width = this.pendingChangeContext.width;
         var height = this.pendingChangeContext.height;
         var version = this.pendingChangeContext.version;
         var pageId = this.pendingChangeContext.pageId;
         this.pendingChangeContext = null;
         this.changeContext(url, x, y, scale,defaultScl,width,height,version,pageId);
      }
   };

   ///////////////
   //range -1 .. 1
   SjZoom.prototype.setAlign = function (inX,inY){
      this.alignX = inX || 0;
      this.alignY = inY || 0;
   };

   function SjEvent(inViewer){
      this.viewer = inViewer;
   };

   SjEvent.prototype.onEvent = function(inType,inHandler){
      this.viewer.addEventListener(inType,inHandler);
   };

   SjEvent.prototype.onZoom = function(inType){
      this.viewer.addEventListener(inType,inHandler);
   };

   ///////////////
   function SjURL(inURL){
      if(inURL.length==0) return null;
      this.url=inURL;
      this.port='';
      this.protocol='';
      this.host='';
      var protocolIdx=this.url.indexOf('://');
      if(protocolIdx>=0){
         this.protocol=this.url.substring(0,protocolIdx).toLowerCase();
         this.host=this.url.substring(protocolIdx+3);
         if(this.host.indexOf('/')>=0) this.host=this.host.substring(0,this.host.indexOf('/'));
         var atIdx=this.host.indexOf('@');
         if(atIdx>=0){
            var credentials=this.host.substring(0,atIdx);
            var colonIndex=credentials.indexOf(':');
            if(colonIndex>=0){
               this.username=credentials.substring(0,colonIndex);
               this.password=credentials.substring(colonIndex);
            }else{
               this.username=credentials;
            }
            this.host=this.host.substring(atIdx+1);
         }
         var portIdx=this.host.indexOf(':');
         if(portIdx>=0){
            this.port=this.host.substring(portIdx);
            this.host=this.host.substring(0,portIdx);
         }
         this.file=this.url.substring(protocolIdx+3);
         this.file=this.file.substring(this.file.indexOf('/'));
      }else{
         this.file=this.url;
      }
   }

   SjZoom.prototype.getImageWidth = function(){
      return (this.imgServerWidth);
   };

   SjZoom.prototype.getImageHeight = function(){
      return (this.imgServerHeight);
   };

   ////////
   SjZoom.prototype.setClickToZoom = function(inState){
      return (this.clickToZoom = inState);
   };

   function compareNumbers(a, b) {
       return b - a;
   }
   function compareNumbersDesc(a, b) {//descending order
       return b - a;
   }

   SjZoom.prototype.setZoomScl = function(inArray){
      if (typeof inArray != 'undefined'){
         this.zoomSclArray = new Array();
         if (inArray[0] == 0){
            this.zoomScl = false;
         }else{
            this.zoomScl = true;
            this.zoomSclArray[0]=this.defaultScl/Math.pow(this.zoom_factor , 0);
            for (var i=0;i<inArray.length;i++){
               this.zoomSclArray.push(inArray[i]);
            }
         }
         this.zoomSclArray.sort(compareNumbersDesc);
      }else{
         this.zoomScl = false;
      }
   };

   SjZoom.prototype.setMapper = function(inMapName,inOver,inOut){
      if(inMapName){
        if (document.all) {
         var map = document.all[inMapName];
         if (map){
            var areas = map.all.tags('AREA');
         }
        } else if (document.getElementsByName) {
         var map = document.getElementsByName(inMapName)[0];
         if (map){
            var areas = map.getElementsByTagName('AREA');
         }
        }
        if (areas) {
         for (var a = 0; a < areas.length; a++) {
           areas[a].onmouseover=inOver;
           areas[a].onmouseout=inOut;
           areas[a].onmousedown=function(){
                           //alert("down");
                           return false;
                          };
         }
        }
      }
   };
};/*
ADOBE CONFIDENTIAL
Copyright 2005 Adobe Systems Incorporated
All Rights Reserved.

NOTICE:  All information contained herein is, and remains the property of Adobe Systems Incorporated and its suppliers,
if any.  The intellectual and technical concepts contained herein are proprietary to Adobe Systems Incorporated and its
suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret or 
copyright law. Dissemination of this information or reproduction of this material is strictly forbidden unless prior 
written permission is obtained from Adobe Systems Incorporated.
*/
if (typeof S7ZoomViewer == "undefined") {

   var S7ZoomViewer = {};

   var SjZViewer = function(baseServer,baseImage,width,height,newWidth, newHeight,transparency, imgVersion,inView,pageId,inParams){
      this.baseServerUrl = baseServer;
      this.onEvent = new Object();
      this.SjElement = SjElement;
      this.SjElement();
      if (typeof tsj != 'undefined'){
         this.codePath		= tsj.path;
      }else if(typeof sj != 'undefined'){
         this.codePath		= sj.path;
      }else{
         this.codePath		= '../dhtml/';
      }
      if ((typeof inView == 'undefined') || (inView == null)) {
         inView = 'izView';
      }
       if (sjGetElement(inView)){
         width = parseInt(sjGetElement(inView).offsetWidth);
         height = parseInt(sjGetElement(inView).offsetHeight);
         var str="";
         str+=' <div id='+this._elementId+'_base';
         str+=' STYLE="position:relative;width:' + width + 'px;height:' + height + 'px;">';
         str+='<table id='+this._elementId+'_tbl_base'+' STYLE="width:' + width + 'px;height:' + height + 'px;border:0px solid #ffffff;"  cellspacing=0 cellpadding=0 >';
         str+=' <tr style="HEIGHT:'+height+'px;"><td>';
         str +='<img id='+this._elementId+'_img';
         str +=' src='+this.codePath+"images/spacer.gif";
         str+=' STYLE="position:absolute;left:0px;top:0px;width:' + width + 'px;height:' + 0 + 'px;"';
         str +=' border="0"';
         str +=' >';
         str+=' <div  id='+this._elementId;
         str+=' STYLE="position:absolute;left:0px;top:0px;width:' + width + 'px;height:' + height + 'px;">';
         str+=' </div> ';
         str+=' </td></tr>';
         str+=' </table> ';
         str+=' </div> ';
         sjSetLayerHTML(inView,str);
         this.elem=sjGetElement(this._elementId);
         this.elem._elementId = this._elementId;
         this.elem_base=sjGetElement(this._elementId+'_base');
         this.elem_base._elementId = this._elementId+'_base';
         this.x = 0;
         this.y = 0;
      }else{
         var str="";
         str+=' <div id='+this._elementId+'_base';
         str+=' STYLE="position:relative;width:' + width + 'px;height:' + height + 'px;">';
         str+='<table id='+this._elementId+'_tbl_base'+' STYLE="width:' + width + 'px;height:' + height + 'px;border:0px solid #ffffff;"  cellspacing=0 cellpadding=0 >';
         str+=' <tr style="HEIGHT:'+height+'px;"><td>';
         str +='<img id='+this._elementId+'_img';
         str +=' src='+this.codePath+"images/spacer.gif";
         str+=' STYLE="position:absolute;left:0px;top:0px;width:' + width + 'px;height:' + 0 + 'px;"';
         str +=' border="0"';
         str +=' >';
         str+=' <div  id='+this._elementId;
         str+=' STYLE="position:absolute;left:0px;top:0px;width:' + width + 'px;height:' + height + 'px;">';
         str+=' </div> ';
         str+=' </td></tr>';
         str+=' </table> ';
         str+=' </div> ';
            document.write(str);

         this.elem=sjGetElement(this._elementId);
         this.elem._elementId = this._elementId;
         this.elem_base=sjGetElement(this._elementId+'_base');
         this.elem_base._elementId = this._elementId+'_base';
         this.x = 0;
         this.y = 0;
      }

      this.transparency = transparency;

       if (inParams){
         this.params = this.makeParamObject(inParams);
         if ( typeof this.params.persistence  != 'undefined') {
            this.cookieExpiration = getExpDate(0, 0, this.params.persistence);//by default 30min
         }
         var st = sjIS.getCookie(escape(baseImage+".state"));
         this.state = st.split(';');
      }

      this.zviewer = new SjZoom(this.elem,baseServer+baseImage,width,height,true,true,true,this.transparency);
      var oMap = document.getElementById('s7map_'+this.zviewer._elementId);
      if (oMap){
         document.body.removeChild(oMap);
      }
       oMap = document.createElement('map');
      oMap.id= 's7map_'+this.zviewer._elementId;
      oMap.name= 's7map_'+this.zviewer._elementId;
      if (typeof oMap!="undefined"){
         if (document.all) {
            document.body.insertAdjacentHTML('afterBegin',' <map id="' + oMap.id +'" name="'+oMap.name+'"></map> ');
         } else if (document.getElementById) {
            document.body.appendChild(oMap);
         }
      }
       this.zviewer.toXY(0,0);
      this.zviewer.initHandlers();

      //if (((baseServer) && (baseImage)) && ((newWidth)&&(newHeight)&&(imgVersion))){
      if (((baseServer) && (baseImage)) && ((newWidth)&&(newHeight))){
         this.zviewer.changeContext(baseServer+baseImage,null,null,null,null,newWidth, newHeight, imgVersion,pageId);
      }else if ((baseServer) && (baseImage)){
         this.zviewer.changeContext(baseServer+baseImage,null,null,null,null,null,null,pageId);
      }
      var sjZoomViewer = this;
      this.zviewer.addEventListener('endZoom',
         function (o){
               switch(o.target.state){
                  case "zoomIn":
                  if (sjZoomViewer.onEvent.onImageZoomedIn){
                     sjZoomViewer.onEvent.onImageZoomedIn(1+Math.log(o.target.defaultScl/o.target.currentScl)/Math.log(o.target.zoom_factor));
                  }
                  break;
                  case "zoomOut":
                  if (sjZoomViewer.onEvent.onImageZoomedOut){
                     sjZoomViewer.onEvent.onImageZoomedOut(1+Math.log(o.target.defaultScl/o.target.currentScl)/Math.log(o.target.zoom_factor));
                  }
                     break;
                  case "reset":
                  if (sjZoomViewer.onEvent.onImageResetted){
                     sjZoomViewer.onEvent.onImageResetted(1+Math.log(o.target.defaultScl/o.target.currentScl)/Math.log(o.target.zoom_factor));
                  }
                     break;
                  case "changeContext":
                  if (sjZoomViewer.onEvent.onImageChanged){
                     sjZoomViewer.onEvent.onImageChanged(o.target.oldImage,o.target.mainURL);
                  }
                     break;
                  case "setRGN":
                  if (sjZoomViewer.onEvent.onRegionSet){
                     sjZoomViewer.onEvent.onRegionSet(o.target.currentRGN);
                  }
                     break;
               }
            return false;
         }
      );
   };

   SjZViewer.prototype = new SjElement();

   SjZViewer.prototype.addToPage = function(absolutePos) {
   /*
   if(absolutePos) {
         sjGetElementStyle(this.elem_base._elementId).position='absolute';
         sjSetXY(this.elem_base._elementId,this.x,this.y);
      }else{
         sjGetElementStyle(this.elem_base._elementId).position ='relative';
          this.zviewer.toXY(0,0);
      }
   */
   };

   SjZViewer.prototype.enableNav = function(position,inX,inY,inWidth,inHeight) {
      if( position >= 1 && position <= 4 ) {
         return (this.zviewer.enableNav(position,null,null,50,50));
      }else if( position > 4 ) {
         return (this.zviewer.enableNav(position,inX,inY,inWidth || 50,inHeight || 50));
      };
   };

   SjZViewer.prototype.setBorderNav = function(sz,inColor) {
      if (this.zviewer.navLayer){
         this.zviewer.navLayer.setBorder(sz,inColor);
      }
   };

   SjZViewer.prototype.setBackground = function(bgColor) {
      if (bgColor.toLowerCase() == "transparent"){
         bgColor = "";
      }
      if( ""+bgColor != "undefined" && ""+bgColor.length > 6 ) {
         this.zviewer.color("#"+bgColor.substr(bgColor.length-6));
         if (this.zviewer.navLayer){
            this.zviewer.navLayer.color("#"+bgColor.substr(bgColor.length-6));
         }
      } else {
         this.zviewer.color(bgColor);
         if (this.zviewer.navLayer){
            this.zviewer.navLayer.color(bgColor.substr(bgColor.length-6));
         }
      };
   };

   /*
   SjZViewer.prototype.setImage = function(img, reset, newWidth, newHeight, imgVersion) {
      if (reset || (this.zviewer.initialScl == this.zviewer.currentScl)){
         this.zviewer.changeContext(img,null,null,null,null,newWidth, newHeight, imgVersion);
      }else{
         this.zviewer.changeContext(img,this.zviewer.currentX,this.zviewer.currentY,this.zviewer.currentScl,null,newWidth, newHeight, imgVersion);
      }
   };
   */
   SjZViewer.prototype.setImage = function(img, reset, newWidth, newHeight, imgVersion,pageId) {
      if (this.zviewer.foreImage._fadeid) {
         clearTimeout(this.zviewer.foreImage._fadeid);
         this.zviewer.foreImage._fadeid = null;
      }
      if (reset || (this.zviewer.initialScl == this.zviewer.currentScl)){
         this.zviewer.changeContext(img,null,null,null,null,newWidth, newHeight, imgVersion,pageId);
      }else{
         this.zviewer.changeContext(img,this.zviewer.currentX,this.zviewer.currentY,this.zviewer.currentScl,null,newWidth, newHeight, imgVersion,pageId);
      }
   };

   SjZViewer.prototype.setBrochureImage = function(img, reset, defaultScl, newWidth, newHeight, imgVersion,pageId) {
      if (this.zviewer.foreImage._fadeid) {
         clearTimeout(this.zviewer.foreImage._fadeid);
         this.zviewer.foreImage._fadeid = null;
      }
      if (reset || (this.zviewer.initialScl == this.zviewer.currentScl)){
         this.zviewer.changeContext(img,null,null,null,defaultScl,newWidth, newHeight, imgVersion,pageId);
      }else{
         this.zviewer.changeContext(img,this.zviewer.currentX,this.zviewer.currentY,this.zviewer.currentScl,defaultScl,newWidth, newHeight, imgVersion,pageId);
      }
   };

   SjZViewer.prototype.setFadeTime = function(inFadeTime) {
      this.zviewer.fadeTime = inFadeTime*1000;
   };

   SjZViewer.prototype.setTurnTime = function(inTurnTime) {
      this.zviewer.turnTime = inTurnTime*1000;
   };

   SjZViewer.prototype.setTransitionTime = function(inTransitionTime) {
      this.zviewer.transitionTime = inTransitionTime*1000;
   };

   SjZViewer.prototype.setWaitIconTimer = function(inTimerStr){
      var tempStr = inTimerStr.split(",");
      this.zviewer.waitIconTimer.showDelay = (tempStr[0]-0)*1000;
      this.zviewer.waitIconTimer.hideDelay = (tempStr[1]-0)*1000;
   };


   SjZViewer.prototype.setMaxZoom = function(limit) {
      this.zviewer.setMaxZoom(this.zviewer.max_zoom,this.zviewer.zoom_factor*limit/100,limit/100);
   };

   SjZViewer.prototype.setZoomStep = function(amount) {
      if (amount == 0){
         var d = this.zviewer.defaultScl/Math.pow(this.zviewer.zoom_factor , 0);
         this.zviewer.setMaxZoom(1,d);
      }else{
         this.zviewer.setMaxZoom(this.zviewer.max_zoom, Math.pow(2,1/amount),this.zviewer.zoom_factor_limit);
      }
   };

   SjZViewer.prototype.zoomOut = function() {
      this.zviewer.ZoomOut(this.zviewer.backImage);
   };

   SjZViewer.prototype.zoomIn = function() {
      this.zviewer.ZoomIn(this.zviewer.backImage);
   };

   SjZViewer.prototype.pan = function(direction,amount) {
      var directionX=0;
      var directionY=0;
      switch(direction){
         case 'leftup':
            directionX=-1;directionY=-1;
            break;
         case 'up':
            directionX=0;directionY=-1;
            break;
         case 'rightup':
            directionX=1;directionY=-1;
            break;
         case 'left':
            directionX=-1;directionY=0;
            break;
         case 'right':
            directionX=1;directionY=0;
            break;
         case 'leftdown':
            directionX=-1;directionY=1;
            break;
         case 'down':
            directionX=0;directionY=1;
            break;
         case 'rightdown':
            directionX=1;directionY=1;
            break;
      }
      this.zviewer.pan(this.zviewer.backImage,directionX,directionY,amount);
   };

   SjZViewer.prototype.reset = function() {
      this.zviewer.ResetView(this.zviewer.backImage);
   };

   SjZViewer.prototype.initialRGN = function(rgn) {
      this.zviewer.ZoomInit(rgn,"rgn");
   };

   SjZViewer.prototype.initialRGNN = function(rgn) {
      this.zviewer.ZoomInit(rgn,"rgnn");
   };

   SjZViewer.prototype.initialRGNA = function(rgn) {
      this.zviewer.ZoomInit(rgn,"rgna");
   };

   SjZViewer.prototype.setRGN = function(rgn) {
      this.zviewer.ZoomSet(rgn,"rgn");
   };

   SjZViewer.prototype.setRGNN = function(rgn) {
      this.zviewer.ZoomSet(rgn,"rgnn");
   };

   SjZViewer.prototype.setRGNA = function(rgn) {
      this.zviewer.ZoomSet(rgn,"rgna");
   };

   SjZViewer.prototype.setBorder = function(sz,bgColor) {
      var w =	parseInt(sjGetWidth(this.elem_base._elementId));
      var h =	parseInt(sjGetHeight(this.elem_base._elementId));
      var bgColor = bgColor || "#666666";
      var sz = sz || 0;
         if( ""+bgColor != "undefined" && ""+bgColor.length > 6 ) {
   //			sjSetBackColor(this.elem_base._elementId,"#"+bgColor.substr(bgColor.length-6));
            sjSetBackColor(this._elementId+'_img',"#"+bgColor.substr(bgColor.length-6));
            sjSetBorder(this._elementId+'_tbl_base',sz,'solid',"#"+bgColor.substr(bgColor.length-6));
            if (this.zviewer.navLayer)
               sjSetBorder(this.zviewer.navLayer._elementId,1,'solid',"#"+bgColor.substr(bgColor.length-6));
         } else {
   //			sjSetBackColor(this.elem_base._elementId,bgColor);
            sjSetBackColor(this._elementId+'_img',bgColor);
            sjSetBorder(this._elementId+'_tbl_base',sz,'solid',bgColor);
            if (this.zviewer.navLayer)
               sjSetBorder(this.zviewer.navLayer._elementId,1,'solid',bgColor);
         };
            sjSetWidth(this.elem_base._elementId, w+2*sz);
            sjSetHeight(this.elem_base._elementId, h+2*sz);
            sjSetWidth(this._elementId+'_tbl_base', w+2*sz);
            sjSetHeight(this._elementId+'_tbl_base', h+2*sz);
            sjSetXY(this.elem._elementId, sz,sz);
            this.zviewer.imgBorder = sz;
   };

   SjZViewer.prototype.setFormat = function(str) {
      this.zviewer.setFormat(str);
   };

   SjZViewer.prototype.setCachingModel = function(str) {
      this.zviewer.setCachingModel(str);
   };

   SjZViewer.prototype.addInformation = function(str) {
      this.zviewer.addInformation(str);
   };

   SjZViewer.prototype.setHelpPage = function(str,w,h) {
      this.zviewer.setHelpPage(str,w,h);
   };

   SjZViewer.prototype.initialRGN = function(rgn) {
      this.zviewer.ZoomInit(rgn,"rgn");
   };

   SjZViewer.prototype.initialRGNN = function(rgn) {
      this.zviewer.ZoomInit(rgn,"rgnn");
   };

   SjZViewer.prototype.initialRGNA = function(rgn) {
      this.zviewer.ZoomInit(rgn,"rgna");
   };

   SjZViewer.prototype.advanced = function( zoomAmount,tiles,percision,transitionLoops,buf_size ) {
      this.zviewer.advanced( zoomAmount,tiles,percision,transitionLoops,buf_size );
   };


   SjZViewer.prototype.enableUI = function(imgFolder,offset,spacing) {
         sjSetHeight(this.elem_base._elementId,parseInt(sjGetHeight(this._elementId+'_tbl_base'))+20-Math.min(20,offset)+1);
         //sjSetHeight(this._elementId+'_tbl_base',parseInt(sjGetHeight(this._elementId+'_tbl_base'))+20-Math.min(20,offset)+1);
         sjSetHeight(this._elementId+'_img',20-Math.min(20,offset)+1);
         sjSetWidth(this._elementId+'_img',parseInt(sjGetWidth(this._elementId+'_tbl_base')));
         sjSetXY(this._elementId+'_img',0,parseInt(sjGetHeight(this._elementId+'_tbl_base')));
         this.zviewer.enableUI(imgFolder,offset,spacing);
   };

   SjZViewer.prototype.enableCloseButton = function(position) {
      this.zviewer.enableCloseButton(position);
   };

   SjZViewer.prototype.showInformation = function() {
      this.zviewer.showInformation();
   };

   ////////
   SjZViewer.prototype.setClickToZoom = function(inState){
      return (this.zviewer.clickToZoom = inState);
   };

   ///////
   SjZViewer.prototype.setAltText = function(inTooltip){
      if (this.zviewer.mapImage){
         sjGetElement(this.zviewer.mapImage.img._uId).alt = inTooltip;
         sjGetElement(this.zviewer.mapImage.img._uId).title = inTooltip;
      }else if(this.zviewer.foreImage){
         sjGetElement(this.zviewer.foreImage.img._uId).alt = inTooltip;
         sjGetElement(this.zviewer.foreImage.img._uId).title = inTooltip;
      }
   };

   ///////
   SjZViewer.prototype.getViewerState = function() {
       var i = -1;
      var idx = 0;
      for (i = 0; i < this.zviewer.pageId.length; i++) {
           if (this.zviewer.pageId.charAt(i).charCodeAt(0) >= 48 && this.zviewer.pageId.charAt(i).charCodeAt(0) <= 57) {
               break;
           }
       }
      if (i < this.zviewer.pageId.length){
         idx = parseInt(this.zviewer.pageId.substring(i));
      }
      var stateForXML = "";
      stateForXML += '<state version="1">';
      stateForXML += '<ilc>';
      stateForXML += '<currentImageIdx>'+idx+'</currentImageIdx>';
      stateForXML += '</ilc>';
      stateForXML += '<zpc>';
      stateForXML += '<scale>'+this.zviewer.currentScl+'</scale>';
      stateForXML += '<center>';
      stateForXML += '<x>'+Math.round(this.zviewer.currentScl*(-this.zviewer.currentX+this.zviewer.viewSize.width/2))+'</x>';
      stateForXML += '<y>'+Math.round(this.zviewer.currentScl*(-this.zviewer.currentY+this.zviewer.viewSize.height/2))+'</y>';
      stateForXML += '</center>';
      stateForXML += '</zpc>';
      stateForXML += '</state>';
      return stateForXML;
   };

   ///////
   SjZViewer.prototype.makeParamObject = function(inParams){
      var paramObject = null;
      if ((typeof inParams != 'undefined') && (inParams!= null)){
         var paramObject = new Object();
         for (var i = 0; i < inParams.length; i+=2){
            paramObject[inParams[i]] = inParams[i+1];
         }
      }
      return paramObject;
   };
   ///////
   SjZViewer.prototype.setHotSpotEnable = function(inState){
      return (this.zviewer.hotSpotEnable = inState);
   };
   ///////
   SjZViewer.prototype.imageLabel = function(inLabel){
      if (typeof inLabel != 'undefined'){
         this.zviewer.oimgLabel = this.zviewer.imgLabel;
         this.zviewer.imgLabel = inLabel;
      }
      return this.zviewer.imgLabel;
   };

}
;

         if (typeof BaseZoomWidget == "undefined")
			{
				var BaseZoomWidget = BaseWidget.extend({

					create: function(selector, settings) {
						var jQ = this.base(selector, settings);
						var s = jQ.widgetState();

						s.zoomControl = null;
						s.zoomNavigator = null;

                  
                  sjCallbacks[selector] = function(data) {
                     $(selector).widgetClass().onPropsReturned(selector, data);
                  };

                  sjErrCallbacks[selector] = function(data) {
                     $(selector).widgetClass().updateImage(selector, "no_image");
                  };

                  this.updateImage(selector, s.imageName);

                        return jQ;
					},

					setPropCallback: function(selector, callback) {
						var s = $(selector).widgetData();
						s.callback = callback;
					},

					onUpdateImage: function(selector, event, imageName) {
                        this.updateImage(selector, imageName);
					},
                    onUpdateImageSwatch: function(selector, event, imageName) {
                        this.updateImageSwatch(selector, imageName);
                    },

					updateImage: function(selector, imageName) {
						var self = this;
                        var s = $(selector).widgetState();
                        imageName = (imageName != null ? imageName : this.getCurrentImage(selector));
                        self.doUpdate(selector,s.imageName, imageName);
                        //this.setPropCallback(selector, function(props) { self.doUpdate(selector, props); alert("3333333"+props);});
						//this.getImageProps(selector, imageName);
					},
                    updateImageSwatch: function(selector, imageName) {
                        var self = this;
                        var s = $(selector).widgetState();
                        imageName = (imageName != null ? imageName : this.getCurrentImage(selector));
                        self.doUpdate(selector,s.imageName, imageName);
                        //this.setPropCallback(selector, function(props) { self.doUpdate(selector, props); alert("3333333"+props);});
                        //this.getImageProps(selector, imageName);
                    },

					getCurrentImage: function(selector) {
                        var s = $(selector).widgetState();
                        return s.imageName;
					},

					getImageProps: function(selector, imageName) {
						var s = $(selector).widgetState();
						s.imageName = imageName;

						
						var url = s.baseURL + s.imageName;// + "?scl=1&req=props,json&id=" + encodeURIComponent(selector);
                        $.getScript(url);
					},

					/**
					 * This method is called when data comes back from the scene7 server.
					 * It returns a data object, and the Id we passed to the request, which
					 * is actually the selector.  If a callback was specified, it will be called
					 * and passed the image properties as it's only parameter.
					 * @private
					 */
					onPropsReturned: function(selector, data) {
						var s = $(selector).widgetState();

						
						s.imageProps = {};
						for (var p in data)
						{
							s.imageProps[p.replace(/image\./,"")] = data[p];
						}

						if ($(selector).widgetData().callback)
						{
							
							$(selector).widgetData().callback(s.imageProps);
							this.setPropCallback(selector, null);
						}
					},

					doUpdate: function(selector, imageProps, imageName) {
                        var s = $(selector).widgetState();
                        var imgWidget = '#entityZoomImageWidget_ZoomPanel_EntityZoom_Zoom';
                        ImageWidget.setImageSrc(imgWidget, ImageWidget.getImageSrc(imgWidget), imageName);

                  if (s.zoomControl)
						{
		                    //s.zoomControl.setImage(s.baseURL + s.imageName, true, imageProps.width, imageProps.height);
						}
						else
						{
		                    //this.createNew(selector, imageProps);
						}
					},

					createNew: function(selector, imageProps) {
						var jQ = $(selector);
						var s = jQ.widgetState();
						var self = this;
                        alert(s.baseURL+"."+s.imageName);
						s.zoomControl = new SjZViewer(s.baseURL, s.imageName, null, null,
															   imageProps.width, imageProps.height, false, null,
                                                'izView_' + jQ[0].id);

						
						s.zoomControl.setZoomStep(1);
						s.zoomControl.setMaxZoom(100);
						s.zoomControl.setTurnTime(0.35);
						s.zoomControl.setTransitionTime(0.5);
						s.zoomControl.setBackground('0xffffff');

						
						// TODO: This particular call causes the page to regenerate all of the script : BF 09/11/2008
                  s.zoomControl.zviewer.setWaitIconURL(s.waitIcon);
						s.zoomControl.setWaitIconTimer('3.0,0.1');

						
						s.zoomControl.onEvent.onImageZoomedIn = function(scale, cScale) {
							jQ.widgetTrigger("scene7zoomin", [scale, (cScale == 1)]);
						};

						s.zoomControl.onEvent.onImageZoomedOut = function(scale) {
							jQ.widgetTrigger("scene7zoomout", [scale]);
						};

						s.zoomControl.onEvent.onImageResetted = function(scale) {
							jQ.widgetTrigger("scene7reset", [scale]);
						};

						s.zoomControl.onEvent.onImageChanged = function(oldImage, newImage) {
							jQ.widgetTrigger("scene7imagechanged", [oldImage, newImage]);
						};

						s.zoomControl.onEvent.onRegionSet = function(reigon) {
							jQ.widgetTrigger("scene7panned", [reigon]);
						};

						
						if (s.showNavigator)
						{
							if (sjGetElement('izNav_' + jQ[0].id))
							{
								s.zoomNavigator = new SjZoomNav(null,null,null,'absolute','izNav_' + jQ[0].id);

								s.zoomNavigator.setBorder(s.navigatorBorderWidth, '0x' + s.navigatorBorderColor);
								s.zoomNavigator.setViewer(s.zoomControl.zviewer);
								s.zoomNavigator.visible(true);
							}
						}


						// Hook up our buttons
						if (s.showControls)
						{
							if (s.showZoomControls)
							{
								$(".controls .zoom-in", jQ).click(function() {
									s.zoomControl.zoomIn();
								});

								$(".controls .zoom-out", jQ).click(function() {
									s.zoomControl.zoomOut();
								});

								$(".controls .zoom-reset", jQ).click(function() {
									s.zoomControl.reset();
								});
							}

							if (s.showPanControls)
							{
								$(".controls .panning .pan-up", jQ).click(function() {
									s.zoomControl.pan('up',1);
								});

								$(".controls .panning .pan-down", jQ).click(function() {
									s.zoomControl.pan('down',1);
								});

								$(".controls .panning .pan-left", jQ).click(function() {
									s.zoomControl.pan('left',1);
								});

								$(".controls .panning .pan-right", jQ).click(function() {
									s.zoomControl.pan('right',1);
								});
							}

							$(".close", jQ).click(function() {
								
								$("body", document).trigger("lightboxWidget_hide");
							});
						}

						$(".button", jQ).hover(
							function() {
								$(this).addClass("mouseover");
							},
							function() {
								$(this).removeClass("mouseover");
							}
						);

						// Event handlers for zoom controls
						jQ.widgetBind("zoomin", function() {
							s.zoomControl.zoomIn();
						});

						jQ.widgetBind("zoomout", function() {
							s.zoomControl.zoomOut();
						});

						jQ.widgetBind("reset", function() {
							s.zoomControl.reset();
						});

					}

				});

			}
		
			if (typeof EntityZoomWidget == "undefined")
			{
				var EntityZoomWidget = BaseWidget.extend({

					create: function(selector, settings) {
						var jQ = this.base(selector, settings);

						$(".entity-zoom .button").hover(
							function() { $(this).addClass("mouseover"); },
							function() { $(this).removeClass("mouseover"); }
						);

						// Event handlers for zoom controls
						jQ.widgetBind("zoomin", function() {
							$(selector + "_Zoom").widgetTrigger("zoomin");
						});

						jQ.widgetBind("zoomout", function() {
							$(selector + "_Zoom").widgetTrigger("zoomout");
						});

						jQ.widgetBind("reset", function() {
							$(selector + "_Zoom").widgetTrigger("reset");
						});

						return jQ;
					},

					rebind: function(selector, boundSelector) {
						var s = $(selector).widgetState();
						s.boundSelector = boundSelector;
					}

				});
			}
		

		var BackgroundZoomWidget = BaseWidget.extend({

			create: function(selector, state) {

				var jQ = this.base(selector, state);

				
				var eZoom = selector + "_EntityZoom";
				$('.buttons .zoom-in', jQ).click(function() {
					$(eZoom).widgetTrigger("zoomin");
				}).assignMouseEvents();

				$('.buttons .zoom-out', jQ).click(function() {
					$(eZoom).widgetTrigger("zoomout");
				}).assignMouseEvents();

				$('.buttons .zoom-reset', jQ).click(function() {
					$(eZoom).widgetTrigger("reset");
				}).assignMouseEvents();

				$(".BackgroundZoom .close-button").assignMouseEvents();

				$(eZoom).widgetBind('scene7zoomin', function(event, scale, maxZoom) {
					$(".controls .zoom-reset", jQ).parent().removeClass("disabled");
					$(".controls .zoom-out", jQ).parent().removeClass("disabled");
					if (maxZoom) {
						$(".controls .zoom-in", jQ).parent().addClass("disabled");
					}
				});

				$(eZoom).widgetBind('scene7zoomout', function(event, scale) {
					if (scale == 1) {
						$(".controls .zoom-reset", jQ).parent().addClass("disabled");
						$(".controls .zoom-out", jQ).parent().addClass("disabled");
					}
					$(".controls .zoom-in", jQ).parent().removeClass("disabled");
				});

				$(eZoom).widgetBind('scene7reset', function() {
					$(".controls .zoom-reset", jQ).parent().addClass("disabled");
					$(".controls .zoom-out", jQ).parent().addClass("disabled");
					$(".controls .zoom-in", jQ).parent().removeClass("disabled");
				});

				$(eZoom).widgetBind('scene7imagechanged', function() {
					$(".controls .zoom-reset", jQ).parent().addClass("disabled");
					$(".controls .zoom-out", jQ).parent().addClass("disabled");
					$(".controls .zoom-in", jQ).parent().removeClass("disabled");
				});

				return jQ;
			}
			
		});
	

	if (typeof EntityAltImagesWidget == "undefined")
	{
		var EntityAltImagesWidget = Base.extend({
			constructor: null,

			create: function(selector, settings)
			{
				var jQ = $(selector);
				jQ.widgetState(settings).widgetClass(EntityAltImagesWidget);

				$(".button", jQ).assignMouseEvents();

				var self = this;
				$(".image-item", jQ).hover(
						function() {
							var parts = this.elementData;

							if (parts.productId)
							{
								self.overProduct(selector, parts.productId);
								jQ.widgetTrigger("ensembleproducthover", [parts.productId]);
							}
						},	function() {});


				$(".image-item", jQ).click(function()
				{
					$(".swatch-image-item").removeClass("active");
					self.updateImage(selector, $(this), 0);
					return false;
				});


				$(".navigate-previous", jQ).click(function()
				{
					self.updateImage(selector, $(".image-item.active", jQ), -1);
					return false;
				});

				$(".navigate-next", jQ).click(function()
				{
					self.updateImage(selector, $(".image-item.active", jQ), 1);
					return false;
				});
			},

			updateImage: function(/** String */selector, /** String */altSelector, /** String */dir)
			{
				var jQ = $(selector);
				var s = jQ.widgetState();

				if (dir == 0) {
					$(".image-item", jQ).removeClass("active");
					$(altSelector).addClass("active");
				} else {
					var items = $(".image-item", jQ).not(".navigation");
					var idx = items.index($(altSelector)[0]);
					var newIdx = idx + dir;
					newIdx = (newIdx < 0 ? items.length - 1 : (newIdx > items.length - 1 ? 0 : newIdx));

					$(".image-item", jQ).removeClass("active");
					$(altSelector).addClass("active");
				}

				var data = $(altSelector).elementData();
				jQ.widgetTrigger("updateimage", [data.altImage]);

				EventTracker.track("AltImage", s.entityType.properCase(), s.entityName, data.altImage);

				if (data.productId) {
					// This is an ensemble and they clicked a product (0 if it's the ensemble)
					jQ.widgetTrigger("ensembleproductselected", [data.productId]);
				}
			},

			overProduct: function(/** String */selector, /** Number */productId)
			{
				var jQ = $(selector);
				$(".image-item", jQ).removeClass("mouseover");
				$(".image-item.e-prod" + productId, jQ).addClass("mouseover");
			},

			selectProduct: function(/** String */selector, /** Number */productId)
			{
				var jQ = $(selector);
				var alt = $(" .e-prod" + productId, jQ);
				var fileURL = alt.entityData("altImage");

				jQ.widgetTrigger("updateimage", [fileURL]);
			},

			getWidgetClassName: function()
			{
				return "EntityAltImagesWidget";
			}
		});
	}



	if (typeof EntitySwatchImagesWidget == "undefined")
	{
		var EntitySwatchImagesWidget = Base.extend({
			constructor: null,

			create: function(selector, settings)
			{
				var jQ = $(selector);
				jQ.widgetState(settings).widgetClass(EntitySwatchImagesWidget);

				$(".button", jQ).assignMouseEvents();

				var self = this;
                $(".swatch-image-item", jQ).hover(
                        function() {
                            var parts = this.elementData;

                            if (parts.productId)
                            {
                                self.overProduct(selector, parts.productId);
                                jQ.widgetTrigger("ensembleproducthover", [parts.productId]);
                            }
                        },	function() {});


                $(".swatch-image-item", jQ).click(function()
				{
					$(".image-item").removeClass("active");
					self.updateImageSwatch(selector, $(this), 0);
					return false;
				});

                $(".swatch-navigate-previous", jQ).click(function()
				{
					self.updateImageSwatch(selector, $(".swatch-image-item.active", jQ), -1);
					return false;
				});

				$(".swatch-navigate-next", jQ).click(function()
				{
					self.updateImageSwatch(selector, $(".swatch-image-item.active", jQ), 1);
					return false;
				});

			},

            updateImageSwatch: function(/** String */selector, /** String */altSelector, /** String */dir)
            {
                var jQ = $(selector);
                //var jQ1 = $(document.getElementsByName("altImagesWdigetId")[0].value);
                var s = jQ.widgetState();

                if (dir == 0) {
                    $(".swatch-image-item", jQ).removeClass("active");
                    //$(".image-item", jQ1).removeClass("active");
                    $(altSelector).addClass("active");
                } else {
                    var items = $(".swatch-image-item", jQ).not(".navigation");
                    var idx = items.index($(altSelector)[0]);
                    var newIdx = idx + dir;
                    newIdx = (newIdx < 0 ? items.length - 1 : (newIdx > items.length - 1 ? 0 : newIdx));

                    $(".swatch-image-item", jQ).removeClass("active");
                    //$(".image-item", jQ1).removeClass("active");
                    $(altSelector).addClass("active");
                }

                var data = $(altSelector).elementData();
                jQ.widgetTrigger("updateimageswatch", [data.swatchImage]);

                EventTracker.track("SwatchImage", s.entityType.properCase(), s.entityName, data.swatchImage);

                if (data.productId) {
                    // This is an ensemble and they clicked a product (0 if it's the ensemble)
                    jQ.widgetTrigger("ensembleproductselected", [data.productId]);
                }
            },

            overProduct: function(/** String */selector, /** Number */productId)
			{
				var jQ = $(selector);
				$(".image-item", jQ).removeClass("mouseover");
				$(".image-item.e-prod" + productId, jQ).addClass("mouseover");
            },

			selectProduct: function(/** String */selector, /** Number */productId)
			{
				var jQ = $(selector);
				var alt = $(" .e-prod" + productId, jQ);
				var fileURL = alt.entityData("swatchImage");

				jQ.widgetTrigger("updateimageswatch", [fileURL]);
			},

			getWidgetClassName: function()
			{
				return "EntitySwatchImagesWidget";
			}
		});
	}


		if (typeof BreadcrumbWidget == "undefined") {
			var BreadcrumbWidget = Base.extend({
				constructor: null,

				create: function(selector, settings) {
					$(selector).widgetState(settings).widgetClass(BreadcrumbWidget);
					
					PersistentStorage.register(BreadcrumbWidget, selector);
				},

				addBreadcrumb: function(selector, name, index) {
					var jQ = $(selector);
					var ti = $(".crumb", jQ).length;
					if (index <= (ti - 1)) {
						var j = index - 1;
						// replace
						$(".crumb:gt(" + j + ")", jQ).add($(".delim:gt(" + (j - 1) + ")", jQ)).remove();
						jQ.append('<div class="delim"><!-- --></div>').append('<div class="crumb last">' + name + '</div');
					} else {
						// append - Should handle the 'organic' growth model...
						$(".last", jQ).removeClass("last");
						jQ.append('<div class="delim"><!-- --></div>').append('<div class="crumb last">' + name + '</div');
					}
					var li = $(".crumb", jQ).index($(".crumb.last")[0]);
					var state = PersistentStorage.loadPersistent();
					$(".crumb.last", jQ).click(function(event) {
						PersistentStorage.executeState(state);
						var i = $(".crumb", jQ).index(this);
						$(".crumb:gt(" + i + ")", jQ).add($(".delim:gt(" + (i - 1) + ")", jQ)).remove();
					});
				},

				removeBreadcrumbs: function(selector, index) {
					var jQ = $(selector);
				},

			/**
			 * Public method which external widgets can invoke (normally via an event bind)
			 * which will refresh the state of this widget to show the sub categories for
			 * the given parent category.
			 *
			 * @param selector {String} The selector name of the element in the DOM
			 * @param event {Event} The event object
			 * @param parentCategoryId {Number} The parent category Id
			 */
				loadBreadcrumbs: function(selector, event, categoryId) {
					var jQ = $(selector);
					var s = jQ.widgetState();
					var self = this;

					jQ.widgetLoad("com.fry.ocpsdk.widget.catalog.navigation.BreadcrumbWidget",
					{
						categoryId: categoryId
					},
							  function() {
							  }
							  );
				},
				
				restoreState: function(state, selector) {
					var catId = state["categoryId"];
					var subcatId = state["subcategoryId"];
					if (subcatId) {
						this.loadBreadcrumbs(selector, null, subcatId);
					} else if (catId) {
						this.loadBreadcrumbs(selector, null, catId);
					}
				},

				getWidgetClassName: function() {
					return "BreadcrumbWidget";
				}
			});
		}
	/**
 * @fileoverview A variant matrix is an object that handles the collection of possible variants
 * for a product.  The one method that really matters here is the "fireEvents" method of the
 * {@link VariantMatrixWidget} which will fire the appropriate events to update variant displays
 * for a product.
 * <p/>
 * This work is based on, and heavily depends on, the <tt>AdvancedVariantTranslator</tt> supplied with
 * the OCP.  If you plan to extend the information available for your variants.  I would recommend
 * extending the translator so nothing is removed (which this library depends upon).
 *
 * @author Brett Fattori (bfattori@fry.com)
 */


if (typeof VariantMatrices == "undefined")
{
	/**
	 * @class The collection of all {@link VariantMatrixWidget} instances that are currently
	 *        available within the page.  Variant matrices are added and removed as they
	 *        become available or go out of scope.
	 */
	var VariantMatrices = Base.extend({

		constructor: null,

		/**
		 * Add a variant matrix to the collection for the specified product Id.  There is only one
		 * matrix per unique product.
		 *
		 * @param productId The product Id the matrix belongs to
		 * @param variantMatrix The matrix to associate
		 */
		add: function(productId, variantMatrix) {
         this["_pM" + productId] = variantMatrix;

         // Munge attributes and the axis into objects where the keys points to the indices
			var munged = {};
         var axis = this["_pM" + productId].axis;
			for (var x in axis) {
				munged[axis[x]] = x;
			}
			this["_pM" + productId].axis = munged;
			this["_pM" + productId].axisLength = axis.length;
			this["_pM" + productId].attributesM = [];
         var attr = this["_pM" + productId].attributes;
         for (var y in attr) {
				var aMunged = {};
				for (var z in attr[y]) {
					aMunged[attr[y][z]] = z;
				}
				this["_pM" + productId].attributesM[y] = aMunged;
			}
		},

		/**
		 * Get the variant matrix for the given product
		 * @param productId The product Id of the matrix to retrieve
		 */
		get: function(productId) {
			return this["_pM" + productId];
		},

		/**
		 * Remove the reference to the matrix for the given product
		 * @param productId The product Id of the matrix to remove
		 */
		remove: function(productId) {
			try
			{
				this["_pM" + productId] = null;
				delete this["_pM" + productId];
			}
			catch (ex) {
				// empty for a reason
			}
		},

		/**
		 * Clear all references to variant matrices within the page
		 */
		clear: function() {
			for (var e in this) {
				if (e.substring(0,2) == "_pM")
				{
					try
					{
						this[e] = null;
						delete this[e];
					}
					catch(ex) {
						// empty for a reason
					}
				}
			}
		}
   });
}

if (typeof VariantMatrixWidget == "undefined") {

   /**
    * @class The <tt>VariantMatrixWidget</tt> is an object that operates against the set of
    *        arrays created by the java <tt>VariantMatrixWidget</tt> class.
    *        The axis array indexes into the attributes array, which indexes into
    *        the matrix itself.  Providing access to one of the axis attributes
    *        will garner information about complimentary axis'.
    *        <p/>
    *        For example, if you have a variant matrix covering color and size,
    *        you would be able to provide a color, and learn from that all of the
    *        available sizes.  When working with a <tt>VariantMatrixWidget</tt> it is
    *			 important to understand that the matrix is a multidimensional array.  Each
    *			 axis (color, size, pattern, etc.) is one of the dimensions.  Each axis
    *			 can contain many attributes (blue, green, small, large, etc.).
    *			 <p/>
    *			 For each possible variant in the matrix, there is one entry.  Each entry
    *			 is indexed by a key which is comprised of the attribute index for each axis.
    *			 For a simple item with two axis', say color and size with color being axis zero
    *			 and size being axis one, there would be an attribute value for each color and
    *			 size which is the index of the value for each axis.
    *			 <p/>
    *			 For example, there might be the following data:
    *			 <ul>
    *			 <li>COLOR_NAME: ["red", "blue", "green"]</li>
    *			 <li>SIZE_NAME: ["small", "medium", "large", "x-large"]</li>
    *			 </ul>
    *			 The values in each attribute array are used to determine their index, so
    *			 "red" is zero, "blue" is one, and "green" is two.  The same goes for the
    *			 sizes with "small" being zero, "medium" being one, and so on.  Putting
    *			 the two of them together based on each axis' index would result in a
    *			 key such as "[0,1]" for "red, medium" or "[2,3]" for "green, x-large".
    *			 These keys are used to identify each available variant for the product.
    *			 Some keys will not result in a valid variant, so no entry will exist returning
    *			 <tt>null</tt> if the matrix is queried for that key.
    *			 <p/>
    *			 Using the default variant translator class on the server, each variant
    *			 in the matrix will contain a set of properties (located on the variant's "props"
    *			 field) which indicate such things as backorder state, in-stock availability, price,
    *			 and more.  Examine the <tt>AdvancedVariantTranslator</tt> class in the OCP for
    *			 more information.
    *			 <p/>
    *
    * @param selector {String/jQuery} The element in the DOM which represents the variant matrix
    * @param state {Object} The widget's state at creation
    * @see VariantMatrices
    */
	var VariantMatrixWidget = BaseWidget.extend({

		create: function(selector, state) {
         var jQ = $(selector);
         var s = jQ.widgetState();

			if (state.variantMatrix) {
				if(!VariantMatrices.get(state.productId)) {
					VariantMatrices.add(state.productId,
                                    {
                                       axis: state.axisIndexes,
                                       attributes: state.attributeIndexes,
                                       keys: state.variantKeys,
                                       matrix: state.variantMatrix,
													ordered: state.orderedSelection,
													updateLast: state.updateLastSelector
												});
            }

				s.variantSelectors = [];
				s.selections = {};
            s.selectedVariantId = state.productVariantId;

				// If a default variant was specified, make sure to restore the selections
            if (s.selectedVariantId) {
               var key, mtx = VariantMatrices.get(state.productId);
               for (var o in mtx.matrix) {
                  if (mtx.matrix[o].id == s.selectedVariantId) {
                     key = o;
                     break;
                  }
               }

               for (var a in mtx.axis) {
                  this.setAxisSelection(selector, a, mtx.matrix[key].trans[mtx.axis[a]]);
               }
            }

         } else {
				// There's only one variant, so just locate the field and fill it in
				if (state.singleVariantId) {
					$("#" + state.variantIdField).val(state.singleVariantId);
				}
			}
		},

		/**
		 * Add a selector to the <tt>VariantMatrixWidget</tt> in the order of
		 * creation.  This method can be used to look up a selector at a later time by
		 * its source-order index.
		 * @param selector {String} The selector name of the element in the DOM
		 * @private
		 */
		addVariantSelector: function(selector, variantSelector) {
			var s = $(selector).widgetState();
			var sels = s.variantSelectors;
			var found = false;
			for (var i in sels) {
				if (sels[i].widgetState().attributeName == variantSelector.widgetState().attributeName) {
					found = true;
				}
			}
			if (!found) {
				// Only add the first of the same type
				sels.push(variantSelector);
			}
		},

		/**
		 * Get the indexed variant selector.  The index is the order in
		 * which the selector was added to the <tt>VariantMatrixWidget</tt>.
		 * @param selector {String} The selector name of the element in the DOM
		 * @param index {Number} The index at which the selector resides
		 * @return {jQuery} A jQuery object which represents the variant selector
		 */
		getVariantSelector: function(selector, index) {
			return $(selector).widgetState().variantSelectors[index];
		},

		/**
       * Get the product Id this variant matrix operates against.
		 * @param selector {String} The selector name of the element in the DOM
       * @return {Number} The Id of the product
       */
      getProductId: function(selector) {
         return $(selector).widgetState().productId;
      },

		/**
		 * Get the axis name for the given index number.  Axis' are used to determine
		 * the ordering of the attribute indexes in the variant matrix's keys.
		 *
		 * @param selector {String} The selector name of the element in the DOM
		 * @param axisIndex {Number} The index of the axis
		 * @return {String} The name of the axis for the given index
		 */
		getAxisForIndex: function(selector, axisIndex) {
			var s = $(selector).widgetState();
			return s.axisIndexes[axisIndex];
		},

		/**
       * Returns the axis index for the given axis name.  Returns <code>-1</code>
       * if the attribute is not within the VariantMatrix.
       *
		 * @param selector {String} The selector name of the element in the DOM
       * @param axis {String} The name of the axis. (e.g. COLOR_NAME, SIZE_NAME, etc.)
       */
      getAxisIndex: function(selector, axisName) {
			if (!(selector || axisName)) {
				return -1;
			}
			axisName = axisName.toUpperCase();
			var mtx = VariantMatrices.get($(selector).widgetState().productId);
			return (mtx.axis[axisName] != null ? Number(mtx.axis[axisName]) : -1);
      },

      /**
       * Get the axis for the given attribute value.  If the value appears in more than one
       * axis, only the first axis the value is in will be returned.
       *
		 * @param selector {String} The selector name of the element in the DOM
       * @param value {String} The attribute value to search upon
       */
      getAxisForValue: function(selector, value) {
         var mtx = VariantMatrices.get($(selector).widgetState().productId);
         for (var axis = 0; axis < mtx.attributes.length; axis++) {
            if (mtx.attributesM[axis][value] != null) {
               return mtx.attributesM[axis][value];
            }
         }
         return -1;
      },

      /**
       * Get the index of the value, for the given axis.
       *
		 * @param selector {String} The selector name of the element in the DOM
       * @param axis {Number/String} Either the index of the axis, or the name of the axis
       * @param value {String} The value within the axis' attribute values to find the index for
       */
      getValueIndex: function(selector, axis, value) {
			var mtx = VariantMatrices.get($(selector).widgetState().productId);
			axis = (typeof axis == "string" ? this.getAxisIndex(selector, axis) : axis);
			return (mtx.attributesM[axis][value] != null ? Number(mtx.attributesM[axis][value]) : -1);
      },

      /**
       * Returns the value stored at the index for the specified axis.
		 * @param selector {String} The selector name of the element in the DOM
       * @private
       */
      getAxisValueForIndex: function(selector, axis, index) {
         var mtx = VariantMatrices.get($(selector).widgetState().productId);
         return mtx.attributes[axis][index];
      },

      /**
       * Get the array of all possible values for the given axis.
       *
		 * @param selector {String} The selector name of the element in the DOM
       * @param axisName {String} The name of the axis
       * @return {Array} An array of values for the given axis
       */
      getAxisValues: function(selector, axisName) {
         var mtx = VariantMatrices.get($(selector).widgetState().productId);
         var axis = this.getAxisIndex(selector, axisName);
         if (axis == -1) {
            throw new Error("Invalid axisName specified");
         }
         return mtx.attributes[axis];
      },

		/**
		 * Get the array of all possible values for the given axis.
		 *
		 * @param selector {String} The selector name of the element in the DOM
		 * @param axisName {String} The name of the axis
		 * @return {Array} An array of values for the given axis
		 */
		getAxisValueIndexes: function(selector, axisName) {
			var mtx = VariantMatrices.get($(selector).widgetState().productId);
			var axis = this.getAxisIndex(selector, axisName);
			if (axis == -1) {
				throw new Error("Invalid axisName specified");
			}
			var a = [];
			var m = mtx.attributesM[axis];
			for (var i in m) {
				a.push(Number(m[i]));
			}
			return a;
		},

		/**
       * Get the number of values available for the axis specified.
       *
		 * @param selector {String} The selector name of the element in the DOM
       * @param axisName {String} The name of the axis to count values for.
       * @return {Number} The count of values for the given axis
       */
      getAxisValueCount: function(selector, axisName) {
         var mtx = VariantMatrices.get($(selector).widgetState().productId);
         var axis = this.getAxisIndex(selector, axisName);
         if (axis == -1) {
            throw new Error("Invalid axisName specified");
         }

         if (mtx.attributeCount[axis] == null) {
            mtx.attributeCount[axis] = 0;
            for (var a in mtx.attributes[axis]) {
               mtx.attributeCount[axis]++;
            }
         }
         return mtx.attributeCount[axis];
      },

      /**
       * Returns an object with the corresponding attributes, for the given axis, populated with the values
       * that will have variants available for them.  So if you passed "COLOR_NAME" and "red" as your
       * attribute and value, and the corresponding attributes are "SIZE_NAME" and "PATTERN_NAME", you
       * will get an object with "SIZE_NAME" and "PATTER_NAME" as the keys, and the possible values
       * for those keys.
       *
		 * @param selector {String} The selector name of the element in the DOM
       * @param axisName {String} The name of the axis
       * @param value {String} The attribute value for the specified axis name
       * @type Array
       */
      getCorrespondingValues: function(selector, axisName, value) {
         // Get the corresponding attributes
			var s = $(selector).widgetState();
			var mtx = VariantMatrices.get($(selector).widgetState().productId);
			var axis = this.getAxisIndex(selector, axisName);
			var cAttr = {};
         for (var x in mtx.axis) {
            if (x != axisName) {
					// If using ordered selection, only return axis' which
					// logically FOLLOW the given axisName
					var idx = this.getAxisIndex(selector, x);
					if (!s.orderedSelection || (s.orderedSelection && idx > axis)) {
						cAttr[x] = [];
					}
				}
         }

         if (value) {
            // Now locate all of the variant keys that have the value at the index
            // of the attribute
            var vIdx = this.getValueIndex(selector, axis, value);
            for (var y in mtx.keys) {
               if (mtx.keys[y][axis] == vIdx) {
                  for (var z in cAttr) {
                     cAttr[z].push(this.getAxisValueForIndex(selector, this.getAxisIndex(selector, z), mtx.keys[y][this.getAxisIndex(selector, z)]));
                  }
               }
            }
         } else {
            // In the case where tha attribute value is null, we
            // just want the full lists for corresponding attributes
            for (var z in cAttr) {
               cAttr[z] = this.getAxisValues(selector, z);
            }
         }

         return cAttr;
      },

      /**
       * Store the value that was selected for the axis.
       *
		 * @param selector {String} The selector name of the element in the DOM
       * @param axisName {String} The axis name to store the selected value for.
       * @param selection {String} The selected value
       */
      setAxisSelection: function(selector, axisName, selection) {
         $(selector).widgetState().selections[axisName] = selection;
      },

      /**
       * Get the selected value for the specified axis in the variant matrix.
       *
		 * @param selector {String} The selector name of the element in the DOM
       * @param axisName {String} The name of the axis
       * @return {String} The value stored for the attribute, or <tt>null</tt> if none
       *                  has been specified.
       */
      getAxisSelection: function(selector, axisName) {
         return $(selector).widgetState().selections[axisName];
      },

      /**
       * Determine if the value for the selected axis creates a condition
       * where the variant is valid.  If so, this method will fire the event
       * "updatevariant" on the body, which will contain the variant Id for
       * the corresponding product Id.  If the variant is invalid, a "-1" will
       * be passed as the variant Id.
       *	<p/>
       * Fires an event, on the matrix widget, that has the variant Id and the
       * corresponding values for the type of attribute.  The name of the event
       * will be the attribute name. (i.e. "COLOR_NAME", "SIZE_NAME", etc...)
       * <p/>
       * ex:
       * <pre>
       *    var mtx = VariantMatrices.get(255);
       *    mtx.fireEvents("COLOR_NAME", selectedColor);
       * </pre>
       * This will fire the corresponding attribute events (in this case "SIZE_NAME")
       * on the matrix widget, passing the product Id and the values that are valid
       * for "SIZE_NAME", given the value for "COLOR_NAME".  Additionally, if
       * the selected color and size combination forms a valid variant, the
       * "updatevariant" event will be fired on the matrix widget passing the
       * product Id and the variant Id.
       * <p/>
       * If <tt>fireStatusEvents</tt> is set to <tt>true</tt> in the VariantMatrix,
       * and the selections result in a valid variant, an additional event will be
       * fired which contains the price, a flag indicating if the variant is in stock,
       * and a backordered-until date (if the variant is out of stock and contains said
       * date).
       *
		 * @param selector {String} The selector name of the element in the DOM
       * @param selectedAxis {String} The name of the axis in the matrix
       * @param selectedValue {String} The value for the named attribute
       */
      fireEvents: function(selector, selectedAxis, selectedValue) {
         var jQ = $(selector);
         var s = jQ.widgetState();
         var mtx = VariantMatrices.get(s.productId);
			var axis = this.getAxisIndex(jQ, selectedAxis);

			// Set the selection
			this.setAxisSelection(jQ, selectedAxis, selectedValue);

         // Alert the corresponding selectors that the state has changed
         var corrAttr = this.getCorrespondingValues(jQ, selectedAxis, selectedValue);
         for (var eName in corrAttr) {
				jQ.widgetTrigger(eName, [s.productId, corrAttr[eName], selectedAxis]);

				// If using ordered selection, invalidate and disable the axis'
				// which follow the selected axis, plus one (so we don't disable
				// the logical next in line making selection impossible)
				var idx = this.getAxisIndex(jQ, eName);
				if (s.orderedSelection && (idx > axis + 1)) {
					var sel = this.getVariantSelector(jQ, idx);
					sel.widgetClass().setInvalid(sel);
					sel.widgetClass().disableSelector(sel);
				}
         }

         // Check to make sure the variant is valid
         var currentEntry = this.getSelectedVariantEntry(selector);
         var variantId = currentEntry ? currentEntry.id : null;
         if (!variantId) {
            $("#" + s.variantIdField).val("");
            jQ.widgetTrigger("updatevariant", [s.productId, -1, null]);
         } else {
            $("#" + s.variantIdField).val(variantId);
            jQ.widgetTrigger("updatevariant", [s.productId, variantId, currentEntry]);

				if (s.fireStatusEvents) {
					jQ.widgetTrigger("variantstatuschanged", [currentEntry.props.price,
							  												currentEntry.props.stock,
							  												currentEntry.props.backDate]);
				}
			}
      },

      /**
       * Force the variant to be invalid and fire the appropriate event.
		 * @param selector {String} The selector name of the element in the DOM
       * @param axisName {String} The name of the axis to invalidate
       */
      makeInvalid: function(selector, axisName) {
         var jQ = $(selector);
         var s = jQ.widgetState();
         var mtx = VariantMatrices.get(s.productId);

         // Alert the corresponding selectors the the state has changed
         var corrAttr = this.getCorrespondingValues(selector, axisName, null);
         for (var eName in corrAttr) {
            jQ.widgetTrigger(eName, [s.productId, corrAttr[eName]]);
         }

         $("#" + s.variantIdField).val("");
         jQ.widgetTrigger("updatevariant", [this.productId, -1]);
         this.setAxisSelection(selector, axisName, null);
      },

      /**
       * Get the variant object, or <tt>null</tt> for the key specified
       * by the array of attribute values
       *
		 * @param selector {String} The selector name of the element in the DOM
       * @param values {Array} An array of indexes for each axis
       * @return {Object} The variant object
       */
      getVariant: function(selector, values) {
         var mtx = VariantMatrices.get($(selector).widgetState().productId);

         var key = [];
         for (var x in values) {
            key.push(this.getValueIndex(selector, x, values[x]));
         }
         key = "[" + key + "]";
         return mtx.matrix[key];
      },

      /**
       * Get the unique values for the given variant axis.  The values are stored in the
       * "props" key of each variant.
		 * @param selector {String} The selector name of the element in the DOM
       * @param axisName {String} The name of the axis
       * @return {Array} An array of unique values for the given axis
       */
      getUniquePropertyValues: function(selector, axisName) {
         var mtx = VariantMatrices.get($(selector).widgetState().productId);
         if (mtx.uniqueProps && mtx.uniqueProps[axisName] != null) {
            return mtx.uniqueProps[axisName];
         }

			if (!mtx.uniqueProps) {
				mtx.uniqueProps = {};
				mtx.uniqueProps[axisName] = {};
			}

			if (!mtx.uniqueProps[axisName]) {
				mtx.uniqueProps[axisName] = {};
			}

         for (var v in mtx.matrix) {
				mtx.uniqueProps[axisName][mtx.matrix[v].trans[this.getAxisIndex(selector, axisName)]] = mtx.matrix[v].props[axisName];
         }

         return mtx.uniqueProps[axisName];
      },

		/**
		 * Return the selected variant key.  If the selection is invalid, this method
		 * will return <tt>null</tt>
		 * @param selector {String} The selector name of the element in the DOM
		 * @return {Array} The key array which can be used to locate the selection in the matrix
		 */
		getSelectedVariantKey: function(selector) {
			var jQ = $(selector);
			var s = jQ.widgetState();
			var mtx = VariantMatrices.get(s.productId);
			var key = [];
			for (var a in mtx.axis) {
				if (mtx.axis[a] == null) {
					return null;
				}
				key.push(this.getValueIndex(selector, a, s.selections[a]));
			}
			return key;
		},

		/**
		 * Get the key which corresponds to the current selections.  This key will
		 * include <tt>null</tt> values for selectors which haven't be set yet.  This
		 * key can be used to determine a range for a particular axis of the matrix.
		 * @param selector {String} The selector name of the element in the DOM
		 * @return {Array} An array of the current variant selector values
		 */
		getCurrentVariantKey: function(selector) {
			var jQ = $(selector);
			var s = jQ.widgetState();
			var mtx = VariantMatrices.get(s.productId);
			var key = [];
			for (var a in mtx.axis) {
				if (mtx.axis[a] != null) {
					var i = this.getValueIndex(selector, a, s.selections[a]);
					if (i != -1) {
						key.push(i);
					}
				}
			}
			return key;
		},

		/**
       * Get the variant entry for the currently selected options.  If an axis isn't
       * selected, or the variant isn't found, <tt>null</tt> is returned.
		 * @param selector {String} The selector name of the element in the DOM
       * @return {Object} The variant object
       */
      getSelectedVariantEntry: function(selector) {
         var key = this.getSelectedVariantKey(selector);
			if (key) {
				var jQ = $(selector);
				var s = jQ.widgetState();
				var mtx = VariantMatrices.get(s.productId);
				key = "[" + key + "]";
				return (mtx.matrix[key]? mtx.matrix[key] : null);
			}
			return null;
		},

		/**
		 * Get the Id of the variant for the currently selected options.  If an attribute isn't
		 * selected, or the variant isn't found, <tt>null</tt> is returned.
		 * @param selector {String} The selector name of the element in the DOM
		 * @return {Number} The currently selected variant, or <tt>null</tt>
		 */
		getSelectedVariantId: function(selector) {
			var e = this.getSelectedVariantEntry(selector);
			return e != null ? e.id : null;
		},

		/**
		 * Get the range of values for the given property and axis based on the current
		 * selections in an ordered matrix. The range is calculated by crawling all of
		 * the possible permutations of variants for a product, using the values which are
		 * already fixed via selectors.
		 * @param selector {String} The selector name of the element in the DOM
		 * @param property {String} One of the properties in the translated variant
		 */
		getAxisValueRange: function(selector, property, initalKey) {
			var jQ = $(selector);
			var s = jQ.widgetState();

			if (!s.orderedSelection) {
				// If the selection is not ordered, we can't reasonably perform the op
				return null;
			}

			var keyLen = s.axisIndexes.length;
			var mtx = VariantMatrices.get(s.productId);
			var self = this;

			function crawl(tKey, rng) {
				if (tKey.length == s.axisIndexes.length) {
					var key = "[" + tKey + "]";
					var vt = (mtx.matrix[key]? mtx.matrix[key] : null);
					if (vt && vt.props[property]) {
						rng[0] = vt.props[property];
						rng[1] = vt.props[property];
					}
				} else {
					var valueSet = self.getAxisValueIndexes(selector, s.axisIndexes[tKey.length]);
					for (var i = 0; i < valueSet.length; i++) {
						var newKey = [].concat(tKey, valueSet[i]);
						if (newKey.length < keyLen) {
							crawl(newKey, rng);
						} else {
							var key = "[" + newKey + "]";
							var vt = (mtx.matrix[key]? mtx.matrix[key] : null);
							if (vt && vt.props[property]) {
								rng[0] = vt.props[property] < rng[0] ? vt.props[property] : rng[0];
								rng[1] = vt.props[property] > rng[1] ? vt.props[property] : rng[1];
							}
						}
					}
				}
			}

			var p = s.variantMatrix["[" + s.variantKeys[0] + "]"].props[property];
			var range = (typeof p == "string" ? ["~~~~~~~~~", " "] : [9999999, -9999999]);
			var initRange = [].concat(range);
			var curKey = this.getCurrentVariantKey(selector);
			crawl(initalKey || curKey, range);
			if (initRange[0] == range[0] || initRange[1] == range[1]) {
				// If the range wasn't found, return null
				return null;
			} else {
				return (range[0] == range[1] ? range[0] : range);
			}
		}
	});
}

if (typeof BaseVariantWidget == "undefined") {
	/**
	 * @class This is the base class for all variant selector widgets.  It will initialize the
	 *        instance and set the event handler for it.  The <tt>state</tt> object should
	 *        contain the <tt>productId</tt> that the variants are attached to.
	 *			 <p/>
	 *			 A variant selector is a part of the entire selection process when choosing
	 *			 a product.  A selector would be the size, color, pattern, or some other
	 *			 atomic part of the whole variant.  A variant is comprised of one or more
	 *			 selectors working in conjunction with each other.
	 *
	 */
	var BaseVariantWidget = BaseWidget.extend({

		// A simple marker method
		isVariantWidget: function() {},

		/**
		 * Create an instance of a variant selector widget.
		 *
		 * @param selector {String} The selector name of the element in the DOM
		 * @param settings {Object} An object which contains any model parameters you wish
		 *                          to persist with the object.
		 */
		create: function(selector, state) {
			var jQ = this.base(selector, state);
			var s = jQ.widgetState();

			s.attributeName = s.attributeName.toUpperCase();
			s.selectedValue = "";

			// Store in non-volatile setting
			s.attributeValues = VariantMatrixWidget.getAxisValues(s.triggerElement, s.attributeName);

			// Bind the event for changes to selection
			var self = this;
			$(s.triggerElement).widgetBind(s.attributeName, function(event, productId, values, correspondingAttribute) {
				self.preUpdateAttributes(selector, event, productId, values, correspondingAttribute);
			});

			// Add this selector to the VariantMatrixWidget so it can be looked up by index
			var mtxW = this.getMatrixWidget(selector);
			VariantMatrixWidget.addVariantSelector(mtxW, jQ);

			return jQ;
		},

		/**
		 * Get the underlying matrix for the selector.  This matrix has been specially munged
		 * to contain the data in such a way that the information can be retrieved in the most
		 * efficient manner.  However, this doesn't mean that it is a good substitution for
		 * working with the {@link VariantMatrixWidget} which contains this selector.
		 * @private
		 */
		getMatrix: function(selector) {
			return VariantMatrices.get($(selector).widgetState().productId);
		},

		/**
		 * Returns <tt>true</tt> if the matrix selection is handled as an
		 * ordered set, rather than as a freely grouped selection.
		 * @param selector {String} The selector name of the element in the DOM
		 * @return {Boolean}
		 */
		isMatrixOrdered: function(selector) {
			return this.getMatrix(selector).ordered;
		},

		/**
		 * Returns <tt>true</tt> if the matrix is ordered and the last item should
		 * be updated with status information.
		 * @param selector {String} The selector name of the element in the DOM
		 * @return {Boolean}
		 */
		isUpdateLast: function(selector) {
			return this.getMatrix(selector).updateLast;
		},

		/**
		 * Returns <tt>true</tt> if the variants in the matrix have differences
		 * (variance) in their pricing.
		 * @param selector {String} The selector name of the element in the DOM
		 * @return {Boolean}
		 */
		isPriceVariance: function(selector) {
			return this.getMatrixWidget(selector).widgetState().priceVariance;
		},

		/**
		 * Returns <tt>true</tt> if this widget isn't the first in an ordered set
		 * of variant selectors.
		 * @param selector {String} The selector name of the element in the DOM
		 */
		isNotFirstInOrderedSet: function(selector) {
			var s = $(selector).widgetState();
			return s.orderedNotFirst;
		},

		/**
		 * Returns <tt>true</tt> if the variant selector is invalid.
		 * @return {Boolean} <tt>true</tt> if invalid
		 */
		isInvalid: function(selector) {
			var s = $(selector).widgetState();
			return (VariantMatrixWidget.getAxisSelection(s.triggerElement, this.getAttributeName(selector)) == null);
		},

		/**
		 * Determine if this is the last selector in the variant group.
		 * @param selector {String} The selector name of the element in the DOM
		 * @return {Boolean} <tt>true</tt> if this is the last selector
		 */
		isLastSelector: function(selector) {
			var mtx = this.getMatrix(selector);
			return (Number(mtx.axis[this.getAttributeName(selector)]) == mtx.axisLength - 1);
		},

		/**
		 * Returns <tt>true</tt> if the selector is disabled when it is first drawn.  This
		 * depends on the selector not being the first selector in the set, that the preceeding
		 * selector has more than 1 selection available, and that ordered selection is
		 * required.
		 *
		 * @param selector {String} The selector name of the element in the DOM
		 * @return {Boolean} <tt>true</tt> if this selector should be disabled
		 */
		isFirstRunDisabled: function(selector) {
			if (this.isMatrixOrdered(selector) && this.isNotFirstInOrderedSet(selector)) {
				// Only do this if ordered selection is enabled and this
				// is NOT the first selector in the set
				var mtx = this.getMatrix(selector);
				var prevSelector = Number(mtx.axis[this.getAttributeName(selector)]) - 1;
				if (prevSelector >= 0) {
					// Check how many items it has.  If more than one, we're disabled
					var mtxW = this.getMatrixWidget(selector);
					var attrLen = VariantMatrixWidget.getAxisValues(mtxW, VariantMatrixWidget.getAxisForIndex(mtxW, prevSelector));
					attrLen = attrLen ? attrLen.length : 0;
					return (attrLen > 1);
				}
			}

			return false;
		},

		/**
		 * Returns <tt>true</tt> if this variant selector widget is disabled.
		 * @param selector {String} The selector name of the element in the DOM
		 * @return {Boolean}
		 */
		isDisabled: function(selector) {
			if ($(selector).widgetState().enabled == undefined) {
				return false;
			}
			
			return !$(selector).widgetState().enabled;
		},

		/**
		 * Get the associated {@link VariantMatrixWidget} that this selector is a part of.
		 * @param selector {String} The selector name of the element in the DOM
		 * @return {VariantMatrixWidget} The associated variant matrix
		 */
		getMatrixWidget: function(selector) {
			return $($(selector).widgetState().triggerElement);
		},

		/**
		 * Get the name of this variant selector widget.  This name corresponds
		 * directly to the axis name in the variant matrix.
		 *
		 * @param selector {String} The selector name of the element in the DOM
		 * @return {String}
		 */
		getAttributeName: function(selector) {
			return $(selector).widgetState().attributeName;
		},

		/**
		 * Get the values that are available for this variant selector widget.
		 *
		 * @param selector {String} The selector name of the element in the DOM
		 * @return {String}
		 */
		getAttributeValues: function(selector) {
			return $(selector).widgetState().attributeValues;
		},

		/**
		 * Set the selected value for the variant widget and fire the events which other
		 * variant widgets are listening for.
		 *
		 * @param selector {String} The selector name of the element in the DOM
		 * @param selectedValue {String} The value which was selected for this attribute
		 */
		setSelectedValue: function(selector, selectedValue) {
			var s = $(selector).widgetState();
			VariantMatrixWidget.fireEvents(s.triggerElement, this.getAttributeName(selector), selectedValue);
			$(selector).widgetTrigger("updatelinkedselector", [selectedValue]);
		},

      /**
       * If the selection would cause the variant to become invalid, this method should
       * be called to appropriately fire events and clear values.
       *
		 * @param selector {String} The selector name of the element in the DOM
       */
      setInvalid: function(selector) {
         var s = $(selector).widgetState();
         VariantMatrixWidget.makeInvalid(s.triggerElement, this.getAttributeName(selector));
			$(selector).widgetTrigger("updatelinkedselector", null);
		},

		/**
		 * Set the selected value for the variant widget, but <i>do not</i> fire the
		 * events for the other variant widgets.  Allows you to update the selector
		 * and associated matirix without triggering unnecessary events.
		 *
		 * @param selector {String} The selector name of the element in the DOM
		 * @param selectedValue {String} The value which was selected for this attribute
		 */
		storeSelectedValue: function(selector, selectedValue) {
         var s = $(selector).widgetState();
			VariantMatrixWidget.setAxisSelection(this.getMatrixWidget(selector),
					  this.getAttributeName(selector), selectedValue);
		},

		/**
		 * Get the selected value for this variant widget.
		 *
		 * @param selector {String} The selector name of the element in the DOM
		 * @return {String}
		 */
		getSelectedValue: function(selector) {
			return $(selector).widgetState().selectedValue;
		},

		/**
		 * This method is is used to filter the call to <tt>updateAttributes</tt> on a child class.
		 * @param selector {String} The selector name of the element in the DOM
		 * @param event {Event} The event object
		 * @param productId {Number} The Id of the product being acted upon
		 * @param values {Array} An array of values which are valid for the variant selector
		 * @param correspondingAttribute {String} The name of the selector which triggered the update
		 */
		preUpdateAttributes: function(selector, event, productId, values, correspondingAttribute) {
			var s = $(selector).widgetState();

			if (productId == s.productId)
			{
				// Check to see if this selector should be enabled now
				var mtx = this.getMatrix(selector);
				if (Number(mtx.axis[this.getAttributeName(selector)]) ==
					 Number(mtx.axis[correspondingAttribute]) + 1) {
					this.preEnableSelector(selector);
				}

				var attributeValues = s.attributeValues;
				var unavailableValues = $.diffArr(attributeValues, values);
				this.updateAttributes(selector, productId, unavailableValues);
			}
		},

		/**
		 * Get the backorder statuses for each value.  Returned as an object
		 * with the value name and corresponding status message.
		 *
		 * @param selector {String} The selector name of the element in the DOM
		 * @param value {String} The value to get the message for
		 * @return {Object} The values are the keys, the statuses are the values
		 */
		getBackorderMessage: function(selector, value) {
			var res = null;
			var mtxW = this.getMatrixWidget(selector);
			var curKey = VariantMatrixWidget.getCurrentVariantKey(mtxW);

			if (curKey != null) {
				var jQ = $(selector);
				var s = $(selector).widgetState();
				var mtx = this.getMatrix(selector);
				var mtxS = mtxW.widgetState();
				var self = this;

				// The backorder messaging
				var boRE = /(\w*)\[(\w*)\]/;
				var backMsg = mtxS.backorderMessage.replace(boRE, "$1");
				var backToMsg = mtxS.backorderMessage.replace(boRE, "$1 $2");

				var idx = VariantMatrixWidget.getValueIndex(mtxW, self.getAttributeName(jQ), value);
				var key = [].concat(curKey).slice(0, VariantMatrixWidget.getAxisIndex(mtxW, this.getAttributeName(selector))).concat(idx);
				var mKey = "[" + key + "]";
				var e = mtx.matrix[mKey];
				if (e) {
					var b = !e.props.stock && e.props.backorderable ? (e.props.backDate ? backToMsg + " " + e.props.backDate : backMsg) : null;
					res = (b ? b : null);
				}
			}

			return res;
		},

		/**
		 * This method is intended to be private and is used to filter the call to
		 * <tt>enableSelector()</tt>.  If the selector to be enabled (in an ordered
		 * selection set) only contains a single value, the selector will be
		 * skipped and the call passed to the next.
		 *
		 * @param selector {String} The selector name of the element in the DOM
		 * @private
		 */
		preEnableSelector: function(selector) {
			var s = $(selector).widgetState();
			this.enableSelector(selector);

			if (this.isMatrixOrdered(selector) && this.getAttributeValues(selector).length == 1) {
				// Skip this selector and move onto the next
				var mtx = this.getMatrix(selector);
				var mtxW = this.getMatrixWidget(selector);
				var idx = Number(mtx.axis[this.getAttributeName(selector)]);
				if (idx + 1 < mtx.axisLength) {
					var sel = VariantMatrixWidget.getVariantSelector(mtxW, idx + 1);
					this.preEnableSelector(sel);
				}
			}
		},

		/**
		 * Stub method so that calling <tt>enableSelector()</tt> won't throw an exception
		 * if it isn't implemented.
		 * @param selector {String} The selector name of the element in the DOM
		 */
		enableSelector: function(selector) {
			$(selector).widgetState().enabled = true;
		},

		/**
		 * Stub method so that calling <tt>disableSelector()</tt> won't throw an exception
		 * if it isn't implemented.
		 * @param selector {String} The selector name of the element in the DOM
		 */
		disableSelector: function(selector) {
			$(selector).widgetState().enabled = false;
		},

		/**
		 * @private
		 */
		singleValue: function(selector, productId, value) {
		},

		/**
		 * Update the values that can be selected in the widget based upon what is determined
		 * to be available for any corresponding variant attributes.  This method is called
		 * automatically when another variant attribute within the product is changed. Thus, if
		 * the color is modified to blue, and the large and extra-large sizes are not available,
		 * those will be passed as the third parameter to this method.
		 *
		 * @param selector {String} The selector name of the element in the DOM
		 * @param productId {Number} The Id of the product the variant attribute is tied to
		 * @param unavailableValues {Array} An array of attribute values that should be filtered out
		 */
		updateAttributes: function(selector, productId, unavailableValues) {
		}

	});
}

if (typeof VariantLinkedSelectorWidget == "undefined") {
	/**
	 * @class This is a specialty class which is used by variant selector widgets which
	 *			 are an aggregation of two or more selectors.  It will link the selectors
	 *			 which are contained within it so they will act as one.
	 */
	var VariantLinkedSelectorWidget = BaseWidget.extend({

		/**
		 * Create an instance of a linked variant selector widget.
		 *
		 * @param selector {String} The selector name of the element in the DOM
		 * @param state {Object} An object which contains any model parameters you wish
		 *                       to persist with the object.
		 */
		create: function(selector, state) {
			var jQ = this.base(selector, state);
			var self = this;
			// We need to pause before setting up the links
			setTimeout(function() {
				self.setupLinkage(selector);
			}, 50);
		},

		/**
		 * @private
		 */
		setupLinkage: function(selector) {
			// Get all of the contained variant selector widgets, ignoring
			// other included widgets
			var jQ = $(selector);
			var vSelSet = {};
			$("*.widget-root", jQ).each(function() {
				if ($(this).widgetClass && $(this).widgetClass() &&
					  ($(this).widgetClass().isVariantWidget)) {
					vSelSet[$(this).attr("id")] = $(this);
				}
			});

			// Link all of the selectors together so they act as one
			for (var s in vSelSet) {
				for (var t in vSelSet) {
					if (t !== s) {
						var f = function(evt, value) {
							var aC = arguments.callee;
							aC.w.widgetClass().storeSelectedValue('#' + aC.s, value, true);
						};
						f.w = vSelSet[s];
						f.s = s;
						vSelSet[t].widgetBind("updatelinkedselector", f);
						// Remember the linkage
						var st = vSelSet[t].widgetState();
						if (!st.linkedTo) {
							st.linkedTo = [];
						}
						st.linkedTo.push(vSelSet[s]);
					}
				}
			}
		}
	});

}
;
        function isUnavailable(value, unavailableValues, unavailableText) {
                  var result = false;

                  if (value.indexOf(unavailableText) > -1) {
                     result = true;

                  } else {
                     var val = value;
                     var idx = val.indexOf(" $");

                     if (idx > -1) {
                        val = val.substring(0, idx);
                     }

                     result = $.inArr(val, unavailableValues);
                  }

                  return result;
               }


            /**
			 * @class This is the class for all dropdown variant widgets.  It will initialize the
			 *        instance and set the event handler for it.  The settings object should
			 *        contain the <tt>productId</tt> that the variants are attached to.
			 *
			 */
			var VariantDropdownWidget = BaseVariantWidget.extend({

				/**
				 * Create an instance of a variant widget.
				 *
				 * @param selector {String} The selector name of the element in the DOM
				 * @param settings {Object} An object which contains any model parameters you wish
				 *                          to persist with the object.
				 */
				create: function(selector, settings) {

					var jQ = this.base(selector, settings);
					var s = jQ.widgetState();
					var values = this.getAttributeValues(jQ);
					var self = this;

					if (this.isFirstRunDisabled(selector)) {
						this.disableSelector(selector);
					}

				
						var selElem = $("select.product-" + s.productId + "-variant", jQ);
						for (var u in values) {
							var opt = $("<option>").attr("value", values[u]).append(values[u]);
							if (values[u] == VariantMatrixWidget.getAxisSelection(this.getMatrixWidget(jQ), this.getAttributeName(jQ))) {
								
								opt.attr("selected", true).addClass("selected");
							}
							selElem.append(opt);
						}

						if (!s.orderedNotFirst && this.getMatrix(selector).ordered &&
							 this.getAttributeValues(selector).length == 1) {
							// Select the only available option for them
                            $("select", selector)[0].selectedIndex = 1;
							this.storeSelectedValue(selector, $("select", selector).val(), true);
						}

						self.fixValueNames(selector);

						selElem.change(function(evt) {
							// Maintain the inactive options
							var ina = $("select.product-" + s.productId + "-variant option.inactive", jQ);

							var jq = $("select.product-" + s.productId + "-variant option", jQ)
									  .removeClass("selected").removeClass("inactive");

							if (s.innerLabel && this.selectedIndex == 0) {
								// Not a valid selection
								self.setInvalid(selector);
								return;
							}

							
							jq.each(function() {
								var j = $(this);
								if(j.val()) {
									j.html(j.val());
								}
							});

							self.fixValueNames(selector);

							$(this.options[this.selectedIndex]).addClass("selected");
							self.setSelectedValue(selector, this.options[this.selectedIndex].value);

							if (s.resetWhenInvalid) {
								
								$("select.product-" + s.productId + "-variant option.selected", jQ).removeClass("inactive");
							}

							// Maintain the inactive options
							ina.each(function() {
								$(this).addClass("inactive");
							});

							if ($.browser.msie) {
								jQ.parent().hide().show();
							}
						});
					

					jQ.show().css("display", "block");
					return jQ;
				},

				/**
				 * Call this method to disable the selector.
				 *
				 * @param selector {String} The selector name of the element in the DOM
				 */
				disableSelector: function(selector) {
					this.base(selector);
					$("select", selector).attr("disabled", "disabled");
				},

				/**
				 * Enable the selector in its own specific way if it is disabled
				 * due to implied order of attribute selection.
				 * @param selector {String} The selector name of the element in the DOM
				 */
				enableSelector: function(selector) {
					this.base(selector);
					$("select", selector).attr("disabled", "");
					if (this.getAttributeValues(selector).length == 1) {
						// Select the only value for them
						var s = $(selector).widgetState();
						this.storeSelectedValue(selector, this.getAttributeValues(selector));	
					}
				},

				/**
				 * Fix the value names to reflect variance in pricing
				 * or backorder status for items.  This is called whenever
				 * the values are updated.
				 * @param selector {String} The selector name of the element in the DOM
				 */
				fixValueNames: function(selector) {
					var jQ = $(selector);
					var s = jQ.widgetState();
					var jq = $("select.product-" + s.productId + "-variant option", jQ);
					var values = [];
					var mtxW = this.getMatrixWidget(selector);
					var curKey = VariantMatrixWidget.getCurrentVariantKey(mtxW);
					var pVariance = this.isPriceVariance(selector);

					var self = this;
					jq.each(function() {
						var j = $(this);
						var bMsg = self.getBackorderMessage(selector, j.val());
						var idx = VariantMatrixWidget.getValueIndex(mtxW, self.getAttributeName(selector), $(this).val());
						if (idx != -1) {
							var key = [].concat(curKey).slice(0, VariantMatrixWidget.getAxisIndex(mtxW, self.getAttributeName(selector))).concat(idx);
							if (j.val() && pVariance) {
								j.html(j.val() + " " + (bMsg != null ? "- " + bMsg + " " : "") + self.formatRange(selector, VariantMatrixWidget.getAxisValueRange(mtxW, s.rangeField, key)));
							} else {
								j.html(j.val() + " " + (bMsg != null ? "- " + bMsg : ""));
							}
						}
					});
				},

				/**
				 * Use the format regEx to create the message which best
				 * represents the given range.
				 * @param selector {String} The selector name of the element in the DOM
				 * @param range {Array/String} Either an array with 2 elements (low, high) or a simple
				 *				value because there isn't a range.
				 * @return {String} The formatted message or an empty string if range is <tt>null</tt>
				 */
				formatRange: function(selector, range) {
					var jQ = $(selector);
					var s = jQ.widgetState();
					if (range && s.showRange) {
						var lRE = /range-low/;
						var pRE = /\[(.*)\]/;
						var hRE = /range-high/;
						if (range.join && range.splice) {
							// It's an array
							return s.rangeMessage.replace(lRE, range[0]).replace(pRE, "$1").replace(hRE, range[1]);
						} else {
							// Simple value
							return s.rangeMessage.replace(lRE, range).replace(pRE, "");
						}
					} else {
						return "";
					}
				},

				/**
				 * Set the selected value for the variant widget, but <i>do not</i> fire the
				 * events for the other variant widgets.  Allows you to update the selector
				 * and associated matirix without triggering unnecessary events.
				 *
				 * @param selector {String} The selector name of the element in the DOM
				 * @param selectedValue {String} The value which was selected for this attribute
				 * @param updateDisplay {Boolean} Set to <tt>true</tt> to have the display updated as well
				 */
				storeSelectedValue: function(selector, selectedValue, updateDisplay) {
					this.base(selector, selectedValue);

					if (updateDisplay) {
						var jQ = $(selector);
						var e = $("select", jQ)[0];
						var s = jQ.widgetState();

						// Maintain the inactive options
						var ina = $("select.product-" + s.productId + "-variant option.inactive", jQ);

						var jq = $("select.product-" + s.productId + "-variant option", jQ)
								  .removeClass("selected").removeClass("inactive");

						jq.each(function() {
							var j = $(this);
							if(j.val()) {
								j.html(j.val());
							}
						});

						this.fixValueNames(selector);

						// Find the associated index to select
						for (var i = 0; i < e.options.length; i++) {
							if (e.options[i].value == selectedValue) {
								$(e.options[i]).addClass("selected");
								e.selectedIndex = i;

								if (s.innerLabel && i == 0) {
									// Not a valid selection
									this.setInvalid(selector);
								}

								break;
							}
						}

						// Maintain the inactive options
						ina.each(function() {
							$(this).addClass("inactive");
						});

						if ($.browser.msie) {
							jQ.parent().hide().show();
						}
					}
				},

				preUpdateAttributes: function(selector, event, productId, values, correspondingAttribute) {
					this.base(selector, event, productId, values, correspondingAttribute);
					this.fixValueNames(selector);
				},

				/**
				 * Update the list to only show the values which are available.  Called
				 * automatically when the corresponding attributes are changed.
				 *
				 * @param selector {String} The selector name of the element in the DOM
				 * @param productId {Number} The Id of the product being updated
				 * @param unavailableValues {Array} All of the values that are not valid and
				 *                          should be disabled.
				 */
				updateAttributes: function(selector, productId, unavailableValues) {
                    // made changes so we do not display out of stock items.
                     var jQ = $(selector);
                     var s = jQ.widgetState();
                     var values = this.getAttributeValues(jQ);
                     var self = this;
                     var selElem = $("select.product-" + productId + "-variant", jQ);
                     var selectedOptionElem = selElem.val();

                     selElem.html('');
                     var defaultOpt = $("<option>").attr("value", "");

                     if (s.innerLabel) {
                        defaultOpt.append("Select " + s.singleValueLabel);
                     }

                    defaultOpt.attr("disabled", "disabled");

                     selElem.append(defaultOpt);
                     var valueRetained = false;
                     for (var u in values) {
                         var value = values[u];
                         selElem.append(opt);
                         if (!isUnavailable(value, unavailableValues, s.unavailableTextSuffix)) {
                            var opt = $("<option>").attr("value", values[u]).append(values[u]);
                            if (value == selectedOptionElem) {
                                 opt.attr("selected", true);
                                 valueRetained = true;
                              }
                              selElem.append(opt);
                         }
                    }


                     if (valueRetained) {
                        this.storeSelectedValue(selector, selectedOptionElem);
                     } else {
                         $("select.product-" + productId + "-variant", jQ)[0].selectedIndex = 0;
                        //this.storeSelectedValue(selector, null);
                     }
                     if ($.browser.msie) {
                        jQ.parent().hide().show();
                     }
                  }

			});
		eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(4(A){A.2u("8.3",{2v:4(){2.c.t+=".3";2.1g(19)},2w:4(B,C){5((/^7/).23(B)){2.15(C)}n{2.c[B]=C;2.1g()}},k:4(){d 2.$3.k},1E:4(B){d B.21&&B.21.11(/\\s/g,"25").11(/[^A-2x-2t-9\\-25:\\.]/g,"")||2.c.1Y+A.f(B)},8:4(C,B){d{c:2.c,2s:C,1S:B,y:2.$3.y(C)}},1g:4(O){2.$h=A("1u:2o(a[m])",2.i);2.$3=2.$h.1m(4(){d A("a",2)[0]});2.$b=A([]);6 P=2,D=2.c;2.$3.Y(4(R,Q){5(Q.u&&Q.u.11("#","")){P.$b=P.$b.16(Q.u)}n{5(A(Q).Z("m")!="#"){A.f(Q,"m.3",Q.m);A.f(Q,"p.3",Q.m);6 T=P.1E(Q);Q.m="#"+T;6 S=A("#"+T);5(!S.k){S=A(D.1I).Z("1b",T).l(D.1f).2n(P.$b[R-1]||P.i);S.f("1c.3",19)}P.$b=P.$b.16(S)}n{D.e.24(R+1)}}});5(O){2.i.l(D.1K);2.$b.Y(4(){6 Q=A(2);Q.l(D.1f)});5(D.7===1r){5(1z.u){2.$3.Y(4(S,Q){5(Q.u==1z.u){D.7=S;5(A.X.1h||A.X.2p){6 R=A(1z.u),T=R.Z("1b");R.Z("1b","");1F(4(){R.Z("1b",T)},2q)}2r(0,0);d o}})}n{5(D.12){6 J=2y(A.12("8-3"+A.f(P.i)),10);5(J&&P.$3[J]){D.7=J}}n{5(P.$h.V("."+D.j).k){D.7=P.$h.y(P.$h.V("."+D.j)[0])}}}}D.7=D.7===x||D.7!==1r?D.7:0;D.e=A.2z(D.e.2H(A.1m(2.$h.V("."+D.W),4(R,Q){d P.$h.y(R)}))).1O();5(A.1n(D.7,D.e)!=-1){D.e.2I(A.1n(D.7,D.e),1)}2.$b.l(D.U);2.$h.q(D.j);5(D.7!==x){2.$b.r(D.7).1A().q(D.U);2.$h.r(D.7).l(D.j);6 K=4(){A(P.i).z("1i",[P.v("1i"),P.8(P.$3[D.7],P.$b[D.7])],D.1A)};5(A.f(2.$3[D.7],"p.3")){2.p(D.7,K)}n{K()}}A(2J).17("2K",4(){P.$3.1d(".3");P.$h=P.$3=P.$b=x})}2G(6 G=0,N;N=2.$h[G];G++){A(N)[A.1n(G,D.e)!=-1&&!A(N).13(D.j)?"l":"q"](D.W)}5(D.w===o){2.$3.1o("w.3")}6 C,I,B={"2F-2B":0,1y:1},E="2m";5(D.14&&D.14.2C==2D){C=D.14[0]||B,I=D.14[1]||B}n{C=I=D.14||B}6 H={1p:"",2E:"",2L:""};5(!A.X.1h){H.1x=""}4 M(R,Q,S){Q.1T(C,C.1y||E,4(){Q.l(D.U).1a(H);5(A.X.1h&&C.1x){Q[0].27.V=""}5(S){L(R,S,Q)}})}4 L(R,S,Q){5(I===B){S.1a("1p","1w")}S.1T(I,I.1y||E,4(){S.q(D.U).1a(H);5(A.X.1h&&I.1x){S[0].27.V=""}A(P.i).z("1i",[P.v("1i"),P.8(R,S[0])],D.1A)})}4 F(R,T,Q,S){T.l(D.j).2l().q(D.j);M(R,Q,S)}2.$3.1d(".3").17(D.t,4(){6 T=A(2).2i("1u:r(0)"),Q=P.$b.V(":2j"),S=A(2.u);5((T.13(D.j)&&!D.1q)||T.13(D.W)||A(2).13(D.1e)||A(P.i).z("1V",[P.v("1V"),P.8(2,S[0])],D.15)===o){2.1s();d o}P.c.7=P.$3.y(2);5(D.1q){5(T.13(D.j)){P.c.7=x;T.q(D.j);P.$b.1B();M(2,Q);2.1s();d o}n{5(!Q.k){P.$b.1B();6 R=2;P.p(P.$3.y(2),4(){T.l(D.j).l(D.1J);L(R,S)});2.1s();d o}}}5(D.12){A.12("8-3"+A.f(P.i),P.c.7,D.12)}P.$b.1B();5(S.k){6 R=2;P.p(P.$3.y(2),Q.k?4(){F(R,T,Q,S)}:4(){T.l(D.j);L(R,S)})}n{2c"1P 2k 2h: 2g 2d 2e."}5(A.X.1h){2.1s()}d o});5(!(/^1H/).23(D.t)){2.$3.17("1H.3",4(){d o})}},16:4(E,D,C){5(C==1r){C=2.$3.k}6 G=2.c;6 I=A(G.1W.11(/#\\{m\\}/g,E).11(/#\\{1t\\}/g,D));I.f("1c.3",19);6 H=E.2A("#")==0?E.11("#",""):2.1E(A("a:3f-38",I)[0]);6 F=A("#"+H);5(!F.k){F=A(G.1I).Z("1b",H).l(G.U).f("1c.3",19)}F.l(G.1f);5(C>=2.$h.k){I.2a(2.i);F.2a(2.i[0].3c)}n{I.28(2.$h[C]);F.28(2.$b[C])}G.e=A.1m(G.e,4(K,J){d K>=C?++K:K});2.1g();5(2.$3.k==1){I.l(G.j);F.q(G.U);6 B=A.f(2.$3[0],"p.3");5(B){2.p(C,B)}}2.i.z("26",[2.v("26"),2.8(2.$3[C],2.$b[C])],G.16)},18:4(B){6 D=2.c,E=2.$h.r(B).18(),C=2.$b.r(B).18();5(E.13(D.j)&&2.$3.k>1){2.15(B+(B+1<2.$3.k?1:-1))}D.e=A.1m(A.1U(D.e,4(G,F){d G!=B}),4(G,F){d G>=B?--G:G});2.1g();2.i.z("1M",[2.v("1M"),2.8(E.1D("a")[0],C[0])],D.18)},29:4(B){6 C=2.c;5(A.1n(B,C.e)==-1){d}6 D=2.$h.r(B).q(C.W);5(A.X.3e){D.1a("1p","3g-1w");1F(4(){D.1a("1p","1w")},0)}C.e=A.1U(C.e,4(F,E){d F!=B});2.i.z("1Q",[2.v("1Q"),2.8(2.$3[B],2.$b[B])],C.29)},20:4(C){6 B=2,D=2.c;5(C!=D.7){2.$h.r(C).l(D.W);D.e.24(C);D.e.1O();2.i.z("22",[2.v("22"),2.8(2.$3[C],2.$b[C])],D.20)}},15:4(B){5(2U B=="2V"){B=2.$3.y(2.$3.V("[m$="+B+"]")[0])}2.$3.r(B).37(2.c.t)},p:4(G,K){6 L=2,D=2.c,E=2.$3.r(G),J=E[0],H=K==1r||K===o,B=E.f("p.3");K=K||4(){};5(!B||!H&&A.f(J,"w.3")){K();d}6 M=4(N){6 O=A(N),P=O.1D("*:2N");d P.k&&P.2O(":2P(2Q)")&&P||O};6 C=4(){L.$3.V("."+D.1e).q(D.1e).Y(4(){5(D.1k){M(2).2W().1l(M(2).f("1t.3"))}});L.1j=x};5(D.1k){6 I=M(J).1l();M(J).2X("<1G></1G>").1D("1G").f("1t.3",I).1l(D.1k)}6 F=A.1R({},D.1v,{1Z:B,1C:4(O,N){A(J.u).1l(O);C();5(D.w){A.f(J,"w.3",19)}A(L.i).z("2b",[L.v("2b"),L.8(L.$3[G],L.$b[G])],D.p);D.1v.1C&&D.1v.1C(O,N);K()}});5(2.1j){2.1j.33();C()}E.l(D.1e);1F(4(){L.1j=A.32(F)},0)},1Z:4(C,B){2.$3.r(C).1o("w.3").f("p.3",B)},1c:4(){6 B=2.c;2.i.1d(".3").q(B.1K).1o("3");2.$3.Y(4(){6 C=A.f(2,"m.3");5(C){2.m=C}6 D=A(2).1d(".3");A.Y(["m","p","w"],4(E,F){D.1o(F+".3")})});2.$h.16(2.$b).Y(4(){5(A.f(2,"1c.3")){A(2).18()}n{A(2).q([B.j,B.1J,B.W,B.1f,B.U].3b(" "))}})},v:4(B){d A.t.30({2Z:B,2Y:2.i[0]})}});A.8.3.31={1q:o,t:"1H",e:[],12:x,1k:"35&#34;",w:o,1Y:"8-3-",1v:{},14:x,1W:\'<1u><a m="#{m}"><1N>#{1t}</1N></a></1u>\',1I:"<1X></1X>",1K:"8-3-2R",j:"8-3-7",1J:"8-3-1q",W:"8-3-e",1f:"8-3-1S",U:"8-3-2T",1e:"8-3-36"};A.8.3.3d="k";A.1R(A.8.3.39,{1L:x,3a:4(C,F){F=F||o;6 B=2,E=2.c.7;4 G(){B.1L=2M(4(){E=++E<B.$3.k?E:0;B.15(E)},C)}4 D(H){5(!H||H.2S){2f(B.1L)}}5(C){G();5(!F){2.$3.17(2.c.t,D)}n{2.$3.17(2.c.t,4(){D();E=B.c.7;G()})}}n{D();2.$3.1d(2.c.t,D)}}})})(1P);',62,203,'||this|tabs|function|if|var|selected|ui|||panels|options|return|disabled|data||lis|element|selectedClass|length|addClass|href|else|false|load|removeClass|eq||event|hash|fakeEvent|cache|null|index|triggerHandler|||||||||||||||||||||hideClass|filter|disabledClass|browser|each|attr||replace|cookie|hasClass|fx|select|add|bind|remove|true|css|id|destroy|unbind|loadingClass|panelClass|tabify|msie|tabsshow|xhr|spinner|html|map|inArray|removeData|display|unselect|undefined|blur|label|li|ajaxOptions|block|opacity|duration|location|show|stop|success|find|tabId|setTimeout|em|click|panelTemplate|unselectClass|navClass|rotation|tabsremove|span|sort|jQuery|tabsenable|extend|panel|animate|grep|tabsselect|tabTemplate|div|idPrefix|url|disable|title|tabsdisable|test|push|_|tabsadd|style|insertBefore|enable|appendTo|tabsload|throw|fragment|identifier|clearInterval|Mismatching|Tabs|parents|visible|UI|siblings|normal|insertAfter|has|opera|500|scrollTo|tab|z0|widget|init|setData|Za|parseInt|unique|indexOf|width|constructor|Array|overflow|min|for|concat|splice|window|unload|height|setInterval|last|is|not|img|nav|clientX|hide|typeof|string|parent|wrapInner|target|type|fix|defaults|ajax|abort|8230|Loading|loading|trigger|child|prototype|rotate|join|parentNode|getter|safari|first|inline'.split('|'),0,{}))
;
		if (typeof TabWidget == "undefined") {
			var TabWidget = Base.extend({
				constructor: null,

				create: function(selector, settings) {
					$(selector).widgetState(settings).widgetClass(TabWidget);
					if ($(selector + "> ul").length == 0) {
						$(selector).hide();
					} else {
					
					var options = settings.options || {};
					if(typeof options === "string") {
						options = eval('(' + options + ')') || {};
					}
					options.select = function(e, ui) {
						var oldz = $(ui.tab.parentNode).css("z-index");
						ui.tab.parentNode.oldz = oldz;
						$("li", selector).each(function(){
							$(this).css("z-index", this.oldz);
						});
						$(ui.tab.parentNode).css("z-index", "1000");
						return true;
					};
					var $tabs = $(selector + "> ul").tabs(options);
				
            	}
				}, 
		
				
		
				getWidgetClassName: function() {
					return "TabWidget";
				}
			});
		}
	