﻿/// <reference path="jquery-1.4.1.js" />
/// <reference path="start.js" />
/// <reference path="extendedcontrols.js" />
//std nav bar

/*BEGIN JQUERY TOOLS MIN*/
(function(c) {
    function p(d, a, b) {
        var e = this, l = d.add(this), h = d.find(b.tabs), j = a.jquery ? a : d.children(a), i; h.length || (h = d.children()); j.length || (j = d.parent().find(a)); j.length || (j = c(a)); c.extend(this, { click: function(f, g) {
            var k = h.eq(f); if (typeof f == "string" && f.replace("#", "")) { k = h.filter("[href*=" + f.replace("#", "") + "]"); f = Math.max(h.index(k), 0) } if (b.rotate) { var n = h.length - 1; if (f < 0) return e.click(n, g); if (f > n) return e.click(0, g) } if (!k.length) { if (i >= 0) return e; f = b.initialIndex; k = h.eq(f) } if (f === i) return e;
            g = g || c.Event(); g.type = "onBeforeClick"; l.trigger(g, [f]); if (!g.isDefaultPrevented()) { o[b.effect].call(e, f, function() { g.type = "onClick"; l.trigger(g, [f]) }); i = f; h.removeClass(b.current); k.addClass(b.current); return e } 
        }, getConf: function() { return b }, getTabs: function() { return h }, getPanes: function() { return j }, getCurrentPane: function() { return j.eq(i) }, getCurrentTab: function() { return h.eq(i) }, getIndex: function() { return i }, next: function() { return e.click(i + 1) }, prev: function() { return e.click(i - 1) } 
        }); c.each("onBeforeClick,onClick".split(","),
function(f, g) { c.isFunction(b[g]) && c(e).bind(g, b[g]); e[g] = function(k) { c(e).bind(g, k); return e } }); if (b.history && c.fn.history) { c.tools.history.init(h); b.event = "history" } h.each(function(f) { c(this).bind(b.event, function(g) { e.click(f, g); return g.preventDefault() }) }); j.find("a[href^=#]").click(function(f) { e.click(c(this).attr("href"), f) }); if (location.hash) e.click(location.hash); else if (b.initialIndex === 0 || b.initialIndex > 0) e.click(b.initialIndex)
    } c.tools = c.tools || { version: "1.2.2" }; c.tools.tabs = { conf: { tabs: "a",
        current: "current", onBeforeClick: null, onClick: null, effect: "default", initialIndex: 0, event: "click", rotate: false, history: false
    }, addEffect: function(d, a) { o[d] = a } 
    }; var o = { "default": function(d, a) { this.getPanes().hide().eq(d).show(); a.call() }, fade: function(d, a) { var b = this.getConf(), e = b.fadeOutSpeed, l = this.getPanes(); e ? l.fadeOut(e) : l.hide(); l.eq(d).fadeIn(b.fadeInSpeed, a) }, slide: function(d, a) { this.getPanes().slideUp(200); this.getPanes().eq(d).slideDown(400, a) }, ajax: function(d, a) {
        this.getPanes().eq(0).load(this.getTabs().eq(d).attr("href"),
a)
    } 
    }, m; c.tools.tabs.addEffect("horizontal", function(d, a) { m || (m = this.getPanes().eq(0).width()); this.getCurrentPane().animate({ width: 0 }, function() { c(this).hide() }); this.getPanes().eq(d).animate({ width: m }, function() { c(this).show(); a.call() }) }); c.fn.tabs = function(d, a) { var b = this.data("tabs"); if (b) return b; if (c.isFunction(a)) a = { onBeforeClick: a }; a = c.extend({}, c.tools.tabs.conf, a); this.each(function() { b = new p(c(this), d, a); c(this).data("tabs", b) }); return a.api ? b : this } 
})(jQuery);
(function(f) {
    function p(a, b, c) { var h = c.relative ? a.position().top : a.offset().top, e = c.relative ? a.position().left : a.offset().left, i = c.position[0]; h -= b.outerHeight() - c.offset[0]; e += a.outerWidth() + c.offset[1]; var j = b.outerHeight() + a.outerHeight(); if (i == "center") h += j / 2; if (i == "bottom") h += j; i = c.position[1]; a = b.outerWidth() + a.outerWidth(); if (i == "center") e -= a / 2; if (i == "left") e -= a; return { top: h, left: e} } function t(a, b) {
        var c = this, h = a.add(c), e, i = 0, j = 0, m = a.attr("title"), q = n[b.effect], k, r = a.is(":input"), u = r && a.is(":checkbox, :radio, select, :button"),
s = a.attr("type"), l = b.events[s] || b.events[r ? u ? "widget" : "input" : "def"]; if (!q) throw 'Nonexistent effect "' + b.effect + '"'; l = l.split(/,\s*/); if (l.length != 2) throw "Tooltip: bad events configuration for " + s; a.bind(l[0], function(d) { if (b.predelay) { clearTimeout(i); j = setTimeout(function() { c.show(d) }, b.predelay) } else c.show(d) }).bind(l[1], function(d) { if (b.delay) { clearTimeout(j); i = setTimeout(function() { c.hide(d) }, b.delay) } else c.hide(d) }); if (m && b.cancelDefault) { a.removeAttr("title"); a.data("title", m) } f.extend(c,
{ show: function(d) {
    if (!e) { if (m) e = f(b.layout).addClass(b.tipClass).appendTo(document.body).hide().append(m); else if (b.tip) e = f(b.tip).eq(0); else { e = a.next(); e.length || (e = a.parent().next()) } if (!e.length) throw "Cannot find tooltip for " + a; } if (c.isShown()) return c; e.stop(true, true); var g = p(a, e, b); d = d || f.Event(); d.type = "onBeforeShow"; h.trigger(d, [g]); if (d.isDefaultPrevented()) return c; g = p(a, e, b); e.css({ position: "absolute", top: g.top, left: g.left }); k = true; q[0].call(c, function() { d.type = "onShow"; k = "full"; h.trigger(d) });
    g = b.events.tooltip.split(/,\s*/); e.bind(g[0], function() { clearTimeout(i); clearTimeout(j) }); g[1] && !a.is("input:not(:checkbox, :radio), textarea") && e.bind(g[1], function(o) { o.relatedTarget != a[0] && a.trigger(l[1].split(" ")[0]) }); return c
}, hide: function(d) { if (!e || !c.isShown()) return c; d = d || f.Event(); d.type = "onBeforeHide"; h.trigger(d); if (!d.isDefaultPrevented()) { k = false; n[b.effect][1].call(c, function() { d.type = "onHide"; k = false; h.trigger(d) }); return c } }, isShown: function(d) { return d ? k == "full" : k }, getConf: function() { return b },
    getTip: function() { return e }, getTrigger: function() { return a } 
}); f.each("onHide,onBeforeShow,onShow,onBeforeHide".split(","), function(d, g) { f.isFunction(b[g]) && f(c).bind(g, b[g]); c[g] = function(o) { f(c).bind(g, o); return c } })
    } f.tools = f.tools || { version: "1.2.2" }; f.tools.tooltip = { conf: { effect: "toggle", fadeOutSpeed: "fast", predelay: 0, delay: 30, opacity: 1, tip: 0, position: ["top", "center"], offset: [0, 0], relative: false, cancelDefault: true, events: { def: "mouseenter,mouseleave", input: "focus,blur", widget: "focus mouseenter,blur mouseleave",
        tooltip: "mouseenter,mouseleave"
    }, layout: "<div/>", tipClass: "tooltip"
    }, addEffect: function(a, b, c) { n[a] = [b, c] } 
    }; var n = { toggle: [function(a) { var b = this.getConf(), c = this.getTip(); b = b.opacity; b < 1 && c.css({ opacity: b }); c.show(); a.call() }, function(a) { this.getTip().hide(); a.call() } ], fade: [function(a) { var b = this.getConf(); this.getTip().fadeTo(b.fadeInSpeed, b.opacity, a) }, function(a) { this.getTip().fadeOut(this.getConf().fadeOutSpeed, a) } ] }; f.fn.tooltip = function(a) {
        var b = this.data("tooltip"); if (b) return b; a = f.extend(true,
{}, f.tools.tooltip.conf, a); if (typeof a.position == "string") a.position = a.position.split(/,?\s/); this.each(function() { b = new t(f(this), a); f(this).data("tooltip", b) }); return a.api ? b : this
    } 
})(jQuery);
(function(a) {
    function t(d, b) {
        var c = this, i = d.add(c), o = a(window), k, f, m, g = a.tools.expose && (b.mask || b.expose), n = Math.random().toString().slice(10); if (g) { if (typeof g == "string") g = { color: g }; g.closeOnClick = g.closeOnEsc = false } var p = b.target || d.attr("rel"); f = p ? a(p) : d; if (!f.length) throw "Could not find Overlay: " + p; d && d.index(f) == -1 && d.click(function(e) { c.load(e); return e.preventDefault() }); a.extend(c, { load: function(e) {
            if (c.isOpened()) return c; var h = q[b.effect]; if (!h) throw 'Overlay: cannot find effect : "' + b.effect +
'"'; b.oneInstance && a.each(s, function() { this.close(e) }); e = e || a.Event(); e.type = "onBeforeLoad"; i.trigger(e); if (e.isDefaultPrevented()) return c; m = true; g && a(f).expose(g); var j = b.top, r = b.left, u = f.outerWidth({ margin: true }), v = f.outerHeight({ margin: true }); if (typeof j == "string") j = j == "center" ? Math.max((o.height() - v) / 2, 0) : parseInt(j, 10) / 100 * o.height(); if (r == "center") r = Math.max((o.width() - u) / 2, 0); h[0].call(c, { top: j, left: r }, function() { if (m) { e.type = "onLoad"; i.trigger(e) } }); g && b.closeOnClick && a.mask.getMask().one("click",
c.close); b.closeOnClick && a(document).bind("click." + n, function(l) { a(l.target).parents(f).length || c.close(l) }); b.closeOnEsc && a(document).bind("keydown." + n, function(l) { l.keyCode == 27 && c.close(l) }); return c
        }, close: function(e) { if (!c.isOpened()) return c; e = e || a.Event(); e.type = "onBeforeClose"; i.trigger(e); if (!e.isDefaultPrevented()) { m = false; q[b.effect][1].call(c, function() { e.type = "onClose"; i.trigger(e) }); a(document).unbind("click." + n).unbind("keydown." + n); g && a.mask.close(); return c } }, getOverlay: function() { return f },
            getTrigger: function() { return d }, getClosers: function() { return k }, isOpened: function() { return m }, getConf: function() { return b } 
        }); a.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","), function(e, h) { a.isFunction(b[h]) && a(c).bind(h, b[h]); c[h] = function(j) { a(c).bind(h, j); return c } }); k = f.find(b.close || ".close"); if (!k.length && !b.close) { k = a('<div class="close"></div>'); f.prepend(k) } k.click(function(e) { c.close(e) }); b.load && c.load()
    } a.tools = a.tools || { version: "1.2.2" }; a.tools.overlay = { addEffect: function(d,
b, c) { q[d] = [b, c] }, conf: { close: null, closeOnClick: true, closeOnEsc: true, closeSpeed: "fast", effect: "default", fixed: !a.browser.msie || a.browser.version > 6, left: "center", load: false, mask: null, oneInstance: true, speed: "normal", target: null, top: "10%"}
    }; var s = [], q = {}; a.tools.overlay.addEffect("default", function(d, b) { var c = this.getConf(), i = a(window); if (!c.fixed) { d.top += i.scrollTop(); d.left += i.scrollLeft() } d.position = c.fixed ? "fixed" : "absolute"; this.getOverlay().css(d).fadeIn(c.speed, b) }, function(d) {
        this.getOverlay().fadeOut(this.getConf().closeSpeed,
d)
    }); a.fn.overlay = function(d) { var b = this.data("overlay"); if (b) return b; if (a.isFunction(d)) d = { onBeforeLoad: d }; d = a.extend(true, {}, a.tools.overlay.conf, d); this.each(function() { b = new t(a(this), d); s.push(b); a(this).data("overlay", b) }); return d.api ? b : this } 
})(jQuery);
(function(e) {
    function n(f, c) { var a = e(c); return a.length < 2 ? a : f.parent().find(c) } function t(f, c) {
        var a = this, l = f.add(a), g = f.children(), k = 0, m = c.vertical; j || (j = a); if (g.length > 1) g = e(c.items, f); e.extend(a, { getConf: function() { return c }, getIndex: function() { return k }, getSize: function() { return a.getItems().size() }, getNaviButtons: function() { return o.add(p) }, getRoot: function() { return f }, getItemWrap: function() { return g }, getItems: function() { return g.children(c.item).not("." + c.clonedClass) }, move: function(b, d) {
            return a.seekTo(k +
b, d)
        }, next: function(b) { return a.move(1, b) }, prev: function(b) { return a.move(-1, b) }, begin: function(b) { return a.seekTo(0, b) }, end: function(b) { return a.seekTo(a.getSize() - 1, b) }, focus: function() { return j = a }, addItem: function(b) { b = e(b); if (c.circular) { e(".cloned:last").before(b); e(".cloned:first").replaceWith(b.clone().addClass(c.clonedClass)) } else g.append(b); l.trigger("onAddItem", [b]); return a }, seekTo: function(b, d, h) {
            if (c.circular && b === 0 && k == -1 && d !== 0) return a; if (!c.circular && b < 0 || b > a.getSize() || b < -1) return a;
            var i = b; if (b.jquery) b = a.getItems().index(b); else i = a.getItems().eq(b); var q = e.Event("onBeforeSeek"); if (!h) { l.trigger(q, [b, d]); if (q.isDefaultPrevented() || !i.length) return a } i = m ? { top: -i.position().top} : { left: -i.position().left }; k = b; j = a; if (d === undefined) d = c.speed; g.animate(i, d, c.easing, h || function() { l.trigger("onSeek", [b]) }); return a
        } 
        }); e.each(["onBeforeSeek", "onSeek", "onAddItem"], function(b, d) { e.isFunction(c[d]) && e(a).bind(d, c[d]); a[d] = function(h) { e(a).bind(d, h); return a } }); if (c.circular) {
            var r = a.getItems().slice(-1).clone().prependTo(g),
s = a.getItems().eq(1).clone().appendTo(g); r.add(s).addClass(c.clonedClass); a.onBeforeSeek(function(b, d, h) { if (!b.isDefaultPrevented()) if (d == -1) { a.seekTo(r, h, function() { a.end(0) }); return b.preventDefault() } else d == a.getSize() && a.seekTo(s, h, function() { a.begin(0) }) }); a.seekTo(0, 0)
        } var o = n(f, c.prev).click(function() { a.prev() }), p = n(f, c.next).click(function() { a.next() }); !c.circular && a.getSize() > 1 && a.onBeforeSeek(function(b, d) {
            o.toggleClass(c.disabledClass, d <= 0); p.toggleClass(c.disabledClass, d >= a.getSize() -
1)
        }); c.mousewheel && e.fn.mousewheel && f.mousewheel(function(b, d) { if (c.mousewheel) { a.move(d < 0 ? 1 : -1, c.wheelSpeed || 50); return false } }); c.keyboard && e(document).bind("keydown.scrollable", function(b) { if (!(!c.keyboard || b.altKey || b.ctrlKey || e(b.target).is(":input"))) if (!(c.keyboard != "static" && j != a)) { var d = b.keyCode; if (m && (d == 38 || d == 40)) { a.move(d == 38 ? -1 : 1); return b.preventDefault() } if (!m && (d == 37 || d == 39)) { a.move(d == 37 ? -1 : 1); return b.preventDefault() } } }); e(a).trigger("onBeforeSeek", [c.initialIndex])
    } e.tools = e.tools ||
{ version: "1.2.2" }; e.tools.scrollable = { conf: { activeClass: "active", circular: false, clonedClass: "cloned", disabledClass: "disabled", easing: "swing", initialIndex: 0, item: null, items: ".items", keyboard: true, mousewheel: false, next: ".next", prev: ".prev", speed: 400, vertical: false, wheelSpeed: 0} }; var j; e.fn.scrollable = function(f) { var c = this.data("scrollable"); if (c) return c; f = e.extend({}, e.tools.scrollable.conf, f); this.each(function() { c = new t(e(this), f); e(this).data("scrollable", c) }); return f.api ? c : this } 
})(jQuery);

/*END JQUERY TOOLS MIN*/

/*BEGIN SCROLL*/
$(function() {

    $('a[href*=#ancla]').click(function() {

        if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '')
        && location.hostname == this.hostname) {

            var $target = $(this.hash);

            $target = $target.length && $target || $('[name=' + this.hash.slice(1) + ']');

            if ($target.length) {

                var targetOffset = $target.offset().top;

                $('html,body').animate({ scrollTop: targetOffset }, 1000);

                return false;

            }

        }

    });

});
/*END SCROLL*/
function initMenu(menu, options) {
    $("ul ul", menu).addClass("hide");
    $("." + options.selector, menu).click(function(event) {
        var currentItem = $(this).get(0);
        $(currentItem).next().toggle("fast");
        $(currentItem).toggleClass(options.selector_expanded);
        if ($(currentItem).next().is(":visible")) {
            currentItem = $(currentItem).next().get(0);
            $(currentItem).css("display", "inline-block");
        }
        var currentVisible = $("ul:visible", menu);
        var parent = $(currentItem).parents("ul");
        for (var i = 0; i < currentVisible.length; i++) {
            var inPath = false;
            for (var j = 0; j < parent.length; j++) {
                if (parent[j] == currentVisible[i] || currentVisible[i] == currentItem) {
                    inPath = true;
                    break;
                }
            }
            if (!inPath) {
                $(currentVisible[i]).hide("fast");
                $(currentVisible[i]).prev().removeClass(options.selector_expanded + " " + options.selector_hover);
            }
        }
    });
    //Hover
    $("." + options.selector, menu).hover(
        function() {
            if ($(this).hasClass(options.selector_expanded))
                return;
            $(this).fadeOut("fast", function() {
                $(this).toggleClass(options.selector_hover);
                $(this).fadeIn("fast");
            })
        },
        function() {
            if ($(this).hasClass(options.selector_expanded))
                return;
            $(this).fadeOut("fast", function() {
                $(this).toggleClass(options.selector_hover);
                $(this).fadeIn("fast");
            })
        });
}
function center(item) {
    var pos = $(item).offset();
    pos.left = Math.max(0, ($(window).width() - $(item).width()) / 2);
    $(item).offset(pos);
}
//NEW DROOP DOWN MENU
//hoverIntent
(function($) {
    /* hoverIntent by Brian Cherne */
    $.fn.hoverIntent = function(f, g) {
        // default configuration options
        var cfg = {
            sensitivity: 7,
            interval: 100,
            timeout: 0
        };
        // override configuration options with user supplied object
        cfg = $.extend(cfg, g ? { over: f, out: g} : f);

        // instantiate variables
        // cX, cY = current X and Y position of mouse, updated by mousemove event
        // pX, pY = previous X and Y position of mouse, set by mouseover and polling interval
        var cX, cY, pX, pY;

        // A private function for getting mouse position
        var track = function(ev) {
            cX = ev.pageX;
            cY = ev.pageY;
        };

        // A private function for comparing current and previous mouse position
        var compare = function(ev, ob) {
            ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
            // compare mouse positions to see if they've crossed the threshold
            if ((Math.abs(pX - cX) + Math.abs(pY - cY)) < cfg.sensitivity) {
                $(ob).unbind("mousemove", track);
                // set hoverIntent state to true (so mouseOut can be called)
                ob.hoverIntent_s = 1;
                return cfg.over.apply(ob, [ev]);
            } else {
                // set previous coordinates for next time
                pX = cX; pY = cY;
                // use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
                ob.hoverIntent_t = setTimeout(function() { compare(ev, ob); }, cfg.interval);
            }
        };

        // A private function for delaying the mouseOut function
        var delay = function(ev, ob) {
            ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
            ob.hoverIntent_s = 0;
            return cfg.out.apply(ob, [ev]);
        };

        // A private function for handling mouse 'hovering'
        var handleHover = function(e) {
            // next three lines copied from jQuery.hover, ignore children onMouseOver/onMouseOut
            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; }

            // copy objects to be passed into t (required for event object to be passed in IE)
            var ev = jQuery.extend({}, e);
            var ob = this;

            // cancel hoverIntent timer if it exists
            if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); }

            // else e.type == "onmouseover"
            if (e.type == "mouseover") {
                // set "previous" X and Y position based on initial entry point
                pX = ev.pageX; pY = ev.pageY;
                // update "current" X and Y position based on mousemove
                $(ob).bind("mousemove", track);
                // start polling interval (self-calling timeout) to compare mouse coordinates over time
                if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout(function() { compare(ev, ob); }, cfg.interval); }

                // else e.type == "onmouseout"
            } else {
                // unbind expensive mousemove event
                $(ob).unbind("mousemove", track);
                // if hoverIntent state is true, then call the mouseOut function after the specified delay
                if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout(function() { delay(ev, ob); }, cfg.timeout); }
            }
        };

        // bind the function to the two event listeners
        return this.mouseover(handleHover).mouseout(handleHover);
    };

})(jQuery);








//dropdownmenu
; (function($) {
    $.fn.superfish = function(op) {

        var sf = $.fn.superfish,
			c = sf.c,
			$arrow = $(['<span class="', c.arrowClass, '"> &#187;</span>'].join('')),
			over = function() {
			    var $$ = $(this), menu = getMenu($$);
			    clearTimeout(menu.sfTimer);
			    $$.showSuperfishUl().siblings().hideSuperfishUl();
			},
			out = function() {
			    var $$ = $(this), menu = getMenu($$), o = sf.op;
			    clearTimeout(menu.sfTimer);
			    menu.sfTimer = setTimeout(function() {
			        o.retainPath = ($.inArray($$[0], o.$path) > -1);
			        $$.hideSuperfishUl();
			        if (o.$path.length && $$.parents(['li.', o.hoverClass].join('')).length < 1) { over.call(o.$path); }
			    }, o.delay);
			},
			getMenu = function($menu) {
			    var menu = $menu.parents(['ul.', c.menuClass, ':first'].join(''))[0];
			    sf.op = sf.o[menu.serial];
			    return menu;
			},
			addArrow = function($a) { $a.addClass(c.anchorClass).append($arrow.clone()); };

        return this.each(function() {
            var s = this.serial = sf.o.length;
            var o = $.extend({}, sf.defaults, op);
            o.$path = $('li.' + o.pathClass, this).slice(0, o.pathLevels).each(function() {
                $(this).addClass([o.hoverClass, c.bcClass].join(' '))
					.filter('li:has(ul)').removeClass(o.pathClass);
            });
            sf.o[s] = sf.op = o;

            $('li:has(ul)', this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over, out).each(function() {
                if (o.autoArrows) addArrow($('>a:first-child', this));
            })
			.not('.' + c.bcClass)
				.hideSuperfishUl();

            var $a = $('a', this);
            $a.each(function(i) {
                var $li = $a.eq(i).parents('li');
                $a.eq(i).focus(function() { over.call($li); }).blur(function() { out.call($li); });
            });
            o.onInit.call(this);

        }).each(function() {
            var menuClasses = [c.menuClass];
            if (sf.op.dropShadows && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass);
            $(this).addClass(menuClasses.join(' '));
        });
    };

    var sf = $.fn.superfish;
    sf.o = [];
    sf.op = {};
    sf.IE7fix = function() {
        var o = sf.op;
        if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity != undefined)
            this.toggleClass(sf.c.shadowClass + '-off');
    };
    sf.c = {
        bcClass: 'sf-breadcrumb',
        menuClass: 'sf-js-enabled',
        anchorClass: 'sf-with-ul',
        arrowClass: 'sf-sub-indicator',
        shadowClass: 'sf-shadow'
    };
    sf.defaults = {
        hoverClass: 'sfHover',
        pathClass: 'overideThisToUse',
        pathLevels: 1,
        delay: 800,
        animation: { opacity: 'show' },
        speed: 'normal',
        autoArrows: true,
        dropShadows: true,
        disableHI: false, 	// true disables hoverIntent detection
        onInit: function() { }, // callback functions
        onBeforeShow: function() { },
        onShow: function() { },
        onHide: function() { }
    };
    $.fn.extend({
        hideSuperfishUl: function() {
            var o = sf.op,
				not = (o.retainPath === true) ? o.$path : '';
            o.retainPath = false;
            var $ul = $(['li.', o.hoverClass].join(''), this).add(this).not(not).removeClass(o.hoverClass)
					.find('>ul').hide().css('visibility', 'hidden');
            o.onHide.call($ul);
            return this;
        },
        showSuperfishUl: function() {
            var o = sf.op,
				sh = sf.c.shadowClass + '-off',
				$ul = this.addClass(o.hoverClass)
					.find('>ul:hidden').css('visibility', 'visible');
            sf.IE7fix.call($ul);
            o.onBeforeShow.call($ul);
            $ul.animate(o.animation, o.speed, function() { sf.IE7fix.call($ul); o.onShow.call($ul); });
            return this;
        }
    });

})(jQuery);
//END NEW DROP DOWN

//EASY SLIDER
/*
* 	Easy Slider 1.5 - jQuery plugin
*	written by Alen Grakalic	
*	http://cssglobe.com/post/4004/easy-slider-15-the-easiest-jquery-plugin-for-sliding
*
*	Copyright (c) 2009 Alen Grakalic (http://cssglobe.com)
*	Dual licensed under the MIT (MIT-LICENSE.txt)
*	and GPL (GPL-LICENSE.txt) licenses.
*
*	Built for jQuery library
*	http://jquery.com
*
*/

/*
*	markup example for $("#slider").easySlider();
*	
* 	<div id="slider">
*		<ul>
*			<li><img src="images/01.jpg" alt="" /></li>
*			<li><img src="images/02.jpg" alt="" /></li>
*			<li><img src="images/03.jpg" alt="" /></li>
*			<li><img src="images/04.jpg" alt="" /></li>
*			<li><img src="images/05.jpg" alt="" /></li>
*		</ul>
*	</div>
*
*/

(function($) {

    $.fn.easySlider = function(options) {

        // default configuration properties
        var defaults = {
            prevId: 'prevBtn',
            prevText: 'Previous',
            nextId: 'nextBtn',
            nextText: 'Next',
            controlsShow: true,
            controlsBefore: '',
            controlsAfter: '',
            controlsFade: true,
            firstId: 'firstBtn',
            firstText: 'First',
            firstShow: false,
            lastId: 'lastBtn',
            lastText: 'Last',
            lastShow: false,
            vertical: false,
            speed: 800,
            auto: false,
            pause: 2000,
            continuous: false
        };

        var options = $.extend(defaults, options);

        this.each(function() {
            var obj = $(this);
            var s = $("li", obj).length;
            var w = $("li", obj).width();
            var h = $("li", obj).height();
            obj.width(w);
            obj.height(h);
            obj.css("overflow", "hidden");
            var ts = s - 1;
            var t = 0;
            $("ul", obj).css('width', s * w);
            if (!options.vertical) $("li", obj).css('float', 'left');

            if (options.controlsShow) {
                var html = options.controlsBefore;
                if (options.firstShow) html += '<span id="' + options.firstId + '"><a href=\"javascript:void(0);\">' + options.firstText + '</a></span>';
                html += ' <span id="' + options.prevId + '"><a href=\"javascript:void(0);\">' + options.prevText + '</a></span>';
                html += ' <span id="' + options.nextId + '"><a href=\"javascript:void(0);\">' + options.nextText + '</a></span>';
                if (options.lastShow) html += ' <span id="' + options.lastId + '"><a href=\"javascript:void(0);\">' + options.lastText + '</a></span>';
                html += options.controlsAfter;
                $(obj).after(html);
            };

            $("a", "#" + options.nextId).click(function() {
                animate("next", true);
            });
            $("a", "#" + options.prevId).click(function() {
                animate("prev", true);
            });
            $("a", "#" + options.firstId).click(function() {
                animate("first", true);
            });
            $("a", "#" + options.lastId).click(function() {
                animate("last", true);
            });

            function animate(dir, clicked) {
                var ot = t;
                switch (dir) {
                    case "next":
                        t = (ot >= ts) ? (options.continuous ? 0 : ts) : t + 1;
                        break;
                    case "prev":
                        t = (t <= 0) ? (options.continuous ? ts : 0) : t - 1;
                        break;
                    case "first":
                        t = 0;
                        break;
                    case "last":
                        t = ts;
                        break;
                    default:
                        break;
                };

                var diff = Math.abs(ot - t);
                var speed = diff * options.speed;
                if (!options.vertical) {
                    p = (t * w * -1);
                    $("ul", obj).animate(
						{ marginLeft: p },
						speed
					);
                } else {
                    p = (t * h * -1);
                    $("ul", obj).animate(
						{ marginTop: p },
						speed
					);
                };

                if (!options.continuous && options.controlsFade) {
                    if (t == ts) {
                        $("a", "#" + options.nextId).hide();
                        $("a", "#" + options.lastId).hide();
                    } else {
                        $("a", "#" + options.nextId).show();
                        $("a", "#" + options.lastId).show();
                    };
                    if (t == 0) {
                        $("a", "#" + options.prevId).hide();
                        $("a", "#" + options.firstId).hide();
                    } else {
                        $("a", "#" + options.prevId).show();
                        $("a", "#" + options.firstId).show();
                    };
                };

                if (clicked) clearTimeout(timeout);
                if (options.auto && dir == "next" && !clicked) {
                    ;
                    timeout = setTimeout(function() {
                        animate("next", false);
                    }, diff * options.speed + options.pause);
                };

            };
            // init
            var timeout;
            if (options.auto) {
                ;
                timeout = setTimeout(function() {
                    animate("next", false);
                }, options.pause);
            };

            if (!options.continuous && options.controlsFade) {
                $("a", "#" + options.prevId).hide();
                $("a", "#" + options.firstId).hide();
            };

        });

    };

})(jQuery);

//END EASYSLIDER

//BEGIN SCROLL TO
; (function(d) { var k = d.scrollTo = function(a, i, e) { d(window).scrollTo(a, i, e) }; k.defaults = { axis: 'xy', duration: parseFloat(d.fn.jquery) >= 1.3 ? 0 : 1 }; k.window = function(a) { return d(window)._scrollable() }; d.fn._scrollable = function() { return this.map(function() { var a = this, i = !a.nodeName || d.inArray(a.nodeName.toLowerCase(), ['iframe', '#document', 'html', 'body']) != -1; if (!i) return a; var e = (a.contentWindow || a).document || a.ownerDocument || a; return d.browser.safari || e.compatMode == 'BackCompat' ? e.body : e.documentElement }) }; d.fn.scrollTo = function(n, j, b) { if (typeof j == 'object') { b = j; j = 0 } if (typeof b == 'function') b = { onAfter: b }; if (n == 'max') n = 9e9; b = d.extend({}, k.defaults, b); j = j || b.speed || b.duration; b.queue = b.queue && b.axis.length > 1; if (b.queue) j /= 2; b.offset = p(b.offset); b.over = p(b.over); return this._scrollable().each(function() { var q = this, r = d(q), f = n, s, g = {}, u = r.is('html,body'); switch (typeof f) { case 'number': case 'string': if (/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)) { f = p(f); break } f = d(f, this); case 'object': if (f.is || f.style) s = (f = d(f)).offset() } d.each(b.axis.split(''), function(a, i) { var e = i == 'x' ? 'Left' : 'Top', h = e.toLowerCase(), c = 'scroll' + e, l = q[c], m = k.max(q, i); if (s) { g[c] = s[h] + (u ? 0 : l - r.offset()[h]); if (b.margin) { g[c] -= parseInt(f.css('margin' + e)) || 0; g[c] -= parseInt(f.css('border' + e + 'Width')) || 0 } g[c] += b.offset[h] || 0; if (b.over[h]) g[c] += f[i == 'x' ? 'width' : 'height']() * b.over[h] } else { var o = f[h]; g[c] = o.slice && o.slice(-1) == '%' ? parseFloat(o) / 100 * m : o } if (/^\d+$/.test(g[c])) g[c] = g[c] <= 0 ? 0 : Math.min(g[c], m); if (!a && b.queue) { if (l != g[c]) t(b.onAfterFirst); delete g[c] } }); t(b.onAfter); function t(a) { r.animate(g, j, b.easing, a && function() { a.call(this, n, b) }) } }).end() }; k.max = function(a, i) { var e = i == 'x' ? 'Width' : 'Height', h = 'scroll' + e; if (!d(a).is('html,body')) return a[h] - d(a)[e.toLowerCase()](); var c = 'client' + e, l = a.ownerDocument.documentElement, m = a.ownerDocument.body; return Math.max(l[h], m[h]) - Math.min(l[c], m[c]) }; function p(a) { return typeof a == 'object' ? a : { top: a, left: a} } })(jQuery);
//END SCROLL TO

//BEGIN WATERMARK
//END WATERMARK

//BEGIN DATEPICKER SPANISH CONFIGURATION
jQuery(function($) {
    $.datepicker.regional['es'] = {
        closeText: 'Cerrar',
        prevText: '&#x3c;Ant',
        nextText: 'Sig&#x3e;',
        currentText: 'Hoy',
        monthNames: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio',
		'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
        monthNamesShort: ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun',
		'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'],
        dayNames: ['Domingo', 'Lunes', 'Martes', 'Mi&eacute;rcoles', 'Jueves', 'Viernes', 'S&aacute;bado'],
        dayNamesShort: ['Dom', 'Lun', 'Mar', 'Mi&eacute;', 'Juv', 'Vie', 'S&aacute;b'],
        dayNamesMin: ['Do', 'Lu', 'Ma', 'Mi', 'Ju', 'Vi', 'S&aacute;'],
        weekHeader: 'Sm',
        dateFormat: 'dd/mm/yy',
        firstDay: 1,
        isRTL: false,
        showMonthAfterYear: false,
        yearSuffix: ''
    };
    $.datepicker.setDefaults($.datepicker.regional['es']);
});
//END DATEPICKER SPANISH CONFIGURATION

//standard hotel filter
function ciSel(event) {
    var cITCal = $(event._textbox._element).attr("CalendarBehavior");
    var COTTBox = $(event._textbox._element).parent().parent().find("#checkOut .text");
    var cOTCal = $(event._textbox._element).parent().parent().find("#checkOut .text").attr("CalendarBehavior");
    var ciDate = new Date(cITCal._selectedDate);
    var coDate = new Date(cOTCal._selectedDate);
    if (coDate.getTime() <= ciDate.getTime() + (24 * 60 * 60 * 1000)) {
        var newDate = new Date(ciDate.getTime() + (2 * 24 * 60 * 60 * 1000));
        cOTCal.set_selectedDate(newDate);
    }
}

function visibleRoom(filter) {
    var number = $("select", filter).get(0).value;
    var r = $(".room", filter);
    var num = Math.min(number, 3);
    for (var i = num; i < 3; i++)
        $(r[i]).hide(300);
    for (var i = 0; i < num; i++)
        $(r[i]).show(300);
}
function visibleAge(childCombo) {
    var childNumber = childCombo.value;
    var childDiv = $(childCombo).parent().parent().find("div.ageBlock");
    var childLabel = $(childCombo).parent().parent().find("div.ageBlock > .ninos");

    if (childNumber == 0)
        childDiv.hide();
    else
        childDiv.show();
    for (var j = 0; j < childNumber; j++)
        $(childLabel.get(j)).fadeIn();
    for (var j = childNumber; j < 3; j++)
        $(childLabel.get(j)).hide();
    //Force fieldset to resize
    var fieldSet = $(childCombo).parent().parent().parent().parent();
    fieldSet.resize();
}

function initHotFilter(filter) {
    visibleRoom(filter);
    var roomCombo = $("select", filter).get(0);
    $(roomCombo).change(function(event) {
        visibleRoom(filter);
    });
    $("div.room", filter).each(function() {
        var childCombo = $("select.combo", this).get(1);
        visibleAge(childCombo);
        $(childCombo).change(function(event) {
            visibleAge(childCombo);
        });
    });
}

function hotSummaryImgHoverIn() {
    var contDiv = $(this).next();
    var hField = contDiv.children().first();
    var img = hField.next();
    img.attr("src", hField.val());
    contDiv.fadeIn("slow");

}
function hotSummaryImgHoverOut() {
    var contDiv = $(this).next();
    contDiv.fadeOut("slow");
}
function initImageHover(divName) {
    var o = $(divName);
    $(divName).hover(hotSummaryImgHoverIn, hotSummaryImgHoverOut);
}

/*jquery ui date pickers*/
function initCalendars(checkInSel, checkOutSel, minCheckIn, minStay) {
    var mCI = new Date().getTime() + 1000 * 24 * 3600 * minCheckIn; //Min allowed checkIn value
    var mS = 1000 * 24 * 3600 * minStay;    //Min Stay allowed value
    $(checkOutSel).datepicker(
        {
            constrainInput: true,
            changeMonth: true,
            monthNamesShort: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
            minDate: new Date(mCI + mS)
        }
    );
    $(checkInSel).datepicker(
        {
            constrainInput: true,
            changeMonth: true,
            monthNamesShort: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
            minDate: new Date(mCI),
            onSelect: function(selectedDate) {
            var checkInDate = $(this).datepicker("getDate");
                var checkOutDate = $(checkOutSel).datepicker("getDate");
                var minCheckout = new Date();
                minCheckout.setTime(checkInDate.getTime() + mS);
                if (checkOutDate.getTime() - checkInDate.getTime() < mS) {
                    checkOutDate.setTime(minCheckout.getTime());
                    $(checkOutSel).datepicker("setDate", checkOutDate);
                }
                $(checkOutSel).datepicker("option", "minDate", new Date(checkInDate.getTime() + mS));
            }
        }
    );
}

/*jquery autocomplete*/
function initAutoComplete(field, endpoint, treeID, langID, valueHolder) {
    $(field).autocomplete({
        source: function(request, response) {
            $.getJSON(
                endpoint,
                {
                    tID: treeID,
                    lID: langID,
                    maxRows: 12,
                    startsWith: request.term
                },
                function(data) {
                    response(data.d);
                }
            );
        },
        select: function(event, ui) {
            if (ui.item != null)
                $(valueHolder).val(ui.item.destID);
        }
    });
}

