﻿$(function () {
    //Global variables
    IE6 = ($.browser.msie && $.browser.version == '6.0') ? true : false;
    IE7 = ($.browser.msie && $.browser.version == '7.0') ? true : false;
    SAFARI = ($.browser.safari) ? true : false;
    for (var i in $.browser) {
        if ($.browser[i])
            BROWSER = i + (($.browser.msie) ? $.browser.version.charAt(0) : '');
    }


    $('form').initializeForm();
    slideShow(5000);
    $("#accordion").accordion({ autoHeight: false, active: false, icons: false, animated: 'bounceslide' });

    // toggles the slickbox on clicking the noted link
   

});
(function ($) {
    $.fn.initializeForm = function () {
        return this.each(function () {
            var form = $(this);

            if (IE6) {
                $(".textfield")
					.focus(function () { $(this).css({ backgroundColor: "#fdfcfa" }); })
					.blur(function () { $(this).css({ backgroundColor: "#ffffff" }); });
            }

            $("#main_menu li")
                .mouseover(function() { $(this).css({ backgroundColor: "#EDE7D6" }); })
                .mouseout(function() { $(this).css({ backgroundColor: "" }); });
            

            $("#tblTools a").click(function(){ 
                if(this.href.indexOf('Photo')>-1)
                {
                    return true;
                }
                if(this.href.indexOf('Entertainment')>-1)
                {
                    return true;
                }
                 if(this.href.indexOf('About')>-1)
                {
                    return true;
                }
                $("#toolsLoader").load(this.href,function(){                
                    $(this).slideDown("slow"); 
               }); 
                return false; 
            }); 

            $(".date-picker", form).each(function () {
                $(this).datepicker({
                    duration: "",
                    showOn: "both",
                    beforeShow: setDatePicker,
                    hideIfNoPrevNext: true,
                    buttonImage: "images/calendar_03.gif",
                    buttonImageOnly: true
                });

                if ($(this).val() == 'mm/dd/yyyy')
                    $(this).val('');
                else {
                    if ($(this).hasClass('date-end') && $(this).hasClass('update-blocks'))
                        getRange();
                }
            }).attr("readonly", "readonly");

            
              $(".wedding-date").datepicker({
                    duration: "",
                    minDate: new Date()
                }).attr("readonly", "readonly");

                $(".rfp-date").datepicker({
                    duration: "",
                    minDate: new Date()
                }).attr("readonly", "readonly");

            function setDatePicker(input) {
                if (($(input).hasClass('date-begin') || $(input).hasClass('date-end')) && $(input).hasClass('update-blocks')) {
                    return {
                        minDate: ($(input).hasClass('date-end') ? ($(".date-begin", $(input).parent().prev()).datepicker("getDate") ? $(".date-begin", $(input).parent().prev()).datepicker("getDate") : new Date()) : new Date()),
                        maxDate: ($(input).hasClass('date-begin') ? $(".date-end", $(input).parent().next()).datepicker("getDate") : null),
                        onClose: getRange
                    };
                } else {
                    return {
                        minDate: ($(input).hasClass('date-end') ? ($(".date-begin", $(input).parent().prev()).datepicker("getDate") ? $(".date-begin", $(input).parent().prev()).datepicker("getDate") : new Date()) : new Date()),
                        maxDate: ($(input).hasClass('date-begin') ? $(".date-end", $(input).parent().next()).datepicker("getDate") : null)
                    };
                }
            }

            function getRange() {
                var start = $(".date-begin", form).datepicker("getDate");
                var end = $(".date-end", form).datepicker("getDate");

                if (start && end) {
                    var one_day = 1000 * 60 * 60 * 24;
                    var days = Math.ceil((end.getTime() - start.getTime()) / (one_day))
                    createBlock(start, days, form);
                    createMeeting(start, days, form);
                }
            }
            // hide all "other" fields
            $("ul.checkboxgroup input.other", form).not(':radio, :checkbox').hide();
            $("ul.checkboxgroup input:not(:text)", form).click(function () {
                if ($(this).hasClass('other')) {
                    $(this).siblings().addClass('required').show();
                    if (!$(this).is(':checked')) {
                        $('.validation-error', $(this).parents('ul')).removeError(form);
                        $(this).siblings().removeClass('required').filter(':text').hide();
                    }
                } else if ($(this).is(':radio')) {
                    $('.validation-error', $(this).parents('ul')).removeError(form);
                    $('.other', $(this).parents('ul')).siblings().removeClass('required').filter(':text').hide();
                }
            });

            $("div.select-other", form).hide();
            // if "Other" is selected, then show it's "other" field
            $("select.select-other", form).change(function () {
                var el = $(this).parent().next()
                if ($(this).val() == "--") {
                    el.show().children('label, input').addClass("required");
                } else {
                    el.hide().children().removeClass("required").find("input").val("");
                    $('.validation-error', el).removeError(form);
                }
            });
        });
    };

   
})(jQuery);



 function slideShow(speed) {


            //append a LI item to the UL list for displaying caption
            $('ul.slideshow').append('<li id="slideshow-caption" class="caption"><div class="slideshow-caption-container"><h3></h3><p></p></div></li>');

            //Set the opacity of all images to 0
            $('ul.slideshow li').css({ opacity: 0.0 });

            //Get the first image and display it (set it to full opacity)
            $('ul.slideshow li:first').css({ opacity: 1.0 });

            //Get the caption of the first image from REL attribute and display it
            $('#slideshow-caption h3').html($('ul.slideshow a:first').find('img').attr('title'));
            $('#slideshow-caption p').html($('ul.slideshow a:first').find('img').attr('alt'));

            //Display the caption
            $('#slideshow-caption').css({ opacity: 0.7, bottom: 0 });

            //Call the gallery function to run the slideshow	
            var timer = setInterval('gallery()', speed);

            //pause the slideshow on mouse over
            $('ul.slideshow').hover(
		function () {
		    clearInterval(timer);
		},
		function () {
		    timer = setInterval('gallery()', speed);
		}
	);

        }

        function gallery() {


            //if no IMGs have the show class, grab the first image
            var current = ($('ul.slideshow li.show') ? $('ul.slideshow li.show') : $('#ul.slideshow li:first'));

            //Get next image, if it reached the end of the slideshow, rotate it back to the first image
            var next = ((current.next().length) ? ((current.next().attr('id') == 'slideshow-caption') ? $('ul.slideshow li:first') : current.next()) : $('ul.slideshow li:first'));

            //Get next image caption
            var title = next.find('img').attr('title');
            var desc = next.find('img').attr('alt');

            //Set the fade in effect for the next image, show class has higher z-index
            next.css({ opacity: 0.0 }).addClass('show').animate({ opacity: 1.0 }, 1000);

            //Hide the caption first, and then set and display the caption
            $('#slideshow-caption').animate({ bottom: -70 }, 300, function () {
                //Display the content
                $('#slideshow-caption h3').html(title);
                $('#slideshow-caption p').html(desc);
                $('#slideshow-caption').animate({ bottom: 0 }, 500);
            });

            //Hide the current image
            current.animate({ opacity: 0.0 }, 1000).removeClass('show');

        }

        function showdetail(a,b) {
            $('#' + a).slideToggle(100);
            if ($('#' + b + '>b').html() == "Hide Details")
                $('#' + b + '>b').html("Show Details");
            else
                $('#' + b + '>b').html("Hide Details");

            //alert(a);


        }