function unhide(divID) {
  var item = document.getElementById(divID);
	if (item) {
    item.className=(item.className=='hidden')?'unhidden':'hidden';
  }
	
}

function hide(divID) {
  var item = document.getElementById(divID);

  if (item) {
    item.className=(item.className=='hidden')?'hidden':'hidden';
  }
	
}

//unhides divID, hides previously shown id stored in the var below
var currentlyShownID = "";

function show(divID) {

  hide(currentlyShownID);
  unhide(divID);
  
  currentlyShownID = divID;
}


jQuery.noConflict();

(function($) {
    $.fn.extend({
        collapsiblePanel: function() {
        // Call the ConfigureCollapsiblePanel function for the selected element
        return $(this).each(ConfigureCollapsiblePanel);
    }
  });
  
})(jQuery);


function ConfigureCollapsiblePanel() {
    jQuery(this).addClass("ui-widget").addClass("collapsibleContainer").addClass("collapsed");
    
    // Check if there are any child elements, if not then wrap the inner text within a new div.
    if (jQuery(this).children().length == 0) {
    jQuery(this).wrapInner("<div></div>");
    }    

    // Add a footer for collapsing    
    jQuery(this).append("<div class='collapsibleContainerFooter ui-widget-footer'><div>Minimize</div></div>");
    
    // Wrap the contents of the container within a new div.
    jQuery(this).children().wrapAll("<div class='collapsibleContainerContent ui-widget-content' style='display: none;'></div>");
    
    // Create a new div as the first item within the container.  Put the title of the panel in here.
    jQuery("<div class='collapsibleContainerTitle ui-widget-header'><div>" + jQuery(this).attr("title") + "</div></div>").prependTo(jQuery(this));
    
    // Assign a call to CollapsibleContainerTitleOnClick for the click event of the new title div.
    jQuery(".collapsibleContainerTitle", this).click(CollapsibleContainerTitleOnClick);
    jQuery(".collapsibleContainerFooter", this).click(CollapsibleContainerTitleOnClick);
}
  
  
function CollapsibleContainerTitleOnClick() {
    // The item clicked is the title div... get this parent (the overall container) and toggle the content within it.
    var widget = jQuery(this).closest(".collapsibleContainer");
    jQuery(".collapsibleContainerContent", widget).slideToggle();
    
    if (widget.hasClass("collapsed"))
    {
      widget.addClass("expanded");
      widget.removeClass("collapsed");
    }
    else
    {
      widget.addClass("collapsed");
      widget.removeClass("expanded");
    }
}

jQuery(document).ready(function(){
			jQuery("ul.level0").wrap("<div class='subnav'></div>"); 
      jQuery(".hastooltip").tooltip({ effect: 'slide'});
      jQuery(".collapsible").collapsiblePanel();
      jQuery("a[rel], img[rel]").overlay({
        mask: 'gray',
        onLoad: function(content) {
          // find the player contained inside this overlay and load it
          if (this.getOverlay().find("a.player").flowplayer(0))
          {
            this.getOverlay().find("a.player").flowplayer(0).load();
          }
        },
        
        onClose: function(content) {
          if ($f())
          {
            $f().unload();
          }
        }
      });
      // install flowplayers
      jQuery("a.player").flowplayer("/skin/frontend/default/tastyimage/flowplayer/flowplayer.commercial-3.1.5.swf", {key: '#$b0fa20269ef4e32b83d'}); 
	  jQuery("a[href='http://tastyimage.com/blog']").attr('href','http://tastyimage.typepad.com/tasty-image/');
});

function show_tech()
{
	document.location = "http://www.tastyimage.com/products/edible-photos-html.html";
}

(function ($) {
    function Countdown() {
        this.regional = [];
        this.regional[''] = {
            labels: ['Years', 'Months', 'Weeks', 'days', 'hours', 'minutes', 'seconds'],
            labelsSingle: ['Year', 'Month', 'Week', 'Day', 'hour', 'minute', 'second'],
            compactLabels: ['y', 'm', 'w', 'd'],
            compactLabelsSingle: ['y', 'm', 'w', 'd'],
            timeSeparator: ':'
        };
        this._defaults = {
            format: 'dHMS',
            layout: '',
            compact: false,
            description: '',
            expiryUrl: null,
            alwaysExpire: false,
            onExpiry: null,
            onTick: null,
            serverTime: null
        };
        $.extend(this._defaults, this.regional[''])
    }
    var q = 'countdown';
    var Y = 0;
    var O = 1;
    var W = 2;
    var D = 3;
    var H = 4;
    var M = 5;
    var S = 6;
    $.extend(Countdown.prototype, {
        markerClassName: 'hasCountdown',
        setDefaults: function (a) {
            extendRemove(this._defaults, a || {})
        },
        _attachCountdown: function (a, b) {
            a = $(a);
            if (a.is('.' + this.markerClassName)) {
                return
            }
            a.addClass(this.markerClassName);
            if (!a[0].id) {
                a[0].id = 'cdn' + new Date().getTime()
            }
            var c = {};
            c.options = $.extend({}, b);
            c._periods = [0, 0, 0, 0, 0, 0, 0];
            this._adjustSettings(c);
            $.data(a[0], q, c);
            this._updateCountdown(a, c)
        },
        _updateCountdown: function (a, b) {
            var c = $(a);
            b = b || $.data(c[0], q);
            if (!b) {
                return
            }
            c.html(this._generateHTML(b));
            var d = this._get(b, 'onTick');
            if (d) {
                d.apply(c[0], [b._hold != 'lap' ? b._periods : this._calculatePeriods(b, b._show, new Date())])
            }
            var e = b._hold != 'pause' && (b._since ? b._now.getTime() <= b._since.getTime() : b._now.getTime() >= b._until.getTime());
            if (e) {
                if (b._timer || this._get(b, 'alwaysExpire')) {
                    var f = this._get(b, 'onExpiry');
                    if (f) {
                        f.apply(c[0], [])
                    }
                    var g = this._get(b, 'expiryUrl');
                    if (g) {
                        window.location = g
                    }
                }
                b._timer = null
            } else if (b._hold == 'pause') {
                b._time = null
            } else {
                var h = this._get(b, 'format');
                b._timer = setTimeout('jQuery.countdown._updateCountdown("#' + c[0].id + '")', (h.match('s|S') ? 1 : (h.match('m|M') ? 30 : 600)) * 980)
            }
            $.data(c[0], q, b)
        },
        _changeCountdown: function (a, b) {
            var c = $.data(a, q);
            if (c) {
                extendRemove(c.options, b || {});
                this._adjustSettings(c);
                $.data(a, q, c);
                this._updateCountdown(a, c)
            }
        },
        _destroyCountdown: function (a) {
            a = $(a);
            if (!a.is('.' + this.markerClassName)) {
                return
            }
            a.removeClass(this.markerClassName).empty();
            var b = $.data(a[0], q);
            if (b._timer) {
                clearTimeout(b._timer)
            }
            $.removeData(a[0], q)
        },
        _pauseCountdown: function (a) {
            this._hold(a, 'pause')
        },
        _lapCountdown: function (a) {
            this._hold(a, 'lap')
        },
        _resumeCountdown: function (a) {
            this._hold(a, null)
        },
        _hold: function (a, b) {
            var c = $.data(a, q);
            if (c) {
                if (c._hold == 'pause' && !b) {
                    c._periods = c._savePeriods;
                    var d = (c._since ? '-' : '+');
                    c[c._since ? '_since' : '_until'] = this._determineTime(d + c._periods[0] + 'Y' + d + c._periods[1] + 'O' + d + c._periods[2] + 'W' + d + c._periods[3] + 'D' + d + c._periods[4] + 'H' + d + c._periods[5] + 'M' + d + c._periods[6] + 'S')
                }
                c._hold = b;
                c._savePeriods = (b == 'pause' ? c._periods : null);
                $.data(a, q, c);
                this._updateCountdown(a, c)
            }
        },
        _getTimesCountdown: function (a) {
            var b = $.data(a, q);
            return (!b ? null : (!b._hold ? b._periods : this._calculatePeriods(b, b._show, new Date())))
        },
        _get: function (a, b) {
            return (a.options[b] != null ? a.options[b] : jQuery.countdown._defaults[b])
        },
        _adjustSettings: function (a) {
            var b = new Date();
            var c = this._get(a, 'serverTime');
            a._offset = (c ? c.getTime() - b.getTime() : 0);
            a._since = this._get(a, 'since');
            if (a._since) {
                a._since = this._determineTime(a._since, null)
            }
            a._until = this._determineTime(this._get(a, 'until'), b);
            a._show = this._determineShow(a)
        },
        _determineTime: function (k, l) {
            var m = function (a) {
                var b = new Date();
                b.setTime(b.getTime() + a * 1000);
                return b
            };
            var n = function (a, b) {
                return 32 - new Date(a, b, 32).getDate()
            };
            var o = function (a) {
                var b = new Date();
                var c = b.getFullYear();
                var d = b.getMonth();
                var e = b.getDate();
                var f = b.getHours();
                var g = b.getMinutes();
                var h = b.getSeconds();
                var i = /([+-]?[0-9]+)\s*(s|S|m|M|h|H|d|D|w|W|o|O|y|Y)?/g;
                var j = i.exec(a);
                while (j) {
                    switch (j[2] || 's') {
                    case 's':
                    case 'S':
                        h += parseInt(j[1]);
                        break;
                    case 'm':
                    case 'M':
                        g += parseInt(j[1]);
                        break;
                    case 'h':
                    case 'H':
                        f += parseInt(j[1]);
                        break;
                    case 'd':
                    case 'D':
                        e += parseInt(j[1]);
                        break;
                    case 'w':
                    case 'W':
                        e += parseInt(j[1]) * 7;
                        break;
                    case 'o':
                    case 'O':
                        d += parseInt(j[1]);
                        e = Math.min(e, n(c, d));
                        break;
                    case 'y':
                    case 'Y':
                        c += parseInt(j[1]);
                        e = Math.min(e, n(c, d));
                        break
                    }
                    j = i.exec(a)
                }
                b = new Date(c, d, e, f, g, h, 0);
                return b
            };
            var p = (k == null ? l : (typeof k == 'string' ? o(k) : (typeof k == 'number' ? m(k) : k)));
            if (p) p.setMilliseconds(0);
            return p
        },
        _generateHTML: function (b) {
            b._periods = periods = (b._hold ? b._periods : this._calculatePeriods(b, b._show, new Date()));
            var c = false;
            var d = 0;
            for (var e = 0; e < b._show.length; e++) {
                c |= (b._show[e] == '?' && periods[e] > 0);
                b._show[e] = (b._show[e] == '?' && !c ? null : b._show[e]);
                d += (b._show[e] ? 1 : 0)
            }

            var f = this._get(b, 'compact');
            var g = this._get(b, 'layout');
            var h = (f ? this._get(b, 'compactLabels') : this._get(b, 'labels'));
            var i = (f ? this._get(b, 'compactLabelsSingle') : this._get(b, 'labelsSingle')) || h;
            var j = this._get(b, 'timeSeparator');
            var k = this._get(b, 'description') || '';
            var l = function (a) {
                return (a < 10 ? '0' : '') + a
            };
            var m = function (a) {
                return (b._show[a] ? periods[a] + (periods[a] == 1 ? i[a] : h[a]) + ' ' : '')
            };
            var n = function (a) {
                return (b._show[a] ? '<div class="countdown_section"><span class="countdown_amount">' + periods[a] + '</span><br/>' + (periods[a] == 1 ? i[a] : h[a]) + '</div>' : '')
            };
            return (g ? this._buildLayout(b, g, h, i) : ((f ? '<div class="countdown_row countdown_amount' + (b._hold ? ' countdown_holding' : '') + '">' + m(Y) + m(O) + m(W) + m(D) + l(periods[H]) + j + l(periods[M]) + (b._show[S] ? j + l(periods[S]) : '') : '<div class="countdown_row countdown_show' + d + (b._hold ? ' countdown_holding' : '') + '">' + n(Y) + n(O) + n(W) + n(D) + n(H) + n(M) + n(S)) + '</div>' + (k ? '<div class="countdown_row countdown_descr">' + k + '</div>' : '')))
        },
        _buildLayout: function (f, g, h, i) {
            var j = g;
            var k = function (a, b) {
                var c = new RegExp('%' + a + '.*%' + a);
                var d = new RegExp('%' + a + '.*');
                while (true) {
                    var e = c.exec(j);
                    if (!e) {
                        break
                    }
                    e[0] = e[0].substr(0, 2) + e[0].substr(2).replace(d, '%' + a);
                    j = j.replace(e[0], f._show[b] ? l(e[0], a, b) : '')
                }
            };
            var l = function (a, b, c) {
                return a.substr(2, a.length - 4).replace(/%nn/g, (f._periods[c] < 10 ? '0' : '') + f._periods[c]).replace(/%n/g, f._periods[c]).replace(/%l/g, f._periods[c] == 1 ? i[c] : h[c])
            };
            k('Y', Y);
            k('O', O);
            k('W', W);
            k('D', D);
            k('H', H);
            k('M', M);
            k('S', S);
            return j
        },
        _determineShow: function (a) {
            var b = this._get(a, 'format');
            var c = [];
            c[Y] = (b.match('y') ? '?' : (b.match('Y') ? '!' : null));
            c[O] = (b.match('o') ? '?' : (b.match('O') ? '!' : null));
            c[W] = (b.match('w') ? '?' : (b.match('W') ? '!' : null));
            c[D] = (b.match('d') ? '?' : (b.match('D') ? '!' : null));
            c[H] = (b.match('h') ? '?' : (b.match('H') ? '!' : null));
            c[M] = (b.match('m') ? '?' : (b.match('M') ? '!' : null));
            c[S] = (b.match('s') ? '?' : (b.match('S') ? '!' : null));
            return c
        },
        _calculatePeriods: function (c, d, e) {
            c._now = e;
            c._now.setMilliseconds(0);
            var f = new Date(c._now.getTime());
            if (c._since && e.getTime() < c._since.getTime()) {
                c._now = e = f
            } else if (c._since) {
                e = c._since
            } else {
                f.setTime(c._until.getTime());
                if (e.getTime() > c._until.getTime()) {
                    c._now = e = f
                }
            }
            f.setTime(f.getTime() - c._offset);
            var g = [0, 0, 0, 0, 0, 0, 0];
            if (d[Y] || d[O]) {
                var h = Math.max(0, (f.getFullYear() - e.getFullYear()) * 12 + f.getMonth() - e.getMonth() + (f.getDate() < e.getDate() ? -1 : 0));
                g[Y] = (d[Y] ? Math.floor(h / 12) : 0);
                g[O] = (d[O] ? h - g[Y] * 12 : 0);
                if (c._since) {
                    f.setFullYear(f.getFullYear() - g[Y]);
                    f.setMonth(f.getMonth() - g[O])
                } else {
                    e = new Date(e.getTime());
                    e.setFullYear(e.getFullYear() + g[Y]);
                    e.setMonth(e.getMonth() + g[O])
                }
            }
            var i = Math.floor((f.getTime() - e.getTime()) / 1000);
            var j = function (a, b) {
                g[a] = (d[a] ? Math.floor(i / b) : 0);
                i -= g[a] * b
            };
            j(W, 604800);
            j(D, 86400);
            j(H, 3600);
            j(M, 60);
            j(S, 1);
            return g
        }
    });

    function extendRemove(a, b) {
        $.extend(a, b);
        for (var c in b) {
            if (b[c] == null) {
                a[c] = null
            }
        }
        return a
    }
    $.fn.countdown = function (a) {
        var b = Array.prototype.slice.call(arguments, 1);
        if (a == 'getTimes') {
            return jQuery.countdown['_' + a + 'Countdown'].apply(jQuery.countdown, [this[0]].concat(b))
        }
        return this.each(function () {
            if (typeof a == 'string') {
                jQuery.countdown['_' + a + 'Countdown'].apply(jQuery.countdown, [this].concat(b))
            } else {
                jQuery.countdown._attachCountdown(this, a)
            }
        })
    };
    jQuery.countdown = new Countdown()
})(jQuery);
