jQuery(document).ready(function(){
    var events = new PhotoGallery({
        wrapper : "#receptions",
        nextText: "&gt;",
        prevText: "&lt;",
        picDelay: 7000
    });

    jQuery("#home-banners #receptions li:first-child").addClass("active");
    var opened=jQuery("#home-banners li.opened");
    opened.find("div.info").show();
    var currentHeight = opened.height();
    opened.css('height', 'auto');
    var height = opened.height();
    opened.css('height', currentHeight + 'px');

    opened.animate({'height': height});


    homeCallouts();
    var showHomeVideo = new ShowHomeVideo;
});

function homeCallouts() {
    jQuery("#home-banners li.expand").bind({
        mouseenter: function(){
            var element = jQuery(this);

            element.find("div.info").show();
            var currentHeight = element.height();
            element.css('height', 'auto');
            var height = element.height();
            element.css('height', currentHeight + 'px');

            element.animate({'height': height});

       /*     element.stop();
            element.animate({height: "165px"}, 200, function(){
                element.find("p.info").show();
            });*/
        },
        mouseleave: function(){
            var element = jQuery(this);
            element.stop();
            element.find("div.info").hide();
            element.animate({height: "78px"}, 400);
        }
    });
}

function ShowHomeVideo() {
    this._body = jQuery("body");
    this.showBtn = jQuery("#view-movie");
    this.player = jQuery("#welcome-video")
    this.closeBtn = jQuery("#close-video");
    var _this = this;

    this.init = function() {
        _this.bindEvents();
        _this.showFirstTimeVideo();
    }

    this.bindEvents = function() {
        _this.showBtn.bind({
            click: function() {
                _this.showVideo();
            }
        });

        _this.closeBtn.bind({
            click: function() {
                _this.hideVideo();
            }
        });
    };

/*    this.showFirstTimeVideo = function() {
        if ("true" != _this.getCookie("home_video")) {
            _this.setCookie("home_video", "true", 210);
            _this.showVideo();
        }
    };*/

    this.showVideo = function() {
        _this.player.fadeIn(300)
        _this._body.addClass("showing-video");
        _this.showBtn.css("opacity", 0.5);
    };

    this.hideVideo = function() {
        _this.player.fadeOut(300)
        _this._body.removeClass("showing-video");
        _this.showBtn.css("opacity", 1);
    };

    this.getCookie = function(c_name) {
        var i,x,y,ARRcookies=document.cookie.split(";");
        for (i=0;i<ARRcookies.length;i++) {
            x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
            y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
            x=x.replace(/^\s+|\s+$/g,"");
            if (x==c_name) {
                return unescape(y);
            }
        }
    };

    this.setCookie = function(c_name,value,exdays) {
        var exdate=new Date();
        exdate.setDate(exdate.getDate() + exdays);
        var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
        document.cookie=c_name + "=" + c_value;
    };

    this.init();
}
