﻿var browserType, operatingSystem

var $ = function(id) {
    return document.getElementById(id);
}

var css_browser_selector = function() {
    var 
		    ua = navigator.userAgent.toLowerCase(),
		    is = function(t) { return ua.indexOf(t) != -1; },
		    h = document.getElementsByTagName('html')[0],
		    b = (!(/opera|webtv/i.test(ua)) && /msie (\d)/.test(ua)) ? ((is('mac') ? 'ieMac ' : '') + 'ie ie' + RegExp.$1)
			    : is('gecko/') ? 'gecko' : is('opera') ? 'opera' : is('konqueror') ? 'konqueror' : is('applewebkit/') ? 'webkit safari' : is('mozilla/') ? 'gecko' : '',
		    os = (is('x11') || is('linux')) ? ' linux' : is('mac') ? ' mac' : is('win') ? ' win' : '';
    browserType = b;
    operatingSystem = os;
    var c = b + os + ' js';
    h.className += h.className ? ' ' + c : c;
} ();

var ajax = new function() {
    var container = null;
    var data = null;
    var _callback = null;

    function checkReadyState(xmlhttp) {
        if (xmlhttp.readyState == 4) {
            if (xmlhttp.status == 200) {
                return true;
            } else {
                var href = window.location.toString();

                if (href.indexOf("search.store.yahoo.com") != -1) {
                    data = "The full menu is not available during search. Sorry for the inconvience.";
                } else {
                    data = "Problem retrieving menu data. Please contact customer service at 800-385-6897.";
                    alert(data);
                }
            }
        }
    }

    function onResponse() {
        if (checkReadyState(xmlhttp)) {
            if (xmlhttp.responseXML == null || xmlhttp.responseXML.documentElement == null) {
                data = xmlhttp.responseText;
                container.innerHTML = data;
                if (_callback != null) _callback();
                return true;
            }
        }
    }

    this.callback = null;

    this.fetchData = function(url, containerId) {
        _callback = this.callback;
        container = $(containerId);

        xmlhttp = null
        // code for Mozilla, etc.
        if (window.XMLHttpRequest)
            xmlhttp = new XMLHttpRequest()
        // code for IE
        else if (window.ActiveXObject)
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
        if (xmlhttp != null) {
            xmlhttp.onreadystatechange = onResponse;
            xmlhttp.open("GET", url, true);
            xmlhttp.send(null);
        } else {
            data = "Your browser does not support XMLHTTP.";
            alert(data);
        }
    }

    this.getData = function() {
        return data;
    }
}

var menu = new function() {
    this.show = function(number) {
        var menuId = 'menu-' + number;
        if ($(menuId).innerHTML == '') {
            ajax.fetchData('' + menuId + '.html', menuId);
        }
        $(menuId).style.display = "block";
    }

    this.hide = function(number) {
        var menuId = 'menu-' + number;
        $(menuId).style.display = "none";
    }
}
/*No flicker on background images for IE*/
try {
    document.execCommand("BackgroundImageCache", false, true);
} catch (err) { }

var getElement = function(id) {
    return $(id);
}

/* Start ProtoTypes */
String.prototype.toProperCase = function() {
    return this.toLowerCase().replace(/^(.)|\s(.)/g, function($1) { return $1.toUpperCase(); });
}
// Replaces all instances of the given substring.
String.prototype.replaceAll = function(strTarget, strSubString) {
    var strText = this;
    var intIndexOfMatch = strText.indexOf(strTarget);

    while (intIndexOfMatch != -1) {
        strText = strText.replace(strTarget, strSubString)
        intIndexOfMatch = strText.indexOf(strTarget);
    }
    return (strText);
}

/*End ProtoTypes */

var common = new objCommon();
var dialog = new objDialog();

function objCommon() {
    this.addEvent = _addEvent;
    this.onLoad = _onLoad;
    this.openWindow = _openWindow;
    this.iif = _iif;
    this.trim = _trim;
    this.imageSwap = _imageSwap;
    this.getNumberSuffix = _getNumberSuffix;
    this.formatDate = _formatDate;
    this.dateAdd = _dateAdd;
    this.getViewportWidth = _getViewportWidth;
    this.getViewportHeight = _getViewportHeight;
    this.getScrollTop = _getScrollTop;
    this.getScrollLeft = _getScrollLeft;
    this.alertOkCancel = _alertOkCancel;
    this.searchEngineRedirect = _searchEngineRedirect;
    this.loadScript = _loadScript;
    this.trackit = _trackit;

    function _trackit(pageid) {
        var trid = cookies.read("trid");
        if (trid == window.undefined) {
            var d = new Date();
            trid = d.getTime();
            cookies.write("trid", trid, 9999);
        }

        if (href.indexOf("photoframesplus.com") != -1) {
            var trackit = new Image(1, 1);
            trackit.src = "http://smithfamilystores.com/photoframesplus/trackit.aspx?pageid=" + pageid + "&userid=" + trid;
        }
    }

    function _loadScript(scriptUrl, scriptName) {
        if (browserType == "gecko") { document.write("<script type='text/javascript' src='" + scriptUrl + "'></script>") }
        else {
            var head = document.getElementsByTagName("head")[0];
            var script = document.createElement("script");

            script.id = scriptName;
            script.type = "text/javascript";
            script.src = scriptUrl;

            head.appendChild(script);
        }
    }

    function _searchEngineRedirect() {
        var query
        query = cookies.read("utmctr");
        if (query != "") {
            window.location.href = "http://search.store.yahoo.com/cgi-bin/nsearch?follow-pro=2&vwcatalog=photoframesplus&catalog=photoframesplus&query=" + query;
        }
    }

    function _alertOkCancel(msg) {
        var answer = confirm(msg)
        if (answer) return true;
        else return false;
    }

    this.getPage = function() {
        var url = window.location.pathname;
        return url.substring(url.lastIndexOf('/') + 1);
    }

    function _addEvent(obj, evType, fn) {
        if (obj.addEventListener) {
            obj.addEventListener(evType, fn, false);
            return true;
        } else if (obj.attachEvent) {
            var r = obj.attachEvent("on" + evType, fn);
            return r;
        } else {
            return false;
        }
    }

    function _getViewportHeight() {
        if (window.innerHeight != window.undefined) return window.innerHeight;
        if (document.compatMode == 'CSS1Compat') return document.documentElement.clientHeight;
        if (document.body) return document.body.clientHeight;

        return window.undefined;
    }

    function _getViewportWidth() {
        var offset = 17;
        var width = null;
        if (window.innerWidth != window.undefined) return window.innerWidth;
        if (document.compatMode == 'CSS1Compat') return document.documentElement.clientWidth;
        if (document.body) return document.body.clientWidth;
    }

    function _getScrollTop() {
        if (self.pageYOffset) // all except Explorer
        {
            return self.pageYOffset;
        }
        else if (document.documentElement && document.documentElement.scrollTop)
        // Explorer 6 Strict
        {
            return document.documentElement.scrollTop;
        }
        else if (document.body) // all other Explorers
        {
            return document.body.scrollTop;
        }
    }

    function _getScrollLeft() {
        if (self.pageXOffset) // all except Explorer
        {
            return self.pageXOffset;
        }
        else if (document.documentElement && document.documentElement.scrollLeft)
        // Explorer 6 Strict
        {
            return document.documentElement.scrollLeft;
        }
        else if (document.body) // all other Explorers
        {
            return document.body.scrollLeft;
        }
    }

    function _onLoad() {

        if (typeof (document.orderform) != 'undefined') {
            var count = document.orderform.elements.length;

            for (i = 0; i < count; i++) {
                var element = document.orderform.elements[i];

                if (element.type == "select-one") {
                    var script = element.getAttribute('onload');
                    if (script != null) {
                        eval(script.replace(/this.id/g, '"' + element.id + '"'));
                    }

                }
            }
        }
    }

    function _openWindow(url, h, w) {
        var left = Math.floor((screen.availWidth - w) / 2);
        var top = Math.floor((screen.availHeight - h) / 2);
        common.openedWindow = window.open(url, "", "scrollbars=yes,height=" + h + ",width=" + w + ",left=" + left + ",top=" + top);

        cancel = true;
    }

    function _iif(exp, ifTrue, ifFalse) {
        if (exp) { return ifTrue; } else { return ifFalse; }
    }

    function _trim(str) {
        return str.replace(/^\s+|\s+$/g, "");
    }

    function _imageSwap(srcId, destId) {
        var src = $(srcId);
        var dest = $(destId);

        //set default thumbnail
        if (typeof this.srcId == 'undefined') {
            this.srcId = 'inset'
        }

        $(this.srcId).style.border = "solid 1px #d6dac3";

        src.style.border = "solid 1px #cc6600"
        dest.src = src.getAttribute("small");

        $("lnkImage").href = "javascript:popup('enlarge.html?" + src.getAttribute("large") + "')"

        dest.width = src.getAttribute("sw");
        dest.height = src.getAttribute("sh");

        this.srcId = srcId;
    }

    function _getNumberSuffix(number) {
        var results = Math.round(number);
        number = number + '';
        results += (number.substr(-(Math.min(number.length, 2))) > 3 && number.substr(-(Math.min(number.length, 2))) < 21 ? "th" : ["th", "st", "nd", "rd", "th"][Math.min(Number(number) % 10, 4)]);
        return results
    }

    function dayToString(theDay) {
        var myDays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]

        return myDays[theDay];
    }

    function _formatDate(date, format) {
        var dateParts = new Array();

        switch (format) {
            case 0:
                dateParts = date.toDateString().split(" ");
                return dateParts[1] + " " + common.getNumberSuffix(dateParts[2]);
            case 1:
                dateParts = date.toLocaleString().split(" ");
                return dateParts[1] + " " + common.getNumberSuffix(dateParts[2].replace(",", ""));
            default:
                dateParts = date.toDateString().split(" ");
                return dayToString(date.getDay()) + ",&nbsp;&nbsp;" + dateParts[1] + " " + common.getNumberSuffix(dateParts[2]);
        }
    }

    function _dateAdd(businessDays, format) {
        var now = new Date();
        //if sunday add one to the business days
        businessDays = businessDays + ((now.getDay() > 0) ? 0 : 1)

        var day = now.getDay();
        var calendarDays = businessDays;
        var deliveryDay = day + businessDays;

        if (deliveryDay >= 6) {
            //deduct this-week days
            businessDays -= 6 - day;
            //count this coming weekend
            calendarDays += 2;
            //how many whole weeks?
            weeks = Math.floor(businessDays / 5);
            //two days per weekend per week
            calendarDays += weeks * 2;
        }

        now.setTime(now.getTime() + calendarDays * 24 * 60 * 60 * 1000);

        return common.formatDate(now, format);
    }
}


function objDialog() {
    this.show = _show;
    this.hide = _hide;
    this.setPopTitle = _setPopTitle;
    this.initialize = _initialize;

    var gPopupMask = null;
    var gPopupContainer = null;
    var gPopFrame = null;
    var gReturnFunc;
    var gPopupIsShown = false;
    var gDefaultPage = "http://site.photoframesplus.com/popups/loading.html";
    var gHideSelects = true;
    var gReturnVal = null;

    var gTabIndexes = new Array();
    // Pre-defined list of tags we want to disable/enable tabbing into
    var gTabbableTags = new Array("A", "BUTTON", "TEXTAREA", "INPUT", "IFRAME");

    // If using Mozilla or Firefox, use Tab-key trap.
    if (!document.all) {
        document.onkeypress = keyDownHandler;
    }

    function initPopUp() {
        // Add the HTML to the body
        theBody = document.getElementsByTagName('BODY')[0];
        popmask = document.createElement('div');
        popmask.id = 'popupMask';
        popcont = document.createElement('div');
        popcont.id = 'popupContainer';
        popcont.innerHTML = '' +
	        '<div id="containerWidth" style="left: 2px;">' +
            '<b class="xtop"><b class="xb1"></b><b class="xb2" style="background-color: #e5ecc9;"></b><b class="xb3" style="background-color: #e5ecc9;"></b><b class="xb4" style="background-color: #e5ecc9;"></b></b>' +
            '<div class="xboxcontent">' +
                '<div id="popupTitleBar" class="dialog">' +
                    '<span id="popupTitle" class="title">&nbsp;</span>' +
                '</div>' +
               '<div id="containerHeight" style="width: 100%;text-align: center;">' +
               '<iframe src="' + gDefaultPage + '" style="background-color:transparent;" scrolling="auto" frameborder="0" allowtransparency="true" id="popupFrame" name="popupFrame"></iframe>' +
                '<a id="popCloseBox" class="close" href="#" onclick="dialog.hide(false);">Close Window</a>' +
                '</div>' +
            '</div>' +
            '<b class="xbottom"><b class="xb4"></b><b class="xb3"></b><b class="xb2"></b><b class="xb1"></b></b>' +
        '</div>';

        theBody.appendChild(popmask);
        theBody.appendChild(popcont);

        gPopupMask = $("popupMask");
        gPopupContainer = $("popupContainer");
        gPopFrame = $("popupFrame");

        // check to see if this is IE version 6 or lower. hide select boxes if so
        // maybe they'll fix this in version 7?
        var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10);
        if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE") > -1) {
            gHideSelects = true;
        }

        // Add onclick handlers to 'a' elements of class submodal or submodal-width-height
        var elms = document.getElementsByTagName('a');
        for (i = 0; i < elms.length; i++) {
            if (elms[i].className.indexOf("submodal") == 0) {
                // var onclick = 'function (){showPopWin(\''+elms[i].href+'\','+width+', '+height+', null);return false;};';
                // elms[i].onclick = eval(onclick);
                elms[i].onclick = function() {
                    // default width and height
                    var width = 400;
                    var height = 200;
                    // Parse out optional width and height from className
                    params = this.className.split('-');
                    if (params.length == 3) {
                        width = parseInt(params[1]);
                        height = parseInt(params[2]);
                    }
                    showPopWin(this.href, width, height, null); return false;
                }
            }
        }
    }

    function _show(url, width, height, returnFunc, showCloseBox) {
        // show or hide the window close widget
        if (showCloseBox == null || showCloseBox == true) {
            $("popCloseBox").style.display = "block";
        } else {
            $("popCloseBox").style.display = "none";
        }
        gPopupIsShown = true;
        disableTabIndexes();
        gPopupMask.style.display = "block";
        gPopupContainer.style.display = "block";
        // calculate where to place the window on screen
        centerPopWin(width, height);

        var titleBarHeight = parseInt($("popupTitleBar").offsetHeight, 10);

        $("containerWidth").style.width = width + "px";
        $("containerHeight").style.height = (height + titleBarHeight) + "px";

        setMaskSize();
        gPopFrame.style.width = parseInt($("popupTitleBar").offsetWidth, 10) + "px";
        gPopFrame.style.height = (height) + "px";

        // set the url
        gPopFrame.src = url;

        gReturnFunc = returnFunc;
        // for IE
        if (gHideSelects == true) {
            hideSelectBoxes();
        }

        window.setTimeout("dialog.setPopTitle();", 1000);

    }

    var gi = 0;
    function centerPopWin(width, height) {
        if (gPopupIsShown == true) {
            if (width == null || isNaN(width)) {
                width = gPopupContainer.offsetWidth;
            }
            if (height == null) {
                height = gPopupContainer.offsetHeight;
            }

            var theBody = document.getElementsByTagName("BODY")[0];
            var scTop = parseInt(common.getScrollTop(), 10);
            var scLeft = parseInt(theBody.scrollLeft, 10);

            setMaskSize();
            var titleBarHeight = parseInt($("popupTitleBar").offsetHeight, 10);

            var fullHeight = common.getViewportHeight();
            var fullWidth = common.getViewportWidth();

            gPopupContainer.style.top = (scTop + ((fullHeight - (height + titleBarHeight)) / 2)) + "px";
            gPopupContainer.style.left = (scLeft + ((fullWidth - width) / 2)) + "px";
        }
    }

    function setMaskSize() {
        var theBody = document.getElementsByTagName("BODY")[0];

        var fullHeight = common.getViewportHeight();
        var fullWidth = common.getViewportWidth();

        if (fullHeight > theBody.scrollHeight) {
            popHeight = fullHeight;
        } else {
            popHeight = theBody.scrollHeight;
        }

        if (fullWidth > theBody.scrollWidth) {
            popWidth = fullWidth;
        } else {
            popWidth = theBody.scrollWidth;
        }

        gPopupMask.style.height = popHeight + "px";
        gPopupMask.style.width = popWidth + "px";
    }
    function _hide(callReturnFunc) {
        gPopupIsShown = false;
        var theBody = document.getElementsByTagName("BODY")[0];
        theBody.style.overflow = "";
        restoreTabIndexes();
        if (gPopupMask == null) {
            return;
        }
        gPopupMask.style.display = "none";
        gPopupContainer.style.display = "none";
        if (callReturnFunc == true && gReturnFunc != null) {
            gReturnVal = window.frames["popupFrame"].returnVal;
            window.setTimeout('gReturnFunc(gReturnVal);', 1);
        }
        gPopFrame.src = gDefaultPage;
        // display all select boxes
        if (gHideSelects == true) {
            displaySelectBoxes();
        }
        $("popupTitle").innerHTML = "&nbsp;";
        dialog.initialize();
    }
    function _setPopTitle() {
        if (window.frames["popupFrame"].document.title == null) {
            window.setTimeout("dialog.setPopTitle();", 10);
        } else {
            $("popupTitle").innerHTML = window.frames["popupFrame"].document.title;
        }
    }
    function keyDownHandler(e) {
        if (gPopupIsShown && e.keyCode == 9) return false;
    }

    // For IE.  Go through predefined tags and disable tabbing into them.
    function disableTabIndexes() {
        if (document.all) {
            var i = 0;
            for (var j = 0; j < gTabbableTags.length; j++) {
                var tagElements = document.getElementsByTagName(gTabbableTags[j]);
                for (var k = 0; k < tagElements.length; k++) {
                    gTabIndexes[i] = tagElements[k].tabIndex;
                    tagElements[k].tabIndex = "-1";
                    i++;
                }
            }
        }
    }
    function restoreTabIndexes() {
        if (document.all) {
            var i = 0;
            for (var j = 0; j < gTabbableTags.length; j++) {
                var tagElements = document.getElementsByTagName(gTabbableTags[j]);
                for (var k = 0; k < tagElements.length; k++) {
                    tagElements[k].tabIndex = gTabIndexes[i];
                    tagElements[k].tabEnabled = true;
                    i++;
                }
            }
        }
    }
    function hideSelectBoxes() {
        for (var i = 0; i < document.forms.length; i++) {
            for (var e = 0; e < document.forms[i].length; e++) {
                if (document.forms[i].elements[e].tagName == "SELECT") {
                    document.forms[i].elements[e].style.visibility = "hidden";
                }
            }
        }
    }
    function displaySelectBoxes() {
        for (var i = 0; i < document.forms.length; i++) {
            for (var e = 0; e < document.forms[i].length; e++) {
                if (document.forms[i].elements[e].tagName == "SELECT") {
                    document.forms[i].elements[e].style.visibility = "visible";
                }
            }
        }
    }

    function _initialize() {
        common.addEvent(window, "load", initPopUp);
        common.addEvent(window, "resize", centerPopWin);
        common.addEvent(window, "scroll", centerPopWin);
        window.onscroll = centerPopWin;
    }
}

var cookies = {
    read: function(name) {
        if (document.cookie.length > 0) {
            begin = document.cookie.indexOf(name + "=");
            if (begin != -1) {
                begin += name.length + 1;
                end = document.cookie.indexOf(";", begin);
                if (end == -1) end = document.cookie.length;
                return unescape(document.cookie.substring(begin, end));
            }
        }
        return
    },
    write: function(name, value, days) {
        if (days) {
            var date = new Date();
            date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
            var expires = "; expires=" + date.toGMTString();
        }
        else var expires = "";
        document.cookie = name + "=" + value + expires + "; path=/";
        this[name] = value;
    },
    remove: function(name) {
        this.write(name, '', -1);
        this[name] = undefined;
    }
};

function objBaseStack(size) {
    var stack = new Array();

    this.push = function(element) {
        stack.push(element);
        if (stack.length > size) {
            return stack.shift();
        }
    }
    this.pop = function() { return stack.pop(); }
    this.length = function() { return stack.length; }
    this.item = function(index) { return stack[index]; }
    this.remove = function(index) {
        var newStack = new Array();
        delete stack[index];
        for (var x = 1; x <= stack.length; x++) {
            if (stack[x - 1] != null) {
                newStack.push(stack[x - 1]);
            }
        }
        stack = newStack;
    }
    this.exists = function(value) {
        for (var x = 1; x <= stack.length; x++) {
            if (stack[x - 1] == value) {
                return x - 1;
            }
        }
        return null;
    }
}

function objStack(containerId, key, baseURL, max, objectName) {
    var baseStack = new objBaseStack(max);
    this.key = key;
    this.baseURL = baseURL;
    this.containerId = containerId;
    this.objectName = objectName;

    this.init = function() {
        var phrases = cookies.read(this.key);
        if (typeof phrases != "undefined") {
            phrases = phrases.split("~");
            for (var x = phrases.length; x >= 1; x--) {
                var phrase = phrases[x - 1].split("·");
                this.add(phrase[0], phrase[1], 'internal');
            }
        }
    }
    this.add = function(name, value, pageType) {
        if (value.indexOf(".html") != -1 || pageType != null) {
            name = name.toProperCase();
            if (name.indexOf(",") != -1) { name = name.substring(0, name.indexOf(",")); }
            name = name.replaceAll("::", '"');
            if (name.length > 26) { name = name.substring(0, 26) + "..."; }
            if (name.indexOf('"') != -1) { name = name.replaceAll('"', '::'); }

            var phrase = name + "·" + value;
            this.remove(phrase);
            baseStack.push(phrase);
            this.save();
        }
    }
    this.show = function() {
        var html = "";

        for (var x = baseStack.length(); x >= 1; x--) {
            var phrase = baseStack.item(x - 1).split("·");
            var name = phrase[0];
            var page = phrase[1];

            html += "<li><img src='http://site.photoframesplus.com/images/smallx.gif' border='0' alt='Remove' style='margin-right: 3px; cursor: pointer;' onclick=\"javascript:" + this.objectName + ".remove('" + baseStack.item(x - 1) + "');" + this.objectName + ".show();\"><a href='" + this.baseURL + page + "'>" + name.replaceAll('::', '"') + "</a></li>";
        }

        if (html != "") {
            html = "<ul>" + html + "</ul>";
        } else {
            html = "<div style='text-align: left;'>(none yet)</div>";
        }
        if ($(this.containerId) != null) {
            $(this.containerId).innerHTML = html;
        }
    }
    this.save = function() {
        var phrases = "";

        for (var x = baseStack.length(); x >= 1; x--) {
            var phrase = baseStack.item(x - 1);
            if (typeof phrase != 'undefined') { phrases += phrase + "~"; };
        }
        if (phrases != "") {
            cookies.write(this.key, phrases.substring(0, phrases.length - 1), 30);
        } else {
            cookies.remove(this.key);
        }
    }
    this.remove = function(value) {
        var index = baseStack.exists(value);
        if (index != null) {
            baseStack.remove(index);
            this.save();
        }
    }
    this.clear = function() {
        baseStack = new objBaseStack(max);
        this.save();
        this.show();
    }
}

function objRecentlyViewed() {
    var max = 5;
    var containerId = null;
    var key = null;
    var baseURL = null;

    this.init = function() {
        this.search.init('searchesContainer');
        this.category.init('categoriesContainer');
        this.product.init('searchesContainer');
        this.page.init('pagesContainer');
    }
    this.clearAll = function() {
        this.search.clear();
        this.category.clear();
        this.product.clear();
        this.page.clear();
    }

    containerId = "searchesContainer";
    key = "rvSearch";
    baseURL = "http://search.store.yahoo.com/cgi-bin/nsearch?follow-pro=2&vwcatalog=photoframesplus&catalog=photoframesplus&query=";
    href = window.location.toString();
    this.search = new objStack(containerId, key, baseURL, max, "rv.search");

    containerId = "categoriesContainer";
    key = "rvCategory";
    if (href.indexOf("photoframesplus.com") != -1) {
        baseURL = "http://www.photoframesplus.com/";
    } else if (href.indexOf("localhost") != -1 || href.indexOf("smithfamilystores.com") != -1) {
        baseURL = href.replace(href.substring(href.lastIndexOf('/') + 1), "");
    } else {
        baseURL = "http://us-f4-edit.store.yahoo.com/RT/NEWEDIT.photoframesplus/";
    }

    this.category = new objStack(containerId, key, baseURL, max, "rv.category");

    containerId = "productsContainer";
    key = "rvProduct";
    this.product = new objStack(containerId, key, baseURL, max, "rv.product");

    containerId = "pagesContainer";
    key = "rvPage";
    this.page = new objStack(containerId, key, baseURL, max, "rv.page");
}
var rv = new objRecentlyViewed();
rv.init();

var currentShowTimer;
var currentHideTimer;
var currentVisibleMenu;

function showflyout(id)
{
    clearTimeout(currentShowTimer);
    if (currentVisibleMenu) {
        clearTimeout(currentHideTimer);         

        if (currentVisibleMenu != id ) {
            runhideflyout(currentVisibleMenu);
            runshowflyout(id);
        }
    } else {
        currentShowTimer = window.setTimeout("runshowflyout('" + id + "')", 300);
    }
}

function runshowflyout(id) {       
    var fly = document.getElementById(id);        
    if (fly) {
        currentVisibleMenu = id;
        fly.style.display="block";
    } 
}

function hideflyout(id) {
    clearTimeout(currentShowTimer);
    if (currentVisibleMenu == id) {
        currentHideTimer = window.setTimeout("runhideflyout('" + id + "')", 200);
    }
}

function runhideflyout(id) {
    clearTimeout(currentHideTimer);
    currentVisibleMenu = "";

    var fly = document.getElementById(id);    
    if (fly) {
        currentVisibleMenu = "";
        fly.style.display="none";
    } 
}

