﻿$(document).ready(function () {

    $(".sideNav ul li a").live('click', function () {
        $(".sideNav ul li a.sub_selected").removeClass('sub_selected');
        $(this).addClass('sub_selected');
    });

    $(".sideNav ul li ul li:first a").addClass('sub_selected');

    // Registers the YouTube API. This is boilerplate taken from http://code.google.com/apis/youtube/iframe_api_reference.html

    /*var tag = document.createElement('script');
    tag.src = "http://www.youtube.com/player_api";
    var firstScriptTag = document.getElementsByTagName('script')[0];
    firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);*/

    var hostname = location.hostname;
    var port = location.hostname == "localhost" ? ":" + location.port : "";
    var host = location.protocol + "//" + hostname + port;

    $('.main_carousel .carouselImages').each(function (n) {
        var _ob = $(this);
        $('img', _ob).each(function (i) {

            //var host = 'http://localhost:49639';
            var ob = $(this);
            var new_image_container = ob.parent().parent();
            var clone = ob.clone();
            var outter = $('<p></p>').append(clone);
            var inner = outter.html();
            var src = host + ob.attr('src') + '?w=900';
            var replace = '<a href="#inline' + n + i + '" rel="fancybox-thumb_' + n + '" class="various">' + inner + '</a>';
            var new_image = $(inner);
            new_image.attr('src', src).attr('id', 'inline' + n + i);
            new_image.removeAttr('width');
            new_image.removeAttr('height');
            new_image_container.append(new_image);
            ob.replaceWith(replace);
        });
    });

    //Check if it's an old version of IE
    var isOldIE = false;
    if ($.browser.msie && $.browser.version.substr(0, 1) < 8) {
        isOldIE = true;
        $('body').addClass("isOldIE");
    }

    //Dropdown on homepage
    $('#homepageRight .dropDown').hover(function () {
        $('.dropDownHidden', this).show();
    }, function () {
        $('.dropDownHidden', this).hide();
    });

    //Dropdown in header
    $('#selectYotel').hover(function () {
        $('.hidden', this).show();
    }, function () {
        $('.hidden', this).hide();
    });

    //
    $('.sideNav .dropDown').hover(function () {
        $(this).addClass('dropDownShow');
    }, function () {
        $(this).removeClass('dropDownShow');
    });

    //Social Media bar
    var socialMedShow = false;

    if ($('#socialmed').hasClass('expanded')) {
        socialMedShow = true;
    }

    $('h3', '#socialmed').click(function () {
        if (socialMedShow) {
            $('#socialmed').removeClass('expanded').removeClass('showing');
            $('.contentContainer', '#socialmed').show().slideUp();
            socialMedShow = false;
        }
        else {
            $('.contentContainer', '#socialmed').slideDown();
            $('#socialmed').addClass('showing');
            socialMedShow = true;
        }
        return false;
    });

    $('.close', '#socialmed').click(function () {
        if (socialMedShow) {
            $('#socialmed').removeClass('expanded').removeClass('showing');
            $('.contentContainer', '#socialmed').show().slideUp();
            socialMedShow = false;
        }
        else {
            $('.contentContainer', '#socialmed').slideDown();
            $('#socialmed').addClass('showing');
            socialMedShow = true;
        }
        return false;
    });

    //image dropdown
    $('#selectYotelInner').hover(function () {
        $('.dropdown', this).show();
    }, function () {
        $('.dropdown', this).hide();
    });

    if ($('.imagecontainer').length > 0 || $('.faqcontainer').length > 0) {
        $('#selectYotelInner a').click(function () {
            $('#selectYotelInner span').text($(this).text());
            $('.dropdown', '#selectYotelInner').hide();
            $('.imagecontainer').hide().eq($(this).index()).show();
            $('.faqcontainer').hide().eq($(this).index()).show();
            return false;
        });
    }

    $('.imagecontainer').each(function () {

        var ob = $(this);
        var carousel = $('.carousel', ob);
        var _next = $('a.next', carousel.next());
        var _prev = $('a.prev', carousel.next());
        var _pager = $('span.pagination', carousel.next());

        carousel.cycle({

            fx: 'scrollHorz',
            speed: 400,
            timeout: 0,
            next: _next,
            prev: _prev,
            pager: _pager

        }).cycle('pause');

        //Hide pagination if there's only one image
        if (carousel.children('.carouselPage').length < 2) {
            $('span.pagination, .next, .prev', this).hide();
        }

    });

    $('.imagecontainer').hide().css("visibility", "visible");
    $('.imagecontainer:first').show();

    $('.faqcontainer').hide();
    $('.faqcontainer:first').show().css({ 'visibility': 'visible' });

    $('.resultsContainer .result').hover(function () {
        $('.hoverResult').removeClass('hoverResult');
        $(this).addClass('hoverResult');
    },
    function () {
        //do Nothing
    });

    //set height of scrollContainer on page load
    scrollInit();

    //reset height of scrollContainer when page resized
    $(window).resize(function () {
        scrollInit();
    });

    $('.scrollSection').each(function (i) {
        $(this).attr('ref', 'ref' + i);
    });

    $('.scrollSection').appendTo('body');
    $('.scrollSection:first').appendTo('#scrollContent').show();

    $('.sideNav ul li a:not(".remoteContent")').live('click', function () {

        $("#remoteContentContainer").hide();
        $("#scrollContainer").show();

        $('.carouselImages').cycle('pause');
        var index = 0;
        var ob = $(this);
        var key;
        var items = $('.sideNav ul li ul li a').not("a.remoteContent").parent();
        $(items).each(function (idx, item) {
            if ($(item).html() == $(ob.parent()).html()) {
                key = idx;
            }
        });
        var relatedContent = $('.scrollSection[ref=ref' + key + ']');
        $('#scrollContent .scrollSection').fadeOut(200).appendTo('body');
        relatedContent.appendTo('#scrollContent').fadeIn(600);
        $('.carouselText', relatedContent).show();
        $('.carouselImages', relatedContent).cycle('resume');
        $("#pause").removeClass('paused');

    });

    $('.sideNav ul li a.remoteContent').live('click', function (e) {
        var fetchURL = $(this).attr("href").replace(/ /g, "-");
        $("#remoteContentContainer").load(fetchURL + " #hotelContentContainer");
        $("#scrollContainer").hide();
        $("#remoteContentContainer").show();
        e.preventDefault();
    });

    //Date picker - airport booking page
    if ($("#bookContainer .checkInDate, #bookContainer .checkOutDate").length) {
        var calendarDates = $("#bookContainer .datePicker").datepicker({
            numberOfMonths: 2,
            dateFormat: 'dd M, yy',
            buttonImage: '/images/calendar_icon.gif',
            buttonImageOnly: true,
            buttonText: '',
            showOn: 'both',
            minDate: 0
        });
    }


    //Date picker - airport Side widget
    if ($(".calendarWidget .datePicker").length) {
        var calendarDates = $(".calendarWidget .datePicker").datepicker({
            numberOfMonths: 1,
            dateFormat: 'dd M, yy',
            buttonImage: '/images/calendar_icon2.gif',
            buttonImageOnly: true,
            buttonText: '',
            showOn: 'both',
            minDate: 0
        });
    }

    //Commented out, UI between city and airport should look the same
    //Date picker - city booking page
    //    if ($("#bookContainer .datePicker").not(".checkInDate").length) {
    //        var calendarDates = $("#bookContainer .datePicker").datepicker({
    //            numberOfMonths: 2,
    //            dateFormat: 'dd M, yy',
    //            buttonImage: '/images/calendar_icon.gif',
    //            buttonImageOnly: true,
    //            showOn: 'both',
    //            minDate: 0,
    //            onClose: function (dateText, inst) {
    //                isFormatValid = validateDateCalendarsFormat(dateText, inst);
    //                isRangeValid = validateDateCalendarsRange(dateText, inst);
    //            }
    //        });
    //    }
    $(".city .checkInDate,.city .checkOutDate").change(function (e) {
        //var Date.parse

        var checkInDateTime = getSelectedDateTimeCity("checkIn");
        var checkOutDateTime = getSelectedDateTimeCity("checkOut");
        var hoursDiff = differenceInHours(checkInDateTime, checkOutDateTime);

        // If the visitor has selected a check in time which is after the check out time
        // then we need to set the check out time as being the check-in time + 1 day

        if (checkOutDateTime <= checkInDateTime) {

            var correctCheckOutTime = new Date(new Date(checkInDateTime).getTime() + (24 * 60 * 60 * 1000));
            setDateTimeControlsCity("checkOut", correctCheckOutTime);
        }
    });


    function getSelectedDateTimeCity(checkInOrOut) {

        var dateField = $("." + checkInOrOut + "Date").val();
        var parsedDate = Date.parse(dateField);
        return parsedDate;
    }

    function setDateTimeControlsCity(checkInOrOut, datime) {
        var dateField = $("." + checkInOrOut + "Date");
        var newCheckOutDate = new Date(datime);
        dateField.val(formatUIDate(newCheckOutDate));
        //dateField.val(newCheckOutDate);
    }



    //Price Breakdown slider
    $('.priceBreakdown').each(function (i) {
        var $this = $(this);
        $this.addClass('priceBreakdown' + i);
        $('.priceBreakdownWindow', this).serialScroll({
            items: 'ul li', // Selector to the items (relative to the matched elements)
            prev: '.priceBreakdown' + i + ' .prev', // Selector to the 'prev' button (absolute)
            next: '.priceBreakdown' + i + ' .next', // Selector to the 'next' button (absolute)
            axis: 'x',
            force: true,
            cycle: false,
            duration: 200,
            constant: false
        });
    });

    //Room info lightbox
    $('.imageLightbox .horizontalCarousel').each(function () {
        var $this = $(this);
        $('.carouselImages', this).cycle({
            fx: 'scrollHorz',
            speed: 400,
            timeout: 4000,
            delay: -3000,
            pause: 'false',
            next: $this.find('.next'),
            prev: $this.find('.prev'),
            pager: $this.find('.pagination')
        }).cycle('pause');

        //Hide pagination if there's only one image
        if ($('.carouselImages', this).children('img').length < 2) {
            $('.pagination, .next, .prev', this).hide();
        }
    });

    //Room duration slider
    if ($("#timeSlider").length) {
        $("#timeSlider").slider({
            value: 0,
            min: -8,
            max: 41,
            step: 1,
            range: true,
            create: function (event, ui) {
                var handles = $('.ui-slider .ui-slider-handle');
                $(handles[0]).html("<div id=\"checkInHandle\">16:00</div><div>Check in</div>");
                $(handles[1]).html("<div id=\"checkOutHandle\">03:00</div><div>Check out</div>");
            },
            slide: function (event, ui) {
                $("#amount").val("$" + ui.value);
                $('#sliderOver24').fadeOut();

                var checkInVal = $(this).slider("values", 0);
                var checkOutVal = $(this).slider("values", 1);
                var newCheckIn = addMinutes(new Date($(".initialCheckIn").val()), (checkInVal * 30));
                var newCheckOut = addMinutes(new Date($(".initialCheckIn").val()), (checkOutVal * 30));
                $("#checkInHandle").text(formatTimeValue(newCheckIn.getHours()) + ":" + formatTimeValue(newCheckIn.getMinutes()));
                $("#checkOutHandle").text(formatTimeValue(newCheckOut.getHours()) + ":" + formatTimeValue(newCheckOut.getMinutes()));
            },
            start: function (event, ui) {
                $('#sliderHelp').fadeOut();
            },
            change: function (event, ui) {
                if (sliderInitialised) {
                    var checkInVal = ui.values[0];
                    var checkOutVal = ui.values[1];
                    var valChanged = "";
                    var thirtyMinOffset = "0";
                    var updateCheckIn = false;
                    var updateCheckOut = false;
                    var incrementFactor = 1;
                    var valueDiff = 0;
                    var previousCheckIn = sliderCheckInVal;
                    var previousCheckOut = sliderCheckOutVal;

                    if (checkInVal != sliderCheckInVal) {
                        valChanged = "checkIn";
                        valueDiff = checkInVal - sliderCheckInVal;
                        //+ve or -ve change?
                        incrementFactor = valueDiff / Math.abs(valueDiff);

                        if (Math.abs(valueDiff % 2) == 1) {
                            checkOutVal += incrementFactor * 1;
                            updateCheckOut = true;
                        }

                    } else if (checkOutVal != sliderCheckOutVal) {
                        valChanged = "checkOut";
                        valueDiff = checkOutVal - sliderCheckOutVal;
                        //+ve or -ve change?
                        incrementFactor = valueDiff / Math.abs(valueDiff);

                        if (Math.abs(valueDiff % 2) == 1) {
                            checkInVal += incrementFactor * 1;
                            updateCheckIn = true;
                        }
                    }

                    sliderCheckInVal = checkInVal;
                    sliderCheckOutVal = checkOutVal;

                    //Check that 4 hour minimum booking is maintained
                    if (checkOutVal - checkInVal < 8) {
                        if ((valChanged == "checkIn") && (checkInVal < 32)) {
                            sliderCheckOutVal = checkInVal + 8;
                            //the order that the sliders are set is important or an infinite loop will be created triggering the change event
                            $(this).slider("values", 1, sliderCheckOutVal);
                            $(this).slider("values", 0, sliderCheckInVal);
                        } else if ((valChanged == "checkOut") && (checkOutVal > 0)) {
                            sliderCheckInVal = checkOutVal - 8;
                            $(this).slider("values", 0, sliderCheckInVal);
                            $(this).slider("values", 1, sliderCheckOutVal);
                        } else {
                            //Revert to previous values, markers are too near to end of timeline
                            sliderCheckInVal = previousCheckIn;
                            sliderCheckOutVal = previousCheckOut;
                            switch (valChanged) {
                                case "checkOut":
                                    $(this).slider("values", 1, sliderCheckOutVal);
                                    break;
                                case "checkIn":
                                    $(this).slider("values", 0, sliderCheckInVal);
                                    break;
                                default:
                                    break;
                            }
                        }
                    } else {
                        if (updateCheckIn) $(this).slider("values", 0, sliderCheckInVal);
                        if (updateCheckOut) $(this).slider("values", 1, sliderCheckOutVal);
                    }

                    //Calculate new check in / out times
                    var newCheckIn = addMinutes(new Date($(".initialCheckIn").val()), (sliderCheckInVal * 30));
                    var newCheckOut = addMinutes(new Date($(".initialCheckIn").val()), (sliderCheckOutVal * 30));
                    $("#checkInHandle").text(formatTimeValue(newCheckIn.getHours()) + ":" + formatTimeValue(newCheckIn.getMinutes()));
                    $("#checkOutHandle").text(formatTimeValue(newCheckOut.getHours()) + ":" + formatTimeValue(newCheckOut.getMinutes()));
                    setDateTimeControls("checkIn", newCheckIn);
                    setDateTimeControls("checkOut", newCheckOut);

                }

                //alert('Changed to ' + ui.values[0] + ", " + ui.values[1]);

                //setDateTimeControls("checkOut", addHours(getSelectedDateTime("checkIn"), ui.value));
                $(".resultsContainer .result").hide();
                $(".resultsContainer .booking_duration_" + ui.value).show();

            }
        });

        if (typeof initialiseSliderValue == "function") {
            initialiseSliderValue();
        } else {
            //$('.ui-slider .ui-slider-handle').text($("#timeSlider").slider("value"));
            //$('.ui-slider .ui-slider-handle').text("Check in");
        }

    }

    //Add Another Guest
    $('.addGuest').click(function () {
        $(this).closest('.roomOccupants').find('.hiddenRoomGuest').first().removeClass('hiddenRoomGuest');
        return false;
    });


    /*
    $('.accordionContent:not(:first)').hide();
    $('.formAccordionHeader:not(:first)').removeClass('open');
    */

    $('.formAccordionHeader a').click(function () {
        $(this).parent().next('.accordionContent').slideToggle();
        $(this).parent().toggleClass('open');
        return false;
    });




    $(".checkInDate, .checkOutDate").change(function (e) {
        var checkInDateTime = getSelectedDateTime("checkIn");
        var checkOutDateTime = getSelectedDateTime("checkOut");
        var hoursDiff = differenceInHours(checkInDateTime, checkOutDateTime);

        if (hoursDiff < 4) {
            checkOutDateTime = addHours(checkInDateTime, 4);
            setDateTimeControls("checkOut", checkOutDateTime);
        }

        setTimeSlider(hoursDiff);

        if (refreshFromWS(checkInDateTime, checkOutDateTime)) {
            showRefreshSearchPrompt();
        } else {
            hideRefreshSearchPrompt();
        }
    });


    $(".calendarWidget .thinSelectBox select, .bookOptions .thinSelectBox select").change(function (e) {
        var triggerControl = $(this);
        var checkInDateTime = getSelectedDateTime("checkIn");
        var checkOutDateTime = getSelectedDateTime("checkOut");
        var hoursDiff = differenceInHours(checkInDateTime, checkOutDateTime);

        if (hoursDiff < 4) {
            checkOutDateTime = addHours(checkInDateTime, 4);
            setDateTimeControls("checkOut", checkOutDateTime);
        }

        setTimeSlider(hoursDiff);

        switch (this.className) {
            case "checkInTimeHour":
                break;
            case "checkOutTimeHour":
                break;
            case "checkInTimeMinutes":
                if ($(".checkOutTimeMinutes").val() != $(this).val()) {
                    $("#checkOutTimeMinutes_input").val($(this).val());
                    $(".checkOutTimeMinutes").val($(this).val());
                }
                break;
            case "checkOutTimeMinutes":
                if ($(".checkInTimeMinutes").val() != $(this).val()) {
                    $("#checkInTimeMinutes_input").val($(this).val());
                    $(".checkInTimeMinutes").val($(this).val());
                }
                break;
            default:
                //Nothing to do here
        }

        if (refreshFromWS(checkInDateTime, checkOutDateTime)) {
            showRefreshSearchPrompt();
        } else {
            hideRefreshSearchPrompt();
        }
    });

    //Manage bookings table
    if ($(".bookingListTable").length) {
        $(".bookingListTable").each(function () {
            $(".row", this).hover(function () {
                $(this).addClass("selected");
            }, function () {
                $(this).removeClass("selected");
            });
        });

        $(".bookingListTable .row").click(function () {
            window.location = $(this).find('a').attr('href');
        });
    }

});

// DateTime search functions

function getSelectedDateTime(checkInOrOut) {
    var dateField = $("." + checkInOrOut + "Date");
    var hourField = $("." + checkInOrOut + "TimeHour");
    var minutesField = $("." + checkInOrOut + "TimeMinutes");
    var leadingZeroTrim = /\b0/;

    var fullDateMS = Date.parse(dateField.val() + " " + hourField.val() + ":" + minutesField.val());
    var fullDate = new Date(fullDateMS);

    return fullDate;
}

function differenceInHours(startTime, endTime) {
    var diffMS = endTime - startTime;
    return diffMS / 1000 / 60 / 60;
}

function setDateTimeControls(checkInOrOut, dateTime) {
    var dateField = $("." + checkInOrOut + "Date");
    var hourField = $("." + checkInOrOut + "TimeHour");
    var minutesField = $("." + checkInOrOut + "TimeMinutes");

    dateField.val(formatUIDate(dateTime));
    //hour fields
    $("#" + checkInOrOut + "TimeHour_input").val(formatTimeValue(dateTime.getHours()));
    $("." + checkInOrOut + "TimeHour").val(formatTimeValue(dateTime.getHours()));

    //minute fields
    $("#" + checkInOrOut + "TimeMinutes_input").val(formatTimeValue(dateTime.getMinutes()));
    $("." + checkInOrOut + "TimeMinutes").val(formatTimeValue(dateTime.getMinutes()));
}

function formatUIDate (dateTime){
    var dateString = dateTime.getDate() + " " + translateMonth(dateTime.getMonth()) + ", " + dateTime.getFullYear();
    return dateString;
}

function translateMonth(month){
    var monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
    return monthNames[month];
}

function formatTimeValue(timeUnit) {
    //Pad a 1-digit value with a leading zero to match select values
    if (("" + timeUnit).length == 1) {
        var paddedValue = ("0" + timeUnit);
        return paddedValue;
    } else {
        return timeUnit;
    }
}

function addHours(dateTime, hours){
    var inMS = dateTime.getTime();
    var hoursInMS = hours * 60 * 60 * 1000;
    var outMS = inMS + hoursInMS;

    return new Date(outMS);
}

function addMinutes(dateTime, minutes) {
    var inMS = dateTime.getTime();
    var minsInMS = minutes * 60 * 1000;
    var outMS = inMS + minsInMS;

    return new Date(outMS);
}

function refreshFromWS(rangeStart, rangeEnd) {
    if ((differenceInHours(getBaseStart(), getBaseEnd()) <= 24) && ((rangeStart < getBaseStart()) || (rangeEnd > getBaseEnd()))) {
        //check in or check out is beyond original 24-hour window
        return true;
    } else if (differenceInHours(getBaseStart(), getBaseEnd()) > 24) {
        //original range more than 24 hours, always needs a fresh call to web service
        return true;
    } else {
        return false;
    }
}

function getBaseStart(){
    return new Date($(".searchRangeStart").val());
}

function getBaseEnd(){
    return new Date($(".searchRangeEnd").val());
}

function setTimeSlider(hoursDiff) {
    if (hoursDiff < 24) {
        $("#timeSliderContainer").show();
        $('#timeSlider').slider('value', hoursDiff);
        $('.ui-slider .ui-slider-handle').text($("#timeSlider").slider("value"));
    } else {
        $("#timeSliderContainer").hide();
    }
}

function showRefreshSearchPrompt() {
    $("#refreshSearchMessage").show();
    $(".resultsContainer .result").hide();
}

function hideRefreshSearchPrompt() {
    $("#refreshSearchMessage").hide();
}

// End DateTime search functions

// DatePicker validation functions - City

function validateDateCalendarsRange(dateText, inst) {
    var startDate = $("*[id$='txtCheckInDate']").val();
    startDate = $.datepicker.parseDate('dd M, yy', startDate)
    var endDate = $("*[id$='txtCheckOutDate']").val();
    endDate = $.datepicker.parseDate('dd M, yy', endDate)
    var result = false;
    if (startDate > endDate) {
        // Do something
        $('#invalidCheckinDate').show();

    }
    else {
        $('#invalidCheckinDate').hide();
        result = true;
    }
    return result;
}

function validateDateCalendarsFormat(dateText, inst) {
    var result = false;
    try {
        //var selectedDate = $.datepicker.parseDate('dd/mm/yy', dateText);dd M, yy
        var selectedDate = $.datepicker.parseDate('dd M, yy', dateText);
        $('#invalidCheckinDateFormat').hide();
        result = true;
    }
    catch (e) {
        $('#invalidCheckinDateFormat').show();
    }
    return result;
}

// Set scroll window height
function scrollInit() {
    var scrollHeight = $(window).height() - 83;

    if (scrollHeight < 780) {
        scrollHeight = 780;
    }

    //make the page a bit longer for IE6/7
    if ($.browser.msie && $.browser.version.substr(0, 1) < 8) {
        scrollHeight += 225;
    }

    $('.iframe').height(scrollHeight);

    $('#scrollContainer').height(scrollHeight);
    $('#scrollWindow').height(scrollHeight - 150);
    $('#bottomMask').height(scrollHeight - ($('#topMask').height() + 325));
}

function initDropDowns() {
    $('.dropDown').selectbox({ maxLength: 40 });
}

/** Returns a map containing all the url parameters for the current page in where the
 *  key of the map is the url parameter name.
 */
function getUrlParameters() {
    var map = {};
    var count = 0;

    var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (m, key, value) {
        map[key] = value;
        count++;
    });

    map["count"] = count;
    return map;
}

/** Called when the YouTube API loads. This finds all instances of the video player div
 *  and extracts the video id, passing this into the api so that a video is created.
 */
function onYouTubePlayerAPIReady() {

   /* $(".videoPlayer").each(function (index, element) {

        var videoId = element.innerHTML;
        element.innerHTML = '';

        player = new YT.Player(element, {
            height: '300',
            width: '540',
            videoId: videoId,
            playerVars: { wmode: 'opaque', rel: 0 },
            events: {
                'onStateChange' : onPlayerStateChange
            }
        });
    });*/
}

/** Called when a YouTube video changes its state. We watch for the play event
 *  so that we can pause the carousel and for the ended event so that we can restart it
 */
/*function onPlayerStateChange(event) {

    if (event.data == YT.PlayerState.PLAYING) {
        $('.carouselImages').cycle('pause');
        $('#pause').addClass('paused');
    }
    else if (event.data == YT.PlayerState.ENDED) {
        $('.carouselImages').cycle('resume');
        $('#pause').removeClass('paused');
    }
}*/

/*function onYouTubePlayerReady(playerId) {
    //ytplayer = document.getElementById("myytplayer");
    playerId.addEventListener("onStateChange", "onytplayerStateChange");
}

function onytplayerStateChange(newState) {
    alert("Player's new state: " + newState);
}*/
