function loadGlobalVariables() {
    $.getScript('/js/GlobalVariables.js', null);
}

$(function () {
    loadGlobalVariables();
    /*
    Homepage marquee
    */
    $('#mobileRedirectAnchor').click(function () {

        var action = window.location.pathname;
        var movieIdRegex = /(\/[0-9]+)/;
        var showtimeIndex = action.indexOf('/showtimes/');
        var targetUrl = mobileHost;

        if (showtimeIndex > -1) {
            var movieId = action.match(movieIdRegex)[0];
            if (movieId !== "") {
                targetUrl = mobileHost + "/movie" + movieId;
            }
        }

        $.dough("siteVersion", "mobile", { domain: domainSite });
        window.location = targetUrl;
        return false;
    });

    if ($('#slides').length > 0) {
        $.getJSON('/home/slider?guid=' + $('#marquee').attr('rel'), function(data) {
            $.each(data.promos, function(i, promo) {
                if (promo.url) {
                    $('<div/>', {
                        html: $('<a/>', {
                            href: promo.url,
                            target: promo.window,
                            html: $('<img/>', {
                                src: webHost + '/img/' + promo.image
                            })
                        })
                    }).appendTo('.slides_container');
                } else {
                    $('<div/>', {
                        html: $('<img/>', {
                            src: webHost + '/img/' + promo.image
                        })
                    }).appendTo('.slides_container');
                }
            });
            $('#slides').slides({
                    preload: true,
                    preloadImage: '/img/loading.gif',
                    slideSpeed: 500,
                    slideEasing: 'easeOutQuad',
                    generatePagination: false,
                    play: 5000,
                    pause: 2500,
                    hoverPause: true
                });
        });
    }

		$("#skybox_slides").slides({
			play:8000,
			generatePagination:false
		});
		
    var theater_id = $("#theater_id").attr("value");
    var userName = "";
    var userEmail = "";

    /*	Theater specific promos
    if ((theater_id == "11" || theater_id == "29" || theater_id == "12" || theater_id == "2") && $("body").attr("id") === "home") {
    var html = "<div id=\"promo_2\">" +
    "<a href=\"/gifts-and-events/\">" +
    "<img src=\"/img/sidebar_valentines_cayman.jpg\" width=\"336\" height=\"170\" alt=\"\" />" +
    "</a>" +
    "</div>";
    $("#right").append(html);
    } else if ($("body").attr("id") === "home") {
    var html = "<div id=\"promo_2\">" +
    "<a href=\"/gifts-and-events/\">" +
    "<img src=\"/img/sidebar_valentines.jpg\" width=\"336\" height=\"170\" alt=\"\" />" +
    "</a>" +
    "</div>";
    $("#right").append(html);
    }
    */
    //Ticket #255
//    if (theater_id == "3" && $("body").attr("id") === "home") {
//        var html = "<div id=\"promo_3\">" +
//                    "<a href=\"/our-theaters/family-movies/gilbert-az/\">" +
//                        "<img src=\"/img/gilbert-reel-parents-right.jpg\" width=\"336\" alt=\"\" />" +
//                    "</a>" +
//                "</div>";
//        $("#right").append(html);
//    }



    if (theater_id == "13" || theater_id == "44" || theater_id == "21") {
        $('p.pass_disclaimer').css({ 'display': 'none' });
    }

    $.preloadCssImages();

    $(".wrap label").inFieldLabels({
        fadeOpacity: 0,
        fadeDuration: 100
    });

    $('input.date').DatePicker({
        format: 'A, B d, Y',
        date: $('input.date').val(),
        current: $('input.date').val(),
        starts: 0,
        position: 'bottom',
        onBeforeShow: function () {
            $('input.date').DatePickerSetDate($('input.date').val(), true);
        },
        onChange: function (formated, dates) {
            $('input.date').val(formated);
            $('input.date').DatePickerHide();
            var date = new Date($('input.date').val());
            document.location.href = '/tickets-and-showtimes/?date=' + ((date.getMonth() + 1) + '%2F' + (date.getDate()) + '%2F' + date.getFullYear());
        }
    });

    $("#location_search .change_locaiton").keypress(function (e) {
        if (e.keyCode == 13 || e.keyCode == 10) {
            document.location.href = '/home/setlocation/' + $("#location_search .change_locaiton").val();
            //            var getBtnId = $("#location_search .go").attr("id");
            //            __doPostBack(getBtnId, 'ChangeLocation|' + $("#location_search .change_locaiton").val());
            return false;
        }
    });

    $("#location_search .go").click(function () {
        document.location.href = '/home/setlocation/' + $("#location_search .change_locaiton").val();
        return false;
    });

    $("#find_location .go").click(function () {
        document.location.href = '/home/setlocation/' + $("#find_location .change_locaiton").val();
        return false;
    });

    $("#find_location .change_locaiton").keypress(function (e) {
        if (e.keyCode == 13 || e.keyCode == 10) {
            document.location.href = '/home/setlocation/' + $("#find_location .change_locaiton").val();
            //            var getBtnId = $("#find_location .go").attr("id");
            //            __doPostBack(getBtnId, 'ChangeLocation|' + $("#find_location .change_locaiton").val());
            return false;
        }
    });

    $("#your_showtimes .movie:first,#home #coming_attractions .attraction:first").css("border-top", "1px dotted #434343");
    $("#footer ul li:last").css("background", "none");
    $(".movie dl").each(function () {
        $("dd:last", this).css("background", "none");
    });

    $(".calendar").click(function () {
        $(".date").click();
    });

    $('a[rel="external"]').click(function () {
        window.open($(this).attr("href"));
        return false;
    });

    if ($(".change_theater").length) {
        var current_date = $("#currentdate").attr("value").split(" ");
        //var current_date = $(".showtime_dates option:selected").attr("value").split(" ");
        current_date = current_date[0].replace("/", "-").replace("/", "-");

        $("#home a.change_theater").click(function () {
            var h = $("#find_theater").outerHeight() + 40;
            $("#left .inner").animate({ height: h }, 800);
            $("#location_set").fadeOut(function () {
                $("#find_theater").fadeIn();
            });
            return false;
        });

        $("#tickets_and_showtimes .change_theater").click(function () {
            $("#theater_showtimes").animate({ height: 0, opacity: 0 }, 800, function () {
                $(this).css("display", "none");
            });
            $("#location_set").animate({ height: 108, opacity: 0 }, 800, function () {
                $(this).css("display", "none");
                $("#find_theater").fadeIn();
            });
            return false;
        });
    }
    $("a.info_prices").click(function () {
        $("#basic-modal-content").modal({
            maxWidth: 620,
            minHeight: 550,
            positiontype: "absolute",
            overlayClose: true, onShow: function () {
                $("#simplemodal-container").append("<div class=\"loading\"></div>");
                $("#simplemodal-container").addClass("theater_info");
                var theaterId = $("#theater_id").attr("value");
                $.ajax({
                    type: "GET",
                    url: "/theater/gettheater/" + theater_id + "",
                    dataType: "json",
                    success: function (theater) {
                        var contentString = '<div id="theater_content">' +
                        '<h2>' + theater.Name + '</h2><p>' + theater.Description + '</p>' +
                        '<div id=\"price_list\">' +
                        '<h2>Ticket Prices</h2>' +
                        '<table border=\"0\" cellpadding=\"3\" cellspacing=\"3\" width=\"560\">' +
                        '</table>' +
                        '<p style=\"margin-top:10px;\">A $1.25 service fee will be charged per ticket purchased online.</p>' +
                        '</div>' +
                        '<div id=\"special_list\">' +
                        '</div>' +
                    '</div>';
                        $("#basic-modal-content").append(contentString);
                        $.each(theater.Prices, function (i, item) {
                            $('<tr><td width=\"520\" style=\"padding:5px 0px 5px 0px;\">' + item.Description + '</td><td align=\"right\">' + item.Price + '</td></tr><tr><td style=\"border-bottom:solid 1px #808080;\" colspan=\"2\"><img src=\"/img/spacer.gif\" alt=\"\" border=\"0\" width=\"1\" height=\"1\" /></td></tr>').appendTo("#price_list table");
                        });
                        if (theater.TheaterSpecials.length > 0) {
                            $('<h2>Theater Specials</h2>' +
                              '<table border=\"0\" cellpadding=\"3\" cellspacing=\"3\" width=\"560\">' +
                              '</table>').appendTo("#special_list");

                            $.each(theater.TheaterSpecials, function (i, item) {
                                $('<tr><td width=\"520\" style=\"padding:5px 0px 5px 0px;\">' + item.Description + '</td></tr><tr><td style=\"border-bottom:solid 1px #808080;\" colspan=\"2\"><img src=\"/img/spacer.gif\" alt=\"\" border=\"0\" width=\"1\" height=\"1\" /></td></tr>').appendTo("#special_list table");
                            });
                        }
                        $(".loading").remove();
                        $("#simplemodal-container").animate({ height: $('#theater_content').outerHeight() }, 500, function () {
                            $(".simplemodal-close").show();
                            $("#basic-modal-content").css("display", "block");
                        });
                    }
                });
            }
        });
        return false;
    });

    $("a.prices").click(function () {
        $("#basic-modal-content").modal({
            maxWidth: 620,
            minHeight: 200,
            positiontype: "absolute",
            overlayClose: true, onShow: function () {
                $("#simplemodal-container").append("<div class=\"loading\"></div>");
                $("#simplemodal-container").addClass("price_info");
                var theaterId = $("#theater_id").attr("value");
                $.ajax({
                    type: "GET",
                    url: "/theater/gettheater/" + theater_id + "",
                    dataType: "json",
                    success: function (theater) {
                        var contentString = '<div id="theater_content">' +
                        '<div id=\"price_list\">' +
                        '<h2>Ticket Prices</h2>' +
                        '<table border=\"0\" cellpadding=\"3\" cellspacing=\"3\" width=\"560\">' +
                        '</table>' +
                        '<p style=\"margin-top:10px;\">A $1.25 service fee will be charged per ticket purchased online.</p>' +
                        '</div>' +
                        '<div id=\"special_list\">' +
                        '</div>' +
                    '</div>';
                        $("#basic-modal-content").append(contentString);
                        $.each(theater.Prices, function (i, item) {
                            $('<tr><td width=\"520\" style=\"padding:5px 0px 5px 0px;\">' + item.Description + '</td><td align=\"right\">' + item.Price + '</td></tr><tr><td style=\"border-bottom:solid 1px #808080;\" colspan=\"2\"><img src=\"/img/spacer.gif\" alt=\"\" border=\"0\" width=\"1\" height=\"1\" /></td></tr>').appendTo("#price_list table");
                        });
                        if (theater.TheaterSpecials.length > 0) {
                            $('<h2>Theater Specials</h2>' +
                              '<table border=\"0\" cellpadding=\"3\" cellspacing=\"3\" width=\"560\">' +
                              '</table>').appendTo("#special_list");

                            $.each(theater.TheaterSpecials, function (i, item) {
                                $('<tr><td width=\"520\" style=\"padding:5px 0px 5px 0px;\">' + item.Description + '</td></tr><tr><td style=\"border-bottom:solid 1px #808080;\" colspan=\"2\"><img src=\"/img/spacer.gif\" alt=\"\" border=\"0\" width=\"1\" height=\"1\" /></td></tr>').appendTo("#special_list table");
                            });
                        }
                        $(".loading").remove();
                        $("#simplemodal-container").animate({ height: $('#theater_content').outerHeight() }, 500, function () {
                            $(".simplemodal-close").show();
                            $("#basic-modal-content").css("display", "block");
                        });

                    }
                });
            }
        });
        return false;
    });

    $("a.show_on_map").click(function () {
        $("#basic-modal-content").modal({
            minHeight: 450,
            positiontype: "absolute",
            overlayClose: true, onShow: function () {
                $("#simplemodal-container").addClass("map");
                var theaterId = $("#theater_id").attr("value");
                $.ajax({
                    type: "GET",
                    url: "/theater/gettheater/" + theater_id + "",
                    dataType: "json",
                    success: function (theater) {
                        $(".loading").remove();
                        $("#basic-modal-content").append("<div id=\"map\"></div>");
                        function initialize() {
                            var myLatlng = new google.maps.LatLng(theater.Latitude, theater.Longitude);
                            var myOptions = {
                                zoom: 14,
                                center: myLatlng,
                                mapTypeId: google.maps.MapTypeId.ROADMAP,
                                mapTypeControlOptions: { style: google.maps.MapTypeControlStyle.DROPDOWN_MENU },
                                backgroundColor: "#000000"
                            };
                            var map = new google.maps.Map(document.getElementById("map"), myOptions);
                            var contentString = '<div id="map_content">' +
                    '<div class="left_col">' +
                    '<img src="' + theater.ImageUrl + '" alt="' + theater.Name + '" class="theater" />' +
                    '</div>' +
                    '<div class="right_col">' +
                    '<h1>' + theater.Name + '</h1>' +
                    '<p>' + theater.Address + '<br/>' + theater.Phone + '</p>' +
                    '<p><a href="/tickets/' + theater.Permalink + '">Showtimes</a>' +
                    '<form action="http://maps.google.com/maps" method="get" target="_blank">' +
                    '<p>Start address: <input type="text" size=30 maxlength=40 name="saddr" id="saddr" value="" /><br>' +
                    '<INPUT value="Get Directions" TYPE="SUBMIT">' +
                    '<input type="hidden" name="daddr" value=""/>' +
                    '</p>' +
                    '</div>' +
                    '</div>';
                            var infowindow = new google.maps.InfoWindow({
                                content: contentString
                            });
                            var marker = new google.maps.Marker({
                                position: myLatlng,
                                map: map,
                                title: 'Uluru (Ayers Rock)'
                            });
                            google.maps.event.addListener(marker, 'click', function () {
                                infowindow.open(map, marker);
                            });
                        }
                        initialize();
                    }
                });
            }
        });
        return false;
    });

    $("#tickets_and_showtimes a.tickets").click(function () {
        var movie_name = $(this).parent().find("h3").html();
        var movie_data = "";

        $.each($(this).parent().find(".times"), function (index, value) {
            movie_data += $(value).html() + "<br /><br />"
        });
        var disclaimer = "";
        if (theater_id == "7") {
            disclaimer = "<p><small>Premiere balcony seating is available for SELECT showtimes. If you do not see an option to select \"Premiere Seating\" when purchasing tickets, that showtime is all general seating.</small></p>";
        }
        $("#basic-modal-content").modal({
            maxWidth: 640,
            maxHeight: 150,
            overlayClose: true,
            positiontype: "absolute",
            onShow: function () {
                $("#simplemodal-container").addClass("movie");
                var html = "<div id=\"movie_showtimes\" class=\"clearfix\">" +
            "<div class=\"inner clearfix\">" +
            "<h1 id=\"click_showtimes\" class=\"title\">Click Showtimes for Tickets</h1>" +
            "<div class=\"section clearfix\">" +
            "<h3>" + movie_name + "</h3>" +
            "<dl class='times'>" + movie_data + "</dl>" +
            disclaimer +
            "</div>" +
            "</div>" +
            "</div>";
                $("#basic-modal-content").append(html);
            }
        });
        return false;
    });

    $("a.print_showtimes").click(function () {
        var getHref = $(this).attr("href");
        window.open(getHref, 'print', 'width=700,height=600,screenX=100,screenY=200,top=100,left=200,scrollbars=yes,toolbar=no,location=no');
        return false;
    });

    $("a.trailer").click(function () {
        var trailerPath = $(this).attr("href");
        $("#basic-modal-content").modal({
            overlayClose: true,
            containerId: "trailer-container",
            positiontype: "absolute",
            onShow: function () {
                $("#trailer-container").append("<div class=\"loading\"></div>");
                $(".simplemodal-close").hide();
                var html = "<div id=\"video_player\">" +
                    "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"640\" height=\"302\" id=\"myFlashContent\">" +
                        "<param name=\"movie\" value=\"/swf/video-player.swf\" />" +
                        "<param value=\"noscale\" name=\"scale\">" +
                        "<param value=\"true\" name=\"allowfullscreen\">" +
                        "<param value=\"tl\" name=\"salign\">" +
                        "<param value=\"000000\" name=\"bgcolor\">" +
                        "<param value=\"imagePath=&amp;videoPath=" + trailerPath + "&amp;title=&amp;description=&amp;viewInfoButton=false&amp;viewFullscreenButton=false&amp;viewScaleButton=false&amp;viewVolumeControls=true&amp;viewTime=false&amp;viewBigPlayButton=true&amp;viewRightClickMenu=true&amp;mouseHide=true&amp;mouseHideTime=3&amp;doubleClick=false&amp;oneClick=true&amp;spaceKey=true&amp;videoLoop=false&amp;videoAutoPlay=false&amp;videoBufferTime=0.1&amp;tlInterval=100000&amp;soundVolume=0.8&amp;fullSizeView=2&amp;spacing=10&amp;controlHeight=25&amp;volumeLengthW=50&amp;color1=0x2e2e2e&amp;color2=0x000000&amp;alpha1=1&amp;alpha2=1&amp;borderColor=0x555555&amp;borderAlpha=1&amp;timeColor1=0x333333&amp;timeColor2=0x111111&amp;timeAlpha1=1&amp;timeAlpha2=1&amp;timeTextColor1=0xffffff&amp;timeTextColor2=0x888888&amp;scrubberHeight=3&amp;scrubberColor1=0x333333&amp;scrubberAlpha1=1&amp;scrubberColor2=0x88acc4&amp;scrubberAlpha2=1&amp;filterColor=0x0066ff&amp;filterAlpha=1&amp;titleColor=0x88acc4&amp;descriptionColor=0xD3D3D3&amp;infoBackgroundColor=0x000000&amp;infoBackgroundAlpha=0.5\" name=\"flashvars\">" +
                        "<!--[if !IE]>-->" +
                        "<object type=\"application/x-shockwave-flash\" data=\"/swf/video-player.swf\" width=\"640\" height=\"302\">" +
                        "<param value=\"noscale\" name=\"scale\">" +
                        "<param value=\"true\" name=\"allowfullscreen\">" +
                        "<param value=\"tl\" name=\"salign\">" +
                        "<param value=\"000000\" name=\"bgcolor\">" +
                        "<param value=\"imagePath=&amp;videoPath=" + trailerPath + "&amp;title=&amp;description=&amp;viewInfoButton=false&amp;viewFullscreenButton=false&amp;viewScaleButton=false&amp;viewVolumeControls=true&amp;viewTime=false&amp;viewBigPlayButton=true&amp;viewRightClickMenu=true&amp;mouseHide=true&amp;mouseHideTime=3&amp;doubleClick=false&amp;oneClick=true&amp;spaceKey=true&amp;videoLoop=false&amp;videoAutoPlay=false&amp;videoBufferTime=0.1&amp;tlInterval=100000&amp;soundVolume=0.8&amp;fullSizeView=2&amp;spacing=10&amp;controlHeight=25&amp;volumeLengthW=50&amp;color1=0x2e2e2e&amp;color2=0x000000&amp;alpha1=1&amp;alpha2=1&amp;borderColor=0x555555&amp;borderAlpha=1&amp;timeColor1=0x333333&amp;timeColor2=0x111111&amp;timeAlpha1=1&amp;timeAlpha2=1&amp;timeTextColor1=0xffffff&amp;timeTextColor2=0x888888&amp;scrubberHeight=3&amp;scrubberColor1=0x333333&amp;scrubberAlpha1=1&amp;scrubberColor2=0x88acc4&amp;scrubberAlpha2=1&amp;filterColor=0x0066ff&amp;filterAlpha=1&amp;titleColor=0x88acc4&amp;descriptionColor=0xD3D3D3&amp;infoBackgroundColor=0x000000&amp;infoBackgroundAlpha=0.5\" name=\"flashvars\">" +
                        "<!--<![endif]-->" +
                            "<a href=\"http://www.adobe.com/go/getflashplayer\">" +
                                "<img src=\"http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif\" alt=\"Get Adobe Flash player\" />" +
                            "</a>" +
                        "<!--[if !IE]>-->" +
                        "</object>" +
                            "<!--<![endif]-->" +
                        "</object>" +
                    "</div>";
                $("#basic-modal-content").css("display", "none").append(html);
                $(".simplemodal-close").show();
                $(".loading").remove();
                $("#basic-modal-content").css("display", "block");
            },
            minHeight: 302
        });
        return false;
    });

    /*
    $("a.view_trailer,a.view_synopsis,.movie_poster").click(function() {
    $(this).parents(".movie").find(".movie_title").click();
    return false;
    });
    */


    if (theater_id == "7") {
        $(".movie dl.times dd a").click(function () {
            var href = $(this).attr("href");
            $("#basic-modal-content").modal({
                maxWidth: 300,
                maxHeight: 100,
                overlayClose: true,
                positiontype: "absolute",
                onShow: function () {
                    $("#simplemodal-container").addClass("disclaimer");
                    var html = "<p>Premiere balcony seating is available for SELECT showtimes. If you do not see an option to select &ldquo;Premiere Seating&rdquo; when purchasing tickets, that showtime is all general seating.</p><p><a href=" + href + " class=\"btn continue\">Continue</a></p>";
                    $("#basic-modal-content").append(html);
                }
            });
            return false;
        });
    }

    $("#showtimes .changetheater").click(function () {
        $("#changetheater").slideDown(300);
    });

    $('.PrintAtHome').qtip({
        content: 'Print Tickets At Home',
        show: 'mouseover',
        hide: 'mouseout',
        position: {
            corner: {
                target: 'topMiddle',
                tooltip: 'bottomMiddle'
            }
        },
        style: {
            padding: 2,
            background: '#121212',
            color: '#fff',
            textAlign: 'center',
            border: {
                width: 0,
                radius: 3,
                color: '#121212'
            },
            tip: true
        }
    });
    $('.Kiosk').qtip({
        content: 'Ticket Kiosk',
        show: 'mouseover',
        hide: 'mouseout',
        position: {
            corner: {
                target: 'topMiddle',
                tooltip: 'bottomMiddle'
            }
        },
        style: {
            padding: 2,
            background: '#121212',
            color: '#fff',
            textAlign: 'center',
            border: {
                width: 0,
                radius: 3,
                color: '#121212'
            },
            tip: true
        }
    });
    $('.GameRoom').qtip({
        content: 'Gaming Room',
        show: 'mouseover',
        hide: 'mouseout',
        position: {
            corner: {
                target: 'topMiddle',
                tooltip: 'bottomMiddle'
            }
        },
        style: {
            padding: 2,
            background: '#121212',
            color: '#fff',
            textAlign: 'center',
            border: {
                width: 0,
                radius: 3,
                color: '#121212'
            },
            tip: true
        }
    });
    $('.WheelChair').qtip({
        content: 'Wheelchair Accessible',
        show: 'mouseover',
        hide: 'mouseout',
        position: {
            corner: {
                target: 'topMiddle',
                tooltip: 'bottomMiddle'
            }
        },
        style: {
            padding: 2,
            background: '#121212',
            color: '#fff',
            textAlign: 'center',
            border: {
                width: 0,
                radius: 3,
                color: '#121212'
            },
            tip: true
        }
    });
    $('.WheelChair').qtip({
        content: 'Wheelchair Accessible',
        show: 'mouseover',
        hide: 'mouseout',
        position: {
            corner: {
                target: 'topMiddle',
                tooltip: 'bottomMiddle'
            }
        },
        style: {
            padding: 2,
            background: '#121212',
            color: '#fff',
            textAlign: 'center',
            border: {
                width: 0,
                radius: 3,
                color: '#121212'
            },
            tip: true
        }
    });
    $('.ListeningDevices').qtip({
        content: 'Listening Devices Available',
        show: 'mouseover',
        hide: 'mouseout',
        position: {
            corner: {
                target: 'topMiddle',
                tooltip: 'bottomMiddle'
            }
        },
        style: {
            padding: 2,
            background: '#121212',
            color: '#fff',
            textAlign: 'center',
            border: {
                width: 0,
                radius: 3,
                color: '#121212'
            },
            tip: true
        }
    });
    $('.PartyRoom').qtip({
        content: 'Party Room!',
        show: 'mouseover',
        hide: 'mouseout',
        position: {
            corner: {
                target: 'topMiddle',
                tooltip: 'bottomMiddle'
            }
        },
        style: {
            padding: 2,
            background: '#121212',
            color: '#fff',
            textAlign: 'center',
            border: {
                width: 0,
                radius: 3,
                color: '#121212'
            },
            tip: true
        }
    });
    $('.AllStadiumSeating').qtip({
        content: 'All Stadium Seating',
        show: 'mouseover',
        hide: 'mouseout',
        position: {
            corner: {
                target: 'topMiddle',
                tooltip: 'bottomMiddle'
            }
        },
        style: {
            padding: 2,
            background: '#121212',
            color: '#fff',
            textAlign: 'center',
            border: {
                width: 0,
                radius: 3,
                color: '#121212'
            },
            tip: true
        }
    });

    $('.G').qtip({
        content: 'General Audiences - All ages admitted',
        show: 'mouseover',
        hide: 'mouseout',
        position: {
            corner: {
                target: 'topMiddle',
                tooltip: 'bottomMiddle'
            }
        },
        style: {
            padding: 2,
            background: '#121212',
            color: '#fff',
            textAlign: 'center',
            border: {
                width: 0,
                radius: 3,
                color: '#121212'
            },
            tip: true
        }
    });
    $('.PG').qtip({
        content: 'Parental Guidance Suggested - Some material may not be suitable for children',
        show: 'mouseover',
        hide: 'mouseout',
        position: {
            corner: {
                target: 'topMiddle',
                tooltip: 'bottomMiddle'
            }
        },
        style: {
            padding: 2,
            background: '#121212',
            color: '#fff',
            textAlign: 'center',
            border: {
                width: 0,
                radius: 3,
                color: '#121212'
            },
            tip: true
        }
    });
    $('.PG-13').qtip({
        content: 'Parents Strongly Cautioned - Some material may not be suitable for children under 13',
        show: 'mouseover',
        hide: 'mouseout',
        position: {
            corner: {
                target: 'topMiddle',
                tooltip: 'bottomMiddle'
            }
        },
        style: {
            padding: 2,
            background: '#121212',
            color: '#fff',
            textAlign: 'center',
            border: {
                width: 0,
                radius: 3,
                color: '#121212'
            },
            tip: true
        }
    });
    $('.R').qtip({
        content: 'Restricted - Under 17 requires accompanying parent or adult guardian',
        show: 'mouseover',
        hide: 'mouseout',
        position: {
            corner: {
                target: 'topMiddle',
                tooltip: 'bottomMiddle'
            }
        },
        style: {
            padding: 2,
            background: '#121212',
            color: '#fff',
            textAlign: 'center',
            border: {
                width: 0,
                radius: 3,
                color: '#121212'
            },
            tip: true
        }
    });
    $("#promo_email .sign_up").click(function () {
        var userName = $("#promo_email #name").val();
        var userEmail = $("#promo_email #email").val();
        if (userName && userEmail) {
            window.location = "/hollywood-insider/?u=" + userName + "&e=" + userEmail + "";
        }
        return false;
    });
    $("input.email").keypress(function (e) {
        if (e.keyCode == 13 || e.keyCode == 10) {
            var userName = $("#promo_email .name").val();
            var userEmail = $("#promo_email .email").val();
            if (userName && userEmail) {
                window.location = "/hollywood-insider/?u=" + userName + "&e=" + userEmail + "";
            }
            return false;
        }
    });
    if ($("body#hollywood-insider").length) {
        userName = getQuery("u");
        if (userName) {
            userName = userName.replace("%20", " ");
            $(".name").val(userName);
            $(".email").val(getQuery("e"));
        }
    }
});

function getQuery(obj) {
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split("=");
        if (pair[0] == obj) {
            return pair[1];
        }
    }
}

/*
CSS Browser Selector v0.4.0 (Nov 02, 2010)
Rafael Lima (http://rafael.adm.br)
http://rafael.adm.br/css_browser_selector
License: http://creativecommons.org/licenses/by/2.5/
Contributors: http://rafael.adm.br/css_browser_selector#contributors
*/
function css_browser_selector(u){var ua=u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1;},g='gecko',w='webkit',s='safari',o='opera',m='mobile',h=document.documentElement,b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3.6')?g+' ff3 ff3_6':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('blackberry')?m+' blackberry':is('android')?m+' android':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?m+' j2me':is('iphone')?m+' iphone':is('ipod')?m+' ipod':is('ipad')?m+' ipad':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win'+(is('windows nt 6.0')?' vista':''):is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent);
