/*!
* jQuery UI 1.8
*
* Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
* http://docs.jquery.com/UI
*/
jQuery.ui || (function (a) { a.ui = { version: "1.8", plugin: { add: function (c, d, f) { var e = a.ui[c].prototype; for (var b in f) { e.plugins[b] = e.plugins[b] || []; e.plugins[b].push([d, f[b]]) } }, call: function (b, d, c) { var f = b.plugins[d]; if (!f || !b.element[0].parentNode) { return } for (var e = 0; e < f.length; e++) { if (b.options[f[e][0]]) { f[e][1].apply(b.element, c) } } } }, contains: function (d, c) { return document.compareDocumentPosition ? d.compareDocumentPosition(c) & 16 : d !== c && d.contains(c) }, hasScroll: function (e, c) { if (a(e).css("overflow") == "hidden") { return false } var b = (c && c == "left") ? "scrollLeft" : "scrollTop", d = false; if (e[b] > 0) { return true } e[b] = 1; d = (e[b] > 0); e[b] = 0; return d }, isOverAxis: function (c, b, d) { return (c > b) && (c < (b + d)) }, isOver: function (g, c, f, e, b, d) { return a.ui.isOverAxis(g, f, b) && a.ui.isOverAxis(c, e, d) }, keyCode: { BACKSPACE: 8, CAPS_LOCK: 20, COMMA: 188, CONTROL: 17, DELETE: 46, DOWN: 40, END: 35, ENTER: 13, ESCAPE: 27, HOME: 36, INSERT: 45, LEFT: 37, NUMPAD_ADD: 107, NUMPAD_DECIMAL: 110, NUMPAD_DIVIDE: 111, NUMPAD_ENTER: 108, NUMPAD_MULTIPLY: 106, NUMPAD_SUBTRACT: 109, PAGE_DOWN: 34, PAGE_UP: 33, PERIOD: 190, RIGHT: 39, SHIFT: 16, SPACE: 32, TAB: 9, UP: 38} }; a.fn.extend({ _focus: a.fn.focus, focus: function (b, c) { return typeof b === "number" ? this.each(function () { var d = this; setTimeout(function () { a(d).focus(); (c && c.call(d)) }, b) }) : this._focus.apply(this, arguments) }, enableSelection: function () { return this.attr("unselectable", "off").css("MozUserSelect", "").unbind("selectstart.ui") }, disableSelection: function () { return this.attr("unselectable", "on").css("MozUserSelect", "none").bind("selectstart.ui", function () { return false }) }, scrollParent: function () { var b; if ((a.browser.msie && (/(static|relative)/).test(this.css("position"))) || (/absolute/).test(this.css("position"))) { b = this.parents().filter(function () { return (/(relative|absolute|fixed)/).test(a.curCSS(this, "position", 1)) && (/(auto|scroll)/).test(a.curCSS(this, "overflow", 1) + a.curCSS(this, "overflow-y", 1) + a.curCSS(this, "overflow-x", 1)) }).eq(0) } else { b = this.parents().filter(function () { return (/(auto|scroll)/).test(a.curCSS(this, "overflow", 1) + a.curCSS(this, "overflow-y", 1) + a.curCSS(this, "overflow-x", 1)) }).eq(0) } return (/fixed/).test(this.css("position")) || !b.length ? a(document) : b }, zIndex: function (e) { if (e !== undefined) { return this.css("zIndex", e) } if (this.length) { var c = a(this[0]), b, d; while (c.length && c[0] !== document) { b = c.css("position"); if (b == "absolute" || b == "relative" || b == "fixed") { d = parseInt(c.css("zIndex")); if (!isNaN(d) && d != 0) { return d } } c = c.parent() } } return 0 } }); a.extend(a.expr[":"], { data: function (d, c, b) { return !!a.data(d, b[3]) }, focusable: function (c) { var d = c.nodeName.toLowerCase(), b = a.attr(c, "tabindex"); return (/input|select|textarea|button|object/.test(d) ? !c.disabled : "a" == d || "area" == d ? c.href || !isNaN(b) : !isNaN(b)) && !a(c)["area" == d ? "parents" : "closest"](":hidden").length }, tabbable: function (c) { var b = a.attr(c, "tabindex"); return (isNaN(b) || b >= 0) && a(c).is(":focusable") } }) })(jQuery); ;
/*!
* jQuery UI Widget 1.8
*
* Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
* http://docs.jquery.com/UI/Widget
*/
(function (b) { var a = b.fn.remove; b.fn.remove = function (c, d) { return this.each(function () { if (!d) { if (!c || b.filter(c, [this]).length) { b("*", this).add(this).each(function () { b(this).triggerHandler("remove") }) } } return a.call(b(this), c, d) }) }; b.widget = function (d, f, c) { var e = d.split(".")[0], h; d = d.split(".")[1]; h = e + "-" + d; if (!c) { c = f; f = b.Widget } b.expr[":"][h] = function (i) { return !!b.data(i, d) }; b[e] = b[e] || {}; b[e][d] = function (i, j) { if (arguments.length) { this._createWidget(i, j) } }; var g = new f(); g.options = b.extend({}, g.options); b[e][d].prototype = b.extend(true, g, { namespace: e, widgetName: d, widgetEventPrefix: b[e][d].prototype.widgetEventPrefix || d, widgetBaseClass: h }, c); b.widget.bridge(d, b[e][d]) }; b.widget.bridge = function (d, c) { b.fn[d] = function (g) { var e = typeof g === "string", f = Array.prototype.slice.call(arguments, 1), h = this; g = !e && f.length ? b.extend.apply(null, [true, g].concat(f)) : g; if (e && g.substring(0, 1) === "_") { return h } if (e) { this.each(function () { var i = b.data(this, d), j = i && b.isFunction(i[g]) ? i[g].apply(i, f) : i; if (j !== i && j !== undefined) { h = j; return false } }) } else { this.each(function () { var i = b.data(this, d); if (i) { if (g) { i.option(g) } i._init() } else { b.data(this, d, new c(g, this)) } }) } return h } }; b.Widget = function (c, d) { if (arguments.length) { this._createWidget(c, d) } }; b.Widget.prototype = { widgetName: "widget", widgetEventPrefix: "", options: { disabled: false }, _createWidget: function (d, e) { this.element = b(e).data(this.widgetName, this); this.options = b.extend(true, {}, this.options, b.metadata && b.metadata.get(e)[this.widgetName], d); var c = this; this.element.bind("remove." + this.widgetName, function () { c.destroy() }); this._create(); this._init() }, _create: function () { }, _init: function () { }, destroy: function () { this.element.unbind("." + this.widgetName).removeData(this.widgetName); this.widget().unbind("." + this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass + "-disabled " + this.namespace + "-state-disabled") }, widget: function () { return this.element }, option: function (e, f) { var d = e, c = this; if (arguments.length === 0) { return b.extend({}, c.options) } if (typeof e === "string") { if (f === undefined) { return this.options[e] } d = {}; d[e] = f } b.each(d, function (g, h) { c._setOption(g, h) }); return c }, _setOption: function (c, d) { this.options[c] = d; if (c === "disabled") { this.widget()[d ? "addClass" : "removeClass"](this.widgetBaseClass + "-disabled " + this.namespace + "-state-disabled").attr("aria-disabled", d) } return this }, enable: function () { return this._setOption("disabled", false) }, disable: function () { return this._setOption("disabled", true) }, _trigger: function (d, e, f) { var h = this.options[d]; e = b.Event(e); e.type = (d === this.widgetEventPrefix ? d : this.widgetEventPrefix + d).toLowerCase(); f = f || {}; if (e.originalEvent) { for (var c = b.event.props.length, g; c; ) { g = b.event.props[--c]; e[g] = e.originalEvent[g] } } this.element.trigger(e, f); return !(b.isFunction(h) && h.call(this.element[0], e, f) === false || e.isDefaultPrevented()) } } })(jQuery); ;
/*
* jQuery UI Dialog 1.8
*
* Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
* http://docs.jquery.com/UI/Dialog
*
* Depends:
*	jquery.ui.core.js
*	jquery.ui.widget.js
*  jquery.ui.button.js
*	jquery.ui.draggable.js
*	jquery.ui.mouse.js
*	jquery.ui.position.js
*	jquery.ui.resizable.js
*/
(function(b){var a="ui-dialog ui-widget ui-widget-content ui-corner-all ";b.widget("ui.dialog",{options:{autoOpen:true,buttons:{},closeOnEscape:true,closeText:"close",dialogClass:"",draggable:true,hide:null,height:"auto",maxHeight:false,maxWidth:false,minHeight:150,minWidth:150,modal:false,position:"center",resizable:true,show:null,stack:true,title:"",width:300,zIndex:1000},_create:function(){this.originalTitle=this.element.attr("title");var k=this,l=k.options,i=l.title||k.originalTitle||"&#160;",d=b.ui.dialog.getTitleId(k.element),j=(k.uiDialog=b("<div></div>")).appendTo(document.body).hide().addClass(a+l.dialogClass).css({zIndex:l.zIndex}).attr("tabIndex",-1).css("outline",0).keydown(function(m){if(l.closeOnEscape&&m.keyCode&&m.keyCode===b.ui.keyCode.ESCAPE){k.close(m);m.preventDefault()}}).attr({role:"dialog","aria-labelledby":d}).mousedown(function(m){k.moveToTop(false,m)}),f=k.element.show().removeAttr("title").addClass("ui-dialog-content ui-widget-content").appendTo(j),e=(k.uiDialogTitlebar=b("<div></div>")).addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix").prependTo(j),h=b('<a href="#" title="Close"></a>').addClass("ui-dialog-titlebar-close ui-corner-all").attr("role","button").hover(function(){h.addClass("ui-state-hover")},function(){h.removeClass("ui-state-hover")}).focus(function(){h.addClass("ui-state-focus")}).blur(function(){h.removeClass("ui-state-focus")}).click(function(m){/*k.close(m)*/if(k.element.is('#page, #product')){$.bbq.removeState('find');}; $.bbq.removeState(k.element.attr('id'));return false}).appendTo(e),g=(k.uiDialogTitlebarCloseText=b("<span></span>")).addClass("ui-icon ui-icon-closethick").text(l.closeText).appendTo(h),c=b("<span></span>").addClass("ui-dialog-title").attr("id",d).html(i).prependTo(e);if(b.isFunction(l.beforeclose)&&!b.isFunction(l.beforeClose)){l.beforeClose=l.beforeclose}e.find("*").add(e).disableSelection();if(l.draggable&&b.fn.draggable){k._makeDraggable()}if(l.resizable&&b.fn.resizable){k._makeResizable()}k._createButtons(l.buttons);k._isOpen=false;if(b.fn.bgiframe){j.bgiframe()}},_init:function(){if(this.options.autoOpen){this.open()}},destroy:function(){var c=this;if(c.overlay){c.overlay.destroy()}c.uiDialog.hide();c.element.unbind(".dialog").removeData("dialog").removeClass("ui-dialog-content ui-widget-content").hide().appendTo("body");c.uiDialog.remove();if(c.originalTitle){c.element.attr("title",c.originalTitle)}return c},widget:function(){return this.uiDialog},preclose:function(f){animate_closing();},close:function(e){var c=this,d;if(false===c._trigger("beforeClose",e)){return}if(c.overlay){c.overlay.destroy()}c.uiDialog.unbind("keypress.ui-dialog");c._isOpen=false;if(c.options.hide){c.uiDialog.hide(c.options.hide,function(){c._trigger("close",e)})}else{c.uiDialog.hide();c._trigger("close",e)}b.ui.dialog.overlay.resize();if(c.options.modal){d=0;b(".ui-dialog").each(function(){if(this!==c.uiDialog[0]){d=Math.max(d,b(this).css("z-index"))}});b.ui.dialog.maxZ=d}return c},isOpen:function(){return this._isOpen},moveToTop:function(g,f){var c=this,e=c.options,d;if((e.modal&&!g)||(!e.stack&&!e.modal)){return c._trigger("focus",f)}if(e.zIndex>b.ui.dialog.maxZ){b.ui.dialog.maxZ=e.zIndex}if(c.overlay){b.ui.dialog.maxZ+=1;c.overlay.$el.css("z-index",b.ui.dialog.overlay.maxZ=b.ui.dialog.maxZ)}d={scrollTop:c.element.attr("scrollTop"),scrollLeft:c.element.attr("scrollLeft")};b.ui.dialog.maxZ+=1;c.uiDialog.css("z-index",b.ui.dialog.maxZ);c.element.attr(d);c._trigger("focus",f);return c},open:function(){if(this._isOpen){return}var d=this,e=d.options,c=d.uiDialog;d.overlay=e.modal?new b.ui.dialog.overlay(d):null;if(c.next().length){c.appendTo("body");}d._size();d._position(e.position);c.show(e.show);d.moveToTop(true);     if(e.modal){c.bind("keypress.ui-dialog",function(h){if(h.keyCode!==b.ui.keyCode.TAB){return}var g=b(":tabbable",this),i=g.filter(":first"),f=g.filter(":last");if(h.target===f[0]&&!h.shiftKey){i.focus(1);return false}else{if(h.target===i[0]&&h.shiftKey){f.focus(1);return false}}})}b([]).add(c.find(".ui-dialog-content :tabbable:first")).add(c.find(".ui-dialog-buttonpane :tabbable:first")).add(c).filter(":first").focus();d._trigger("open");d._isOpen=true;return d},_createButtons:function(f){var e=this,c=false,d=b("<div></div>").addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix");e.uiDialog.find(".ui-dialog-buttonpane").remove();if(typeof f==="object"&&f!==null){b.each(f,function(){return !(c=true)})}if(c){b.each(f,function(g,i){var h=b('<button type="button"></button>').text(g).click(function(){i.apply(e.element[0],arguments)}).appendTo(d);if(b.fn.button){h.button()}});d.appendTo(e.uiDialog)}},_makeDraggable:function(){var c=this,f=c.options,g=b(document),e;function d(h){return{position:h.position,offset:h.offset}}c.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close",handle:".ui-dialog-titlebar",containment:"document",start:function(h,i){e=f.height==="auto"?"auto":b(this).height();b(this).height(b(this).height()).addClass("ui-dialog-dragging");c._trigger("dragStart",h,d(i))},drag:function(h,i){c._trigger("drag",h,d(i))},stop:function(h,i){f.position=[i.position.left-g.scrollLeft(),i.position.top-g.scrollTop()];b(this).removeClass("ui-dialog-dragging").height(e);c._trigger("dragStop",h,d(i));b.ui.dialog.overlay.resize()}})},_makeResizable:function(h){h=(h===undefined?this.options.resizable:h);var d=this,g=d.options,c=d.uiDialog.css("position"),f=(typeof h==="string"?h:"n,e,s,w,se,sw,ne,nw");function e(i){return{originalPosition:i.originalPosition,originalSize:i.originalSize,position:i.position,size:i.size}}d.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",alsoResize:d.element,maxWidth:g.maxWidth,maxHeight:g.maxHeight,minWidth:g.minWidth,minHeight:d._minHeight(),handles:f,start:function(i,j){b(this).addClass("ui-dialog-resizing");d._trigger("resizeStart",i,e(j))},resize:function(i,j){d._trigger("resize",i,e(j))},stop:function(i,j){b(this).removeClass("ui-dialog-resizing");g.height=b(this).height();g.width=b(this).width();d._trigger("resizeStop",i,e(j));b.ui.dialog.overlay.resize()}}).css("position",c).find(".ui-resizable-se").addClass("ui-icon ui-icon-grip-diagonal-se")},_minHeight:function(){var c=this.options;if(c.height==="auto"){return c.minHeight}else{return Math.min(c.minHeight,c.height)}},_position:function(d){var e=[],f=[0,0],c;d=d||b.ui.dialog.prototype.options.position;if(typeof d==="string"||(typeof d==="object"&&"0" in d)){e=d.split?d.split(" "):[d[0],d[1]];if(e.length===1){e[1]=e[0]}b.each(["left","top"],function(h,g){if(+e[h]===e[h]){f[h]=e[h];e[h]=g}})}else{if(typeof d==="object"){if("left" in d){e[0]="left";f[0]=d.left}else{if("right" in d){e[0]="right";f[0]=-d.right}}if("top" in d){e[1]="top";f[1]=d.top}else{if("bottom" in d){e[1]="bottom";f[1]=-d.bottom}}}}c=this.uiDialog.is(":visible");if(!c){this.uiDialog.show()}this.uiDialog.css({top:0,left:0}).position({my:e.join(" "),at:e.join(" "),offset:f.join(" "),of:window,collision:"fit",using:function(h){var g=b(this).css(h).offset().top;if(g<0){b(this).css("top",h.top-g)}}});if(!c){this.uiDialog.hide()}},_setOption:function(f,g){var d=this,c=d.uiDialog,h=c.is(":data(resizable)"),e=false;switch(f){case"beforeclose":f="beforeClose";break;case"buttons":d._createButtons(g);break;case"closeText":d.uiDialogTitlebarCloseText.text(""+g);break;case"dialogClass":c.removeClass(d.options.dialogClass).addClass(a+g);break;case"disabled":if(g){c.addClass("ui-dialog-disabled")}else{c.removeClass("ui-dialog-disabled")}break;case"draggable":if(g){d._makeDraggable()}else{c.draggable("destroy")}break;case"height":e=true;break;case"maxHeight":if(h){c.resizable("option","maxHeight",g)}e=true;break;case"maxWidth":if(h){c.resizable("option","maxWidth",g)}e=true;break;case"minHeight":if(h){c.resizable("option","minHeight",g)}e=true;break;case"minWidth":if(h){c.resizable("option","minWidth",g)}e=true;break;case"position":d._position(g);break;case"resizable":if(h&&!g){c.resizable("destroy")}if(h&&typeof g==="string"){c.resizable("option","handles",g)}if(!h&&g!==false){d._makeResizable(g)}break;case"title":b(".ui-dialog-title",d.uiDialogTitlebar).html(""+(g||"&#160;"));break;case"width":e=true;break}b.Widget.prototype._setOption.apply(d,arguments);if(e){d._size()}},_size:function(){var d=this.options,c;this.element.css("width","auto").hide();c=this.uiDialog.css({height:"auto",width:d.width}).height();this.element.css(d.height==="auto"?{minHeight:Math.max(d.minHeight-c,0),height:"auto"}:{minHeight:0,height:Math.max(d.height-c,0)}).show();if(this.uiDialog.is(":data(resizable)")){this.uiDialog.resizable("option","minHeight",this._minHeight())}}});b.extend(b.ui.dialog,{version:"1.8",uuid:0,maxZ:0,getTitleId:function(c){var d=c.attr("id");if(!d){this.uuid+=1;d=this.uuid}return"ui-dialog-title-"+d},overlay:function(c){this.$el=b.ui.dialog.overlay.create(c)}});b.extend(b.ui.dialog.overlay,{instances:[],oldInstances:[],maxZ:0,events:b.map("focus,mousedown,mouseup,keydown,keypress,click".split(","),function(c){return c+".dialog-overlay"}).join(" "),create:function(d){if(this.instances.length===0){setTimeout(function(){if(b.ui.dialog.overlay.instances.length){b(document).bind(b.ui.dialog.overlay.events,function(e){return(b(e.target).zIndex()>=b.ui.dialog.overlay.maxZ)})}},1);b(document).bind("keydown.dialog-overlay",function(e){if(d.options.closeOnEscape&&e.keyCode&&e.keyCode===b.ui.keyCode.ESCAPE){d.close(e);e.preventDefault()}});b(window).bind("resize.dialog-overlay",b.ui.dialog.overlay.resize)}var c=(this.oldInstances.pop()||b("<div></div>").addClass("ui-widget-overlay")).appendTo(document.body).css({width:this.width(),height:this.height()});if(b.fn.bgiframe){c.bgiframe()}this.instances.push(c);return c},destroy:function(c){this.oldInstances.push(this.instances.splice(b.inArray(c,this.instances),1)[0]);if(this.instances.length===0){b([document,window]).unbind(".dialog-overlay")}c.remove();var d=0;b.each(this.instances,function(){d=Math.max(d,this.css("z-index"))});this.maxZ=d},height:function(){return b('.main').innerHeight()+"px"},width:function(){return b('.main').innerWidth()+"px"},resize:function(){var c=b([]);b.each(b.ui.dialog.overlay.instances,function(){c=c.add(this)});c.css({width:0,height:0}).css({width:b.ui.dialog.overlay.width(),height:b.ui.dialog.overlay.height()})}});b.extend(b.ui.dialog.overlay.prototype,{destroy:function(){b.ui.dialog.overlay.destroy(this.$el)}})}(jQuery));;
/*
* jQuery UI Effects 1.8
*
* Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
* http://docs.jquery.com/UI/Effects/
*/
jQuery.effects || (function (g) { g.effects = {}; g.each(["backgroundColor", "borderBottomColor", "borderLeftColor", "borderRightColor", "borderTopColor", "color", "outlineColor"], function (l, k) { g.fx.step[k] = function (m) { if (!m.colorInit) { m.start = j(m.elem, k); m.end = i(m.end); m.colorInit = true } m.elem.style[k] = "rgb(" + Math.max(Math.min(parseInt((m.pos * (m.end[0] - m.start[0])) + m.start[0], 10), 255), 0) + "," + Math.max(Math.min(parseInt((m.pos * (m.end[1] - m.start[1])) + m.start[1], 10), 255), 0) + "," + Math.max(Math.min(parseInt((m.pos * (m.end[2] - m.start[2])) + m.start[2], 10), 255), 0) + ")" } }); function i(l) { var k; if (l && l.constructor == Array && l.length == 3) { return l } if (k = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(l)) { return [parseInt(k[1], 10), parseInt(k[2], 10), parseInt(k[3], 10)] } if (k = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(l)) { return [parseFloat(k[1]) * 2.55, parseFloat(k[2]) * 2.55, parseFloat(k[3]) * 2.55] } if (k = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(l)) { return [parseInt(k[1], 16), parseInt(k[2], 16), parseInt(k[3], 16)] } if (k = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(l)) { return [parseInt(k[1] + k[1], 16), parseInt(k[2] + k[2], 16), parseInt(k[3] + k[3], 16)] } if (k = /rgba\(0, 0, 0, 0\)/.exec(l)) { return a.transparent } return a[g.trim(l).toLowerCase()] } function j(m, k) { var l; do { l = g.curCSS(m, k); if (l != "" && l != "transparent" || g.nodeName(m, "body")) { break } k = "backgroundColor" } while (m = m.parentNode); return i(l) } var a = { 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] }; var e = ["add", "remove", "toggle"], c = { border: 1, borderBottom: 1, borderColor: 1, borderLeft: 1, borderRight: 1, borderTop: 1, borderWidth: 1, margin: 1, padding: 1 }; function f() { var n = document.defaultView ? document.defaultView.getComputedStyle(this, null) : this.currentStyle, o = {}, l, m; if (n && n.length && n[0] && n[n[0]]) { var k = n.length; while (k--) { l = n[k]; if (typeof n[l] == "string") { m = l.replace(/\-(\w)/g, function (p, q) { return q.toUpperCase() }); o[m] = n[l] } } } else { for (l in n) { if (typeof n[l] === "string") { o[l] = n[l] } } } return o } function b(l) { var k, m; for (k in l) { m = l[k]; if (m == null || g.isFunction(m) || k in c || (/scrollbar/).test(k) || (!(/color/i).test(k) && isNaN(parseFloat(m)))) { delete l[k] } } return l } function h(k, m) { var n = { _: 0 }, l; for (l in m) { if (k[l] != m[l]) { n[l] = m[l] } } return n } g.effects.animateClass = function (k, l, n, m) { if (g.isFunction(n)) { m = n; n = null } return this.each(function () { var r = g(this), o = r.attr("style") || " ", s = b(f.call(this)), q, p = r.attr("className"); g.each(e, function (t, u) { if (k[u]) { r[u + "Class"](k[u]) } }); q = b(f.call(this)); r.attr("className", p); r.animate(h(s, q), l, n, function () { g.each(e, function (t, u) { if (k[u]) { r[u + "Class"](k[u]) } }); if (typeof r.attr("style") == "object") { r.attr("style").cssText = ""; r.attr("style").cssText = o } else { r.attr("style", o) } if (m) { m.apply(this, arguments) } }) }) }; g.fn.extend({ _addClass: g.fn.addClass, addClass: function (l, k, n, m) { return k ? g.effects.animateClass.apply(this, [{ add: l }, k, n, m]) : this._addClass(l) }, _removeClass: g.fn.removeClass, removeClass: function (l, k, n, m) { return k ? g.effects.animateClass.apply(this, [{ remove: l }, k, n, m]) : this._removeClass(l) }, _toggleClass: g.fn.toggleClass, toggleClass: function (m, l, k, o, n) { if (typeof l == "boolean" || l === undefined) { if (!k) { return this._toggleClass(m, l) } else { return g.effects.animateClass.apply(this, [(l ? { add: m} : { remove: m }), k, o, n]) } } else { return g.effects.animateClass.apply(this, [{ toggle: m }, l, k, o]) } }, switchClass: function (k, m, l, o, n) { return g.effects.animateClass.apply(this, [{ add: m, remove: k }, l, o, n]) } }); g.extend(g.effects, { version: "1.8", save: function (l, m) { for (var k = 0; k < m.length; k++) { if (m[k] !== null) { l.data("ec.storage." + m[k], l[0].style[m[k]]) } } }, restore: function (l, m) { for (var k = 0; k < m.length; k++) { if (m[k] !== null) { l.css(m[k], l.data("ec.storage." + m[k])) } } }, setMode: function (k, l) { if (l == "toggle") { l = k.is(":hidden") ? "show" : "hide" } return l }, getBaseline: function (l, m) { var n, k; switch (l[0]) { case "top": n = 0; break; case "middle": n = 0.5; break; case "bottom": n = 1; break; default: n = l[0] / m.height } switch (l[1]) { case "left": k = 0; break; case "center": k = 0.5; break; case "right": k = 1; break; default: k = l[1] / m.width } return { x: k, y: n} }, createWrapper: function (k) { if (k.parent().is(".ui-effects-wrapper")) { return k.parent() } var l = { width: k.outerWidth(true), height: k.outerHeight(true), "float": k.css("float") }, m = g("<div></div>").addClass("ui-effects-wrapper").css({ fontSize: "100%", background: "transparent", border: "none", margin: 0, padding: 0 }); k.wrap(m); m = k.parent(); if (k.css("position") == "static") { m.css({ position: "relative" }); k.css({ position: "relative" }) } else { g.extend(l, { position: k.css("position"), zIndex: k.css("z-index") }); g.each(["top", "left", "bottom", "right"], function (n, o) { l[o] = k.css(o); if (isNaN(parseInt(l[o], 10))) { l[o] = "auto" } }); k.css({ position: "relative", top: 0, left: 0 }) } return m.css(l).show() }, removeWrapper: function (k) { if (k.parent().is(".ui-effects-wrapper")) { return k.parent().replaceWith(k) } return k }, setTransition: function (l, n, k, m) { m = m || {}; g.each(n, function (p, o) { unit = l.cssUnit(o); if (unit[0] > 0) { m[o] = unit[0] * k + unit[1] } }); return m } }); function d(l, k, m, n) { if (typeof l == "object") { n = k; m = null; k = l; l = k.effect } if (g.isFunction(k)) { n = k; m = null; k = {} } if (g.isFunction(m)) { n = m; m = null } if (typeof k == "number" || g.fx.speeds[k]) { n = m; m = k; k = {} } k = k || {}; m = m || k.duration; m = g.fx.off ? 0 : typeof m == "number" ? m : g.fx.speeds[m] || g.fx.speeds._default; n = n || k.complete; return [l, k, m, n] } g.fn.extend({ effect: function (n, m, p, q) { var l = d.apply(this, arguments), o = { options: l[1], duration: l[2], callback: l[3] }, k = g.effects[n]; return k && !g.fx.off ? k.call(this, o) : this }, _show: g.fn.show, show: function (l) { if (!l || typeof l == "number" || g.fx.speeds[l]) { return this._show.apply(this, arguments) } else { var k = d.apply(this, arguments); k[1].mode = "show"; return this.effect.apply(this, k) } }, _hide: g.fn.hide, hide: function (l) { if (!l || typeof l == "number" || g.fx.speeds[l]) { return this._hide.apply(this, arguments) } else { var k = d.apply(this, arguments); k[1].mode = "hide"; return this.effect.apply(this, k) } }, __toggle: g.fn.toggle, toggle: function (l) { if (!l || typeof l == "number" || g.fx.speeds[l] || typeof l == "boolean" || g.isFunction(l)) { return this.__toggle.apply(this, arguments) } else { var k = d.apply(this, arguments); k[1].mode = "toggle"; return this.effect.apply(this, k) } }, cssUnit: function (k) { var l = this.css(k), m = []; g.each(["em", "px", "%", "pt"], function (n, o) { if (l.indexOf(o) > 0) { m = [parseFloat(l), o] } }); return m } }); g.easing.jswing = g.easing.swing; g.extend(g.easing, { def: "easeOutQuad", swing: function (l, m, k, o, n) { return g.easing[g.easing.def](l, m, k, o, n) }, easeInQuad: function (l, m, k, o, n) { return o * (m /= n) * m + k }, easeOutQuad: function (l, m, k, o, n) { return -o * (m /= n) * (m - 2) + k }, easeInOutQuad: function (l, m, k, o, n) { if ((m /= n / 2) < 1) { return o / 2 * m * m + k } return -o / 2 * ((--m) * (m - 2) - 1) + k }, easeInCubic: function (l, m, k, o, n) { return o * (m /= n) * m * m + k }, easeOutCubic: function (l, m, k, o, n) { return o * ((m = m / n - 1) * m * m + 1) + k }, easeInOutCubic: function (l, m, k, o, n) { if ((m /= n / 2) < 1) { return o / 2 * m * m * m + k } return o / 2 * ((m -= 2) * m * m + 2) + k }, easeInQuart: function (l, m, k, o, n) { return o * (m /= n) * m * m * m + k }, easeOutQuart: function (l, m, k, o, n) { return -o * ((m = m / n - 1) * m * m * m - 1) + k }, easeInOutQuart: function (l, m, k, o, n) { if ((m /= n / 2) < 1) { return o / 2 * m * m * m * m + k } return -o / 2 * ((m -= 2) * m * m * m - 2) + k }, easeInQuint: function (l, m, k, o, n) { return o * (m /= n) * m * m * m * m + k }, easeOutQuint: function (l, m, k, o, n) { return o * ((m = m / n - 1) * m * m * m * m + 1) + k }, easeInOutQuint: function (l, m, k, o, n) { if ((m /= n / 2) < 1) { return o / 2 * m * m * m * m * m + k } return o / 2 * ((m -= 2) * m * m * m * m + 2) + k }, easeInSine: function (l, m, k, o, n) { return -o * Math.cos(m / n * (Math.PI / 2)) + o + k }, easeOutSine: function (l, m, k, o, n) { return o * Math.sin(m / n * (Math.PI / 2)) + k }, easeInOutSine: function (l, m, k, o, n) { return -o / 2 * (Math.cos(Math.PI * m / n) - 1) + k }, easeInExpo: function (l, m, k, o, n) { return (m == 0) ? k : o * Math.pow(2, 10 * (m / n - 1)) + k }, easeOutExpo: function (l, m, k, o, n) { return (m == n) ? k + o : o * (-Math.pow(2, -10 * m / n) + 1) + k }, easeInOutExpo: function (l, m, k, o, n) { if (m == 0) { return k } if (m == n) { return k + o } if ((m /= n / 2) < 1) { return o / 2 * Math.pow(2, 10 * (m - 1)) + k } return o / 2 * (-Math.pow(2, -10 * --m) + 2) + k }, easeInCirc: function (l, m, k, o, n) { return -o * (Math.sqrt(1 - (m /= n) * m) - 1) + k }, easeOutCirc: function (l, m, k, o, n) { return o * Math.sqrt(1 - (m = m / n - 1) * m) + k }, easeInOutCirc: function (l, m, k, o, n) { if ((m /= n / 2) < 1) { return -o / 2 * (Math.sqrt(1 - m * m) - 1) + k } return o / 2 * (Math.sqrt(1 - (m -= 2) * m) + 1) + k }, easeInElastic: function (l, n, k, u, r) { var o = 1.70158; var q = 0; var m = u; if (n == 0) { return k } if ((n /= r) == 1) { return k + u } if (!q) { q = r * 0.3 } if (m < Math.abs(u)) { m = u; var o = q / 4 } else { var o = q / (2 * Math.PI) * Math.asin(u / m) } return -(m * Math.pow(2, 10 * (n -= 1)) * Math.sin((n * r - o) * (2 * Math.PI) / q)) + k }, easeOutElastic: function (l, n, k, u, r) { var o = 1.70158; var q = 0; var m = u; if (n == 0) { return k } if ((n /= r) == 1) { return k + u } if (!q) { q = r * 0.3 } if (m < Math.abs(u)) { m = u; var o = q / 4 } else { var o = q / (2 * Math.PI) * Math.asin(u / m) } return m * Math.pow(2, -10 * n) * Math.sin((n * r - o) * (2 * Math.PI) / q) + u + k }, easeInOutElastic: function (l, n, k, u, r) { var o = 1.70158; var q = 0; var m = u; if (n == 0) { return k } if ((n /= r / 2) == 2) { return k + u } if (!q) { q = r * (0.3 * 1.5) } if (m < Math.abs(u)) { m = u; var o = q / 4 } else { var o = q / (2 * Math.PI) * Math.asin(u / m) } if (n < 1) { return -0.5 * (m * Math.pow(2, 10 * (n -= 1)) * Math.sin((n * r - o) * (2 * Math.PI) / q)) + k } return m * Math.pow(2, -10 * (n -= 1)) * Math.sin((n * r - o) * (2 * Math.PI) / q) * 0.5 + u + k }, easeInBack: function (l, m, k, p, o, n) { if (n == undefined) { n = 1.70158 } return p * (m /= o) * m * ((n + 1) * m - n) + k }, easeOutBack: function (l, m, k, p, o, n) { if (n == undefined) { n = 1.70158 } return p * ((m = m / o - 1) * m * ((n + 1) * m + n) + 1) + k }, easeInOutBack: function (l, m, k, p, o, n) { if (n == undefined) { n = 1.70158 } if ((m /= o / 2) < 1) { return p / 2 * (m * m * (((n *= (1.525)) + 1) * m - n)) + k } return p / 2 * ((m -= 2) * m * (((n *= (1.525)) + 1) * m + n) + 2) + k }, easeInBounce: function (l, m, k, o, n) { return o - g.easing.easeOutBounce(l, n - m, 0, o, n) + k }, easeOutBounce: function (l, m, k, o, n) { if ((m /= n) < (1 / 2.75)) { return o * (7.5625 * m * m) + k } else { if (m < (2 / 2.75)) { return o * (7.5625 * (m -= (1.5 / 2.75)) * m + 0.75) + k } else { if (m < (2.5 / 2.75)) { return o * (7.5625 * (m -= (2.25 / 2.75)) * m + 0.9375) + k } else { return o * (7.5625 * (m -= (2.625 / 2.75)) * m + 0.984375) + k } } } }, easeInOutBounce: function (l, m, k, o, n) { if (m < n / 2) { return g.easing.easeInBounce(l, m * 2, 0, o, n) * 0.5 + k } return g.easing.easeOutBounce(l, m * 2 - n, 0, o, n) * 0.5 + o * 0.5 + k } }) })(jQuery); ;

/*
* jQuery BBQ: Back Button & Query Library - v1.2.1 - 2/17/2010
* http://benalman.com/projects/jquery-bbq-plugin/
* 
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function ($, p) { var i, m = Array.prototype.slice, r = decodeURIComponent, a = $.param, c, l, v, b = $.bbq = $.bbq || {}, q, u, j, e = $.event.special, d = "hashchange", A = "querystring", D = "fragment", y = "elemUrlAttr", g = "location", k = "href", t = "src", x = /^.*\?|#.*$/g, w = /^.*\#/, h, C = {}; function E(F) { return typeof F === "string" } function B(G) { var F = m.call(arguments, 1); return function () { return G.apply(this, F.concat(m.call(arguments))) } } function n(F) { return F.replace(/^[^#]*#?(.*)$/, "$1") } function o(F) { return F.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/, "$1") } function f(H, M, F, I, G) { var O, L, K, N, J; if (I !== i) { K = F.match(H ? /^([^#]*)\#?(.*)$/ : /^([^#?]*)\??([^#]*)(#?.*)/); J = K[3] || ""; if (G === 2 && E(I)) { L = I.replace(H ? w : x, "") } else { N = l(K[2]); I = E(I) ? l[H ? D : A](I) : I; L = G === 2 ? I : G === 1 ? $.extend({}, I, N) : $.extend({}, N, I); L = a(L); if (H) { L = L.replace(h, r) } } O = K[1] + (H ? "#" : L || !K[1] ? "?" : "") + L + J } else { O = M(F !== i ? F : p[g][k]) } return O } a[A] = B(f, 0, o); a[D] = c = B(f, 1, n); c.noEscape = function (G) { G = G || ""; var F = $.map(G.split(""), encodeURIComponent); h = new RegExp(F.join("|"), "g") }; c.noEscape(",/"); $.deparam = l = function (I, F) { var H = {}, G = { "true": !0, "false": !1, "null": null }; $.each(I.replace(/\+/g, " ").split("&"), function (L, Q) { var K = Q.split("="), P = r(K[0]), J, O = H, M = 0, R = P.split("]["), N = R.length - 1; if (/\[/.test(R[0]) && /\]$/.test(R[N])) { R[N] = R[N].replace(/\]$/, ""); R = R.shift().split("[").concat(R); N = R.length - 1 } else { N = 0 } if (K.length === 2) { J = r(K[1]); if (F) { J = J && !isNaN(J) ? +J : J === "undefined" ? i : G[J] !== i ? G[J] : J } if (N) { for (; M <= N; M++) { P = R[M] === "" ? O.length : R[M]; O = O[P] = M < N ? O[P] || (R[M + 1] && isNaN(R[M + 1]) ? {} : []) : J } } else { if ($.isArray(H[P])) { H[P].push(J) } else { if (H[P] !== i) { H[P] = [H[P], J] } else { H[P] = J } } } } else { if (P) { H[P] = F ? i : "" } } }); return H }; function z(H, F, G) { if (F === i || typeof F === "boolean") { G = F; F = a[H ? D : A]() } else { F = E(F) ? F.replace(H ? w : x, "") : F } return l(F, G) } l[A] = B(z, 0); l[D] = v = B(z, 1); $[y] || ($[y] = function (F) { return $.extend(C, F) })({ a: k, base: k, iframe: t, img: t, input: t, form: "action", link: k, script: t }); j = $[y]; function s(I, G, H, F) { if (!E(H) && typeof H !== "object") { F = H; H = G; G = i } return this.each(function () { var L = $(this), J = G || j()[(this.nodeName || "").toLowerCase()] || "", K = J && L.attr(J) || ""; L.attr(J, a[I](K, H, F)) }) } $.fn[A] = B(s, A); $.fn[D] = B(s, D); b.pushState = q = function (I, F) { if (E(I) && /^#/.test(I) && F === i) { F = 2 } var H = I !== i, G = c(p[g][k], H ? I : {}, H ? F : 2); p[g][k] = G + (/#/.test(G) ? "" : "#") }; b.getState = u = function (F, G) { return F === i || typeof F === "boolean" ? v(F) : v(G)[F] }; b.removeState = function (F) { var G = {}; if (F !== i) { G = u(); $.each($.isArray(F) ? F : arguments, function (I, H) { delete G[H] }) } q(G, 2) }; e[d] = $.extend(e[d], { add: function (F) { var H; function G(J) { var I = J[D] = c(); J.getState = function (K, L) { return K === i || typeof K === "boolean" ? l(I, K) : l(I, L)[K] }; H.apply(this, arguments) } if ($.isFunction(F)) { H = F; return G } else { H = F.handler; F.handler = G } } }) })(jQuery, this);
/*
* jQuery hashchange event - v1.2 - 2/11/2010
* http://benalman.com/projects/jquery-hashchange-plugin/
* 
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function ($, i, b) { var j, k = $.event.special, c = "location", d = "hashchange", l = "href", f = $.browser, g = document.documentMode, h = f.msie && (g === b || g < 8), e = "on" + d in i && !h; function a(m) { m = m || i[c][l]; return m.replace(/^[^#]*#?(.*)$/, "$1") } $[d + "Delay"] = 100; k[d] = $.extend(k[d], { setup: function () { if (e) { return false } $(j.start) }, teardown: function () { if (e) { return false } $(j.stop) } }); j = (function () { var m = {}, r, n, o, q; function p() { o = q = function (s) { return s }; if (h) { n = $('<iframe src="javascript:0"/>').hide().insertAfter("body")[0].contentWindow; q = function () { return a(n.document[c][l]) }; o = function (u, s) { if (u !== s) { var t = n.document; t.open().close(); t[c].hash = "#" + u } }; o(a()) } } m.start = function () { if (r) { return } var t = a(); o || p(); (function s() { var v = a(), u = q(t); if (v !== t) { o(t = v, u); $(i).trigger(d) } else { if (u !== t) { i[c][l] = i[c][l].replace(/#.*/, "") + "#" + u } } r = setTimeout(s, $[d + "Delay"]) })() }; m.stop = function () { if (!n) { r && clearTimeout(r); r = 0 } }; return m })() })(jQuery, this);

/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function ($) { $.fn.hoverIntent = function (f, g) { var cfg = { sensitivity: 7, interval: 100, timeout: 0 }; cfg = $.extend(cfg, g ? { over: f, out: g} : f); var cX, cY, pX, pY; var track = function (ev) { cX = ev.pageX; cY = ev.pageY; }; var compare = function (ev, ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); if ((Math.abs(pX - cX) + Math.abs(pY - cY)) < cfg.sensitivity) { $(ob).unbind("mousemove", track); ob.hoverIntent_s = 1; return cfg.over.apply(ob, [ev]); } else { pX = cX; pY = cY; ob.hoverIntent_t = setTimeout(function () { compare(ev, ob); }, cfg.interval); } }; var delay = function (ev, ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); ob.hoverIntent_s = 0; return cfg.out.apply(ob, [ev]); }; var handleHover = function (e) { var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget; while (p && p != this) { try { p = p.parentNode; } catch (e) { p = this; } } if (p == this) { return false; } var ev = jQuery.extend({}, e); var ob = this; if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); } if (e.type == "mouseover") { pX = ev.pageX; pY = ev.pageY; $(ob).bind("mousemove", track); if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout(function () { compare(ev, ob); }, cfg.interval); } } else { $(ob).unbind("mousemove", track); if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout(function () { delay(ev, ob); }, cfg.timeout); } } }; return this.mouseover(handleHover).mouseout(handleHover); }; })(jQuery);

/* Copyright (c) 2009 Brandon Aaron (http://brandonaaron.net)
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
*
* Version: 3.0.2
* 
* Requires: 1.2.2+
*/
(function (c) { var a = ["DOMMouseScroll", "mousewheel"]; c.event.special.mousewheel = { setup: function () { if (this.addEventListener) { for (var d = a.length; d; ) { this.addEventListener(a[--d], b, false) } } else { this.onmousewheel = b } }, teardown: function () { if (this.removeEventListener) { for (var d = a.length; d; ) { this.removeEventListener(a[--d], b, false) } } else { this.onmousewheel = null } } }; c.fn.extend({ mousewheel: function (d) { return d ? this.bind("mousewheel", d) : this.trigger("mousewheel") }, unmousewheel: function (d) { return this.unbind("mousewheel", d) } }); function b(f) { var d = [].slice.call(arguments, 1), g = 0, e = true; f = c.event.fix(f || window.event); f.type = "mousewheel"; if (f.wheelDelta) { g = f.wheelDelta / 120 } if (f.detail) { g = -f.detail / 3 } d.unshift(f, g); return c.event.handle.apply(this, d) } })(jQuery);

/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
*
* $LastChangedDate: 2007-07-21 18:45:56 -0500 (Sat, 21 Jul 2007) $
* $Rev: 2447 $
*
* Version 2.1.1
*/
(function ($) { $.fn.bgIframe = $.fn.bgiframe = function (s) { if ($.browser.msie && $.browser.version < 7) { s = $.extend({ top: 'auto', left: 'auto', width: 'auto', height: 'auto', opacity: true, src: 'javascript:false;' }, s || {}); var prop = function (n) { return n && n.constructor == Number ? n + 'px' : n; }, html = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="' + s.src + '"' + 'style="display:block;position:absolute;z-index:-1;' + (s.opacity !== false ? 'filter:Alpha(Opacity=\'0\');' : '') + 'top:' + (s.top == 'auto' ? 'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')' : prop(s.top)) + ';' + 'left:' + (s.left == 'auto' ? 'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')' : prop(s.left)) + ';' + 'width:' + (s.width == 'auto' ? 'expression(this.parentNode.offsetWidth+\'px\')' : prop(s.width)) + ';' + 'height:' + (s.height == 'auto' ? 'expression(this.parentNode.offsetHeight+\'px\')' : prop(s.height)) + ';' + '"/>'; return this.each(function () { if ($('> iframe.bgiframe', this).length == 0) { this.insertBefore(document.createElement(html), this.firstChild) }; }); } return this; }; })(jQuery);

/* Copyright (c) 2009 Kelvin Luck (kelvin AT kelvinluck DOT com || http://www.kelvinluck.com)
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
* 
* See http://kelvinluck.com/assets/jquery/jScrollPane/
* $Id: jScrollPane.js 90 2010-01-25 03:52:10Z kelvin.luck $
*/
(function ($) {
	$.jScrollPane = { active: [] };
$.fn.jScrollPane = function(settings)
{
		settings = $.extend({}, $.fn.jScrollPane.defaults, settings);
		if ($.browser.msie) {
			settings.reinitialiseOnImageLoad = false;
		}
		var rf = function () { return false; };
		return this.each(
		function()
		{	
			var $this = $(this);
			if (!($this.is(':visible'))) { return }
			var paneEle = this;
			var currentScrollPosition = 0;
			var paneWidth;
			var paneHeight;
			var trackHeight;
			var trackOffset = settings.topCapHeight;
			var $container;
			if ($(this).parent().is('.jScrollPaneContainer')) {
				$container = $(this).parent();
				currentScrollPosition = settings.maintainPosition ? $this.position().top : 0;
				var $c = $(this).parent();
				paneWidth = $c.innerWidth();
				paneHeight = $c.outerHeight();
				$('>.jScrollPaneTrack, >.jScrollArrowUp, >.jScrollArrowDown, >.jScrollCap', $c).remove();
				$this.css({ 'top': 0 });
				//alert('repeating'+$this.attr('class') +'paneWidth '+paneWidth+' paneHeight'+paneHeight)
			} else {

				$this.data('originalStyleTag', $this.attr('style'));
				// Switch the element's overflow to hidden to ensure we get the size of the element without the scrollbars [http://plugins.jquery.com/node/1208]
				$this.css('overflow', 'hidden');
				this.originalPadding = $this.css('paddingTop') + ' ' + $this.css('paddingRight') + ' ' + $this.css('paddingBottom') + ' ' + $this.css('paddingLeft');
				this.originalSidePaddingTotal = (parseInt($this.css('paddingLeft')) || 0) + (parseInt($this.css('paddingRight')) || 0);
				paneWidth = $this.innerWidth();
				paneHeight = $this.innerHeight();
				$container = $('<div></div>').attr({ 'className': 'jScrollPaneContainer' }).css({ 'height': paneHeight + 'px', 'width': paneWidth + 'px' });
				if (settings.enableKeyboardNavigation) {
					$container.attr(
						'tabindex',
						settings.tabIndex
					);
				}
				$this.wrap($container);
				$container = $this.parent();
				//alert('first set '+$this.attr('class') +'paneWidth '+paneWidth+' paneHeight'+paneHeight)
				// deal with text size changes (if the jquery.em plugin is included)
				// and re-initialise the scrollPane so the track maintains the
				// correct size
				$(document).bind(
					'emchange',
					function(e, cur, prev)
					{
						$this.jScrollPane(settings);
					}
				);

			}
			trackHeight = paneHeight;
			if (settings.reinitialiseOnImageLoad) {
				// code inspired by jquery.onImagesLoad: http://plugins.jquery.com/project/onImagesLoad
				// except we re-initialise the scroll pane when each image loads so that the scroll pane is always up to size...
				// TODO: Do I even need to store it in $.data? Is a local variable here the same since I don't pass the reinitialiseOnImageLoad when I re-initialise?
				var $imagesToLoad = $this.data('jScrollPaneImagesToLoad') || $('img', $this);
				var loadedImages = [];
				if ($imagesToLoad.each && $imagesToLoad.length>0) {
					$imagesToLoad.each(function (i, val) {
						$(this).bind('load readystatechange', function () {
							if ($.inArray(i, loadedImages) == -1) { //don't double count images
								loadedImages.push(val); //keep a record of images we've seen
								$imagesToLoad = $.grep($imagesToLoad, function (n, i) {
									return n != val;
								});
								$this.data('jScrollPaneImagesToLoad', $imagesToLoad);
								var s2 = $.extend(settings, { reinitialiseOnImageLoad: false });
								$this.jScrollPane(s2); // re-initialise
							}
						}).each(function (i, val) {
							if (this.complete || this.complete === undefined) {
								//needed for potential cached images
								this.src = this.src;
							}
						});
					});
				};
			}
			$container.removeClass('jScrollPaneUnScrollable')
			var p = this.originalSidePaddingTotal;
			var realPaneWidth = paneWidth - settings.scrollbarWidth - settings.scrollbarMargin - p;
			var cssToApply = { 'height': 'auto', 'width': realPaneWidth + 'px' }
			if (settings.scrollbarOnLeft) {
				cssToApply.paddingLeft = settings.scrollbarMargin + settings.scrollbarWidth + 'px';
			} else {
				cssToApply.paddingRight = settings.scrollbarMargin + 'px';
			}
			$this.css(cssToApply);
			var contentHeight = $this.outerHeight();
			var percentInView = paneHeight / contentHeight;
			var isScrollable = percentInView < .99;

			$container[isScrollable ? 'addClass' : 'removeClass']('jScrollPaneScrollable');
			if (!isScrollable) { $container.addClass('jScrollPaneUnScrollable') };
			if (isScrollable) {
				$container.append(
					$('<div></div>').addClass('jScrollCap jScrollCapTop').css({ height: settings.topCapHeight }),
					$('<div></div>').attr({ 'className': 'jScrollPaneTrack' }).css({ 'width': settings.scrollbarWidth + 'px' }).append(
						$('<div></div>').attr({ 'className': 'jScrollPaneDrag' }).css({ 'width': settings.scrollbarWidth + 'px' }).append(
							$('<div></div>').attr({ 'className': 'jScrollPaneDragTop' }).css({ 'width': settings.scrollbarWidth + 'px' }),
							$('<div></div>').attr({ 'className': 'jScrollPaneDragBottom' }).css({ 'width': settings.scrollbarWidth + 'px' })
						)
					),
					$('<div></div>').addClass('jScrollCap jScrollCapBottom').css({ height: settings.bottomCapHeight })
				);
				var $track = $('>.jScrollPaneTrack', $container);
				var $drag = $('>.jScrollPaneTrack .jScrollPaneDrag', $container);
				var currentArrowDirection;
				var currentArrowTimerArr = []; // Array is used to store timers since they can stack up when dealing with keyboard events. This ensures all timers are cleaned up in the end, preventing an acceleration bug.
				var currentArrowInc;
				var whileArrowButtonDown = function() 
				{
					if (currentArrowInc > 4 || currentArrowInc % 4 == 0) {
						positionDrag(dragPosition + currentArrowDirection * mouseWheelMultiplier);
					}
					currentArrowInc++;
				};
				if (settings.enableKeyboardNavigation) {
					$container.bind(
						'keydown.jscrollpane',
						function(e) 
						{						
							switch (e.keyCode) {
								case 38: //up
									currentArrowDirection = -1;
									currentArrowInc = 0;
									whileArrowButtonDown();
									currentArrowTimerArr[currentArrowTimerArr.length] = setInterval(whileArrowButtonDown, 100);
									return false;
								case 40: //down
									currentArrowDirection = 1;
									currentArrowInc = 0;
									whileArrowButtonDown();
									currentArrowTimerArr[currentArrowTimerArr.length] = setInterval(whileArrowButtonDown, 100);
									return false;
								case 33: // page up
								case 34: // page down
									// TODO
									return false;
								default:

							}
						}
					).bind(
						'keyup.jscrollpane',
						function(e) 
						{
							if (e.keyCode == 38 || e.keyCode == 40) {
								for (var i = 0; i < currentArrowTimerArr.length; i++) {
									clearInterval(currentArrowTimerArr[i]);
								}
								return false;
							}
						}
					);
				}
				if (settings.showArrows) {
					var currentArrowButton;
					var currentArrowInterval;
					var onArrowMouseUp = function(event)
					{
						$('html').unbind('mouseup', onArrowMouseUp);
						currentArrowButton.removeClass('jScrollActiveArrowButton');
						clearInterval(currentArrowInterval);
					};
					var onArrowMouseDown = function () {
						$('html').bind('mouseup', onArrowMouseUp);
						currentArrowButton.addClass('jScrollActiveArrowButton');
						currentArrowInc = 0;
						whileArrowButtonDown();
						currentArrowInterval = setInterval(whileArrowButtonDown, 100);
					};
					$container
						.append(
							$('<a></a>')
								.attr({ 'href': 'javascript:;', 'className': 'jScrollArrowUp', 'tabindex': -1 })
								.css({ 'width': settings.scrollbarWidth + 'px', 'top': settings.topCapHeight + 'px' })
								.html('Scroll up')
								.bind('mousedown', function () { currentArrowButton = $(this); currentArrowDirection = -1; onArrowMouseDown(); this.blur(); return false; })
								.bind('click', rf),
							$('<a></a>')
								.attr({ 'href': 'javascript:;', 'className': 'jScrollArrowDown', 'tabindex': -1 })
								.css({ 'width': settings.scrollbarWidth + 'px', 'bottom': settings.bottomCapHeight + 'px' })
								.html('Scroll down')
								.bind('mousedown', function()
								{
									currentArrowButton = $(this);
									currentArrowDirection = 1;
									onArrowMouseDown();
									this.blur();
									return false;
								})
								.bind('click', rf)
						);
					var $upArrow = $('>.jScrollArrowUp', $container);
					var $downArrow = $('>.jScrollArrowDown', $container);
				}

				if (settings.arrowSize) {
					trackHeight = paneHeight - settings.arrowSize - settings.arrowSize;
					trackOffset += settings.arrowSize;
				} else if ($upArrow) {
					var topArrowHeight = $upArrow.height();
					settings.arrowSize = topArrowHeight;
					trackHeight = paneHeight - topArrowHeight - $downArrow.height();
					trackOffset += topArrowHeight;
				}
				trackHeight -= settings.topCapHeight + settings.bottomCapHeight;
				$track.css({ 'height': trackHeight + 'px', top: trackOffset + 'px' });
				var $pane = $(this).css({ 'position': 'absolute', 'overflow': 'visible' });
				var currentOffset;
				var maxY;
				var mouseWheelMultiplier;
				// store this in a seperate variable so we can keep track more accurately than just updating the css property..
				var dragPosition = 0;
				var dragMiddle = percentInView * paneHeight / 2;
				// pos function borrowed from tooltip plugin and adapted...

				var getPos = function (event, c) {
					var p = c == 'X' ? 'Left' : 'Top';
					return event['page' + c] || (event['client' + c] + (document.documentElement['scroll' + p] || document.body['scroll' + p])) || 0;
				};
				var ignoreNativeDrag = function () { return false; };
				var initDrag = function()
				{
					ceaseAnimation();
					currentOffset = $drag.offset(false);
					currentOffset.top -= dragPosition;
					maxY = trackHeight - $drag[0].offsetHeight;
					mouseWheelMultiplier = 2 * settings.wheelSpeed * maxY / contentHeight;
				};
				var onStartDrag = function(event)
				{
					initDrag();
					dragMiddle = getPos(event, 'Y') - dragPosition - currentOffset.top;
					$('html').bind('mouseup', onStopDrag).bind('mousemove', updateScroll);
					if ($.browser.msie) {
						$('html').bind('dragstart', ignoreNativeDrag).bind('selectstart', ignoreNativeDrag);
					}
					return false;
				};
				var onStopDrag = function()
				{				
					$('html').unbind('mouseup', onStopDrag).unbind('mousemove', updateScroll);
					dragMiddle = percentInView * paneHeight / 2;
					if ($.browser.msie) {
						$('html').unbind('dragstart', ignoreNativeDrag).unbind('selectstart', ignoreNativeDrag);
					}
				};
				var positionDrag = function(destY)
				{
					$container.scrollTop(0);
					destY = destY < 0 ? 0 : (destY > maxY ? maxY : destY);
					dragPosition = destY;
					$drag.css({ 'top': destY + 'px' });
					var p = destY / maxY;
					$this.data('jScrollPanePosition', (paneHeight - contentHeight) * -p);
					$pane.css({ 'top': ((paneHeight - contentHeight) * p) + 'px' });
					$this.trigger('scroll');
					if (settings.showArrows) {
						$upArrow[destY == 0 ? 'addClass' : 'removeClass']('disabled');
						$downArrow[destY == maxY ? 'addClass' : 'removeClass']('disabled');
					}
				};
				var updateScroll = function(e)
				{
					positionDrag(getPos(e, 'Y') - currentOffset.top - dragMiddle);
				};
				var dragH = Math.max(Math.min(percentInView * (paneHeight - settings.arrowSize * 2), settings.dragMaxHeight), settings.dragMinHeight);
				$drag.css(
					{ 'height': dragH + 'px' }
				).bind('mousedown', onStartDrag);
				var trackScrollInterval;
				var trackScrollInc;
				var trackScrollMousePos;
				var doTrackScroll = function()
				{
					if (trackScrollInc > 8 || trackScrollInc % 4 == 0) {
						positionDrag((dragPosition - ((dragPosition - trackScrollMousePos) / 2)));
					}
					trackScrollInc++;
				};
				var onStopTrackClick = function()
				{
					clearInterval(trackScrollInterval);
					$('html').unbind('mouseup', onStopTrackClick).unbind('mousemove', onTrackMouseMove);

				};
				var onTrackMouseMove = function(event)
				{
					trackScrollMousePos = getPos(event, 'Y') - currentOffset.top - dragMiddle;
				};
				var onTrackClick = function(event)
				{
					initDrag();
					onTrackMouseMove(event);
					trackScrollInc = 0;
					$('html').bind('mouseup', onStopTrackClick).bind('mousemove', onTrackMouseMove);
					trackScrollInterval = setInterval(doTrackScroll, 100);
					doTrackScroll();
					return false;
				};
				$track.bind('mousedown', onTrackClick);
				$container.bind(
					'mousewheel',
					function (event, delta) {
						delta = delta || (event.wheelDelta ? event.wheelDelta / 120 : (event.detail) ?
																					   -event.detail / 3 : 0);
						initDrag();
						ceaseAnimation();
						var d = dragPosition;
						positionDrag(dragPosition - delta * mouseWheelMultiplier);
						var dragOccured = d != dragPosition;
						return !dragOccured;
					}
				);
				var _animateToPosition;
				var _animateToInterval;
				function animateToPosition()
				{
					var diff = (_animateToPosition - dragPosition) / settings.animateStep;
					if (diff > 1 || diff < -1) {
						positionDrag(dragPosition + diff);
					} else {
						positionDrag(_animateToPosition);
						ceaseAnimation();
					}
				}
				var ceaseAnimation = function()
				{
					if (_animateToInterval) {
						clearInterval(_animateToInterval);
						delete _animateToPosition;
					}
				};
				var scrollTo = function(pos, preventAni)
				{
					if (typeof pos == "string") {

						// Legal hash values aren't necessarily legal jQuery selectors so we need to catch any
						// errors from the lookup...
						var p2 = '';
						if (pos.indexOf('#') > -1 && pos.length > 1) {
							pos = pos + ', *[name ="' + (pos.substr(pos.indexOf('#') + 1)) + '"]'
						}
						try {
							$e = $(pos, $this);
						} catch (err) {
							return;
						}
						if (!$e.length) return;
						pos = $e.offset().top - $this.offset().top;
					}
					ceaseAnimation();
					var maxScroll = contentHeight - paneHeight;
					pos = pos > maxScroll ? maxScroll : pos;
					$this.data('jScrollPaneMaxScroll', maxScroll);
					var destDragPosition = pos / maxScroll * maxY;
					if (preventAni || !settings.animateTo) {
						positionDrag(destDragPosition);
					} else {
						$container.scrollTop(0);
						_animateToPosition = destDragPosition;
						_animateToInterval = setInterval(animateToPosition, settings.animateInterval);
					}
				};
				$this[0].scrollTo = scrollTo;
				$this[0].scrollBy = function(delta)
				{
					var currentPos = -parseInt($pane.css('top')) || 0;
					scrollTo(currentPos + delta);
				};
				initDrag();
				scrollTo(-currentScrollPosition, true);
				// Deal with it when the user tabs to a link or form element within this scrollpane
				$('*:not(.h_scrollImg, .countries *, .secure_icon *)', this).bind(
					'focus',
					function(event)
					{
						var $e = $(this);
						// loop through parents adding the offset top of any elements that are relatively positioned between
						// the focused element and the jScrollPaneContainer so we can get the true distance from the top
						// of the focused element to the top of the scrollpane...
						var eleTop = 0;
						while ($e[0] != $this[0]) {
							eleTop += $e.position().top;
							$e = $e.offsetParent();
						}
						var viewportTop = -parseInt($pane.css('top')) || 0;
						var maxVisibleEleTop = viewportTop + paneHeight;
						var eleInView = eleTop > viewportTop && eleTop < maxVisibleEleTop;
						if (!eleInView) {
							var destPos = eleTop - settings.scrollbarMargin;
							if (eleTop > viewportTop) { // element is below viewport - scroll so it is at bottom.
								destPos += $(this).height() + 15 + settings.scrollbarMargin - paneHeight;
							}
							scrollTo(destPos);
						}
					}
				)

				if (settings.observeHash) {
					// use event delegation to listen for all clicks on links and hijack them if they are links to
					// anchors within our content...
					/*
					$(document).bind('click', function(e){
													   
					$target = $(e.target);
						
					if ($target.is('.info_page a, .sizechart_content a, .promo a')) {
					var h = $target.attr('href');
							
					if(h.indexOf('#')>-1){
					h=h.substr(h.indexOf('#'));
					}
					if (h && h.substr(0, 1) == '#' && h.length > 1) {
					setTimeout(function(){
					scrollTo(h, !settings.animateToInternalLinks);
					}, $.browser.safari ? 100 : 0);
					e.preventDefault();
					return false;
					}
					}
						
					});
					*/
					// try not to bind anonymous functions to the document
					$('a[href*="#"]', $this).each(
						function () {
							var $lnk = $(this);
							var h = $lnk.attr('href');
							if (h.indexOf('#') > -1) {
								h = h.substr(h.indexOf('#'));
							}
							if (h && h.substr(0, 1) == '#' && h.length > 1) {
								$lnk.bind('click',
									function (e) {
										setTimeout(function () {
											scrollTo(h, !settings.animateToInternalLinks);
										}, $.browser.safari ? 100 : 0);
										e.preventDefault();
										return false;
									}
								)
							}
						}
					)

				}
				// Deal with dragging and selecting text to make the scrollpane scroll...
				function onSelectScrollMouseDown(e)
				{
					$(document).bind('mousemove.jScrollPaneDragging', onTextSelectionScrollMouseMove);
					$(document).bind('mouseup.jScrollPaneDragging', onSelectScrollMouseUp);
				}
				var textDragDistanceAway;
				var textSelectionInterval;
				function onTextSelectionInterval()
				{

					direction = textDragDistanceAway < 0 ? -1 : 1;
					$this[0].scrollBy(textDragDistanceAway / 2);
				}
				function clearTextSelectionInterval()
				{
					if (textSelectionInterval) {
						clearInterval(textSelectionInterval);
						textSelectionInterval = undefined;
					}
				}
				function onTextSelectionScrollMouseMove(e)
				{
					var offset = $this.parent().offset().top;
					var maxOffset = offset + paneHeight;
					var mouseOffset = getPos(e, 'Y');
					textDragDistanceAway = mouseOffset < offset ? mouseOffset - offset : (mouseOffset > maxOffset ? mouseOffset - maxOffset : 0);
					if (textDragDistanceAway == 0) {
						clearTextSelectionInterval();
					} else {
						if (!textSelectionInterval) {
							textSelectionInterval = setInterval(onTextSelectionInterval, 100);
						}
					}
				}
				function onSelectScrollMouseUp(e)
				{
					$(document)
					  .unbind('mousemove.jScrollPaneDragging')
					  .unbind('mouseup.jScrollPaneDragging');
					clearTextSelectionInterval();
				}
				$container.bind('mousedown.jScrollPane', onSelectScrollMouseDown);

				$.jScrollPane.active.push($this[0]);
			} else {
				$this.css(
					{
						'height': paneHeight + 'px',
						'width': paneWidth - this.originalSidePaddingTotal + 'px',
						'padding': this.originalPadding
					}
				);
				$this[0].scrollTo = $this[0].scrollBy = function () { };
				// clean up listeners
				$this.parent().unbind('mousewheel').unbind('mousedown.jScrollPane').unbind('keydown.jscrollpane').unbind('keyup.jscrollpane');

			}
		}

	)
	};

$.fn.jScrollPaneRemove = function()
{
	$(this).each(function()
	{
			$this = $(this);
			var $c = $this.parent();
			if ($c.is('.jScrollPaneContainer')) {
				$this.css({ 'top': '', 'height': '', 'width': '', 'padding': '', 'overflow': '', 'position': '' });
				$this.attr('style', $this.data('originalStyleTag'));
				$c.after($this).remove();
			}
		});
	}

	$.fn.jScrollPane.defaults = {
		scrollbarWidth: 11,
		scrollbarMargin: 5,
		wheelSpeed: 18,
		showArrows: false,
		arrowSize: 0,
		animateTo: false,
		dragMinHeight: 1,
		dragMaxHeight: 99999,
		animateInterval: 100,
		animateStep: 3,
		maintainPosition: true,
		scrollbarOnLeft: false,
		reinitialiseOnImageLoad: true,
		tabIndex: 0,
		enableKeyboardNavigation: true,
		animateToInternalLinks: false,
		topCapHeight: 0,
		bottomCapHeight: 0,
		observeHash: false
	};
	// clean up the scrollTo expandos
	$(window)
	.bind('unload', function () {
		var els = $.jScrollPane.active;
		for (var i = 0; i < els.length; i++) {
			els[i].scrollTo = els[i].scrollBy = null;
		}
	}
);
})(jQuery);
/*
* Copyright (c) 2008 Threeformed Media (http://www.threeformed.com)
* This is licensed under GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
* 
* *******
* 
* This plugin is derived in part from JScrollPane created by Kevin Luck(http://www.kelvinluck.com)
* 
* Copyright (c) 2006 Kelvin Luck (kelvin AT kelvinluck DOT com || http://www.kelvinluck.com)
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
* 
* See http://kelvinluck.com/assets/jquery/jScrollPane/
* $Id: jScrollPane.js 3125 2007-09-06 20:39:42Z kelvin.luck $
*/

var _jscr_originalSizes=new Array();var _jscr_differenceSizes=new Array();var _jscr_previousWindowSize=new Array();var _jscr_originalPercentages=new Array();var _jscr_intervals=new Array();var _jscr_trackInt=new Array();var _jscr_originalPos=new Array();var _jscr_globalProperties=new Array();jQuery.jScrollHorizontalPane={active:[]};jQuery.fn.jScrollHorizontalPane=function(settings)
{settings=jQuery.extend({scrollbarHeight:11,scrollbarMargin:5,wheelSpeed:18,showArrows:false,arrowSize:10,animateTo:false,dragMinWidth:1,dragMaxWidth:99999,animateInterval:100,animateStep:3,maintainPosition:true,resize:true,minimumWidth:200,reset:false},settings);return this.each(function()
{if(settings.reset==true){jQuery.fn.jScrollHorizontalPane.reset();}
		var $this = jQuery(this); var mouseWheelNext = 0; var mouseWheelMove = false; var currentId = $this.attr('id'); if (currentId == undefined) { currentId = $this.attr('class'); }
var previousWindow=_jscr_previousWindowSize[currentId];_jscr_originalPos[currentId]=-1;_jscr_globalProperties[currentId]=settings;_jscr_previousWindowSize[currentId]=$(window).width();if(_jscr_originalSizes[currentId]==undefined){if((jQuery.browser.msie)&&(parseInt(jQuery.browser.version)==6)){var outerWidth=parseInt($this.outerWidth())-parseInt($this.offset().left);_jscr_differenceSizes[currentId]=$this.offset().left/$(window).width();}else{var outerWidth=$this.outerWidth();_jscr_differenceSizes[currentId]=$this.position().left/$(window).width();}
percentageWidth=(outerWidth/$(window).width());_jscr_originalPercentages[currentId]=percentageWidth;_jscr_originalSizes[currentId]=$(window).width();}else{percentageWidth=_jscr_originalPercentages[currentId];diff=_jscr_differenceSizes[currentId]-(($this.offset().left+_jscr_originalPos[currentId])/$(window).width());percentageWidth=percentageWidth+diff;};
		var halfIntervals = new Array(); _jscr_intervals = new Array(); halfIntervals[0] = 0; _jscr_intervals[0] = 0; margin = $this.position().left; offset = 1; if (margin < 0) { margin = 0; }
		$(".scroll-interval", $this).each(function (i, elem) { pos = $(elem).position().left - margin; if (pos != 0) { _jscr_intervals[i + offset] = pos; } else { offset--; } }); if (_jscr_intervals.length <= 1) { _jscr_intervals = new Array(); }
if(jQuery(this).parent().is('.hScrollPaneContainer')){var currentScrollPosition=settings.maintainPosition?$this.offset().left:0;var $c=jQuery(this).parent();var paneWidth=$c.outerWidth();var paneHeight=$c.innerHeight();var rightPos=$this.offset().left+_jscr_originalPos[currentId]+paneWidth;if((previousWindow!=$(window).width())&&((rightPos>$(window).width())||(previousWindow<$(window).width()))&&(settings.resize==true)){if($(window).width()>=_jscr_originalSizes[currentId]){paneWidth=($(window).width()*percentageWidth);}else{paneWidth=$(window).width()-($this.offset().left+_jscr_originalPos[currentId])-10;}
				if (paneWidth < settings.minimumWidth) { paneWidth = settings.minimumWidth; };
jQuery(this).parent().css({'height':paneHeight+'px','width':paneWidth+'px'});}
			var trackWidth = paneWidth; if ($c.unmousewheel) { if ($.browser.opera) { $c.unbind("mousewheel", fn = function () { }); } else { $c.unmousewheel(); } }
jQuery('>.hScrollPaneTrack, >.hScrollArrowLeft, >.hScrollArrowRight',$c).remove();$this.css({'left':0});_jscr_originalPos[currentId]=-1;}else{var currentScrollPosition=0;this.originalPadding=$this.css('paddingTop')+' '+$this.css('paddingRight')+' '+$this.css('paddingBottom')+' '+$this.css('paddingLeft');this.originalSidePaddingTotal=(parseInt($this.css('paddingLeft'))||0)+(parseInt($this.css('paddingRight'))||0);var paneWidth=$this.outerWidth();var rightPos=$this.offset().left+_jscr_originalPos[currentId]+paneWidth;if((rightPos)>$(window).width()){paneWidth=$(window).width()*percentageWidth;}
			if (paneWidth < settings.minimumWidth) { paneWidth = settings.minimumWidth; };
			var paneHeight = $this.innerHeight(); var trackWidth = paneWidth; $this.wrap(jQuery('<div></div>').attr({ 'className': 'hScrollPaneContainer' }).css({ 'height': paneHeight + 'px', 'width': paneWidth + 'px' })); jQuery(document).bind('emchange', function (e, cur, prev)
{$this.jScrollHorizontalPane(settings);});}
		var p = this.originalSidePaddingTotal; $this.css({ 'height': paneHeight - settings.scrollbarHeight - p + 'px', 'width': 'auto', 'paddingRight': settings.scrollbarMargin + 'px' }); var contentWidth = $this.outerWidth(); var ieWidth = 0; $this.children().each(function (i, elem) { if ($(elem).outerWidth() > ieWidth) { ieWidth = $(elem).outerWidth(); } }); if (ieWidth > contentWidth) { contentWidth = ieWidth; }
var percentInView=paneWidth/contentWidth;var trackIntervals=new Array();if(percentInView<0.99){var $container=$this.parent();$container.append(jQuery('<div></div>').attr({'className':'hScrollPaneTrack'}).css({'height':settings.scrollbarHeight+'px'}).append(jQuery('<div></div>').attr({'className':'hScrollPaneDrag'}).css({'height':settings.scrollbarHeight+'px'}).append(jQuery('<div></div>').attr({'className':'hScrollPaneDragLeft'}).css({'height':settings.scrollbarHeight+'px'}),jQuery('<div></div>').attr({'className':'hScrollPaneDragRight'}).css({'height':settings.scrollbarHeight+'px'}))));var $track=jQuery('>.hScrollPaneTrack',$container);for(inter in _jscr_intervals){if(settings.showArrows==true){scrollOffset=settings.arrowSize;}else{scrollOffset=0;}
				intervalTrackPos = _jscr_intervals[inter] / contentWidth * $track.width() - (scrollOffset); trackIntervals[inter] = intervalTrackPos; if (trackIntervals[inter - 1] != undefined) { halfIntervals[inter - 1] = (trackIntervals[inter] + trackIntervals[inter - 1]) / 2; }
if(inter!=0){interObj=jQuery('<div>|</div>').attr({'className':'hScrollIntervalTrack'}).css({'left':intervalTrackPos+'px'})
$track.append(interObj);}}
var $drag=jQuery('>.hScrollPaneTrack .hScrollPaneDrag',$container);if(settings.showArrows){var currentArrowButton;var currentArrowDirection;var currentArrowInterval;var currentArrowInc;var whileArrowButtonDown=function()
{if(currentArrowInc>4||currentArrowInc%4==0){positionDrag(dragPosition+currentArrowDirection*mouseWheelMultiplier);}
currentArrowInc++;};var onArrowMouseUp=function(event)
				{ jQuery('body').unbind('mouseup', onArrowMouseUp); currentArrowButton.removeClass('hScrollActiveArrowButton'); clearInterval(currentArrowInterval); arrowUp = true; moveIntervals(); }; var onArrowMouseDown = function () { jQuery('body').bind('mouseup', onArrowMouseUp); currentArrowButton.addClass('hScrollActiveArrowButton'); currentArrowInc = 0; whileArrowButtonDown(); currentArrowInterval = setInterval(whileArrowButtonDown, 100); }; $container.append(jQuery('<a></a>').attr({ 'href': 'javascript:;', 'className': 'hScrollArrowLeft' }).css({ 'width': settings.arrowSize + 'px' }).html('Scroll Left').bind('mousedown', function ()
				{ currentArrowButton = jQuery(this); currentArrowDirection = -1; onArrowMouseDown(); this.blur(); return false; }), jQuery('<a></a>').attr({ 'href': 'javascript:;', 'className': 'hScrollArrowRight' }).css({ 'width': settings.arrowSize + 'px' }).html('Scroll Right').bind('mousedown', function ()
{currentArrowButton=jQuery(this);currentArrowDirection=1;onArrowMouseDown();this.blur();return false;}));if(settings.arrowSize){trackWidth=paneWidth-settings.arrowSize-settings.arrowSize;$track.css({'width':trackWidth+'px',left:settings.arrowSize+'px'})}else{var leftArrowWidth=jQuery('>.hScrollArrowLeft',$container).width();settings.arrowSize=leftArrowWidth;trackWidth=paneWidth-leftArrowWidth-jQuery('>.hScrollArrowRight',$container).width();$track.css({'width':trackWidth+'px',left:leftArrowWidth+'px'})}}
			var $pane = jQuery(this).css({ 'position': 'absolute', 'overflow': 'visible' }); var currentOffset; var maxX; var mouseWheelMultiplier; var dragPosition = 0; var dragMiddle = percentInView * paneWidth / 2; var getPos = function (event, c) { var p = c == 'X' ? 'Left' : 'Bottom'; return event['page' + c] || (event['client' + c] + (document.documentElement['scroll' + p] || document.body['scroll' + p])) || 0; }; var ignoreNativeDrag = function () { return false; }; var currentInterval = 0; var direction = 1; var arrowUp = false; var intervalMove = false; _jscr_trackInt[currentId] = -1; ; var initDrag = function ()
{ceaseAnimation();currentOffset=$drag.offset(false);currentOffset.left-=dragPosition;maxX=trackWidth-$drag[0].offsetWidth;mouseWheelMultiplier=2*settings.wheelSpeed*maxX/contentWidth;};var onStartDrag=function(event)
{initDrag();dragMiddle=getPos(event,'X')-dragPosition-currentOffset.left;jQuery('body').bind('mouseup',onStopDrag).bind('mousemove',updateScroll);if(jQuery.browser.msie){jQuery('body').bind('dragstart',ignoreNativeDrag).bind('selectstart',ignoreNativeDrag);}
return false;};var onStopDrag=function()
			{ jQuery('body').unbind('mouseup', onStopDrag).unbind('mousemove', updateScroll); dragMiddle = percentInView * paneWidth / 2; moveIntervals(); if (jQuery.browser.msie) { jQuery('body').unbind('dragstart', ignoreNativeDrag).unbind('selectstart', ignoreNativeDrag); } }; var positionDrag = function (destX)
			{ evaluateIntervals(dragPosition, destX); destX = destX < 0 ? 0 : (destX > maxX ? maxX : destX); dragPosition = destX; $drag.css({ 'left': destX + 'px' }); var p = destX / maxX; _jscr_originalPos[currentId] = (paneWidth - contentWidth) * p * -1; $pane.css({ 'left': ((paneWidth - contentWidth) * p) + 'px' }); $this.trigger('scroll'); }; var updateScroll = function (e)
{positionDrag(getPos(e,'X')-currentOffset.left-dragMiddle);};var evaluateIntervals=function(position,destX){if((intervalMove==false)&&(mouseWheelMove!=true)){_jscr_trackInt[currentId]=-1;halfInter=-1;smallInter=-1;bigInter=-1;endDragPos=destX+$drag.width();fullTrackWidth=$('.hScrollPaneTrack').width();for(inter in trackIntervals){if((endDragPos>=fullTrackWidth)&&(endDragPos>=trackIntervals[inter])){_jscr_trackInt[currentId]=inter;}else if(destX>=trackIntervals[inter]){smallInter=inter;}else{bigInter=inter;break;}}
if(_jscr_trackInt[currentId]==-1){smallDistance=destX-trackIntervals[smallInter];largeDistance=trackIntervals[bigInter]-destX;if(smallDistance<=largeDistance){_jscr_trackInt[currentId]=smallInter;}else{_jscr_trackInt[currentId]=bigInter;}}}else{intervalMove=false;}}
var moveIntervals=function(){if(_jscr_trackInt[currentId]!=-1){if(arrowUp==true){if((direction==-1)&&(_jscr_trackInt[currentId]!=0)){_jscr_trackInt[currentId]=currentInterval-1;}else if((direction==1)&&(_jscr_trackInt[currentId]!=(_jscr_intervals.length-1))){_jscr_trackInt[currentId]=parseInt(currentInterval)+1;}
arrowUp=false;}
intervalMove=true;positionDrag(trackIntervals[_jscr_trackInt[currentId]]);currentInterval=_jscr_trackInt[currentId];}}
			var arrowSize = 0; if (settings.showArrows == true) { arrowSize = settings.arrowSize; }
var dragH=Math.max(Math.min(percentInView*(paneWidth-arrowSize*2),settings.dragMaxWidth),settings.dragMinWidth);$drag.css({'width':dragH+'px'}).bind('mousedown',onStartDrag);var trackScrollInterval;var trackScrollInc;var trackScrollMousePos;var doTrackScroll=function()
{if(trackScrollInc>8||trackScrollInc%4==0){positionDrag((dragPosition-((dragPosition-trackScrollMousePos)/2)));}
trackScrollInc++;};var onStopTrackClick=function()
			{ clearInterval(trackScrollInterval); moveIntervals(); jQuery('body').unbind('mouseup', onStopTrackClick).unbind('mousemove', onTrackMouseMove); }; var onTrackMouseMove = function (event)
			{ trackScrollMousePos = getPos(event, 'X') - currentOffset.left - dragMiddle; }; var onTrackClick = function (event)
{initDrag();onTrackMouseMove(event);trackScrollInc=0;jQuery('body').bind('mouseup',onStopTrackClick).bind('mousemove',onTrackMouseMove);trackScrollInterval=setInterval(doTrackScroll,100);doTrackScroll();};$track.bind('mousedown',onTrackClick);if($container.mousewheel){$container.mousewheel(function(event,delta){var movePos=-1;if($.browser.opera){delta=event.wheelDelta/120;}
if(trackIntervals.length>1){mouseWheelMove=true;if(delta<0){_jscr_trackInt[currentId]=parseInt(_jscr_trackInt[currentId])+1;if((_jscr_trackInt[currentId])>=trackIntervals.length-1){_jscr_trackInt[currentId]=trackIntervals.length-1;}
if((parseInt($drag.width())+parseInt(trackIntervals[_jscr_trackInt[currentId]]))>parseInt($('.hScrollPaneTrack').width())){movePos=parseInt($('.hScrollPaneTrack').width())-$drag.width();}}else{_jscr_trackInt[currentId]=parseInt(_jscr_trackInt[currentId])-1;if(_jscr_trackInt[currentId]<0){_jscr_trackInt[currentId]=0;}}}
					initDrag(); ceaseAnimation(); var d = dragPosition; if (mouseWheelMove == true) { if (movePos == -1) { positionDrag(trackIntervals[_jscr_trackInt[currentId]]); } else { positionDrag(movePos); } } else { positionDrag(dragPosition - delta * mouseWheelMultiplier); }
moveIntervals();var dragOccured=d!=dragPosition;mouseWheelMove=false;return!dragOccured;},false);}
			var _animateToPosition; var _animateToInterval; function animateToPosition()
			{ var diff = (_animateToPosition - dragPosition) / settings.animateStep; if ((diff > 1 || diff < -1) && ((dragPosition + diff + $drag.width()) < (paneWidth))) { positionDrag(dragPosition + diff); } else { positionDrag(_animateToPosition); ceaseAnimation(); } }
			var ceaseAnimation = function ()
{if(_animateToInterval){clearInterval(_animateToInterval);delete _animateToPosition;}};var scrollTo=function(pos,preventAni)
{if(typeof pos=="string"){$e=jQuery(pos,this);if(!$e.length)return;pos=$e.position().left;}
ceaseAnimation();var destDragPosition=-pos/(paneWidth-contentWidth)*maxX;if(!preventAni||settings.animateTo){_animateToPosition=destDragPosition;_animateToInterval=setInterval(animateToPosition,settings.animateInterval);}else{positionDrag(destDragPosition);}};$this[0].scrollTo=scrollTo;$this[0].scrollBy=function(delta)
{var currentPos=-parseInt($pane.css('left'))||0;scrollTo(currentPos+delta);};initDrag();scrollTo(-currentScrollPosition,true);jQuery.jScrollHorizontalPane.active.push($this[0]);}else{var scrollTo=function(pos,preventAni){}
$this[0].scrollTo=scrollTo;$this.css({'height':paneHeight-this.originalSidePaddingTotal+'px','width':paneWidth+'px','padding':this.originalPadding});}})};jQuery.fn.jScrollHorizontalPane.reset=function(){_jscr_originalSizes=new Array();_jscr_differenceSizes=new Array();_jscr_previousWindowSize=new Array();_jscr_originalPercentages=new Array();_jscr_intervals=new Array();_jscr_trackInt=new Array();_jscr_originalPos=new Array();_jscr_globalProperties=new Array();}
jQuery(window).bind('unload',function(){var els=jQuery.jScrollHorizontalPane.active;for(var i=0;i<els.length;i++){els[i].scrollTo=els[i].scrollBy=null;}});(function($)
{jQuery(function($){$(window).wresize(resizeScroller);function resizeScroller(){$('.scroll-pane').each(function(i,elem){if($(elem).attr('id')==undefined){id=$(elem).attr('class');}else{id=$(elem).attr('id');}
$(elem).jScrollHorizontalPane(_jscr_globalProperties[$(elem).attr('id')]);});}});$.fn.wresize=function(f)
{version='1.1';wresize={fired:false,width:0};function resizeOnce()
{if($.browser.msie)
{if(!wresize.fired)
				{ wresize.fired = true; }
else
{var version=parseInt($.browser.version,10);wresize.fired=false;if(version<7)
					{ return false; }
else if(version==7)
{var width=$(window).width();if(width!=wresize.width)
{wresize.width=width;return false;}}}}
return true;}
function handleWResize(e)
{if(resizeOnce())
{return f.apply(this,[e]);}}
this.each(function()
{if(this==window)
			{ $(this).resize(handleWResize); }
			else
{$(this).resize(f);}});return this;};})(jQuery);
/*
* jQuery ifixpng plugin
* (previously known as pngfix)
* Version 2.0  (04/11/2007)
* @requires jQuery v1.1.3 or above
*
* Examples at: http://jquery.khurshid.com
* Copyright (c) 2007 Kush M.
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/
(function ($) {
	$.ifixpng = function (customPixel) {
		$.ifixpng.pixel = customPixel;
	};
	$.ifixpng.getPixel = function () {
		return $.ifixpng.pixel || '/images/spacer.gif';
	};
	$.ifixpng.setSize = function (loadedImg, targetImg) {
		var $l = $(loadedImg);
		$(targetImg).css('height', $l.height()).css('width', $l.width()).positionFix();
		$l.remove();
	};
	var hack = {
		ltie7: $.browser.msie && $.browser.version < 7,
		filter: function (src) {
			return "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=crop,src='" + src + "')";
		}
	};
	$.fn.ifixpng = hack.ltie7 ? function () {
		return this.each(function () {
			var $$ = $(this);
			var base = $('base').attr('href');
			if ($$.is('img') || $$.is('input')) {
				if ($$.attr('src')) {
					if ($$.attr('src').match(/.*\.png([?].*)?$/i)) {
						// use source tag value if set 
						var source = (base && $$.attr('src').substring(0, 1) != '/') ? base + $$.attr('src') : $$.attr('src');
						// apply filter
						//alert($$.attr('alt')+': '+$$.attr('width')+': '+$$.attr('height'))
						var w = $$.attr('width') || $$.css('width');
						if (w == 'auto') { w = $$.width(); }
						var h = $$.attr('height') || $$.css('height');
						if (h == 'auto') { h = $$.height(); }
						$$.css({ filter: hack.filter(source), width: w, height: h })
						  .attr({ src: $.ifixpng.getPixel() })
						  .positionFix()
						  .attr('onmouseover', '')
						  .attr('onmouseout', '')
						  .addClass('.pngfixed');
						//if(w = 0||h==0){
						$('<img src="' + source + '" style="position:absolute;left:-9999px;top:-9999px;" />').bind('load', function () { $.ifixpng.setSize(this, $$) }).appendTo($('body'));
						//}
					}
				}
			}
		});
	} : function () { return this; };
	$.fn.iunfixpng = hack.ltie7 ? function () {
		return this.each(function () {
			var $$ = $(this);
			var src = $$.css('filter');
			if (src.match(/src=["']?(.*\.png([?].*)?)["']?/i)) {
				src = RegExp.$1;
				if ($$.is('img') || $$.is('input')) {
					$$.attr({ src: src }).css({ filter: '' });
				} else {
					$$.css({ filter: '', background: 'url(' + src + ')' });
				}
			}
		});
	} : function () { return this; };
	$.fn.positionFix = function () {
		return this.each(function () {
			var $$ = $(this);
			var position = $$.css('position');
			if (position != 'absolute' && position != 'relative') {
				$$.css({ position: 'relative' });
			}
		});
	};
})(jQuery);



$.extend($.ui.dialog.prototype, {
	'loadContent': function (src, dat) {
		var me = this.element;
		var myReturn = me.data('popup').returnTo;
		if (myReturn.length > 0) {
			$('.ajax_content', me).contents().appendTo(myReturn.empty());
			//$('.ajax_content',me).empty();
		} else {
			$('.ajax_content', me).empty();
		}
		myReturn = [];
		if ($('.ajax_content .loader', me).length == 0) {
			$('.ajax_content', me).append($('.loader', me).clone().css('display', ''));
		}
		if (src == "initial_content") { src = "#" + src; }
		if (src.length > 1 && src.substring(0, 1) == '#') {
			var id = src;
			if (src == "#initial_content") {
				var base = window.location.protocol + '//' + window.location.host;
				id = unescape(window.location.href.split('#')[0].replace(base, ''));
				var s = $.deparam.fragment();
				if (s.popup || s.overlay) {
					$.bbq.removeState(['popup', 'overlay'])
				}
			} else {
				myReturn = $(src);
			}
			var c = $(src).contents().clone(true);
			//alert(src+' c.html() '+c.length)
			$('#login_errors', c).empty().css('display', 'none')
			var state = {};
			if (!($(src).children().length == 0)) {
				$(src).empty();
				var oldContentState = $.deparam.fragment(me.attr('id'));
				showPage(c, id, me);
				if (oldContentState == id) {
					$(window).trigger('hashchange');
				}
			} else {
				$.bbq.removeState(me.attr('id'))
			}
			$('#initial_content').remove();
		} else {
			if (!me.dialog('isOpen')) {
				me.removeClass('showing')
				animate_opening(me, false, src, dat);
			} else {
				me.dialog('loadRemote', src, dat);
			}
		}
		me.data('popup').returnTo = myReturn;
	},
	'loadRemote': function (src, dat) {
		var me = this.element;
		var urlToUse = src;
		if (urlToUse && isLocalUrl(urlToUse)) {
			var paramToAdd = 'serveas=ajax';
			var prefix = "?";
			var rqType = "GET";

			if (!dat) {
				dat = '';
				if (urlToUse.indexOf(prefix) > -1) {
					prefix = "&";
				}
				urlToUse += prefix + paramToAdd;
			} else if (dat.indexOf(paramToAdd) == -1) { dat += '&' + paramToAdd; rqType = "POST"; }
			$.ajax({ type: rqType, url: urlToUse, cache: false, data: dat,
				success: function (a) {
					if (me.dialog('isOpen')) {
						if (me.attr('id') == 'page' || me.attr('id') == 'product') {
							$("#productcode3").val(src);
						}
						var toShow = [];
						var idx = a.indexOf('<body')
						if (idx > -1) {
							a = a.substr(idx, a.indexOf('</body>') + 7);
							$(a).each(function () { if (this.id == 'initial_content') { toShow = $(this.innerHTML) } });
						} else {
							toShow = $(a);
						}
						showPage(toShow, src, me);
					}
				},
				error: function () {
					showPage($('<div class="page_content"><div class="content"><div class="error"><p>Error loading page</p></div></div></div>'), src, me);
				}
			});
		} else {
			showPage($('<div class="page_content"><div class="content"><div class="error"><p>Error loading page</p></div></div></div>'), src, me);
		}
	}
});

function isLocalUrl(testString) {
	var host = window.location.host;
	if (testString.indexOf('javascript:') != -1) {
		return false;
	}
	var hostStart = testString.indexOf('://')
	if (hostStart != -1) {
		return (testString.indexOf(host) == hostStart + 3)
	}
	return true;
}
function popup_formpost(formObj, popup) {
	var f = $(formObj);
	$(popup).dialog('loadContent', f.attr('action'), f.serialize() + '&serveas=ajax');
}
function animate_opening(popup, contentsReady, src, dat) {

	//alert('animate_opening ('+popup.attr('id') +', '+contentsReady+', '+src+', '+dat+') isOpen: '+popup.dialog('isOpen')+' is opening:'+popup.hasClass('opening'))
	if (!popup.dialog('isOpen') || popup.hasClass('opening')) {
		popup.dialog('open');
		setVisiblePopupClass();
		popup.addClass('opening');
		popup.removeClass('showing');
		$('.ui-dialog-titlebar-close', popup.parent()).css('display', 'none');
		$('.ajax_content, .ajax_footer, .ajax_navigation', popup).css('display', 'none');
		centreMain();
		var bg = $('.bg, .nav_bg', popup).show();
		var bgHeight = 495;
		var bgTop = 0;
		if (!popup.is('#prom')) {
			if (popup.is('#page')) {
				bgTop = 56;
			} else if (popup.is('#overlay')) {
				bgHeight = 150;
			}else if(popup.is('#find')){
				bgHeight=247;
			}
			var alreadyloading = contentsReady
			bg.animate({ height: bgHeight, top: bgTop }, 500, function () { popup.removeClass('opening'); fadeInContents(popup); if (!alreadyloading) { alreadyloading = true; popup.dialog('loadRemote', src, dat) }; });
		} else {
			bg.css('height', $('.homepage_promo_image').outerHeight(true) + 'px').animate({ left: 0 }, 600).animate({ height: 385 }, 600, function () { popup.removeClass('opening'); fadeInContents(popup); centreMain(); });
		}
		if (popup.attr('id') == 'page' || popup.attr('id') == 'prom') {
			$('.ajax_header', popup).append($('.main > .header').contents().not('script'));
			$('.ajax_footer', popup).append($('.main > .footer').contents().not('script'));
		}
	}

}
function animate_closing(popup) {
	popup.removeClass('opening');
	popup.renderSocialMedia(false);
	if (popup.attr('id') == 'page' || popup.attr('id') == 'prom') {
		$('.main > .header').append($('.ajax_header', popup).contents().not('script'));
		$('.main > .footer').append($('.ajax_footer', popup).contents().not('script'));
	}
	if (popup.attr('id') == 'page') {
		if ($.trim($('#shopping_cart .summary_items', popup).text()) != 'empty') {
			var h = $('<div class="cart_holder" />');
			$('.main').append(h);
			h.append($('#shopping_cart', popup));
		}
	}
	var myReturn = popup.data('popup').returnTo;
	if (myReturn && myReturn.length > 0) {
		$('.ajax_content', popup).contents().appendTo(myReturn.empty());
		//$('.ajax_content',me).empty();
	} else {
		$('.ajax_content *', popup).unbind();
		$('.ajax_content', popup).empty();
	}
	popup.data('popup').returnTo = [];
	popup.data('bbq').url = '';
	popup.data('bbq').cache = {};
	var bg = $('.bg, .nav_bg', popup);
	var bgHeight = 10;
	var bgTop = 243;
	if (popup.is('#page')) {
		bgTop = 279;
	}else if(popup.is('#overlay, #find')){
		//$('.popup_login .section_close').trigger('click');
		bgTop = 90;
	}
	$('.ui-dialog-titlebar-close', popup.parent()).css('display', 'none');
	$('.ajax_content,  .ajax_footer,  .ajax_navigation', popup).css('display', 'none');
	//$(' .ajax_navigation',popup).html('').css('display','none');
	if (!popup.is('#prom')) {
		bg.animate({ height: bgHeight, top: bgTop }, 200, function () { bg.css('display', 'none'); popup.dialog('close'); setVisiblePopupClass(); })
	} else {
		bg.animate({ height: $('.homepage_promo_image').outerHeight(true) }, 600).animate({ left: 990 }, 600, function () { bg.css('display', 'none'); popup.dialog('close'); setVisiblePopupClass(); })
	}
}
function fadeInContents(popup, onlyIfNotShowing) {	
	var doAnimation = true;
	doAnimation = !popup.hasClass('showing');
	// findinstore has different sized popup windows depending on the content
	if(popup.is('#find')){
		var type='storefinder_form';		
		if($('.result',popup).length>0){
			if($('.cart_order',popup).length>0){
				type='from_cart';				
		}else{
				type='from_product';
		}
		}
		findInstoreResize(popup,type);
	}
	if (doAnimation) {
		var c = $('.ajax_content', popup);
		var pt = $('.page_title:first', c);
		if (pt.length > 0) {
			document.title = pt.text();
		} else {
			document.title = title_default;
		}
		if ($('.ajax_content.fadedin', popup).length == 0) {
		if($('.store_locator',popup).length>0){
			$('.store_locator .areas',popup).wrap('<div class="areas_container" />')
			$('.store_locator .stores',popup).wrap('<div class="stores_container" />');
			$('.store_locator .locator').append('<div class="loading_screen"><p class="loading_message">Loading Google Map scripts</p></div>');
			addMapScript();
		}
			$('form', popup).filter(function () { var frm = $(this); if (frm.hasClass('existing-handler') || frm.hasClass('processed') || frm.is('.affiliates form')) { return false } else { frm.addClass('processed'); return true; } }).submit(function () { popup_formpost(this, popup); return false; })
			var cb = $('.ui-dialog-titlebar-close', popup.parent()).css('display', 'none');
			if ($('.cart_breadcrumbs, .email_a_friend, .guest_login, .secure_message', popup).length > 0) {
				cb = false;
			}
			$('.ajax_header, .ajax_footer, .ajax_navigation', popup).css('display', '');
			c.css('display', '').css('opacity', 0).addClass('fadedin').ajaxifyLinks();
			popup.addClass('showing');
			$('input.quantity', popup).upDownArrows();
		$('.need_help',popup).tooltip({ vPosition: 'middle', hAlign: 'left' });
		$('.detailed .breakdown th.quantity',popup).applyToolTip();
			popup.pngFix();
			$('.outfits', popup).outFitViewer();
		$('.Related_Products .Item',popup).flipOnMouseOver();
		if($('.Listing .Item',popup).length>0){
			$('.Listing .Item',popup).listingPreviews({popupID:popup.attr('id')});
		}
			var sm = $('.sitemap', popup);
			if (sm.length > 0 && $('.section', sm).length == 0) {
				var nxtSection = [];
				$('.sitemap').children().each(function (idx) {
					var me = $(this);
					if (me.is('h1') && me.index() > 0) {
						nxtSection = $('<div class="section" />')
						me.after(nxtSection);
					} else if (me.is('.sitemap_catalogue')) {
						me.appendTo(nxtSection);
					}
				});
				$('.sitemap .section').tabulate({ cell_selector: '.sitemap_catalogue' })
			}
			$('.matrix:visible', popup).jScrollHorizontalPane(); //h_scroller();		
		$('.info_page, .sizechart_content, .promo, .account_login, .search_results',popup).addClass('scroller_hash');
			var sc = $('.scroller_hash', popup);
			if (sc.length > 0) {
				sc.jScrollPane({ observeHash: true });
			} else {
			$('.cart_content:not(.contact_us), .popup_countries .countries, #product_holder .ProductDescription, .content>.email_a_friend .ProductDescription, .pricing_matrix, .incentives, .store_locator .areas, .store_locator .stores',popup).addClass('scroller_nohash');
				sc = $('.scroller_nohash', popup);
				if (sc.length > 0) {
					sc.jScrollPane({ observeHash: false });
					var po = $('.payment_option', popup).attr('id', 'jumpto');
					if (po.length > 0 && ($('.errorHighlight', po).length > 0) || (window.location.search && window.location.search.indexOf('action=setpayment') > -1)) {
						$('.cart_content')[0].scrollTo('#jumpto')
					}
				}
				$('.contact_us', popup).parent().css({ 'height': '420px', 'overflow': 'auto' }).jScrollPane({ observeHash: false });
			}
		$('.result .scroll_area',popup).jScrollPane();
			if ($('.login_module', popup).fancyAccordion().length == 0) { $('input:visible:first', popup).focus() };
			if ($.browser.msie) {
				$('input[type=password]').each(function () {
					if ($(this).data('initialvalue')) {
						this.value = $(this).data('initialvalue');
					}
				})
			}
			setMouseOverPreviews();
			$('.social_media>.facebook, .social_media>.twitter', popup).hover(function () { $(this).addClass('over'); $('body').addClass('social_over'); }, function () { if ($('.fb_send_button_form_widget:visible', this).length == 0) { $(this).removeClass('over'); $('body').removeClass('social_over') } });
			$('.stock_level .resultcode_3',popup).attr('title','Contact store to confirm availability');
		}
		c.stop();
		c.animate({ 'opacity': 1 }, 1000, function () {
			c.css('opacity', '');
			if (cb) {
				cb.css('display', '');
			} else {
				$('.ui-dialog-titlebar-close', popup.parent()).css('display', 'none');
			}
			try {
				$('.outfits', popup).data('outFitViewer').doReveal()
			} catch (err) { }
			if ($('.outfits', popup).length == 0) {
				popup.renderSocialMedia(true);
			}
		});

	}
}

function setVisiblePopupClass() {
	var visibleOne = [];
	var highestZ = 0;
	$('.ui-dialog').removeClass('on_top').each(function () {
		var me = $(this);
		var myZ = parseInt(me.css('z-index'))
		if (me.css('display') == 'block' && myZ >= highestZ) {
			highestZ = myZ;
			visibleOne = me;
		}
	})
	if (visibleOne.length > 0) {
		visibleOne.addClass('on_top');

	}
	var pt = $('.on_top .page_title:first');
	if (pt.length > 0) {
		document.title = pt.text();
	} else {
		document.title = title_default;
	}
}

function ajax_link_clicked(lnk, evt) {
	var state = {}
	var type = $(lnk).attr('href').substr(0, 5);
	var url = $(lnk).attr('href').substr(6) || '';
	try { pageTracker._trackPageview(url); } catch (e) { }
	if (type == "#page") {
		state.page = url;
		$.bbq.removeState(['show','product','popup','prom','find']);
		if ($(lnk).attr('show_prod') == 'last') {
			state.show = 'last';
		}
	} else if (type == "#prod") {
		$.bbq.removeState(['show','popup','prom','find'])
		if ($('#page').dialog('isOpen') && $('#page .ProductDetails').length == 0) {
			state.product = url;
		} else {
			state.page = url;
		}
	} else if (type == "#popr") {
		$('#popup').dialog('loadContent', url);
	} else if (type == "#popl") {
		$('#popup').dialog('loadContent', "#" + url);
	} else if (type == "#over") {
		$.bbq.removeState(['show','find'])
		$('#overlay').dialog('loadContent', "#" + url);
	} else if (type == "#prom") {
		$.bbq.removeState(['page','show','product','popup','find'])
		if ($('#prom').length == 0) {
			promo_layer = makePopup('prom', 5);
		}
		$('#prom').dialog('loadContent', "#" + url);
	}else if(type=="#find"){
		if($('#find').length==0){
			find_layer=makePopup('find',6);
		}	
		$('#find').dialog('loadContent',url);
	}else if(type=="#maps"){
			$('#stores').dialog('loadContent',url);
} else if (type == "#stores") {
    $('#stores').dialog('loadContent', url);
	} else {
		state.show = url;
	}
	if (url.length > 0) {
		$.bbq.pushState(state);
	}
	return false;
}


var popups = [];
function makePopup(id, type) {
	var isModal = (type == 1 || type == 4 || type == 5 || type==6);
	var popup_settings = { modal: isModal, dialogClass: 'estar_layer', width: 990, height: 600, autoOpen: false, resizable: false, draggable: false, closeOnEscape: false };
	var popup_contents = '<div class="print_header"><img src="/images/print_logo.gif"/></div><div class="bg"></div><div class="nav_bg"></div><div class="ajax_header"></div><div class="ajax_content"></div><div class="loader"><img src="/images/loader.gif" alt="Loading" /></div><div class="ajax_navigation"></div><div class="ajax_footer"></div>';
	switch (type) {
		case 1:
			popup_settings.dialogClass = "estar_modal";
			break;
		case 2:
			popup_settings.dialogClass = "estar_product";
			popup_settings.width = 760;
			popup_settings.height = 495;
			popup_contents = '<div class="print_header"><img src="/images/print_logo.gif"/></div><div class="bg"></div><div class="ajax_content"></div><div class="loader"><img src="/images/loader.gif" alt="Loading" /></div>';
			break;
		case 3:
			popup_settings.dialogClass = "estar_popup";
			popup_settings.width = 760;
			popup_settings.height = 495;
			popup_contents = '<div class="print_header"><img src="/images/print_logo.gif"/></div><div class="bg"></div><div class="ajax_content"></div><div class="loader"><img src="/images/loader.gif" alt="Loading" /></div>';
			break;
		case 4:
			popup_settings.dialogClass = "estar_overlay";
			popup_settings.width = 270;
			popup_settings.height = 'auto';
			popup_settings.minHeight = 150;
			popup_contents = '<div class="print_header"><img src="/images/print_logo.gif"/></div><div class="bg"></div><div class="ajax_content"></div><div class="loader"><img src="/images/loader.gif" alt="Loading" /></div>';
			break;
		case 5:
			popup_settings.dialogClass = "estar_promo";
			popup_settings.width = 990;
			popup_settings.height = 365;
			popup_contents = '<div class="print_header"><img src="/images/print_logo.gif"/></div><div class="bg"></div><div class="ajax_content"></div><div class="loader"><img src="/images/loader.gif" alt="Loading" /></div>';
			break;
		case 6:		
		popup_settings.dialogClass="estar_find";
		popup_settings.width=435;
		popup_settings.height=263;
		popup_settings.position='center';
		popup_contents='<div class="bg"><table class="filler" cellpadding="0" cellspacing="0"><tr><td><img src="/images/spacer.gif" /><td></tr></table></div><div class="ajax_content"></div>';		
		break;
		case 7:		
		popup_settings.dialogClass="estar_storelocator";
		popup_settings.width=933;
		popup_settings.height=495;
		popup_contents='<div class="print_header"><img src="/images/print_logo.gif"/></div><div class="bg"></div><div class="ajax_content"></div><div class="loader"><img src="/images/loader.gif" alt="Loading" /></div>';
		break
		default:
			break;
	}
	var popup = $('<div id="' + id + '">' + popup_contents + '</div>');
	popup.appendTo($('body'));
	popup.data('bbq', { cache: {} })
	popup.data('popup', { returnTo: [] })
	popup.dialog(popup_settings);
	popups.push(popup);
	return popup;
}

$(window).bind('hashchange', function (e) {
	$('.ui-dialog-content').each(function () {
		var h = $(this);
		var isOpen = (h.dialog('isOpen') || h.hasClass('opening'))
		var myData = h.data('bbq');
		var myUrl = e.getState(h.attr('id')) || '';
		if (myUrl.length == 0) {
			if (isOpen) {
				animate_closing(h);
			}
			return;
		}
		if (!(myData.url === myUrl)) {
			myData.url = myUrl;
			if (myData.cache[myUrl]) {
				$('.ajax_content *', h).unbind();
				$('.ajax_content', h).empty().removeClass('fadedin').append(myData.cache[myUrl].clone(true)).ajaxifyLinks();
				h.removeClass('showing')
				myData.cache[myUrl] = false;
				if (!isOpen) {
					animate_opening(h, true);
				} else if (!h.hasClass('opening')) {					
					fadeInContents(h);
				}
			} else {
				if (myUrl.length > 0) {
					h.dialog('loadContent', myUrl);
				}
			}
		} else {
			if (myData.cache[myUrl]) {
				$('.ajax_content *', h).unbind();
				$('.ajax_content', h).empty().removeClass('fadedin').append(myData.cache[myUrl].clone(true)).ajaxifyLinks();
				h.removeClass('showing');
				myData.cache[myUrl] = false;
				if (!isOpen && !h.hasClass('opening')) {
					animate_opening(h, true);
				} else if (!h.hasClass('opening')) {
					fadeInContents(h, (!(!e.getState('show'))));
				}
			}
		}
		var breadcrumbs = $('.ajax_content .breadcrumbs', h)
		var f = $.deparam.fragment().product || '';
		if (breadcrumbs.length > 0 && (h.attr('id') == 'product' || (h.attr('id') == 'page' && f.length == 0))) {
			$('.ajax_footer .breadcrumbs').remove();
			$('.ajax_footer').prepend(breadcrumbs.clone(true).css('display', '').ajaxifyLinks())
		}
	});
	if (e.getState('show')) {
		showSection(e.getState('show'));
	}
	if (!e.getState('page')) {
		$('.footer .breadcrumbs').remove();
	}
});

function showPage(pageCode, url, popup) {
	//alert('showPage '+url)
	var cart = $('#shopping_cart', pageCode).ajaxifyLinks();
	if (cart.length > 0) {
		$('#page #shopping_cart, .main > .cart_holder').remove();
		$('#page .ajax_navigation').append(cart);
	}
	var state = {}
	state[popup.attr('id')] = unescape(url);
	var nav = $('.page_navigation', pageCode).css('display', 'none');
	if (nav.length > 0 && popup.attr('id') == 'page') {
		$('#page .ajax_navigation .page_navigation').remove()
		$('#page .ajax_navigation').prepend(nav.clone(true).css('display', '').ajaxifyLinks());
		$('#page .ajax_navigation').pngFix();
		$('#page .ajax_navigation .nav_hierarchy li').expandingMenu()
	}
	var breadcrumbs = $('.breadcrumbs', pageCode).css('display', 'none');
	if (breadcrumbs.length > 0) {
		$('.ajax_footer .breadcrumbs').remove();
		$('.ajax_footer').prepend(breadcrumbs.clone(true).css('display', '').ajaxifyLinks())
	}
	popup.data('bbq').cache = {};
	popup.data('bbq').cache[url] = pageCode;
	$.bbq.pushState(state);

	if (pageCode.children().length > 0) {
		//alert('showPage: '+url)	
		if ($.deparam.fragment()[popup.attr('id')] == url) {
			$(window).trigger('hashchange');
		}
	} else {
		//alert('closing')
		$.bbq.removeState(pageCode.attr('id'))
	}
}


var navPendingOpen = null;
var navClosing = null;
var navOpening = null;
var navPriority = null;
var navOpen = null;
var navDormant = true;
function scrollBGTo(newY) {
	$('.bg_images').stop().animate({ top: newY }, 2400, 'easeInOutQuart');
}
function openChildNav($obj, hasPriority) {
	if (hasPriority) {
		navPriority = $obj;
	}
	navPendingOpen = $obj;
	var waitABit = false;
	$obj.siblings().each(function () {
		var sib = $(this);
		if (sib.hasClass('closing')) {
			waitABit = true;
		}
		if (sib.is('.opening, .open')) {
			closeChildNav(sib);
			waitABit = true;
		}
	});
	if (waitABit) { return }
	if (hasPriority) {
		setTimeout('closeOpenNav()', 2000);
	}
	navPendingOpen = null;
	navOpening = $obj;
	var tmp = $obj;
	tmp.addClass('opening');
	navDormant = false;
	var childNav = $('ul', $obj);
	if (childNav.css('display') != 'block') {
		childNav.slideDown(500, function () { childNav.css('visibility', 'visible').animate({ 'margin-left': 20, 'margin-right': 0, 'opacity': 1 }, 500, 'easeInQuart', function () { setAsOpen(tmp) }) })
	} else {
		childNav.css({ 'visibility': 'visible', 'margin-left': '20px', 'margin-right': '0', 'opacity': 1 }).slideDown(20, function () { setAsOpen(tmp) });
	}
}
function closeOpenNav() {
	//alert(navDormant);
	if (navDormant == true) {
		closeChildNav(navPriority);
	}
}
function setAsOpen($obj) {
	$obj.addClass('open').removeClass('opening');
	if (navPendingOpen != null && navPendingOpen != $obj) { openChildNav(navPendingOpen) }
	navPriority = null;
}
function closeChildNav($obj) {
	navDormant = true;
	if ($obj == null) {
		$obj = $('.main_navigation li.open');
	}
	var childNav = $('ul', $obj);
	var tmp = $obj;
	if (tmp.is('.open')) {
		tmp.addClass('closing').removeClass('opening').removeClass('open');
		if (childNav.css('display') == 'block') {
			navClosing = $obj;
			childNav.animate({ 'opacity': '1' }, 800, function () { childNav.animate({ 'opacity': 0 }, 400, 'easeInQuart', function () { childNav.css({ 'visibility': 'hidden', 'margin-left': '-10px', 'margin-right': '30px' }).slideUp(300, function () { tmp.removeClass('closing'); if (navPendingOpen != null) { openChildNav(navPendingOpen) }; childNav.css({ 'height': 'auto' }) }) }); })
		} else {
			tmp.removeClass('closing');
		}
	}
}
function stopClosing($obj) {
	if ($obj.is('.open, .opening')) {
		navDormant = false;
	}
	if ($obj.hasClass('closing') && navPendingOpen != $obj && navPriority == $obj) {
		$('ul', $obj).stop(true, false);
		$obj.removeClass('closing');
		navPendingOpen = null;
		openChildNav($obj);
	}
}

function setScrollingBG() {
	var scrollTarget = false;
	var links = $('.main_navigation>ul>li>a, .estore .main_navigation>ul>li>ul>li>a').not('.estore .main_navigation>ul>li>a').each(function (idx) {
		var me = $(this);
		var myLi = me.parent();
		var myClasses = me.attr('class').split(' ');
		var myID = '';
		var found = false;
		for (var i = 0; i < myClasses.length && !found; i++) {
			if (myClasses[i] != 'ajax') {
				myID = myClasses[i];
				found = true;
			}
		}
		if (myID.length > 0) {
			var myImg = $('.bg_images .' + myID);
			if (myImg.length > 0) {
				var targ = idx * -600;
				me.hoverIntent({ over: function () { scrollBGTo(targ) }, out: function () { }, timeout: 200 });
				myLi.hoverIntent({ over: function () { stopClosing(myLi) }, out: function () { closeChildNav(myLi) }, timeout: 200 });
				if (myLi.hasClass('On')) { scrollTarget = targ; }
			} else {
				myLi.hoverIntent({ over: function () { stopClosing(myLi) }, out: function () { closeChildNav(myLi) }, timeout: 200 });
			}
		}
		var childNav = ($('ul', myLi).css({ 'margin-left': -10, 'display': 'none', 'visibility': 'hidden', 'opacity': '0' }).length > 0);
		if (childNav) {
			me.attr('href', '#').bind('click', function () { openChildNav(myLi, true); return false });
		}
	});
	if (scrollTarget) {
		$('.bg_images').css('top', scrollTarget + 'px');
	}
}

function showSection(selector) {
	//alert('showSection('+selector+')');
	var outfits = $('.outfit_viewer');
	if (outfits.length > 0) {
		//alert('outfit_viewer found')
		outfits.data('outFitViewer').showItem(selector);
	}
}

(function ($) {

	// configuration, private helper functions and variables
	var _defaultConfig = {
		animationTime: 800,
		thumbAnimationTime: 400,
		thumbAnimationDelay: 70,
		mainImageWidth: 312,
		itemsPerPage: 24,
		pageNumberSeparator: '<span class="num_as_img_txt"> / </span><img class="separator num_as_img" src="/images/page_numbering_sml_slash.gif" alt="" />',
		itemNumberSeparator: '<span class="num_as_img_txt"> of </span><img class="separator num_as_img" src="/images/page_numbering_slash.gif" alt="" />'
	};

	$.outFitThumb = function (el, idx, viewer) {
		if (this === window) { return new $.outFitThumb(el, idx, viewer) }
		this.thumbnail = $(el).css('position', 'relative');
		if (this.thumbnail.data('outFitThumb')) { return }
		var me = this;
		this.thumbnail.data('outFitThumb', this);
		this.thumbTarget = $('a', el).attr('href');
		this.thumbTarget = unescape(this.thumbTarget.replace('show_', '')).replace('#', '');
		this.idx = idx;
		this.viewer = viewer;
		this.mouseOverlay = $('<div class="mouse_overlay" style="position:absolute;top:0;left:0;display:none;"></div>');
		this.thumbnail.append(this.mouseOverlay);
		this.activeOverlay = $('<div class="active_overlay" style="position:absolute;top:0;left:0;display:none;"></div>');
		this.opaqueOverlay = $('<div class="opaque_overlay pending" style="position:absolute;top:0;left:0;background:#000000;"></div>');
		this.thumbnail.append(this.activeOverlay);
		this.thumbnail.append(this.opaqueOverlay);
		this.thumbnail.hover(this.mouseOverAction, this.mouseOutAction)
		this.thumbnail.click(this.clickAction)
		this.image = $('img:first', el);
		var myDelay = me.viewer.config.thumbAnimationDelay || 100;
		myDelay *= idx;
	}
	$.outFitThumb.prototype = {
		makeInactive: function (newIdx) {
			var me = this; //$(this).data('outFitThumb');
			//alert('makeInactive my idx:'+me.idx+' newIdx'+newIdx)
			var dir = 0;
			if (newIdx > me.idx) {
				dir = 1;
			} else if (newIdx < me.idx) {
				dir = -1;
			}
			var targ = me.activeOverlay.outerWidth() * dir;
			if (!(targ == 0)) {
				if ($.browser.msie && $.browser.version < 7 && dir == -1) {
					targ -= 4;
				}
				me.activeOverlay.css('display', '').animate({ 'left': targ }, me.viewer.config.animationTime || 200)
			}
		},
		makeActive: function (oldIdx) {
			var me = this; //$(this).data('outFitThumb');
			var dir = 0;
			if (oldIdx > me.idx) {
				dir = 1;
			} else if (oldIdx < me.idx) {
				dir = -4;
			}
			var targ = me.activeOverlay.outerWidth() * dir;

			if (!(targ == 0)) {
				if ($.browser.msie && $.browser.version < 7 && dir == -1) {
					targ -= 2;
				}
				me.activeOverlay.css('display', '').css('left', targ + 'px').animate({ 'left': 0 }, me.viewer.config.animationTime || 200)
			}
		},
		mouseOverAction: function () { $(this).data('outFitThumb').mouseOverlay.css('display', ''); },
		mouseOutAction: function () { $(this).data('outFitThumb').mouseOverlay.css('display', 'none'); },
		clickAction: function () { if (!$(this).data('outFitThumb').viewer.isAnimating) { $.bbq.pushState({ show: $(this).data('outFitThumb').thumbTarget }); } },
		reveal: function () {
			//alert('reveal')
			var me = this;
			if (me.opaqueOverlay.hasClass('pending')) {
				me.opaqueOverlay.removeClass('pending');
				me.opaqueOverlay.css({ 'background': '#FFFFFF', 'opacity': '0' }).animate({ opacity: 1 }, me.viewer.config.thumbAnimationTime, function () { me.image.css('visibility', 'visible'); me.reveal(); });
			} else {
				//if(me.image[0].complete){
				if (me.image.css('visibility') == 'hidden') {
					me.image.css('visibility', 'visible');
					setTimeout(function () { me.reveal() }, me.viewer.config.thumbAnimationDelay);
				} else {
					me.opaqueOverlay.animate({ opacity: 0 }, me.viewer.config.thumbAnimationTime, function () { me.opaqueOverlay.remove(); });
				}
				//}else{
				//me.image.bind('load',function(){me.reveal()});
				//}
			}
		}
	}
	$.fn.outFitThumb = function (viewer) {
		return this.each(function (idx) {
			new $.outFitThumb(this, idx, viewer);
		});
	};
	// the main controller constructor
	$.outFitViewer = function (elm, config) {
		if (this === window) { return new $.outFitViewer(elm, config || {}); }
		this.item = $(elm);
		this.config = new $.outFitViewer.config(config);
		if (this.item.data('outFitViewer')) { return; }
		this.item.data('outFitViewer', this);
		var selfref = this.item.data('outFitViewer');
		this.item.addClass('outfit_viewer');
		this.thumbs = $('.thumbnails .thumb', this.item).outFitThumb(this.item.data('outFitViewer'));
		this.viewport = $('<div class="viewport" style="position:relative"><div class="image_holder" style="position:absolute;z-index:1;" /></div>');
		this.item.prepend(this.viewport);
		this.backButton = $('<div class="btn_back" style="position:absolute;left:0;z-index:2;" title="Previous"/>').bind('click', function () { selfref.showPrev() }).hover(function () { $(this).addClass('over') }, function () { $(this).removeClass('over') });
		this.nextButton = $('<div class="btn_next" style="position:absolute;right:0;z-index:3;" title="Next"/>').bind('click', function () { selfref.showNext() }).hover(function () { $(this).addClass('over') }, function () { $(this).removeClass('over') }); ;
		this.viewport.append(this.backButton);
		this.viewport.append(this.nextButton);
		this.numbering = $('.item_numbers', this.item);
		//this.item.append(this.numbering);
		this.numberCurrent = $('.number_current', this.item);
		this.numberOf = $('.number_of', this.item);
		this.itemCount = parseInt(this.numberOf.text(), 10)
		var currentPageLi = $('.page_numbers li.on', this.item)
		this.itemCountOffset = 0;
		this.nextPageLink = null;
		this.prevPageLink = null;
		this.isAnimating = false;
		if (currentPageLi.length > 0) {
			var currentPageIdx = 0;
			var separator = this.config.pageNumberSeparator;
			this.itemCountOffset = (parseInt(currentPageLi.text(), 10) - 1) * this.config.itemsPerPage;
			var pageLinkList = $('.page_numbers li', this.item).each(function (idx) {
				var thisLi = $(this);
				if (this == currentPageLi[0]) {
					currentPageIdx = idx
					thisLi.html('<span>' + asImg(parseInt(thisLi.text(), 10), 2, '/images/page_numbering_sml_') + '</span>')
				} else {
					$('a', this).html(asImg(parseInt(thisLi.text(), 10), 2, '/images/page_numbering_sml_'))
				}
				if (idx > 0) {
					thisLi.prepend($(separator));
				}
			});
			if (currentPageIdx > 0 && pageLinkList.length > 1) {
				this.prevPageLink = $('a', pageLinkList[currentPageIdx - 1]);
			}
			if (currentPageIdx + 1 < pageLinkList.length) {
				this.nextPageLink = $('a', $(pageLinkList[currentPageIdx + 1]));
			}
		}
		//this.numbering.append(this.numberOf);
		this.numberCurrent.html(asImg(this.numberCurrent.text(), this.numberOf.text().length) + this.config.itemNumberSeparator);
		this.numberOf.html(asImg(this.itemCount, this.numberOf.text().length));
		this.heading = $('<div class="cat_name" style="display:none"></div>');
		this.heading.append($('h1:first', this.item))
		this.details = $('<div class="details"/>');
		this.item.append(this.details);
		this.details.prepend(this.heading);
		this.imageHolder = $('.image_holder', this.viewport);
		this.linkHolder = $('<div class="email_links"/>');
		this.item.append(this.linkHolder);
		this.socialHolder = $('<div class="social_media_links"/>');
		this.item.append(this.socialHolder);
		var ih = this.imageHolder;
		var d = this.details;
		var lh = this.linkHolder;
		var sh = this.socialHolder;
		this.fbRendered = false;
		$('.OutfitListing .Outfit').each(function (idx) {
			var myImg = $('.Image', this);
			if (myImg.length == 0) {
				myImg = $('<div class="Image" />');
			}
			ih.append(myImg.css('display', 'none'));
			var myText = $('.OutfitItems', this);
			if (myText.length == 0) {
				myText = $('<div class="OutfitItems" />');
			}
			d.append(myText.css('display', 'none'))
			var myEmailLink = $('.OutfitLinks', this);
			if (myEmailLink.length == 0) {
				myEmailLink = $('<div class="OutfitLinks" />');
			} else {
				myEmailLink = $('.OutfitLinks', this).clone(true);
				$('.OutfitLinks', this).remove();
			}
			lh.append(myEmailLink.css('display', 'none'));
			var mySocialMedia = $('.social_media', this);
			if (mySocialMedia.length == 0) {
				mySocialMedia = $('<div class="social_media" />');
			}
			sh.append(mySocialMedia.css('display', 'none'));
		})
		this.details.wrap('<div class="details_scroller"><div class="details_holder"></div></div>')
		this.imageHolder.css('width', (this.config.mainImageWidth * 2) + 'px')
		this.mainImages = $('.Image', this.viewport).css('float', 'left');
		this.texts = $('.OutfitItems', this.details);
		this.emailLinks = $('.OutfitLinks', this.linkHolder);
		this.socialMedia = $('.social_media', this.socialHolder);
		this.currentIdx = -1;
		this.initialThumb = [];
		this.isRevealed = false;
		if (!$.bbq.getState('show')) {
			if (this.thumbs.length > 0) {
				this.initialThumb = $('.thumbnails .thumb.on', this.item);
				if (this.initialThumb.length == 0) {
					this.initialThumb = $(this.thumbs[0]);
				}
			}
		} else {
			this.initialThumb = $('.thumbnails .thumb a[href=#' + $.bbq.getState('show') + ']').parent();
		}
		//this.item.data('outFitViewer').doReveal()
	};
	$.outFitViewer.config = function (c) { $.extend(this, $.outFitViewer.config, c); };
	$.outFitViewer.config.prototype = _defaultConfig;
	$.outFitViewer.prototype = {
		showItem: function (itemID) {
			if (!this.isRevealed) {
				this.initialThumb = $('.thumbnails .thumb a[href=#' + itemID + ']').parent();
				return;
			}
			itemID = unescape(itemID).replace('#', '')
			var nextIdx = 0;
			var oldIdx = this.currentIdx;
			var self = this;
			if (!this.isAnimating) {
				this.isAnimating = true;
				if (itemID == 'last') {
					nextIdx = $('.OutfitListing .Outfit', this.item).length - 1;
				} else {
					$('.OutfitListing .Outfit', this.item).each(function (idx) { if (this.id == itemID) { nextIdx = idx; } });
				}
				this.currentIdx = nextIdx;
				if (!(oldIdx == nextIdx)) {
					this.backButton.css('display', 'none');
					this.nextButton.css('display', 'none');
					$(this.thumbs[nextIdx]).data('outFitThumb').makeActive(oldIdx);
					var oldImage = null;
					var oldText = null;
					var oldLink = null;
					var oldSocial = null;
					if (oldIdx > -1) {
						$(this.thumbs[oldIdx]).data('outFitThumb').makeInactive(nextIdx);
						oldImage = $(this.mainImages[oldIdx]);
						oldText = $(this.texts[oldIdx]);
						oldLink = $(this.emailLinks[oldIdx]);
						oldSocial = $(this.socialMedia[oldIdx]);
					}
					var nxtImage = $(this.mainImages[nextIdx]).css('display', '');
					var nxtText = $(this.texts[nextIdx]);
					var nxtLink = $(this.emailLinks[nextIdx]);
					var nxtSocial = $(this.socialMedia[nextIdx]);
					var aniTime = this.config.animationTime;
					var likebutton = null;
					var currentNumberDisplay = this.numberCurrent;
					var nextNumberHtml = asImg(this.itemCountOffset + this.currentIdx + 1, this.thumbs.length.toString().length) + this.config.itemNumberSeparator;
					var toFade = $.merge($('#doesnotexist'), this.details);
					$.merge(toFade, this.numbering);
					$.merge(toFade, this.linkHolder);
					$.merge(toFade, this.socialHolder);
					if (oldImage) {
						this.imageHolder.css({ 'left': oldImage.position().left * -1 }).animate({ 'left': nxtImage.position().left * -1 }, aniTime, function () { oldImage.css('display', 'none'); $(this).css('left', 0); })
					} else {
						var startPos = nxtImage.width() * -1
						if (nextIdx == self.config.itemsPerPage - 1) { startPos *= -1 }
					this.imageHolder.css({'left':startPos}).animate({'left':0},aniTime)
				}
				toFade.animate({'opacity':'0'},	aniTime/2, function(){
					if(oldText){
						oldText.css('display','none');
					}
					if(oldLink){
						oldLink.css('display','none');
					}
					if(oldSocial){
						oldSocial.css('display','none');
					}
					nxtText.css('display','');
					nxtLink.css('display','');
					nxtSocial.css('display','');
					self.heading.css('display','');
					$('.details_scroller',self.item).jScrollPane({observeHash:false});
					$(this).animate({'opacity':'1'},aniTime/2,function(){
						$(this).css('opacity','');
					})				
				});				
				setTimeout(function(){
					self.showNextPrev();
					if(oldSocial){
						oldSocial.renderSocialMedia(false);
					}	
					if(nxtSocial){
						nxtSocial.renderSocialMedia(true);
					}
				},10+aniTime)
				
				}
			}
		},
		showNext: function () {
			if (this.currentIdx + 1 < this.config.itemsPerPage) {
				var nxtID = $('.OutfitListing .Outfit', this.item)[this.currentIdx + 1].id;
				if (nxtID) {
					$.bbq.pushState({ show: nxtID })
				}
			} else {
				if (this.nextPageLink) {
					this.nextPageLink.click();
				}
			}

		},
		showPrev: function () {
			if (this.currentIdx > 0) {
				var nxtID = $('.OutfitListing .Outfit', this.item)[this.currentIdx - 1].id;
				if (nxtID) {
					$.bbq.pushState({ show: nxtID });
				}
			} else {
				if (this.prevPageLink) {
					this.prevPageLink.attr('show_prod', 'last').click();
				}
			}
		},
		showNextPrev: function () {
			this.isAnimating = false;
			if (this.currentIdx + this.itemCountOffset > 0) {
				this.backButton.css('display', '');
			} else {
				this.backButton.css('display', 'none');
			}
			if (this.currentIdx + this.itemCountOffset >= this.itemCount - 1) {
				this.nextButton.css('display', 'none');
			} else {
				this.nextButton.css('display', '');
			}
		},
		doReveal: function () {
			var delayTime = this.config.thumbAnimationDelay;
			var revealdelay = 10;
			this.thumbs.each(function (idx) {
				var thisThumb = $(this).data('outFitThumb');
				setTimeout(function () { thisThumb.reveal(); }, delayTime * idx);
				revealdelay += delayTime;
			})
			var self = this;
			setTimeout(function () {
				self.isRevealed = true;
				if (self.initialThumb.length > 0) {
					self.initialThumb.click();
				} else {
					self.showItem($.bbq.getState('show'))
				}
			}, revealdelay)
		}
	};
	// expose as a selector plugin
	$.fn.outFitViewer = function (config) {
		return this.each(function () {
			new $.outFitViewer(this, config);
		});
	};
})(jQuery);


function asImg(num, digits, imgBase) {
	if (!imgBase) {
		imgBase = '/images/page_numbering_'
	}
	var r = '<span class="num_as_img_txt">' + num + '</span>';
	var images = [];
	for (var i = 0; i < 10; i++) {
		images.push('<img class="num_as_img" src="' + imgBase + i + '.gif" alt="' + i + '"/>');
	}
	var s = num.toString().split('');
	if (!digits || digits < s.length) {
		digits = s.length;
	}
	while (digits > 0) {
		digits--;
		var digit = parseInt(s.pop(), 10);
		if (isNaN(digit)) {
			digit = 0;
		}
		r = images[digit] + r;
	}
	return r;
}
function clickAction() {
	return false;
}
function openMe(toOpen) {
	var myLi = $(toOpen).parent();
	var mySibs = $(myLi).siblings();
	$('li', mySibs).removeClass('on');
	$('>ul', myLi).stop().slideDown(300, function () { myLi.addClass('on') });
	$('>ul', mySibs).stop().slideUp(300);
	$('>ul ul', mySibs).slideUp(100);
	mySibs.removeClass('on');
}
(function ($) {
	$.fn.expandingMenu = function (opts) {
		return this.each(function () {
			var me = $(this);
			if ($('ul', me).length > 0) {
				$('>a', me).attr('href', '#').unbind().bind('click', function (e) { e.preventDefault(); openMe(this); });
			}
		});
	};
})(jQuery);

function flipMe(el, obv_selector, rev_selector, time) {
	if (!obv_selector) { obv_selector = '.Image' }
	if (!rev_selector) { rev_selector = '.item_summary' }
	if (!time) { time = 400 }
	var me = $(el);
	var obv = $(obv_selector, el).stop();
	var rev = $(rev_selector, el).stop();
	/*
	if(rev.is(':visible')){
	rev.animate({'left':0,'width':me.innerWidth()+'px'},time)	  
	}else{
	obv.animate({'left':((me.innerWidth()-1)/2)+'px','width':1+'px'},time, function(){obv.css('display','none');rev.css({'left':((me.innerWidth()-1)/2)+'px','width':1+'px'}).css('display','').animate({'left':0,'width':me.innerWidth()+'px'},time)})
	}
	*/
	if (rev.css('display') == 'block') {
		rev.animate({ 'opacity': 1 }, time)
	} else {
		obv.animate({ 'opacity': 0 }, time, function () { obv.css('display', 'none'); rev.css({ 'opacity': 0, 'display': 'block' }).animate({ 'opacity': 1 }, time, function () { rev.css('opacity', '') }) })
	}
}
function flipBack(el, obv_selector, rev_selector, time) {
	if (!obv_selector) { obv_selector = '.Image' }
	if (!rev_selector) { rev_selector = '.item_summary' }
	if (!time) { time = 300 }
	var me = $(el);
	var obv = $(obv_selector, el).stop();
	var rev = $(rev_selector, el).stop();
	/*
	if(obv.is(':visible')){
	obv.animate({'left':0,'width':me.innerWidth()+'px'},time)	  
	}else{
	rev.animate({'left':((me.innerWidth()-1)/2)+'px','width':1+'px'},time, function(){rev.css('display','none');obv.css({'left':((me.innerWidth()-1)/2)+'px','width':1+'px'}).css('display','').animate({'left':0,'width':me.innerWidth()+'px'},time)})
	}
	*/
	if (obv.css('display') == 'block') {
		obv.animate({ 'opacity': 1 }, time)
	} else {
		rev.animate({ 'opacity': 0 }, time, function () { rev.css({ 'display': 'none', 'opacity': '' }); obv.css({ 'opacity': 0, 'display': 'block' }).animate({ 'opacity': 1 }, time, function () { obv.css('opacity', '') }) })
	}
}

(function ($) {
	$.fn.flipOnMouseOver = function (opts) {
		var defaults = { 'obv_selector': '.Image', 'rev_selector': '.item_summary', 'time': 300 }
		var o = $.extend(defaults, opts)
		return this.each(function () {
			var me = $(this);
			if (me.hasClass('flipper')) { return }
			me.addClass('flipper')
			var lnk = $('a', me).attr('title', '');
			if (lnk.length > 0) {
				$('img', me).attr('alt', '');
				me.css('cursor', 'pointer');
				me.bind('click', function () { ajax_link_clicked(lnk) })
			}
			$(o.rev_selector, me).css('display', 'none');
			//$(o.obv_selector,me).css({'height':me.css('height'),'width':me.css('width')});
			var me = $(this).hoverIntent(function () { flipMe(this, o.obv_selector, o.rev_selector, o.time) }, function () { flipBack(this, o.obv_selector, o.rev_selector, o.time) })
		});
	};
})(jQuery);

(function ($) {
	$.fn.upDownArrows = function (opts) {
		var defaults = { holder: '<span class="up_down"/>', 'up_button': '<img alt="Increase" title="Increase" src="/images/input_arrow_up.gif"/>', 'down_button': '<img title="Decrease" alt="Decrease" src="/images/input_arrow_down.gif"/>', 'max_value': 99, 'min_value': 1 }
		var o = $.extend(defaults, opts);
		return this.each(function () {
			var $input = $(this);
			var myMax = o.max_value;
			if ($input.attr('max')) {
				myMax = parseInt($input.attr('max'), 10)
			}
			var myMin = o.min_value;
			if ($input.attr('min')) {
				myMin = parseInt($input.attr('min'), 10)
			}
			if ($input.hasClass('up_down_added')) { return }
			$input.addClass('up_down_added');
			$input.blur(function () {
				this.value = this.value.replace(/[^0-9\.]/g, '');
				if (this.value.length == 0 || parseInt(this.value, 10) < myMin) {
					this.value = myMin;
				}
				if (this.value > myMax) {
					this.value = myMax;
				}
				if (isNaN(this.value)) {
					this.value = myMin;
				}
			})
			var $holder = $(o.holder)
			$input.after($holder)
			if (isNaN($input.val()) || $input.val() < myMin) { $input.val(myMin) } else if ($input.val() > myMax) { $input.val(myMax) }
			$(o.up_button).bind('click', function () { if (isNaN($input.val())) { $input.val(myMin) } else if ($input.val() < myMax) { $input.val(parseInt($input.val(), 10) + 1) } }).appendTo($holder);
			$(o.down_button).bind('click', function () { if (isNaN($input.val()) || !($input.val() > myMin)) { $input.val(myMin) } else { $input.val(parseInt($input.val(), 10) - 1) } }).appendTo($holder);
		});
	};
})(jQuery);


function centreMain() {
	var m = $('.main').css({ 'margin-top': '0', 'top': '0' });
	var targY = Math.floor(($(window).height() - m.height()) / 2);
	if (targY < 0) {
		targY = 0
	};
	var targX = m.offset().left;
	m.css('padding-top', targY + 'px');
	$('.ui-widget-overlay, .estar_modal').css({ 'top': targY + 'px', 'left': targX + 'px' });
	var refObj = $('#page').dialog('isOpen') ? $('.estar_modal .ajax_header') : $('.main .header')
	$('.estar_product, .estar_popup, .estar_storelocator').css({'top':(refObj.offset().top + refObj.outerHeight(true))+'px','left':(targX+29) +'px' });
	$('.estar_promo').css({ 'top': (refObj.offset().top + refObj.outerHeight(true) + 52) + 'px', 'left': targX + 'px' });
	$('.homepage_promo_holder').css({ 'top': (refObj.offset().top + refObj.outerHeight(true) + 52) + 'px' });
	var useH = $('#overlay .ajax_content').height();
	if (useH < $('#overlay .bg').height()) {
		useH = $('#overlay .bg').height();
	}
	var newY = ($(window).height() - useH) / 2;
	if (newY < 0) { newY = 0 }
	$('.estar_overlay').css({ 'top': (newY) + 'px', 'left': (targX + 300) + 'px' });
	useH=330;
	if(useH<$('#find .bg').outerHeight(true)){
		useH=$('#find .bg').outerHeight(true);
	}
	newY=($(window).height()-useH)/2;
	if(newY<0){newY=0}
	$('.estar_find').css({'top':(newY)+'px','left':(targX+500)+'px' });
}

var shareCount = 1;
(function ($) {
	$.fn.ajaxifyLinks = function (opts) {
		var defaults = {}
		var o = $.extend(defaults, opts);
		var currentUrl = window.location.protocol + '//' + window.location.host;
		return this.each(function () {
			//alert('ajaxifying '+this.className)
		var links=$('a',this).not('[href^="javascript:"], [href^="mailto:"], [target="_blank"], .no_ajax, .ajaxed, .cancel, .affiliates a, .info_page a, .sizechart_content a, .promo a, .account_login a, .AlphabetLinks a, .social_media a, .store_locator a').each(function(){											
				var lnk = $(this);
				lnk.addClass('ajaxed');
				var myHref = lnk.attr('href') || '';
				if (myHref.indexOf('#') > -1) {
					if (myHref.substr(0, 1) == "#") {
						if (lnk.hasClass('popup_link')) {
							myHref = "#popl_" + myHref.substr(1);
						} else if (lnk.hasClass('overlay_link')) {
							myHref = "#over_" + myHref.substr(1);
						} else if (lnk.hasClass('promo_link')) {
							myHref = "#prom_" + myHref.substr(1);
					}else if(lnk.hasClass('find_link')){
						myHref = "#find_"+myHref.substr(1);
					}else if(lnk.hasClass('map_link')){
						myHref = "#maps_"+myHref.substr(1);				
						} else {
							myHref = "#show_" + myHref.substr(1);
						}
						lnk.click(function () { return ajax_link_clicked(lnk); });
					} else { //IE7 sometimes prepends hash links with the page URI, so we need to strip this out for inpage anchors
						var parts = myHref.split('#');
						//alert('parts[1]: '+parts[1]+' parts[0]:\n' +parts[0]+'\ncurrentUrl+window.location.pathname+window.location.search\n'+currentUrl+window.location.pathname+window.location.search)
						if (parts[0] == currentUrl + window.location.pathname + window.location.search) {
							myHref = parts[1] || '';
							if (lnk.hasClass('popup_link')) {
								myHref = "#popl_" + myHref;
							} else if (lnk.hasClass('overlay_link')) {
								myHref = "#over_" + myHref;
							} else if (lnk.hasClass('promo_link')) {
								myHref = "#prom_" + myHref;
						}else if(lnk.hasClass('find_link')){
							myHref = "#find_"+myHref;
						}else if(lnk.hasClass('map_link')){
							myHref = "#maps_"+myHref;				
							} else {
								myHref = "#show_" + myHref;
							}
							lnk.click(function () { return ajax_link_clicked(lnk); });
						}
					}
				} else if (myHref.indexOf('http') == -1 || myHref.indexOf(currentUrl) == 0) {
					myHref = myHref.replace(currentUrl, '')
					if (lnk.hasClass('popup_link')) {
						myHref = "#popr_" + myHref;
					} else if (lnk.hasClass('product_link')) {
						myHref = "#prod_" + myHref;
					} else if (lnk.hasClass('promo_link')) {
						myHref = "#prom_" + myHref;
				}else if(lnk.hasClass('find_link')){
					myHref = "#find_"+myHref;
				}else if(lnk.hasClass('map_link')){
					myHref = "#maps_"+myHref;				
					} else {
						myHref = "#page_" + myHref;
					}
					lnk.click(function () { return ajax_link_clicked(lnk); });
				}
				$(lnk).attr('href', myHref);
			})
		});
	};
})(jQuery);

(function ($) {
	$.fn.fancyAccordion = function (opts) {
		var defaults = {
			section_selector: '.module_section',
			toggle_link_selector: '.section_toggle',
			close_link_selector: '.section_close',
			content_selector: '.section_content',
			nextToOpen: [],
			intervalID: null
		}
		var settings = $.extend(defaults, opts);
		return this.each(function () {
			var $accordion = $(this);
			if ($accordion.hasClass('fancy_accordion')) {
				if ($('.open:first input:visible', $accordion).length > 0) {
					$('.open:first input:visible', $accordion)[0].focus();
				}
				return;
			}
			function open_next() {
				if (settings.nextToOpen.length > 0) {
					settings.animating = true;
					centreMe();
					var openingLink = settings.nextToOpen;
					var $myAccordion = openingLink.parents('.fancy_accordion:first');
					settings.nextToOpen = [];
					if ($(settings.content_selector, $myAccordion).filter(function () { return $(this).is('.open') }).length == 0) {
						var $myContent = openingLink.parents(settings.section_selector + ':first').find(settings.content_selector);
						$myContent.slideDown("normal", function () {
							centreMain();
							$myContent.animate({ opacity: 1 }, "slow", null, function () {
								$('li', $myContent).css("position", "relative");
								$myContent.removeClass('closed').addClass('open').css({ opacity: '' });
								if ($('input:visible', $myContent).length > 0) {
									$('input:visible', $myContent)[0].focus();
								}
								settings.animating = false;
							});
						});
					}
				} else {
					settings.animating = false;
				}
			}
			function closeThis(toClose) {
				settings.animating = true;
				var closingDiv = $(toClose);
				$('li', closingDiv).css('position', 'static');
				closingDiv.animate({ opacity: 0 }, "slow", null, function () {
					closingDiv.slideUp("normal", open_next);
				});
				closingDiv.addClass('closed').removeClass('open');
				centreMe()
			}
			function centreMe() {
				if (settings.intervalID != null) {
					clearInterval(settings.intervalID)
					settings.intervalID = null;
				}
				centreMain();
				if (settings.animating == true) {
					settings.intervalID = setInterval(function () { centreMe(); }, 20)
				}
			}
			$accordion.addClass('fancy_accordion');
			$(settings.content_selector, $accordion).each(function () {
				var $content = $(this);
				if ($content.css('display') == 'none') {
					$content.addClass('closed');
					$('li', $content).css('position', 'static');
				} else {
					$content.addClass('open');
				}
			});
			$(settings.toggle_link_selector, $accordion).click(function () {
				var me = $(this)
				var $myAccordion = me.parents('.fancy_accordion:first');

				var $myContent = me.parents(settings.section_selector + ':first').find(settings.content_selector);
				if ($myContent.hasClass('closed')) {
					settings.nextToOpen = me;
				} else {
					settings.nextToOpen = [];
				}
				me.blur();
				if ($(settings.content_selector + '.open', $myAccordion).each(function () { closeThis(this); }).length == 0) {
					open_next();
				}
				return false;
			});
			$(settings.close_link_selector, $accordion).click(function () {
				var $myContent = $(this).parents(settings.section_selector + ':first').find(settings.content_selector);
				closeThis($myContent);
				$(this).blur();
				return false;
			});
			$('.open:first input:visible', $accordion)[0].focus();
		});
	};
})(jQuery);

/* tabulate */
(function ($) {
	$.fn.tabulate = function (opts) {
		var defaults = {
			cell_selector: '.Item'
		};
		var o = $.extend(defaults, opts);
		return this.each(function () {
			var selfref = $(this);
			var cells = $(o.cell_selector, selfref).css({ 'float': 'left', 'display': 'block' });
			var cols = Math.floor(selfref.innerWidth() / cells.outerWidth(true));
			if (cells.length > 0) {
				cells.each(function (i) {
					if (i % cols == cols - 1 || i == cells.length - 1) {
						$(this).after($('<div class="divider" style="clear:left"></div>'));
					}
				});
				var heights = [];
				function setHeights(e) {
					cells.each(function (i) {
						var myRow = Math.floor(i / cols);
						$(this).css("height", "auto");
						var myH = $(this).height();
						if (heights[myRow] == undefined || heights[myRow] == null || heights[myRow] < myH) {
							heights[myRow] = myH;
						}
					});
					cells.each(function (i) {
						var myRow = Math.floor(i / cols);
						$(this).css("height", heights[myRow] + "px");
					});
				}
				$('img', cells).bind('load', function (e) { setHeights(e); });
				setHeights();
			}
		});
	};
})(jQuery);


(function ($) {
	///<summary>
	/// Constructor for the display area that reveals product details in the listing view
	///</summary>
	$.ListingPreview = function(settings){
		if(this === window){return new $.listingPreview(settings);}
		this.preview_div=$('#'+settings.popupID+'_'+settings.previewID);
		this.popup_layer=$('#'+settings.popupID);
		// make an externally available reference to this object, so we can expose its public methods and attributes
		this.preview_div.data('ListingPreview',this);	
		//create a reference to this object for internal scoping
		var selfref=this;			
		// initialise status variables
		this.current_item=null; // reference to the item currently being displayed
		this.current_link=null; // the product link of the current item, we will be passing clicks onto this link
		this.next_item=null;    // reference to the next item to be displayed
		this.mouse_point=null;  // we need to store the mouse position when the opening is delayed
		this.is_open=false;     // whether the preview is visible (or in the process of appearing/disappearing)
		//
		this.offset_h=settings.offsetHorizontal;
		this.offset_v=settings.offsetVertical;			
		// reference parts of the display
		this.image_holder=$('.preview_image',this.preview_div);
		this.details_holder=$('.preview_details',this.preview_div);
		this.mask=$('.preview_mask',this.preview_div);
		this.current_link=$('.Image .product_link',this.current_item);
		// set up the display elements
		if(this.preview_div.length==0){
			if(this.popup_layer.length>0){
				// create a main holder div and add it to the popup layer
				this.preview_div=$('<div id="'+settings.popupID+'_'+settings.previewID+'" class="listing_preview" style="display:none"/>');
				this.popup_layer.append(this.preview_div);
				// create holders for the various parts of the product preview
				this.image_holder=$('<div class="preview_image" />');
				this.preview_div.append(this.image_holder);
				this.details_holder=$('<div class="preview_details" />');
				this.preview_div.append(this.details_holder);		
				this.mask=$('<div class="preview_mask" style="position:absolute;display:none"/>');
				this.preview_div.append(this.mask);				
			}else{
				return null;
			}			
		}
	
		// The first time the positioning happens it does not work properly for all browsers,
		// so we'll set a dummy position now
		// this way subsequent positioning will behave as expected
		this.preview_div.offset({left:0,top:0});
	}
	/** Declare public functions of the ListingPreview **/
	$.ListingPreview.prototype= {		
		///<summary>
		/// Sets the next product to be displayed, is called by mouseover event of listing item
		/// Note this does not always open the display, but puts it in a pending queue if the display is already showing another item
		///</summary>
		///<param name="product_listing">
		/// HTML element containing the next item to be displayed
		///</param>
		showItem:function(product_listing, evt){
			var me=this;
			me.next_item = product_listing;
			me.mouse_point={left:evt.pageX,top:evt.pageY};
			$(product_listing).bind('mousemove', function(ev){me.trackMouse(ev);})
			if(!me.is_open){
				me.openDisplay();
			}
		},
		
		///<summary>
		/// clears any queued items
		///</summary>
		clearItem:function(){
			var me=this;
			me.next_item=null;
		},
		
		///<summary>
		/// Displays the current item, sets the current contents and starts the opening animation
		///</summary>
		openDisplay:function(){
			var me=this;
			me.is_open=true;
			me.preview_div.css('display','');
			if(me.next_item!=me.current_item){
				me.current_item=me.next_item;
				me.next_item=null;
				me.current_link=$('.Image .product_link',me.current_item);
				var img_src=$('>img',me.current_link).attr('src').toLowerCase().replace('/thumb/','/preview/');				
				if(img_src.indexOf('/preview/')==-1){					
					img_src="/images/default_noimage_180x268.gif";					
				}
				me.image_holder.css('visibility','hidden');
				me.image_holder.bind('click',function(){me.current_link.trigger('click');});
				me.image_holder.append($('<img src="'+img_src+'" title="click for more details" />'));
				me.details_holder.css('visibility','hidden');
				me.details_holder.append($('.item_summary',me.current_item).clone(true));
				$('h2',me.details_holder).bind('click',function(){me.current_link.trigger('click');});
			}	
			$('.estar').css('z-index','0')	
			me.doReveal();	
		},
		///<summary>
		/// Runs the opening animation
		///</summary>
		doReveal:function(){
			var me=this;
			me.trackMouse();
			me.finishReveal();
			//var myHeight=me.preview_div.height();
			//me.mask.css({'display':'','height':'2px','top':((myHeight-4)/2)+'px'});
			//me.mask.animate({'height':(myHeight-2),'top':0},300,function(){me.finishReveal();});
		},
		///<summary>
		/// Finishes the reveal, called when the animation ends
		///</summary>
		finishReveal:function(){
			var me=this;
			me.preview_div.addClass('open');
			me.details_holder.css('visibility','')
			me.image_holder.css('visibility','');
			me.mask.css('display','none');
		},
		///<summary>
		/// Runs the close animation
		///</summary>
		closeDisplay:function(){
			var me=this;
			/*
			me.mask.stop(true,false);
			var myHeight=me.preview_div.height();
			if(me.mask.css('display')!='none'){
				me.mask.css({'display':'','height':(myHeight-2)+'px','top':'1px'});
			}
			*/
			if(me.current_item){
				$(me.current_item).unbind('mousemove')
			}
			me.preview_div.removeClass('open');
			me.details_holder.css('visibility','hidden')
			me.image_holder.css('visibility','hidden');
			//me.mask.animate({'height':2,'top':(myHeight/2)},150,function(){me.setAsClosed();});
			me.setAsClosed();
		},
		///<summary>
		/// Finishes the closing function and opens the queued item (if any)
		///</summary>
		setAsClosed:function(){
			var me=this;
			me.is_open=false;
			me.image_holder.contents().remove();
			me.details_holder.contents().remove();
			me.mask.css({'height':'','top':'','display':'none'})
			me.preview_div.css('display','none');
			me.current_item=null;
			if(me.next_item!=null){
				me.openDisplay();
			}
			$('.estar').css('z-index','');
		},		
		///<summary>
		///follows the movement of the mouse, maintaining an offset distance at all times
		///</summary>
		///<param name="evt">
		/// optional event object generated by the mousemove event
		/// if not present a stored mouse position us used
		///</param>
		trackMouse:function(evt){
			var me=this;			
			// extract the position from the event object passed in
			if(evt){
				me.mouse_point={left:evt.pageX,top:evt.pageY};
			}	
			if(me.is_open && me.mouse_point){				
				//for some reason we need to set the height of our div before we play with it, so measure its contents
				var myH=me.image_holder.outerHeight(true)+me.details_holder.outerHeight(true);
				//and set its height
				me.preview_div.css('height',myH+'px');
				//measure the popup width
				var myW=me.preview_div.width();		
				//we need to try and keep the  preview inside the visible window area, so first determine the mininmum and maximum coordinates		
				var bounding_box=$(window);//me.popup_layer;
				var minX=bounding_box.scrollLeft();//.offset().left;
				var maxX=minX+bounding_box.width()-myW;
				var minY=bounding_box.scrollTop();//.offset().top;
				var maxY=minY+bounding_box.height()-(myH+1);
				// make a new coordinates object that we will use to poisition the display, based on the mouse position
				var new_point={left:me.mouse_point.left,top:me.mouse_point.top};				 
				if((new_point.left + me.offset_h) >= maxX){
					new_point.left =  new_point.left-(me.offset_h + myW)
				}else{
					new_point.left += me.offset_h;
				}
				if((new_point.top + me.offset_v) >= maxY){
					new_point.top = new_point.top -(me.offset_v + myH)
				}else{
					new_point.top += me.offset_v;
				}	
				if(new_point.left<minX){
					new_point.left=minX;
				}	
				if(new_point.top<minY){
					new_point.top=minY;
				}
				me.preview_div.offset(new_point);
			}
		},
		toString:function(){return 'ListingPreview'}
	}
	
	///<summary>
	/// jQuery function called on listing items, sets up a ListingPreview object and sets the mouseover behaviours for the items
	///</summary>
	$.fn.listingPreviews = function(opts) {  
    var defaults = { 
			popupID:'page',
		 	previewID:'ListingPreview',
			offsetHorizontal:30,
			offsetVertical:30
    };   
    var o = $.extend(defaults, opts); 
		var preview= new $.ListingPreview({	popupID:o.popupID,	previewID:o.previewID, offsetHorizontal:o.offsetHorizontal, offsetVertical:o.offsetVertical }) 		
    return this.each(function() { 	
			var selfref=this;	
   		$(this).hover(function(evt){if($(selfref).closest('.on_top').length>0){preview.showItem(selfref,evt);}},function(evt){preview.clearItem();preview.closeDisplay();})
    });   
 };  	
})(jQuery);



(function($){  
	//define an object with public methods and variables for each thumbnail image
	$.mouseOverPreview = function (el, indx, settings) {
		if (this === window) { return new $.mouseOverPreview(el, indx, settings) }
		this.item = $(el);
		if (this.item.data('mouseOverPreview')) { return };
		this.item.data('mouseOverPreview', this);
		this.idx = indx;
		this.opts = settings;
		this.image = $('img', el);
		this.imgSrc = this.image.attr('src');
		if (!this.imgSrc || this.imgSrc.length == 0) {
			return;
		}
		this.imgSrc = this.imgSrc.toLowerCase().replace('/upsell/', '/preview/');
		this.imgTitle = this.image.attr('alt');
		this.preview = $('<div />');
		this.preview.addClass(this.opts.previewClass);
		this.item.append(this.preview);
		this.previewContent = $('<div class="content"/>').css('visibility', 'hidden');
		this.previewContent.append($('<img src="' + this.imgSrc + '" title="' + this.imgTitle + '" />'));
		this.previewMask = $('<div class="mask" style="height:2px;top:91px" />');
		this.preview.append(this.previewMask);
		this.preview.append(this.previewContent);
		this.preview.css('display', 'none');

	}
	$.mouseOverPreview.prototype = {
		openPreview: function () {
			var me = this;
			me.item.css('z-index', '1');
			me.preview.css('display', 'block');
			me.previewMask.animate({ 'height': me.preview.height(), 'top': 0 }, 300, function () { me.showContents() });
		},
		showContents: function () {
			var me = this;
			me.preview.addClass('open');
			me.previewContent.css({ 'visibility': 'visible', 'opacity': '0' });
			me.previewContent.stop(false, false).animate({ 'opacity': 1 }, 400);
		},
		closePreview: function () {
			var me = this;
			me.previewContent.css({ 'visibility': 'hidden', 'opacity': '' });
			me.preview.removeClass('open');
			me.previewMask.stop(true, true).animate({ 'height': 2, 'top': 90 }, 100, function () { me.finishClose() });
		},
		finishClose: function () {
			var me = this;
			me.previewContent.stop().css({ 'visibility': 'hidden', 'opacity': '' });
			me.previewMask.stop().css({ 'height': '2px', 'top': '90px' })
			me.preview.css('display', 'none').removeClass('open');
			me.item.css('z-index', '');
			if (typeof (me.opts.closedCallback) == 'function') {
				me.opts.closedCallback(me.idx);
			}
		}
	}
	//jquery function returns array of mouseOverPreview objects
	$.fn.mouseOverPreviews = function (opts) {
		var defaults = {
			previewClass: 'preview',
			closedCallback: function (idx) { }
		};
		var o = $.extend(defaults, opts);
		return this.each(function (idx) {
			new $.mouseOverPreview(this, idx, o)
		});
	};
})(jQuery);


function setMouseOverPreviews() {
	var pending = null;
	var active = null;
	var currentlyOver = null;
	function hasClosed(idx) {
		active = null;
		if (pending != null && pending == currentlyOver) {
			mousedOver(pending);
		}
	}
	function mousedOver(idx, delay) {
		// a delay is required to stop browser getting confused when mousing from one to another
		// without the delay the openPreview animation never completes
		if (delay) {
			setTimeout(function () { mousedOver(idx) }, 50);
			return;
		}
		currentlyOver = idx;
		if (active == null) {
			$(previews[idx]).data('mouseOverPreview').openPreview();
			active = idx;
		} else {
			pending = idx;
		}
		return false;
	}
	function mousedOut(idx) {
		currentlyOver = null;
		pending = null;
		$(previews[idx]).data('mouseOverPreview').closePreview();
	}
	var previews = $('.account_giftregistry .Image .product_image img').not('[src*=noimage]').parent().mouseOverPreviews({ closedCallback: hasClosed });
	previews.each(function (idx) { var myID = idx; $(this).hoverIntent(function () { mousedOver(myID, true) }, function () { mousedOut(myID) }) });
	return false;
}


var runAlready = false;
function showInitialContent() {
	if (!runAlready) {
		runAlready = true;
		var parts = window.location.href.split('#')
		var thisUrl = unescape(parts[0]);
		var localUrl = window.location.pathname + window.location.search;
		var showInitial = false;
		var s = $.deparam.fragment();
		if($('#initial_content .store_locator').length>0 && !s.page && (!s.stores || s.stores==thisUrl || s.stores==localUrl )){
			
			store_layer.dialog('loadContent','#initial_content');	
		}else if(!s.page || s.page==thisUrl || s.page==localUrl || s.page=='#message'){		
			modal_window.dialog('loadContent', '#initial_content');
		} else {
			$('#initial_content').remove();
			if (s.popup || s.overlay) {
				$.bbq.removeState(['popup', 'overlay'])
			} else {
				if (parts.length > 1 && parts[1] && parts[1].length > 1) {
					$(window).trigger('hashchange');
				}
			}
		}
		if ($('#ch_offers').length > 0) {
			overlay_layer.dialog('loadContent', '#ch_offers');
		}
	}
}

(function ($) {
	$.fn.pngFix = function (settings) {
		if ($.browser.msie && ($.browser.version < 7)) {
			return this.each(function () {
				$('img[src*=".png"]', this).not('.pngfixed').ifixpng();
			});
		}
	};
})($);

var modal_window = null;
var prod_layer = null;
var popup_layer = null;
var overlay_layer = null;
var promo_layer = null;
var find_layer=null;
var store_layer=null;

function slideInPromoImage() {
	if ($.browser.msie && $.browser.version < 7) {
		$('.homepage_promo_image').css({ left: '0px' });
	} else {
		var promoBg = $('<div style="background:#000000;position:absolute"/>')
		promoBg.css({ 'height': $('.homepage_promo_image').height() + 'px', 'width': $('.homepage_promo_image').width() + 'px' })
		var targX = $('.homepage_promo_image').width() * -1;
		$('.homepage_promo_image').css('width', promoBg.css('width')).prepend(promoBg);
		$('.homepage_promo_image a').css({ 'display': 'none', 'position': 'relative' });
		$('.homepage_promo_image').animate({ left: targX }, 1000, function () { $('.homepage_promo_image a').css({ 'display': '', 'opacity': 0 }).animate({ 'opacity': 1 }, 1000); });
	}
}

var lastScriptLoaded;
function loadInScript(scriptURL) {
	var holder = $('.script_additions');
	if (holder.length == 0) {
		holder = $('<div class="script_additions" style="visibility:hidden;height:0;width:0"	/>')
		$('body').append(holder);
	}
	if(scriptURL!=lastScriptLoaded)
	{	
		holder.empty();
		lastScriptLoaded = scriptURL;
		var s = document.createElement('script')
		s.src = scriptURL;
		holder[0].appendChild(s);
	}
}

var focussed_form = null;
if ($.browser.msie) {
	$(document).keypress(function (e) {
    if(e.keyCode == 13 && focussed_form!=null)  
    { 
			$(focussed_form).trigger('submit');
		}
	});
	$('input[type="password"], input[type="text"], select').live('focus', focus_form).live('blur', unfocus_form);
}
function focus_form() {
	if (this.id == 'searchterm') {
		focussed_form = [];
	} else {
		focussed_form = $(this).closest('form');
	}
	if (focussed_form.length == 0) {
		focussed_form = null;
	}
}
function unfocus_form() {
	focussed_form = null;
}

function openVerifyWindow() {
	var r = false;
	var pw = window.open('', 'verify', 'status=1,location=0,scrollbars=1,resizeable=yes,width=400,height=600');
	if (pw != null) {
		pw.focus();
	} else {
		r = true;
	}
	return r;
}

function correctNamespacedSelector(toTry) {
	// create an object to store results and avoid repeating the tests
	if (correctNamespacedSelector.results == undefined) {
		correctNamespacedSelector.results = {};
	}
	// do we already have a result for this string?
	if (correctNamespacedSelector.results[toTry]) {
		return correctNamespacedSelector.results[toTry];
	}
	// set up an xml node to test on
	var testNode = $('<test><' + toTry + ' /></test>');
	// create a variable to hold the selector being tested
	var testString = toTry;
	// we will need to split the selector on the colon
	var parts = toTry.split(':');
	// function to test a selector string to see if it finds the tag
	var doTest = function () {
		return ($(testString, testNode).length == 1);
	}
	// run the test on various permutations, successful selector will be in the testString variable, an empty string denotes a failed series of tests
	if (!doTest()) {
		testString = parts.join('\\:');
		if (!doTest()) {
			testString = '[nodeName="' + toTry + '"]';
			if (!doTest()) {
				if (parts.length > 1) {
					testString = parts[parts.length - 1];
					if (!doTest()) {
						testString = '[nodeName="' + testString + '"]';
						if (!doTest()) {
							testString = '';
						}
					}
				} else {
					testString = '';
				}
			}
		}
	}
	//store the correct selector in the results object and return it
	return correctNamespacedSelector.results[toTry] = testString;
}


(function ($) {
	$.fn.renderSocialMedia = function (opts) {
		// Facebook and twitter both add in iframes which call back to their servers to avoid having too many iframes open at once
		// this function will render, remove or re-render the iframes.  	
		return this.each(function () {
			var me = $(this);
			// not all browsers handle namespaced tags the same, some require different formats of selector
			var selector = correctNamespacedSelector('fb:like');
			var fblikes = [];
			if (selector.length > 0) {
				// we have found a jquery selector that the browser can use
				fblikes = $(selector, me);
			} else {
				// manually find the XFBML tags			
				$('.facebook *', me).each(function () {
					if ("like" == this.tagName.toLowerCase() || "fb:like" == this.tagName.toLowerCase()) {
						fblikes.push(this);
					}
				})
			}
			if (opts === false) {
				//remove twitter added iframes
				$('iframe.twitter-share-button', me).remove();
				//remove facebook added content and flag the tag as needing rerendering
				for (var i = 0; i < fblikes.length; i++) {
					fblikes[i].className = 'rerender';
					fblikes[i].innerHTML = '';
				}
			} else {
				// write in the twitter links
				if (window.location.protocol.indexOf('https') != 0) {
					if ($('.twitter-link', me).each(function () {
						var srclink = $(this);
						var newlink = srclink.clone();
						newlink.addClass('twitter-share-button');
						srclink.after(newlink);
					}).length > 0) {
						$.getScript('http://platform.twitter.com/widgets.js');
					}
				}
				if (fblikes.length > 0) {
					var rerender = false;
					for (var i = 0; i < fblikes.length; i++) {
						if (fblikes[i].className == 'rerender') {
							fblikes[i].className == '';
							var oldlike = $(fblikes[i]);
							var newlike = oldlike.clone();
							oldlike.after(newlike);
							oldlike.remove()
							rerender = true;
						}
					}
					if (window.FB) {
						fbRenderOnLoad = [];
						FB.XFBML.parse(this);
					} else {
						fbRenderOnLoad = (me);
					}
				}
			}
		});
	};
})(jQuery);

function addFBScript() {
	var fbr = document.getElementById('fb-root');
	if (fbr) {
		var e = document.createElement('script');
		e.async = true;
		e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
		fbr.appendChild(e);
	}
}
function addMapScript() {
	map_initialised = false;
	if (window.ESTAR) {
		try {
			delete window.ESTAR;
		} catch (err) {
			window.ESTAR = false;
		}
	}
	if ($('#mapscripts').length == 0) {
		$('body').append('<div id="mapscripts"></div>');
		// google maps api loads from different address when under ssl	
		var scriptSrc = 'http://maps.google.com/maps/api/js?sensor=false&callback=initialise_store_locator';
		if (document.location.protocol == 'https:') {
			scriptSrc = 'https://maps-api-ssl.google.com/maps/api/js?v=3&sensor=false&callback=initialise_store_locator';
		}
		var e = document.createElement('script');
		e.async = true;
		e.src = scriptSrc;
		document.getElementById('mapscripts').appendChild(e);
	} else {
		initialise_store_locator();
	}
}
/// Checks the page for stores with coordinates and creates data objects for each, creates a data object to represent locations
function get_stores_data() {
	// define a return object and create an empty array in it called 'stores'
	var r = {};
	r.stores = [];
	// iterate through each store element on the page that has a data-coordinates attribute
	$('.stores .store[data-coordinates]').each(function () {
		//create a jquery reference to the current store element
		var current_store = $(this);
		var coords = current_store.attr('data-coordinates').split(',');
		// do we have a pair of coordinetes
		if (coords.length == 2) {
			// create a new store object
			var store = {};
			//populate the store object with data from the cureent store element					
			store.id = current_store.attr('id');
			store.name = $('.store_name', current_store).text();
			store.point = { lon: coords[0], lat: coords[1], zoom: 15 };
			store.description = current_store.html();
			// we need to associate a store with a set of parent locations
			// create an empty array to store parent ids
			var parents = [];
			// find the first parent location, this will be a div class="area" that contains a link to the current_store 
			var parent_location = $('.area a[href$=#' + store.id + ']').closest('.area'); ;
			// iterate through the parents
			while (parent_location.length > 0) {
				// make a note of the id
				var id = parent_location.attr('id');
				// add the id to the start of the array
				parents.unshift(id);
				// finnd the next parent location, this will be a div class="area" that contains a link to the current area
				parent_location = $('.area a[href$=#' + id + ']').closest('.area');
			}
			if (parents.length > 0) {
				store.parents = parents;
			}
			// add the new store to the array
			r.stores.push(store);
		}
	});
	r.locations = get_locations_data();
	return r;
}
				
/// recursive function drills down into locations and maps them as a hierarchical set of arrays
function get_locations_data(location_element) {
	var r = [];
	var locations;
	if (!location_element) {
		locations = $('.areas > .area');
	} else {
		locations = $('> ul > li > .area', location_element);
	}
	locations.each(function () {
		var location_object = {};
		location_object.id = $(this).attr('id');
		location_object.name = $('.area a[href$=#' + location_object.id + '], .country a[href$=#' + location_object.id + ']').text();
		var child_locations = get_locations_data(this);
		if (child_locations.length > 0) {
			location_object.locations = child_locations;
		}
		r.push(location_object);
	});
	return r;
}
					// function is passed into the map object and is called when a store receives focus
function map_show_store(id) {
	//hide all store dtails
	$('.stores>.store').css('display', 'none');
	//reveal the selected one
	$('#' + id).css('display', '');
	var storeLink = $('.area a[href$=#' + id + ']');
	$('.areas a').removeClass('active');

	if (storeLink.parent().is('li.store_link')) {
		//set the state for parent links	
		show_parent_areas(storeLink.parent());
		storeLink.parent().addClass('on').removeClass('off');
		storeLink.addClass('active');
	}
	//clear any directions
	$('#directions_display').html('');
	// show store column contents
	$('.map_directions, .print_button').css('display', '');
	$(document).trigger('emchange');
}				
// function is passed into the map object and is called when a location recieves focus
function map_show_area(id) {
	$('.areas a').removeClass('active');
	var current_area = $('#' + id);
	// close all lists
	$('li.location').each(function () { set_location_off($(this)) })
	$('a[href$="#' + id + '"]').addClass('active')

	show_parent_areas(current_area);
	//clear any store details that are showing
	$('.stores>.store').css('display', 'none');
	$('#directions_display').html('');
	// hide store column contents
	$('.map_directions, .print_button').css('display', 'none');
	$(document).trigger('emchange');

}
					/*
					
					*/
					// works up the hierarchical lists adding the class opening up the lis on he way up
function show_parent_areas(current_area) {
	// get the next location li up the tree
	var next_area = current_area.closest('li.store_link, li.location');
	// clear the on class for the store links 						
	$('li.store_link').removeClass('on').addClass('off');
	$('li.store_link a').removeClass('active');
	// set the open status
	set_location_on(next_area);
	// carry on up the tree
	if (next_area.parent().closest('li.location').length > 0) {
		show_parent_areas(next_area.parent());
	} else {
		// we have reached the top level, so set the containing area div to .on'
		current_area.closest('div.area').addClass('on').removeClass('off').siblings().addClass('off').removeClass('on');
		var country_div = next_area.closest('div.area').addClass('on').removeClass('off');

		if (country_div.length > 0) {
			country_div.siblings().addClass('off').removeClass('on');
		} else {
			country_div = current_area;
		}
		var id = country_div.attr('id');
		if (id) {
			if (id.length > 0) {
				$('.country a').removeClass('active');
				var cl = $('.country a[href$="#' + id + '"]').addClass('active');
				cl.parent().addClass('on').removeClass('off').siblings().addClass('off').removeClass('on');
				var countryname = cl.text();
				if (countryname.length > 0) {
					try {
						var fmap = document.getElementById('store_locator_flash_map');
						if (fmap) {
							fmap.showCountry(countryname);
						}
					} catch (err) { }
				}
			}
		}
	}
}
					// sets the status of a li to indicate that it should be open
function set_location_on($li) {
	$li.addClass('on').removeClass('off');
	$('> .indicator', $li).html('-');
}
					// sets the status of a li to indicate that it should be closed
function set_location_off($li) {
	$li.addClass('off').removeClass('on');
	$('> .indicator', $li).html('+');
}

function show_hide_map() {
	var show_text = 'Show Map';
	var hide_text = 'Close Map';
	var lnk = $('#toggle_map_link');
	if (lnk.attr('title') == show_text) {
		$('.google_map_bg').css({ 'left': '172px', "height": "10px", 'top': '170px' }).animate({ "top": "0px", "height": "341px" }, function () { $('.store_locator .google_map_holder').css('left', '196px'); });
		lnk.attr('title', hide_text).html('<img src="/images/b_close_map.gif" alt="Close Map" />');

	} else {

		$('.store_locator .google_map_holder').css('left', '-9000px');
		$('.google_map_bg').css({ "height": "341px", 'top': '0px' }).animate({ "top": "170px", "height": "10px" }, function () { $('.google_map_bg').css('left', '-9999px') });
		lnk.attr('title', show_text).html('<img src="/images/b_show_map.gif" alt="Show Map" />');
	}
}
					
				
		  		// function is passed into the map object and is called when a directions are returned
function map_show_directons(directions_obj) {
	$('#directions_display').empty().append($(estar_google_map.directions_list()))
	$(document).trigger('emchange');
}
					
// initialise the map object
var estar_google_map;
				
				// called when the flash movie initialises, we need to set it's country to match that of the map object
				// if not it will be set when the initial location is set in the map
function setFlashCountry() {
	var countryname = $('.country .on>a').text();
	if (countryname && countryname.length > 0) {
		var fmap = document.getElementById('store_locator_flash_map');
		if (fmap) {
			fmap.showCountry(countryname);
		}
	}
}
			
				
var map_initialised=false;
function initialise_store_locator() {
	//console.log('initialise_store_locator')
	if (map_initialised || !(window.google && window.google.maps)) {
		return;
	}

	if (!window.ESTAR) {
		$('.loading_screen .loading_message').html('Synchronising store data')
		$.getScript('/assets/estar_map.js', initialise_store_locator);
		return;
	}
	$('.loading_screen').remove()
	//console.log('    OK lets do it')
	map_initialised = true;
	estar_google_map = new ESTAR.store_map({
		map_height: 304,
		map_width: 505,
		popup_width: 650,
		popup_height: 630,
		//marker_image:'http://cr/images/google_map_marker.png',
		display_store: map_show_store,
		display_area: map_show_area,
		display_directions: map_show_directons,
		onsite_version: true,
		show_unselected_markers: false,
		filter_markers_by_location: true,
		show_marker_data: true
	});

	$('.store_locator .store_link a').bind('click', function (evt) { evt.preventDefault(); var hr = this.href.split('#'); if (hr.length > 1) { estar_google_map.show_store(hr[1]); } });
	// add the +- symbols to the start of the lis in the store navigation	and set their status to off (closed)
	$('.store_locator .areas li.location').addClass('off').prepend($('<span class="indicator">+</span>'));
	$('.store_locator .location_detail').addClass('off');
	// hide store details
	$('.store_locator .stores>.store').css('display', 'none');
	//move the lodirectins finder out of its parent div				
	$('.store_locator .map_directions').each(function () { $('.store_locator .stores').append($(this)) });
	$('.store_locator .google_map_container').each(function () { $('.store_locator .locator').prepend($(this)) });
	// add a show/hide map button and hide the map.					
	$('.store_locator .print_button').each(function () { $('.stores .store:last').after($(this)) });
	$('.store_locator .print_button').prepend($('<a href="#" id="toggle_map_link" title="Close Map" onclick="show_hide_map(); return false;"><img src="/images/b_close_map.gif" alt="Close Map"/></a>'));
	$('.store_locator .print_button a, .store_locator .close_map a').bind('click',function(evt){evt.preventDefault();});
	$('.store_locator .directions_form a').each(function () { this.title = 'Directions' }).bind('click',function(evt){evt.preventDefault();});
	var initialID = $('.store_locator .stores .store.on').attr('id');
	if (initialID && initialID.length > 0) {
		estar_google_map.show_store(initialID);
	} else {
		initialID = $('.store_locator .country li.on a').attr('href');
		if (initialID && initialID.length > 1) {
			estar_google_map.show_location(initialID.split('#')[1])
		}
	}
	//estar_google_map.show_location('location_1');
	estar_google_map.set_data(get_stores_data());
	swfobject.embedSWF("/assets/maps.swf", "flash_map", "261", "313", "9.0.0", false, { country: 'New Zealand' }, { wmode: "transparent", allowScriptAccess: "always" }, { id: 'store_locator_flash_map' });
	show_hide_map();
	// Bind the location and store links to the map
	$('.store_locator .areas .location>a, .store_locator .country li a, #flash_map area').bind('click',
						function (evt) {
							evt.preventDefault();
							var hr = this.href.split('#');
							if (hr.length > 1) {
								if ($(this).parent().is('li.location.on')) {
									var loc = $(this).closest('div[id^="location_"]');
									if (loc.length > 0) {
										estar_google_map.show_location(loc.attr('id'));
									}
								}
								else { estar_google_map.show_location(hr[1]); }
							}
						});
}


	
function findInstoreResize(popup,type){
	// change the class of the container to suit the type
	if(!type){
		type='storefinder_form';
	}
	var resultClasses='from_product from_cart cart_confirmation';
	var par = popup.parent().removeClass('storefinder_form storefinder_result in_cart '+resultClasses);	
	par.addClass(type);	
	if(resultClasses.indexOf(type)>-1){
		par.addClass('storefinder_result');	
	}
	if($('#page .cart_content').length>0){
		par.addClass('in_cart');	
	}
	var bg=$('.bg',popup)
	var targW=418;
	var targH=247;
	var targM=-305;
	var targT=-1;
	var bgW=bg.width();
	var bgH=bg.height();
	// type values
	// 'storefinder_form' = default, this is the initial search form
	// 'from_product' = Result set from a search on a product
	// 'from_cart' = Result set from a cart search
	// 'cart_confirm' = confirmation window when posting back to cart
	
	switch(type){
		case 'from_product':
			targW=486;
			targM-=34;
			targH=341;
		break;
		case 'from_cart':
			targW=509;
			targM-=44;
			targH=500;
			targT=$(window).height()/2-259;
			if(targT<0){targT=0;}
		break;
		case 'cart_confirmation':
			targW=486;
			targM-=34;
			targH=130;
			targT=$(window).height()/2-109;
			if(targT<0){targT=0;}
		break;
		default:			
		break;
	}
	if(targW != bgW || targH != bgH){
		bg.animate({'width':targW,'height':targH})
		if(targT<0){
			popup.parent().animate({'margin-left':targM});
		}else{
			popup.parent().animate({'margin-left':targM,'top':targT});
		}
	}
}
	
function toggle_store_availability(clicked){
	var lnk=$(clicked);
	var closeMe=lnk.hasClass('less');
	$('.basic .view_more a').removeClass('less');
	var store_tr=lnk.closest('tr');
	var store_id=store_tr.attr('data-storeid');
	$('.detailed .breakdown:visible').hide(400,function(){$(document).trigger('emchange')});
	if(!closeMe){
		lnk.addClass('less');
		$('.detailed[data-storeid="'+store_id+'"] .breakdown').show(400,function(){$(document).trigger('emchange')});		
	}
	return false;
}

function toggle_store_confirmation(clicked){
	var frm=document.getElementById('hidden_store_form');	
	var r=false;
	if(frm){
		var fields=frm.elements;	
		var clk=$(clicked);
		var row=clk.closest('tr.basic');
		if(row.length>0){
			$('input',row).each(
				function(){ 
					var n=this.name;
					var found=false;
					for(var i=0; i < fields.length && !found; i++){
						if(fields[i].name==n){
							fields[i].value=this.value;
							found=true;
						}
					}
					if(!found){
						var inp = document.createElement('input');
						inp.type='hidden'; 
						inp.name=n; 
						inp.value=this.value;
						frm.appendChild(inp);
					}
				});
			if($('.availability .full',row).length>0){
				frm.submit();
				r=true;
			}else{
				findInstoreResize($('#find'),'cart_confirmation');
			}
		}else{
		//	$('#find .chosen').removeClass('chosen');
				findInstoreResize($('#find'),'from_cart');
		}
	}
	return r;
}

(function ($) {
	$.fn.applyToolTip=function(opts){
		var defaults = {
			tipText: 'This shows the quantity available versus the quantity requested',
			vPosition: 'below',
			hAlign: 'right'		
		};	
		var o = $.extend(defaults, opts);
		return this.each(function () {
			var selfref = $(this);
			if(!selfref.hasClass('.tip_added')){
				selfref.addClass('.tip_added');
				var c=selfref.html();
				selfref.empty();
				var t=$('<span class="added_tooltip">'+o.tipText+'</span>');
				selfref.append(t);
				t.tooltip($.extend(o,{linkText:c}))
			}
		})
	}
})(jQuery);
/* tooltip */

(function ($) {
	$.fn.tooltip = function (opts) {
		var defaults = {
			linkText: 'Need Help?',
			popupClass: 'tooltip_message',
			vPosition: 'above',
			hAlign: 'center'
		};
		

		var o = $.extend(defaults, opts);
		return this.each(function () {
			var selfref = $(this);
			var tip = [];
			if (selfref.data('tooltip')) {
				return;
			}
			function showTip() {
				if (tip.length == 0) {
					tip = $('<div style="position:absolute;display:none;" class="' + o.popupClass + '"><div class="message_wrapper"><div class="message_body"></div></div></div>');
					$('.message_body', tip).html(selfref.data('tooltip'));
					selfref.append(tip);
				}
				tip.css('display', 'block');
				positionTip();
			}
			function positionTip() {
				var new_x = 0;
				var new_y = 0;
				switch (o.vPosition) {
					case "above":
						new_y = tip.outerHeight(true) * -1
						break;
					case "below":
						new_y = selfref.outerHeight(true);
						break;
					case "middle":
						new_y = ((tip.outerHeight(true) * -1) + selfref.outerHeight(true)) / 2;
						break;
					default:
						break;
				}
				switch (o.hAlign) {
					case "left":
						new_x = 0;
						break;
					case "right":
						new_x = (tip.outerWidth(true) * -1) + selfref.outerWidth(true);
						break;
					case "center":
						new_x = ((tip.outerWidth(true) * -1) + selfref.outerWidth(true)) / 2;
						break;
					default:
						break;
				}
				tip.css({ 'top': new_y + 'px', 'left': new_x + 'px' });
			}
			function hideTip() {
				tip.css('display', 'none');
			}
			selfref.data('tooltip', selfref.html());
			selfref.empty();
			if (selfref.css('position') == 'static') { selfref.css('position', 'relative') }
			
			selfref.html(o.linkText);
			selfref.hover(showTip, hideTip)
		});
	};
})(jQuery);

title_default = "Country Road - Shop";

$(document).ready(function (e) {
	if ($.browser.msie) {
		$('body').addClass('ie_version_'+parseInt($.browser.version));
		
		$('input[type=password]').each(function () {
			if (this.value && this.value.length > 0) {
				var v = this.value;
				$(this).data('initialvalue', v);
			}
		})
		if($.browser.version<9){
			$('.in_store a.option_deliver[onclick]').removeClass('no_ajax').each(function(){var hr=this.href; this.href="#"; this.onclick="if(chkPromotions()){window.location.href='"+hr+"';}"})
		if ($.browser.version < 7) {
			$('img.country_indicator').wrap('<span class="country_indicator"></span>');
		}
	}
	}
	$(window).bind('resize', centreMain);
	setScrollingBG();
	$('.main').ajaxifyLinks().pngFix();
	modal_window = makePopup('page', 1);
	prod_layer = makePopup('product', 2);
	popup_layer = makePopup('popup', 3);
	overlay_layer = makePopup('overlay', 4);
  store_layer=makePopup("stores",7);
	showInitialContent();
	centreMain();
	$('.main').css('visibility', 'visible')
	var promoImg = $('.homepage_promo_image img');
	if (promoImg.length > 0) {
		if (promoImg[0].complete) {
			slideInPromoImage();
		} else {
			promoImg.bind('load', function () { slideInPromoImage() })
		}
	}
	addFBScript();

}).bind('unload', function () { $('*').unbind(); });

	

