var tb_show = false;
var tb_remove = false;
(function(f) {
    f.browser.msie6 = f.browser.msie && /MSIE 6\.0/i.test(window.navigator.userAgent) && !/MSIE 7\.0/i.test(window.navigator.userAgent);
    f(document).ready(function() {
    g("a.shopp-thickbox, area.shopp-thickbox, input.shopp-thickbox");
    imgLoader = new Image(); 
    imgLoader.src = tb_pathToImage
});
function g(h) {
    f(h).click(function() {
        var j = this.title || this.name || null;
        var i = this.href || this.alt; var k = this.rel || false;
        tb_show(j, i, k, true);
        this.blur();
        return false
    })
}
tb_show = function(q, i, n, p) {
    try {
        if (typeof document.body.style.maxHeight === "undefined") {
            f("body", "html").css({ height: "100%", width: "100%" });
            f("html").css("overflow", "hidden");
            if (document.getElementById("TB_HideSelect") === null) {
                f("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");
                f("#TB_overlay").click(tb_remove)
            }
        } else {
            if (document.getElementById("TB_overlay") === null) {
                f("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
                f("#TB_overlay").click(tb_remove)
            }
        }
        if (p) {
            f("#TB_overlay").hide()
        }
        if (a()) {
            f("#TB_overlay").addClass("TB_overlayMacFFBGHack")
        } else {
            f("#TB_overlay").addClass("TB_overlayBG")
        }
        if (p) {
            f("#TB_overlay").fadeIn(500)
        }
        if (q === null) { q = "" }
        f("body").append("<div id='TB_load'><img src='" + imgLoader.src + "' /></div>");
        f("#TB_load").show();
        var j;
        if (i.indexOf("?") !== -1) {
            j = i.substr(0, i.indexOf("?"))
        } else { j = i }
        var l = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/;
        var r = j.toLowerCase().match(l);
        if (i.indexOf("?shopp_image=") != -1 || r == ".jpg" || r == ".jpeg" || r == ".png" || r == ".gif" || r == ".bmp") {
            TB_PrevCaption = "";
            TB_PrevURL = "";
            TB_PrevHTML = "";
            TB_NextCaption = "";
            TB_NextURL = "";
            TB_NextHTML = "";
            TB_imageCount = "";
            TB_FoundURL = false;
            if (n) {
                TB_TempArray = f("a[rel=" + n + "]").get();
                for (TB_Counter = 0; ((TB_Counter < TB_TempArray.length) && (TB_NextHTML === "")); TB_Counter++) {
                    var m = TB_TempArray[TB_Counter].href.toLowerCase().match(l);
                    if (!(TB_TempArray[TB_Counter].href == i)) {
                        if (TB_FoundURL) {
                            TB_NextCaption = TB_TempArray[TB_Counter].title;
                            TB_NextURL = TB_TempArray[TB_Counter].href;
                            TB_NextHTML = "<span id='TB_next'>&nbsp;&nbsp;<a href='#'>" + SHOPP_TB_NEXT + " &gt;</a></span>"
                        } else {
                            TB_PrevCaption = TB_TempArray[TB_Counter].title;
                            TB_PrevURL = TB_TempArray[TB_Counter].href;
                            TB_PrevHTML = "<span id='TB_prev'>&nbsp;&nbsp;<a href='#'>&lt; " + SHOPP_TB_BACK + "</a></span>"
                        }
                    } else {
                        TB_FoundURL = true;
                        TB_imageCount = SHOPP_TB_IMAGE.replace(/%d/, (TB_Counter + 1)).replace(/%d/, (TB_TempArray.length))
                    }
                }
            }
            imgPreloader = new Image();
            imgPreloader.onload = function() {
                imgPreloader.onload = null;
                var v = b();
                var t = v[0] - 150;
                var A = v[1] - 150;
                var u = imgPreloader.width;
                var s = imgPreloader.height;
                if (u > t) {
                    s = s * (t / u);
                    u = t;
                    if (s > A) {
                        u = u * (A / s);
                        s = A
                    }
                } else {
                    if (s > A) {
                        u = u * (A / s);
                        s = A; 
                        if (u > t) { 
													s = s * (t / u); 
													u = t 
												} 
										} 
								} 
								TB_WIDTH = u + 30; 
								TB_HEIGHT = s + 60; 
								f("#TB_window").append("<a href='' id='TB_ImageOff' title='Close'><img id='TB_Image' src='" + i + "' width='" + u + "' height='" + s + "' alt='" + q + "'/></a><div id='TB_caption'>" + q + "<div id='TB_secondLine'>" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "</div></div><div id='TB_closeWindow'>" + SHOPP_TB_CLOSE + " <a href='#' id='TB_closeWindowButton' title='Close'>X</a></div>"); 
								f("#TB_closeWindowButton").click(tb_remove); 
								if (!(TB_PrevHTML === "")) { 
									function z() {
										if (f(document).unbind("click", z)) { 
											f(document).unbind("click", z) 
										} 
										f("#TB_window").remove(); 
										f("body").append("<div id='TB_window'></div>"); 
										tb_show(TB_PrevCaption, TB_PrevURL, n); 
										return false 
									} 
									f("#TB_prev").click(z) 
								} 
								if (!(TB_NextHTML === "")) { 
									function w() { 
										f("#TB_window").remove(); 
										f("body").append("<div id='TB_window'></div>"); 
										tb_show(TB_NextCaption, TB_NextURL, n); 
										return false 
									} 
									f("#TB_next").click(w) 
								} 
								document.onkeydown = function(x) { 
									if (x == null) { 
										keycode = event.keyCode 
									} else { 
										keycode = x.which 
									} 
									if (keycode == 27) { 
										tb_remove() 
									} else { 
										if (keycode == 190) { 
											if (!(TB_NextHTML == "")) { 
												document.onkeydown = ""; w() 
											} 
										} else { 
											if (keycode == 188) { 
												if (!(TB_PrevHTML == "")) { 
													document.onkeydown = ""; 
													z() 
												} 
											} 
										} 
									} 
								}; 
								c(); 
								f("#TB_load").remove(); 
								f("#TB_ImageOff").click(tb_remove); 
								f("#TB_window").css({ display: "block" }) }; 
								imgPreloader.src = i 
							} else { 
								var h = i.replace(/^[^\?]+\??/, ""); 
								var k = e(h); 
								TB_WIDTH = (k.width * 1) + 30 || 630; 
								TB_HEIGHT = (k.height * 1) + 40 || 440; 
								ajaxContentW = TB_WIDTH - 30; 
								ajaxContentH = TB_HEIGHT - 45; 
								if (i.indexOf("TB_iframe") != -1) { 
									urlNoQuery = i.split("TB_"); 
									f("#TB_iframeContent").remove(); 
									if (k.modal != "true") { 
										f("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>" + q + "</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' title='Close'>close</a> or Esc Key</div></div><iframe frameborder='0' hspace='0' src='" + urlNoQuery[0] + "' id='TB_iframeContent' name='TB_iframeContent" + Math.round(Math.random() * 1000) + "' onload='tb_showIframe()' style='width:" + (ajaxContentW + 29) + "px;height:" + (ajaxContentH + 17) + "px;' > </iframe>") 
									} else { 
										f("#TB_overlay").unbind(); f("#TB_window").append("<iframe frameborder='0' hspace='0' src='" + urlNoQuery[0] + "' id='TB_iframeContent' name='TB_iframeContent" + Math.round(Math.random() * 1000) + "' onload='tb_showIframe()' style='width:" + (ajaxContentW + 29) + "px;height:" + (ajaxContentH + 17) + "px;'> </iframe>") 
									} 
								} else { 
									if (f("#TB_window").css("display") != "block") { 
										if (k.modal != "true") { 
											f("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>" + q + "</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton'>close</a> or Esc Key</div></div><div id='TB_ajaxContent' style='width:" + ajaxContentW + "px;height:" + ajaxContentH + "px'></div>") 
										} else { 
											f("#TB_overlay").unbind(); 
											f("#TB_window").append("<div id='TB_ajaxContent' class='TB_modal' style='width:" + ajaxContentW + "px;height:" + ajaxContentH + "px;'></div>") 
										} 
									} else { 
										f("#TB_ajaxContent")[0].style.width = ajaxContentW + "px"; 
										f("#TB_ajaxContent")[0].style.height = ajaxContentH + "px"; 
										f("#TB_ajaxContent")[0].scrollTop = 0; 
										f("#TB_ajaxWindowTitle").html(q) 
									} 
								} 
								f("#TB_closeWindowButton").click(tb_remove); 
								if (i.indexOf("TB_inline") != -1) { 
									f("#TB_ajaxContent").append(f("#" + k.inlineId).children()); 
									f("#TB_window").unload(function() { f("#" + k.inlineId).append(f("#TB_ajaxContent").children()) }); 
									c(); 
									f("#TB_load").remove(); 
									f("#TB_window").css({ display: "block" }) 
								} else { 
									if (i.indexOf("TB_iframe") != -1) { 
										c(); 
										if (f.browser.safari) { 
											f("#TB_load").remove(); 
											f("#TB_window").css({ display: "block" }) 
										} 
									} else { 
										f("#TB_ajaxContent").load(i += "&random=" + (new Date().getTime()), function() { c(); f("#TB_load").remove(); g("#TB_ajaxContent a.shopp-thickbox"); f("#TB_window").css({ display: "block" }) }) 
									} 
								} 
							} 
							if (!k.modal) { 
								document.onkeyup = function(s) { 
									if (s == null) { 
										keycode = event.keyCode 
									} else { 
										keycode = s.which 
									} 
									if (keycode == 27) { 
										tb_remove() 
									} 
								} 
							} 
						} catch (o) { } 
					}; 
					function d() { 
						f("#TB_load").remove(); 
						f("#TB_window").css({ display: "block" }) 
					} 
					tb_remove = function() { 
						f("#TB_imageOff").unbind("click"); 
						f("#TB_closeWindowButton").unbind("click"); 
						f("#TB_window").fadeOut("fast", function() { f("#TB_window,#TB_overlay,#TB_HideSelect").trigger("unload").unbind().remove() }); 
						f("#TB_load").remove(); 
						if (typeof document.body.style.maxHeight == "undefined") { 
							f("body", "html").css({ height: "auto", width: "auto" }); 
							f("html").css("overflow", "") 
						} 
						document.onkeydown = ""; 
						document.onkeyup = ""; 
						return false 
					}; 
					function c() { 
						f("#TB_window").css({ marginLeft: "-" + parseInt((TB_WIDTH / 2), 10) + "px", width: TB_WIDTH + "px" }); 
						if (!(jQuery.browser.msie6)) { 
							f("#TB_window").css({ marginTop: "-" + parseInt((TB_HEIGHT / 2), 10) + "px" }) 
						} 
					} 
					function e(l) { 
						var m = {}; 
						if (!l) { return m } 
						var h = l.split(/[;&]/); 
						for (var k = 0; k < h.length; k++) { 
							var o = h[k].split("="); 
							if (!o || o.length != 2) { continue } 
							var j = unescape(o[0]); 
							var n = unescape(o[1]); 
							n = n.replace(/\+/g, " "); 
							m[j] = n 
						} 
						return m 
					} 
					function b() { 
						var k = document.documentElement; 
						var i = window.innerWidth || self.innerWidth || (k && k.clientWidth) || document.body.clientWidth; 
						var j = window.innerHeight || self.innerHeight || (k && k.clientHeight) || document.body.clientHeight; 
						arrayPageSize = [i, j]; 
						return arrayPageSize 
					} 
					function a() { 
						var h = navigator.userAgent.toLowerCase(); 
						if (h.indexOf("mac") != -1 && h.indexOf("firefox") != -1) { return true } 
					} 
				})(jQuery);