function MM_swapImgRestore() { //v3.0
    var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}
function MM_preloadImages() { //v3.0
    var d = document; if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++)
            if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; } 
    }
}

function MM_findObj(n, d) { //v4.01
    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
    var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
        if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
}



/*overstate*/
$(document).ready(function() {
    $(".menuoverstate").each(function(i) {

        preload_image = new Image();
        preload_image.src = this.src.replace(".jpg", "_o.jpg");

        $(this).hover(
            function() {
                if (this.src.indexOf("_o.jpg") == -1) {
                    this.src = this.src.replace(".jpg", "_o.jpg");
                }

            },

            function() {
                this.src = this.src.replace("_o.jpg", ".jpg");

            });

    }
        );
    $(".menuoverstate-png").each(function(i) {

        preload_image = new Image();
        preload_image.src = this.src.replace(".png", "_o.png");

        $(this).hover(
            function() {
                if (this.src.indexOf("_o.png" == -1)) {
                    this.src = this.src.replace(".png", "_o.png");
                }

            },

            function() {
                this.src = this.src.replace("_o.png", ".png");

            });

    }
        );
    $(".menuoverstate-ql").each(function(i) {

        $(this).hover(
            function() {
                $(this).stop().animate({ opacity: 0.5 }, "fast");
                $(this).children(".overstate").each(function(i) {
                    preload_image = new Image();
                    preload_image.src = this.src.replace(".jpg", "_o.jpg");
                    if (this.src.indexOf("_o.jpg") == -1) {
                        this.src = this.src.replace(".jpg", "_o.jpg");
                    }
                });

            },
            function() {
                $(this).stop().animate({ opacity: 1.0 }, "fast");
                $(this).children(".overstate").each(function(i) {
                    preload_image = new Image();
                    preload_image.src = this.src.replace(".jpg", "_o.jpg");
                    this.src = this.src.replace("_o.jpg", ".jpg");
                });
            }
        );
    });
});
$(document).ready(function () {
    $('.calendar-day').each(function () {
        try {
            if ($(this).html() == document.getElementById('ctl00_cphRight_hdnSelectedDate').value.substring(0, 2)) {
                $(this).addClass("selected");

                var stringSplit = $(this).attr("onclick").toString().split(',');
                for (var i = 2; i < stringSplit.length; i++) {
                    if (i == stringSplit.length - 1) {
                        stringSplit[i] = jQuery.trim(stringSplit[i].substring(0, 4));
                    }
                    else {
                        stringSplit[i] = jQuery.trim(stringSplit[i]);
                    }
                }
                stringSplit[0] = '';
                var year = stringSplit[1];
                stringSplit[1] = '';
                /* This is held on controls/calendar.ascx as it needs aspx input */
                changeSelected($(this), year.replace(/\"/g, "").trim(), stringSplit);
            }
        }
        catch (e) { }

    });
});
/*hidden text with images*/
$(document).ready(function () {


    $(".hidden-content").hide();

    $("#[class^=nav_]").toggle(function () {
        $(this).removeClass("active");
        $(this).removeClass("active_title");
        $(this).children().each(function () {
            if ($(this).hasClass("active"))
                $(this).removeClass("active");
            $(this).removeClass("active_title");
        });
    }, function () {
        $(this).addClass("active");
        $(this).addClass("active_title");
        $(this).children().each(function () {
            $(this).addClass("active");
            $(this).addClass("active_title");
        });
    });

    $("#[class^=nav_]").click(function () {
        $(this).next(".hidden-content").slideToggle("slow");
    });

    $("#[class^=navt]").toggle(function () {
        $(this).removeClass("active_title");
        $(this).children().each(function () {
            $(this).removeClass("active_title");
        });
    }, function () {
        $(this).addClass("active_title");
        $(this).children().each(function () {
            $(this).addClass("active_title");
        });
    });

    $("#[class^=navt]").click(function () {
        $(this).next(".hidden-content").slideToggle("slow");
    });
});

/*overstate thumbs*/
$(document).ready(function() {
    $(".gallery-thumbs img").css("opacity", "1.0");
    $(".gallery-thumbs img").hover(function() {
        $(this).stop().animate({ opacity: 0.5 }, "fast");
    },

        function() {
            $(this).stop().animate({ opacity: 1.0 }, "fast");
        });
});

/*overstate recommend*/
$(document).ready(function() {
    //$("a img").css("opacity", "1.0");
    $("a img").hover(function() {
        if (!$(this).is('.slider-img') && !$(this).is('#weKnowImg')) {
            $(this).stop().animate({ opacity: 0.5 }, "fast");
        }
    },

        function() {
            if (!$(this).is('.slider-img') && !$(this).is('#weKnowImg')) {
                $(this).stop().animate({ opacity: 1.0 }, "fast");
            }
        });

    //$(".fader").css("opacity", "1.0");
    $(".fader").hover(function() {
        $(this).stop().animate({ opacity: 0.5 }, "fast");
    },

    function() {
        $(this).stop().animate({ opacity: 1.0 }, "fast");
    });
});

/*hidden text*/
/*hidden text with images*/
$(document).ready(function() {


    $(".hidden-content").hide();

    $(".title-hide").toggle(function() {
        $(this).addClass("active");
    }, function() {
        $(this).removeClass("active");
    });

    $(".title-hide").click(function() {
        $(this).next(".hidden-content").slideToggle("slow");
    });
});

$(document).ready(function() {
    var toggleStatus = [];
    var contents = [];
    $("#tab-wrapper").children().each(function(i) {
        contents[i] = $(this);
    });

    $(".tab-top-wrapper").children().each(function(i) {
        toggleStatus[i] = false;
        jQuery(this).click(function() {
            if (toggleStatus[i] == false) {
                for (j = 0; j < toggleStatus.length; j++) {
                    toggleStatus[j] = false;
                    $(contents[j]).hide();
                    $(".tab-top-wrapper").children().removeClass("current");
                }

                $(this).addClass("current");
                toggleStatus[i] = true;
                $(contents[i]).show();
            }
        });
    });

    var innerToggleStatus = [];
    var innerContents = [];
    $("#inner-tab-wrapper").children().each(function(i) {
    innerContents[i] = $(this);
    });

    $(".inner-tab-top-wrapper").children().each(function(i) {
    innerToggleStatus[i] = false;
        jQuery(this).click(function() {
        if (innerToggleStatus[i] == false) {
            for (j = 0; j < innerToggleStatus.length; j++) {
                innerToggleStatus[j] = false;
                $(innerContents[j]).hide();
                    $(".inner-tab-top-wrapper").children().removeClass("current");
                }

                $(this).addClass("current");
                innerToggleStatus[i] = true;
                $(innerContents[i]).show();
            }
        });
    });

    var accommToggleStatus = [];
    var accommContents = [];
    $("#accomm-tab-wrapper").children().each(function(i) {
        accommContents[i] = $(this);
    });

    $(".accomm-tab-top-wrapper").children().each(function(i) {
    accommToggleStatus[i] = false;
        jQuery(this).click(function() {
        if (accommToggleStatus[i] == false) {
            for (j = 0; j < accommToggleStatus.length; j++) {
                accommToggleStatus[j] = false;
                $(accommContents[j]).hide();
                $(".accomm-tab-top-wrapper").children().removeClass("current");
                }

                $(this).addClass("current");
                accommToggleStatus[i] = true;
                $(accommContents[i]).show();
            }
        });
    });
});

var slidey;
var id;
$(document).ready(function() {

    $(".winter-pack").each(function() {


        $(this).hover(function() {
            slidey = $(this).find(".slideshow");
            id = setInterval("slideSwitch()", 2000);

        }, function() { clearInterval(id);});

    });
    $(".summer-pack").each(function() {

        $(this).hover(function() {
            slidey = $(this).find(".slideshow");
            id = setInterval("slideSwitch()", 2000);


        }, function() { clearInterval(id) });

    });
    $(".slideshow-expert").each(function() {
        var ss = this;
        setInterval(function() {
            var active = $(ss).find('.active');
            var next = $(ss).find('.inactive');


            $(next).css({ opacity: 0.0 })
                .addClass('active')
                .animate({ opacity: 1.0 }, 500, function() {
                    $(active).removeClass('active');
                });
            $(next).removeClass('inactive').addClass('active');
            $(active).addClass('inactive');

        }, 5000);
    });


    jQuery('#trip-slideshow').cycle({
        fx: 'fade',
        timeout: '7000',
        pager: '#trip-nav',
        pagerAnchorBuilder: function(idx, slide) {
            // return selector string for existing anchor
            return '#trip-nav li:eq(' + idx + ') a';
        }
    });
});

function slideSwitch() {
    var $active = $(slidey).children('IMG.active');
    if ($active.length == 0) $active = $(slidey).children('IMG:last');

    var $next = $active.next().length ? $active.next()
                : $(slidey).children('IMG:first');

    $active.addClass('last-active');

    $next.css({ opacity: 0.0 })
                .addClass('active')
                .animate({ opacity: 1.0 }, 500, function() {
                    $active.removeClass('active last-active');
                });
}

function changeLargeThumbPNG(source, alt, id) {
    document.getElementById(id).src = source.replace("_t.png", ".png");
    document.getElementById(id).alt = alt;
}
