$(document).ready(function() {
    $(window).resize(function() {
		winHeight = $(window).height();
		winWidth = $(window).width();
		winWidthAdj = $(window).width() * widthCalc;
		winHeightAdj = $(window).height() * heightCalc;
	    $(".vposM").vAlign();
        $(".picCenter").hAlign();
	});
      
      (function ($) {
	      // VERTICALLY ALIGN FUNCTION
	      $.fn.vAlign = function() {
		      return this.each(function(i){
		        var ah = $(this).height();
		        var ph = $(window).height();
		        var mh = (ph - ah) / 2;
		        if(mh>0) {
		          $(this).css('margin-top', mh);
		        } else {
		          $(this).css('margin-top', 0);
		        }
		      });
	      };
      })(jQuery);
      
      (function ($) {
	      // VERTICALLY ALIGN FUNCTION
	      $.fn.hAlign = function() {
	          return this.each(function(i){
		        var ah = $(this).width();
		        var ph = $(window).width();
		        var mh = (ph - ah) / 2;
		        if(mh>0) {
		          $(this).css('margin-left', mh);
		        } else {
		          $(this).css('margin-left', 0);
		        }
		      });
	      };
      })(jQuery);
     
	$('.iconPic').each(function() {
	    $(this).css({
	        opacity: 0
	    }).bind('load', function() {
	        $(this).animate({
	            opacity: 1
	        }, 500);
	    });
	});

	function thumbsIn() {
		$('.nextLink').fadeOut();
		$('.navBox').fadeIn();
		$('#thumbsShow').hide();
		$('#thumbsHide').fadeIn();
	}

	function thumbsOut() {
		$('.nextLink').fadeIn();
		$('.navBox').fadeOut();
		$('#thumbsHide').hide();
		$('#thumbsShow').fadeIn();
	}

	function thumbsKO() {
		$('.navBox').fadeOut();
		$('#thumbsHide').hide();
		$('#thumbsShow').hide();
	}

	$('#thumbsShow').click(function() {thumbsIn();});
	
	$('#thumbsHide').click(function() {thumbsOut();});
	
	function wagNavIn() {
		$('#navBoxWag').fadeIn();
		$('#wagNavShow').hide();
		$('#wagNavHide').show();
	}

	function wagNavOut() {
		$('#navBoxWag').fadeOut();
		$('#wagNavHide').hide();
		$('#wagNavShow').fadeIn();
	}

	function wagNavKO() {
		$('#navBoxWag').fadeOut();
		$('#wagNavHide').hide();
		$('#wagNavShow').hide();
	}

	$('#wagNavShow').click(function() {wagNavIn();});

	$('#wagNavHide').click(function() {wagNavOut();});

	function myFunc() {
		$('#closer1').fadeIn();
		$('#basePlate').fadeIn();
	}

	$('#closer1').click(function() {
		$('#galleryHolder').load('/blank.html', function() { 
			$('#galleryHolder').hide();
			$('#navHolder').hide();
			$('.psBox').fadeIn();
		});
		$('.linkBar').load('/blank.html', function() {$('.linkBar').hide();});
	});

	$('.opener').click(function() {
		$('#basePanel').fadeOut();
		$('.footerAdd').hide();
		$('.footerGal').hide();
	});

	$('#panWag').click(function() {
		$('.footerAdd').hide();
		$('#footer').removeClass("footerFull");
		$('#basePanel').fadeOut();
		$('#pagePanel').load('/core/wag2013/3');
		$('#pagePanel').fadeIn();
		wagNavIn();
		$('.psBox').fadeIn();
	});
	$('#panPoetic').click(function() {
	  window.location = '/core/poeticscience';
	});
	
	$('#zoomCloser').click(function() {
		$('#bigPicBox').fadeOut();
		$('#scrim2').fadeOut();
		$('#scrollBox').hide();
		$('#zoomCloser').fadeOut();
	});  

	$('#preloader').load('/core/galleries', function() {});
	$('.footerGalLink').click(function() {
		window.location = '/core/galleries';
	});




	$('#pagePanel').delay(500).fadeIn();

	$('.footerGalLink').click(function() { window.location = '/core/galleries'; });
	
	$.vegas({
	  src:'/images/structure/grndwag-lo.jpg',
	  fade:2000,
	  load:function() {
		$( function() {
		  $.vegas({
		    src:'/images/structure/grndwag-hi.jpg',
		    fade:2000
		  });
		});
	  }
	});

	$('.psBox').fadeIn();

	$('#wagNavHide').fadeIn();
	$('#closeVideo').click(function() {
		$('#closeVideo').hide();
		$('#videoLayer').load('/blank.html', function() {$('#videoLayer').hide();});
	});
});

