﻿/// <reference path="jquery-1.4.3.min.js" />

; (function ($) {
    /// <param name="$" type="jQuery" />
    $.browserInfer = (function () {
        /// <summary>
        ///     The browserInfer object provides information about the current browser.
        ///     This utilizes the jQuery.support object which does not use browser UA sniffing.
        ///     IMPORTANT! This is NOT 100% certain but should be useful enough to cater for the
        ///     major browser engines.
        ///     Current browsers detected : IE6 - IE9, Firefox, Webkit, Chrome, Safari & Opera.
        ///     http://www.javascriptkit.com/javatutors/objdetect3.shtml
        /// </summary>

        return {
            ie: !$.support.leadingWhitespace || (Boolean(window.XDomainRequest) && Boolean(window.Performance)),

            ie6: !$.support.leadingWhitespace && !$.support.boxModel && !window.XMLHttpRequest,

            ie7: !$.support.leadingWhitespace && !$.support.boxModel && !$.support.hrefNormalized,

            ie8: !$.support.leadingWhitespace && $.support.hrefNormalized,

            ie9: Boolean(window.XDomainRequest) && Boolean(window.Performance),

            firefox: $.support.leadingWhitespace && Boolean(window.globalStorage),

            webkit: !$.support.checkOn,

            chrome: Boolean(window.chrome),

            safari: !$.support.checkOn && !Boolean(window.chrome),

            opera: Boolean(window.opera)
        };
    } ());
} (jQuery));

// Cached browserInfer object for detection.
var $browserInfer = jQuery.browserInfer;

/*
jquery.fixSelect

Fixes an whereby IE chops long options in a select box with fixed width. It does this by
surrounding the element within a span of the same width with overflow-x set to hidden,
and setting the select width to auto on a mousedown or keyup event then back to its
previous value on blur.

Syntax:

$jQueryCollection.fixSelect([minWidth]);

The minWidth parameter is optional, but can be used to hard set a width for the elements.
If the result doesn't look quite right, you can use CSS to fix the result: the added span
wrapping the select element has the class "selectFix" to make this possible.

Two custom events are exposed:

- "initfix" will recompute the natural width of the element; and
- "applyfix" will resize the select element (e.g. after assigning focus programmatically).

(Merciful heavens, IE should just be taken outside and *shot*. This apparently simple code
involved more obscure bug workarounds than I have time or space to document.)
*/

(function ($) {

    $.fn.fixSelect = function (minWidth) {
        /* Fix only applies to IE 8 and below. */
        return (!($.browser.msie && $.browser.version < 9)) ? this : this.each(function () {
            if (this.tagName.toLowerCase() == 'select') { // Also only applies to select elements.

                var el = this,
			$this = $(this),
			minWidth = minWidth ? minWidth : el.offsetWidth, // Current width used as minimum.
			elementWidth = $this.outerWidth(),
			$wrapper = $('<div class="selectFix"></div>').css({ // Wraps the select element.
			    display: ($this.css('display') == 'block') ? 'block' : 'inline',
			    "float": $this.css('float'),
			    overflowX: 'hidden',
			    overflowY: 'visible',
			    width: minWidth
			}),
			naturalWidth;

                /* Set up element margins on wrapper instead. (For more complex styles, use CSS.) */
                $.each('marginTop marginRight marginBottom marginLeft'.split(' '), function (i, prop) {
                    $wrapper.css(prop, $this.css(prop));
                    $this.css(prop, 0);
                });

                if ($this.is(':visible')) { // Doesn't work for invisible elements, they have zero width!
                    /* Determine what the "natural" (i.e. automatic) width would be. */
                    $this.width('auto');
                    naturalWidth = $this.outerWidth();
                    $this.width(minWidth);

                    $this
				.wrap($wrapper)
				.bind('mousedown keyup applyfix', function () {
				    /* Use "auto" or fixed width, whichever is biggest. */
				    //$this.width((naturalWidth < elementWidth) ? minWidth : 'auto');
					$this.width("auto");
				    /* Horribly, IE 6 will ignore the overflow anyway unless some part of the
				    select element is already hidden before the options list is displayed. */
				    if ($.browser.version == 6) $this.css('marginLeft', 1);
				})
				.bind('change blur', function () {
				    /* Reset the element to fixed width. */
				    $this.width(minWidth);
				    if ($.browser.version == 6) $this.css('marginLeft', 0);
				})
				.bind('initfix', function () {
				    /* Recalculate "natural" width. */
				    $this.width('auto');
				    naturalWidth = $this.outerWidth();
				    $this.width(minWidth);
				});
                }
            }
        });
    }

})(jQuery);
jQuery(document).ready(function () {
    
    if ($browserInfer.ie && !$browserInfer.ie9) {
        jQuery("#ddlQBFilm").css({"float":"left"}).after("<div style=\"clear:both\"></div>").fixSelect("250px");
    }
});

function RefreshImage(valImageId) {
    var objImage = document.images[valImageId];
    if (objImage == undefined) {
        return;
    }
    var now = new Date();

    objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
}

function checkemail(emailstr) {
    var emailFilter = /^(([a-zA-Z0-9_\-]+)|(([a-zA-Z0-9_\-]+)([\.]{1,1}[a-zA-Z0-9_\-]+)+)+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
    if (!(emailFilter.test(emailstr)))
        return false;
    return true;
}

function loadMap(lat, lng) {
    var myLatlng = new google.maps.LatLng(lat, lng);
    var myOptions = {
        zoom: 13,
        center: myLatlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    var map = new google.maps.Map(document.getElementById("MapContainer"), myOptions);

    var marker = new google.maps.Marker({
        position: myLatlng,
        map: map
    });
}

// Show the cinemas that are showing the selected movie
function showCinemaSelect(filmIDs, source, posX, posY) {

    // film ids are a comma seperated list of film ids pass this to the function to get the list of cinemas.
    jQuery.getJSON("/cinemas/controls/getShowingCinemas.aspx", { ajax: 'true', filmIDs: filmIDs }, function (data) {

        if (data.length >= 1) {
            // We have received some data from the json call show the overlay
            showCinemaSelectOverlay(data, source, posX, posY);
        }

    });

}

// Show the cinemas that are showing the selected movie
function showCinemaSelectGenre(genreIDs, source, posX, posY) {

    // film ids are a comma seperated list of film ids pass this to the function to get the list of cinemas.
    jQuery.getJSON("/cinemas/controls/getShowingCinemas.aspx", { ajax: 'true', genreIDs: genreIDs }, function (data) {

        if (data.length >= 1) {
            // We have received some data from the json call show the overlay
            showCinemaSelectOverlay(data, source, posX, posY);
        }

    });

}

function showCinemaSelectOverlay(data, source, posX, posY) {
    // Does the cinema selection panel exist? If not, create it
    if (jQuery("#pnlCinemaSel").length < 1) {
        // No, create it and apply put the relevant elements within
        var pnlCinemaSel = document.createElement("div");
        var $pnlCinemaSel = jQuery(pnlCinemaSel);
        $pnlCinemaSel.attr("id", "pnlCinemaSel");
        $pnlCinemaSel.attr("style", "display:none;");
        $pnlCinemaSel.html("<div class=\"tooltip_wrapper\" style=\"width: 321px; height: 400px; position: absolute; top: 0px; left: 0px; z-index:-1;\"><!-- --></div><div class=\"overlay_close\"><a href=\"#\">&nbsp;</a></div><div id=\"cinemaSelContent\"><h1>Please select a cinema</h1><p>So we can give you the right film times!</p><p><select id=\"cinemaSel\"><option>Select a cinema</option></select></p><p><input type=\"button\" id=\"btnCinemaSel\" value=\"Submit\" class=\"btn_submit\" /></p></div>");
        
        jQuery("body").append($pnlCinemaSel);
    }

    // Array of cinemas are in the variable 'data' loop through this and create the string of <option> elements to be placed inside the cinema select
    var options = "<option value=\"\">Select a cinema</option>";
    for (var i = 0; i < data.length; i++) {
        options += "<option value=\"" + data[i].url + "\">" + data[i].name + "</option>";
    }

    // Insert the list of options into the select
    jQuery("select#cinemaSel").html(options);

    // The function call is coming from the flash movie, position according to it's place on the page
    if (source === "hero") {

        // Get the position on screen of the flash movie
        var posn = jQuery("#flashContainer").offset();
        posX = posn.left + 100;
        posY = posn.top + 85;
    }
    else {
        posY = posY - 90;
    }
    
    jQuery("#pnlCinemaSel").css({
        "left": posX,
        "top": posY
    }).show();

    mouseInOverlay = true;
}

function vertCenter(contEl, innerEl, spacerElement) {
    var heightDiff = contEl.height() - innerEl.height();
    if (heightDiff % 2 > 0)
        heightDiff--;
    spacerElement.css("height", heightDiff / 2 + "px");
}

function NSBannerHeightCheck() {
    var subContHeight = 338 - jQuery(".bannerpart_sponsor").height();
    var bannerpart_sub = jQuery(".bannerpart_sub");
    var heightDiff = subContHeight - bannerpart_sub.height();
    if (heightDiff % 2 > 0)
        heightDiff--;
    bannerpart_sub.css({
        "margin-top": heightDiff / 2 + "px",
        "margin-bottom": heightDiff / 2 + "px"
    })
}

function showOverlay(cinemaID, mapTab) {
    // Overlay html has not been written onto page yet, do that then populate it
    if (!jQuery("#overlay").length > 0) {
        var overlay = document.createElement("div");
        var $overlay = jQuery(overlay);
        $overlay.attr("id", "overlay");
        $overlay.css({ "height": jQuery(document).height() + "px" });
        $overlay.html("<img src='/media/image/livery/overlay_bg.png' width='100%' height='" + jQuery(document).height() + "' />");
        jQuery("#main_wrap").append($overlay);
    }

    // The content placeholder to place on top of the overlay has not been created
    if (!jQuery("#overlay_content").length > 0) {
        var overlay_content = document.createElement("div");
        var $overlay_content = jQuery(overlay_content);
        $overlay_content.attr("id", "overlay_content");
        var posn = jQuery("#wrap").offset();
        var posX = posn.left + 10;
        $overlay_content.css({"left": posX + "px"});
        jQuery("#main_wrap").append($overlay_content);
    }

    jQuery("#overlay").show();
    jQuery("#overlay_content").show();

    jQuery.ajax({
        url: "/cinemas/ThisCinema.aspx?cinemaid=" + cinemaID,
        cache: false,
        success: function (html) {
            jQuery("#overlay_content").html(html);
            Cufon.replace('#this_cinema h1', { fontFamily: 'DIN-Black', fontWeight: '900' });
            if (mapTab == true) {
                showMapTab();
            }
            jQuery("#overlay_content").prepend("<div class=\"overlay_close\"><a href=\"#\">&nbsp;</a></div>");
        }
    });

}

function showMapTab() {
    var showLink = jQuery("#this_cinema .nav_tabs .map_tab");
    showLink.siblings().removeClass("active").removeClass("no_border");
    showLink.addClass("active");
    showLink.prev().addClass("no_border");
    jQuery("#this_cinema .tab_content").removeClass("active");
    jQuery("#this_cinema_" + showLink.find("a").attr("rel")).addClass("active");
    if (jQuery("#this_cinema_" + showLink.find("a").attr("rel")).hasClass("map_tab")) {
        loadMap(lat, lng);
    }
}

var mouseInOverlay = false;

jQuery(document).ready(function () {

    NSBannerHeightCheck();

    Cufon.replace('#quick_book h1', { fontFamily: 'DIN-Black', fontWeight: '900' });
    Cufon.replace('#something_different .tab_content h1, #hero_container h1, h1.cinema_header', { fontFamily: 'DIN-Black', fontWeight: '900' });

    jQuery("#genre_tabs li:last").addClass("last");
    jQuery("#genre_tabs li.active").prev().addClass("no_border");
    jQuery(".sub_tabs li:last").addClass("last");
    jQuery("#this_cinema .nav_tabs li:last").addClass("last");

    jQuery("#overlay_content .overlay_close a").live("click", function (e) {
        e.preventDefault();
        jQuery("#overlay_content").hide();
        jQuery("#overlay").hide();
    });

    jQuery("#pnlCinemaSel .overlay_close a").live("click", function (e) {
        e.preventDefault();
        jQuery("#pnlCinemaSel").hide();
    });

    jQuery(".show_map").live("click", function (e) {
        e.preventDefault();
        var clickedElement = jQuery(this);
        showOverlay(clickedElement.attr("rel"), true);
    });

    jQuery(".overlay_show_map").live("click", function (e) {
        e.preventDefault();
        showMapTab();
    });

    jQuery("#this_cinema .nav_tabs li a").live("click", function (e) {
        e.preventDefault();
        var clickedElement = jQuery(this);
        clickedElement.parent().siblings().removeClass("active").removeClass("no_border");
        clickedElement.parent().addClass("active");
        clickedElement.parent().prev().addClass("no_border");
        clickedElement.blur();
        jQuery("#this_cinema .tab_content").removeClass("active");
        jQuery("#this_cinema_" + clickedElement.attr("rel")).addClass("active");
        if (jQuery("#this_cinema_" + clickedElement.attr("rel")).hasClass("map_tab")) {
            loadMap(lat, lng);
        }
    });

    jQuery(".btn_cinema_info").click(function (e) {
        e.preventDefault();
        var clickedElement = jQuery(this);
        showOverlay(clickedElement.attr("rel"), false);
    });

    jQuery("#overlay").live("mouseup", function () {
        jQuery("#overlay_content").hide();
        jQuery("#overlay").hide();
    });

    vertCenter(jQuery("#something_different .tab_content.active"), jQuery("#something_different .tab_content.active .item_content"), jQuery("#something_different .tab_content.active .item_spacer"));

    jQuery(".tab a").click(function (e) {
        e.preventDefault();
        var thisEl = jQuery(this);
        var closestDiv = thisEl.closest("div");
        thisEl.parent().siblings().removeClass("active");
        thisEl.parent().siblings().removeClass("no_border");
        thisEl.parent().prev().addClass("no_border");
        thisEl.parent().addClass("active");
        closestDiv.find(".tab_content").removeClass("active");
        var contEl = closestDiv.find("#tab_content_" + thisEl.attr("rel"));
        var innerEl = contEl.find(".item_content");
        var spacerElement = contEl.find(".item_spacer");

        contEl.addClass("active");
        vertCenter(contEl, innerEl, spacerElement);
        thisEl.blur();
    });

    jQuery(document).mouseup(function () {
        if (jQuery("#pnlCinemaSel").is(":visible") && mouseInOverlay === false) {
            jQuery("#pnlCinemaSel").hide();
        }
    });

    // As cinemaSel is a dynamic element that is added to the page post load we have to use a .live function to bind the change event
    jQuery("#btnCinemaSel").live("click", function (e) {
        e.preventDefault();
        // Redirect to the cinema page that the user has selected.
        if (jQuery("#cinemaSel").val() != "")
            window.location.href = jQuery("#cinemaSel").val();
    });

    jQuery(".btn_submit, .btn_short_cta, .btn_tall_cta").live("mouseenter", function () {
        jQuery(this).addClass("hover");
    });
    jQuery(".btn_submit, .btn_short_cta, .btn_tall_cta").live("mouseleave", function () {
        jQuery(this).removeClass("hover");
    });

    jQuery('.tooltip_wrapper').live("mouseenter", function () {
        mouseInOverlay = true;
        //jQuery("#cinemaSelContent h1").text("true")
    });

    jQuery('.tooltip_wrapper').live("mouseleave", function () {
        mouseInOverlay = false;
        //jQuery("#cinemaSelContent h1").text("false")
    });

    jQuery("#cinemaSelContent *").live("mouseenter", function () {
        mouseInOverlay = true;
        //jQuery("#cinemaSelContent h1").text("true *")
    });

    jQuery("#test").click(function (e) {
        e.preventDefault();
        var filmIDs = jQuery(this).attr("rel");
        showCinemaSelect(filmIDs);
    });

    // Pre-book link clicked
    jQuery(".lnkPreBook").live("click", function (e) {
        e.preventDefault();
        showCinemaSelect(jQuery(this).attr("rel"), "", e.pageX, e.pageY);
    });

    // Genre link clicked
    jQuery(".lnkGenre").live("click", function (e) {
        e.preventDefault();
        showCinemaSelectGenre(jQuery(this).attr("rel"), "", e.pageX, e.pageY);
    });

    jQuery(".showTrailer").click(
        function () {
            jQuery("#myMoviesFrame").attr("src", jQuery(this).attr("href"));
            window.scroll(0, 0);
            return false;
        }
    );

    jQuery("#cmSignup .btnSubmit").click(
        function () {
            if (!checkemail(jQuery("#cmSignup #EmailAddress").val())) {
                alert('Please enter a valid email address.');
                return false;
            }
        }
    )

    jQuery("#mainnav li li").hover(
        function () {
            jQuery(this).parent().parent().addClass("hover");
            jQuery(this).find("ul").fadeIn(00);
        },
        function () {
            jQuery(this).parent().parent().removeClass("hover");
            jQuery(this).find("ul").fadeOut(000);
        }
    )

    jQuery("#mainnav li").hover(
        function () {
            jQuery(this).addClass("hover1");
            jQuery(this).find("ul").fadeIn(0);
        },
        function () {
            jQuery(this).removeClass("hover1");
            jQuery(this).find("ul").fadeOut(000);
        }
    )

    jQuery("select#ddlQBCinema").change(function () { SelectedCinemaCallback() });

    jQuery("select#ddlQBFilm").change(
        function () {
            jQuery("select#ddlQBDay, select#ddlQBTime").attr("disabled", true);
            jQuery("select#ddlQBDay, select#ddlQBTime").closest("p").addClass("dis");
            jQuery("#ScheduleID").val('');
            jQuery.getJSON("/cinemas/controls/QBOptions.aspx?srcChange=film&cinemaID=" + jQuery("select#ddlQBCinema").val(), { id: jQuery(this).val(), ajax: 'true' }, function (j) {
                var options = '';
                for (var i = 0; i < j.length; i++) {
                    options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
                }

                if (j.length > 1) {
                    jQuery("select#ddlQBDay").html(options);
                    jQuery("select#ddlQBTime").html('<option value="">Select a time</option>');
                    jQuery("select#ddlQBDay").removeAttr("disabled");
                    jQuery("select#ddlQBDay").closest("p").removeClass("dis");
                }
                else {
                    jQuery("select#ddlQBDay, select#ddlQBTime").html(options);
                }
            })
        }
    );

    jQuery("select#ddlQBDay").change(
        function () {
            jQuery("select#ddlQBTime").attr("disabled", true);
            jQuery("select#ddlQBTime").closest("p").addClass("dis");
            jQuery("#ScheduleID").val('');
            jQuery.getJSON("/cinemas/controls/QBOptions.aspx?srcChange=day&cinemaID=" + jQuery("select#ddlQBCinema").val() + "&filmID=" + jQuery("select#ddlQBFilm").val(), { id: jQuery(this).val(), ajax: 'true' }, function (j) {
                var options = '';
                for (var i = 0; i < j.length; i++) {
                    options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
                }

                jQuery("select#ddlQBTime").html(options);
                if (j.length > 1) {
                    jQuery("select#ddlQBTime").removeAttr("disabled");
                    jQuery("select#ddlQBTime").closest("p").removeClass("dis");
                }
            })
        });

    jQuery("select#ddlQBTime").change(
        function () {
            if (jQuery("select#ddlTime").val() != '') {
                jQuery("#ScheduleID").val(jQuery(this).val());
            }
            else {
                jQuery("#ScheduleID").val('');
            }
        }
    );

    jQuery("#subQB").click(
        function () {

            if ((!isNaN(jQuery("#ScheduleID").val()) && (jQuery("#ScheduleID").val() != '')) && (!isNaN(jQuery("#ddlQBFilm").val()) && (jQuery("#ddlQBFilm").val() != '')) && (!isNaN(jQuery("#ddlQBCinema").val()) && (jQuery("#ddlQBCinema").val() != ''))) {
                var CinemaID = jQuery("#ddlQBCinema").val();
                if (CinemaID == 99)
                    CinemaID = 1;

                if((!isNaN(jQuery("#hidiFrame").val()) && (jQuery("#hidiFrame").val() != ''))) {

                    // DEV
                    //window.location.href = 'http://localhost:62761/cinemas/BookingRedirect.aspx?ScheduleID=' + jQuery("#ScheduleID").val() + '&filmid=' + jQuery("#ddlQBFilm").val() + '&cinemaid=' + CinemaID;
                    // STAGE
                    window.open('/cinemas/BookingRedirect.aspx?ScheduleID=' + jQuery("#ScheduleID").val() + '&filmid=' + jQuery("#ddlQBFilm").val() + '&cinemaid=' + CinemaID);
                    // LIVE
                    //window.location.href = 'http://www.apollocinemas.com/cinemas/BookingRedirect.aspx?ScheduleID=' + jQuery("#ScheduleID").val() + '&filmid=' + jQuery("#ddlQBFilm").val() + '&cinemaid=' + CinemaID;
                } else {
                
                    // DEV
                    //window.location.href = 'http://localhost:62761/cinemas/BookingRedirect.aspx?ScheduleID=' + jQuery("#ScheduleID").val() + '&filmid=' + jQuery("#ddlQBFilm").val() + '&cinemaid=' + CinemaID;
                    // STAGE
                    window.location.href = '/cinemas/BookingRedirect.aspx?ScheduleID=' + jQuery("#ScheduleID").val() + '&filmid=' + jQuery("#ddlQBFilm").val() + '&cinemaid=' + CinemaID;
                    // LIVE
                    //window.location.href = 'http://www.apollocinemas.com/cinemas/BookingRedirect.aspx?ScheduleID=' + jQuery("#ScheduleID").val() + '&filmid=' + jQuery("#ddlQBFilm").val() + '&cinemaid=' + CinemaID;
                }
            }
            else {
                alert('Please select your required performance from the boxes above.');
            }
        }
    );


    jQuery(".more").click(function () {
        var clickedElement = jQuery(this);
        var targetElement = clickedElement.closest(".colDetail").find(".filmMoreInfo");
        if (targetElement.is(":visible")) {
            clickedElement.text("more info");
            targetElement.hide();
        }
        else {
            clickedElement.text("less info");
            targetElement.show();
        }
    });

    jQuery("#cmSignupWithCinema").validate({
        errorLabelContainer: jQuery("#cmSignupWithCinema #formErrors"),
        wrapper: 'p',
        rules: {
            email: {
                required: true,
                email: true
            },
            strName: "required"
        },
        messages: {
            email: "Please enter a valid email address",
            strName: "Please enter your name"
        }
    });

    jQuery("#competitionForm").validate({
        errorLabelContainer: jQuery("#competitionForm #compErrors"),
        wrapper: 'li',
        rules: {
            answer: "required",
            strName: "required",
            strEmail: {
                required: true,
                email: true
            },
            strTel: "required",
            strAddress: "required",
            chkTerms: "required"
        },
        messages: {
            answer: "Please select an answer",
            strName: "Please enter your name",
            strEmail: "Please enter a valid email address",
            strTel: "Please enter your telephone number",
            strAddress: "Please enter your address",
            chkTerms: "You must agree to the terms &amp; conditions"
        }
    });

    // for tooltip on seat picker: unavailable areas 
    //jQuery(".areaunavailable").tooltip({ tip: '#tooltip', position: ['top', 'right'], offset: [0, -7], effect: 'toggle', delay: 0 });
    //jQuery(".director").tooltip({ tip: '#tooltip', position: ['top', 'right'], offset: [0, -7], effect: 'toggle', delay: 0 });

    jQuery(".director, .areaunavailable").mouseenter(function () {
        var thisElement = jQuery(this);
        var toolTip = jQuery("#tooltip");
        toolTip.show()
        toolTip.css({
            "left": thisElement.offset().left + 18 + "px",
            "top": thisElement.offset().top - 90 + "px",
            "z-index": 10000,
            "position": "absolute"
        });
    });
    jQuery(".director, .areaunavailable").mouseleave(function () {
        jQuery("#tooltip").hide();
    });
    jQuery(".subtitledHighlight").mouseenter(function () {
        var thisElement = jQuery(this);
        var toolTip = jQuery("#tooltipSubtitled");
        toolTip.show()
        toolTip.css({
            "left": thisElement.offset().left + 18 + "px",
            "top": thisElement.offset().top - 50 + "px",
            "z-index": 10000,
            "position": "absolute"
        });
    });
    jQuery(".subtitledHighlight").mouseleave(function () {
        jQuery("#tooltipSubtitled").hide();
    });
    jQuery(".hplate").mouseenter(function () {
        var thisElement = jQuery(this);
        var toolTip = jQuery("#tooltipHPLate");
        toolTip.show()
        toolTip.css({
            "left": thisElement.offset().left + 18 + "px",
            "top": (thisElement.offset().top - 63) + "px",
            "z-index": 10000,
            "position": "absolute"
        });
    });
    jQuery(".hplate").mouseleave(function () {
        jQuery("#tooltipHPLate").hide();
    });
    jQuery(".parentbaby").mouseenter(function () {
        var thisElement = jQuery(this);
        var toolTip = jQuery("#tooltipParentBaby");
        toolTip.show()
        toolTip.css({
            "left": thisElement.offset().left + 18 + "px",
            "top": thisElement.offset().top - 140 + "px",
            "z-index": 10000,
            "position": "absolute"
        });
    });
    jQuery(".parentbaby").mouseleave(function () {
        jQuery("#tooltipParentBaby").hide();
    });

    // Check to see if there is a takeover, if not then load up standard background
    if (typeof (takeover) == "undefined") {
        var browserCss;

        if ($browserInfer.firefox) {
            browserCss =  "-moz-radial-gradient(50% 0% 0deg,ellipse cover, #838383, #000000 80%)";
        }
        else if ($browserInfer.webkit) {
            browserCss = "-webkit-gradient(radial, center top, 240, center top, 800, from(#838383), to(#000000))";
        }
        else { 
            browserCss = "linear-gradient(#838383, #000000)";
        }

        jQuery("#main_wrap").css({
            "background": "#000",
            "background-image": browserCss 
        });
    }

    // Check to see if there is a full size banner, if not then load up the standard background
    if (typeof (fullbanner) == "undefined") {
        jQuery("#pnl_logo").css({
            "background": "url(/liv/banner_bg.jpg) repeat-x",
            "border-bottom": "1px solid #C94A4F",
            "height": "119px"
        });
        jQuery("#mainnav").css({
            "background": "url(/liv/mainnav_bg.jpg) repeat-x"
        })
    }
    else {
        jQuery("#pnl_logo").css({
            "height": "120px"
        });
        jQuery("#mainnav").css({
            "background": "url(/liv/trans.png) transparent"
        });
    }
	
	 // reald poll functionality
    jQuery('.btn_vote').click(function (e) {
        e.preventDefault();
        var pollResultID = jQuery('[name="realDPoll"]:checked').val();

        jQuery.get("/cinemas/VoteInPoll.aspx?pollResultID=" + pollResultID, function (data) {
            jQuery("#reald3dpollContent").empty().html(data)
        });
    });

});

function SelectCinema_In_Quickbook(cinemaid) {
    $("#ddlQBCinema").val(cinemaid);
    SelectedCinemaCallback()
}

function SelectedCinemaCallback() {

    jQuery("select#ddlQBFilm, select#ddlQBDay, select#ddlQBTime").attr("disabled", true);
    jQuery("select#ddlQBFilm, select#ddlQBDay, select#ddlQBTime").closest("p").addClass("dis");
    jQuery("#ScheduleID").val('');
    jQuery.getJSON("/cinemas/controls/QBOptions.aspx?srcChange=cinema", { id: jQuery("select#ddlQBCinema").val(), ajax: 'true' }, function (j) {
        var options = '';
        for (var i = 0; i < j.length; i++) {
            options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
        }

        if (j.length > 1) {
            jQuery("select#ddlQBFilm").html(options);
            jQuery("select#ddlQBFilm").removeAttr("disabled");
            jQuery("select#ddlQBFilm").closest("p").removeClass("dis");
            jQuery("select#ddlQBDay").html('<option value="">Select a day</option>');
            jQuery("select#ddlQBTime").html('<option value="">Select a time</option>');
        }
        else {
            jQuery("select#ddlQBFilm").html(options);
            jQuery("select#ddlQBDay").html('<option value="">Select a day</option>');
            jQuery("select#ddlQBTime").html('<option value="">Select a time</option>');
        }
    });
}
/*
(function(){
	$(function(){
		var $trailerBut = $(".trailerBut");
		
		$trailerBut.click(function(e){
			
		});
	});
})();*/
