
		var firstPhoto = true;
		(function($) {

			$(function() {
				
				$("#presByIframeContainer").children("iframe").load(function(){
                    var presbyHeight = $(this).contents().find("body").height();

                    if(presbyHeight > 1) {

                        $("#presByIframeContainer").css({
                            "visibility": "visible",
                            "height": presbyHeight
                        });

                        $("#presByIframeContainer").children("iframe").css("height", presbyHeight);

                    }
                });


			});

		})(jQuery);
	
				(function($){
					$(function() {

						$.history.init(check_hash, window.location.href);

						//bind events
						$(".navLink").live("click", pageClick);

						if(window.location.hash.length == 0 || window.location.hash.indexOf("pg_") < 0) {
							$(".photo-index").css("display", "block");
						}
					});


					function pageClick() {

						var hash = "pg_"+this.id.substring(5);
						hash = hash.replace(/^.*#/, '');
						$.history.load(hash);
						return false;
					}


					function check_hash(hash) {

						if(hash) {
							if($.browser.msie) {
								hash = encodeURIComponent(hash);
							}
							sportId = 54
							gameId = 284000019
							currentPage = ($(".currentPage").text());
							page = hash.substring(3);
							photosPerPage = 18;

							changeThumbnails(photosPerPage, currentPage, page, gameId, sportId);

						} else {

							params = window.location.search.substring(1).split("&");

							page = 1;

							for(var i = 0; i < params.length; i++) {
								var NVpair = params[i].split("=");
								if(NVpair[0] == "page") {
									page = NVpair[1];
								}
							}

							sportId = 54
							gameId = 284000019
							currentPage = ($(".currentPage").text());
							photosPerPage = 18;

							changeThumbnails(photosPerPage, currentPage, page, gameId, sportId);

						}
					}



					function changeThumbnails(photosPerPage, currentPage, page, gameId, sportId) {

						dataString = "photosPerPage="+photosPerPage+"&currentPage="+currentPage+"&page="+page+"&gameId="+gameId+"&sportId="+sportId;

						$.ajax({
							type: "GET",
							url: "/ncw/gamepackage10/photos/getThumbnails",
							data: dataString,
							dataType: "json",
							success: function(data) {

								$(".photo-index").html(data.thumbnails.length > 0 ? data.thumbnails : 'No photos currently available.');
								$(".photo-nav").html(data.pageNav);
								if($(".photo-index").is(":hidden")) {
									$(".photo-index").css("display", "block");
								}
								try {
									s_omni.t();
								}catch(e) {

								}
								try{

									if(!(firstPhoto)) {

										$("#presbyIframe")[0].src = $("#presbyIframe")[0].src;

										//to remove html inside poster ad, then replace it with the iframe
										$(".ad-box").html("");
										$(".ad-box").html('<iframe width="300" id="adIframe" scrolling="NO" height="250" frameborder="0" src="/ncw/photos?ads=incontent" marginheight="0" marginwidth="0"/></iframe>');
										$(".prWrap").remove();
									}
									else {
										firstPhoto = false;
									}

								}catch(e){
								}
							},
							error: function(error) {
								 //alert("error: "+error);
							}

						});
					}

				})(jQuery);
	