function popup_setup()
{
	
	Shadowbox.setup("a.photo-gallery", {
        gallery:        "photos",
        continuous:     true,
        displayCounter:   false
    });


	
}


/************************************************************************
 * BEGIN jQuery PNG fix
 */
var blank = new Image();
blank.src = '/images/_global/spacer.gif';

function runPNGfix() {
  var badBrowser = (/MSIE ((5\.5)|6)/.test(navigator.userAgent) && navigator.platform == "Win32");
  if (badBrowser) {
    // get all pngs on page
    $('img[src$=.png]').each(function() {
    
      if (!this.complete) {
      
        this.onload = function() { fixPng(this) };
     
     } else {
     
        fixPng(this);
      }
    });
  }
};

function fixPng(png) {
  // get src
  var src = png.src;
  // set width and height
  if (!png.style.width) { png.style.width = $(png).width(); }
  if (!png.style.height) { png.style.height = $(png).height(); }
  // replace by blank image
  png.onload = function() { };
  png.src = blank.src;
  // set filter (display original image)
  png.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
}

/************************************************************************
 * END jQuery PNG fix
 */


function setSubNav( path )
{
	
	path = path.toLowerCase().replace( "default.asp", "" );
	 
	$("#subnav").find("a").each(function(i) 
	{ 
		
		var link = this.href.toLowerCase().replace( "default.asp", "" );
		if( link == path.toLowerCase() )
		{
			var label = $(this).text();
			setSubNavParent( $(this).parent() );
			$(this).replaceWith( '<span class="selected">' + label + '</span>' ); 
		}
		
		
	});
}

function setSubNavParent( parent )
{
	
	if( $( parent ).parent().attr( 'id' ) == "subnav" )
	{
		$( parent ).addClass( 'selected_parent' );
	
	} else {
		
		setSubNavParent( $( parent ).parent() );
	}
}


function resetVideoGallery()
{
	$("#videogallery").find("a").each(function(i)
 	{
		$(this).removeClass( "selected" );
	});
}


$(document).ready(function() 
{
	 /* swap buttons on rollover */
  	 $(this).find(".button").each(function(i) 
  	 { 	
		$(this).mouseover(function() 
		{ 	
			var src = this.src;
			this.src = src.replace( '_off.', '_over.' );	 
		});
		 
		$(this).mouseout(function()
		{	
			var src = this.src;
			this.src = src.replace( '_over.', '_off.' );	
		});
  	 });
  	 
  	 $("#main").find(".popup_box").each(function(i) 
  	 { 	
  	 	$(this).hide();
  	 });
  	  
  	$("#spotlights").find(".spot-caption").each(function(i) 
	{ 	 	
		var bgImg = '<img src="images/_global/spacer.gif" class="spot-caption-bg" />';		
		$(this).wrap( "<div class='spot-caption-container'></div>");
		$(this).parent().prepend( bgImg );
		$(this).parent().css( "top", 194 )
	 });
	
	$("#spotlights").find(".spot").each(function(i) 
	{ 
		$(this).hover(function(){$(".spot-caption-container", this).stop().animate({top:'108px'},{queue:false,duration:160});}, 
		function(){ $(".spot-caption-container", this).stop().animate({top:'194px'},{queue:false,duration:160});
		});
	
	});
	
	var col = 0;
	$("#videogallery").find(".spot").each(function(i) 
	{ 
		
		
		$(this).hover(function(){$(".spot-caption-container", this).stop().animate({top: '0px' },{queue:false,duration:160});}, 
			function(){ $(".spot-caption-container", this).stop().animate({top:'133px'},{queue:false,duration:160});
		});
		
		if( col == 0 )
		{
			$(this).css( "clear", "both" );
			
		} 
		col++;	
		
		if( col ==  3 ){
		
			$(this).css( "border-right", 0 );
			col = 0;
		
		} 
			
		
		
		//$("#videogallery").css("height", (i * 200) / 2 )
	
	});
	
	$("#subnav").find("li:last").each(function(i) 
	{ 	 
		$(this).css( "border", "0" );
	});
	
	$("#copy").find("img:last").each(function(i) 
	{ 	 
		$(this).css( "margin-bottom", "0" );
	});
 	
 	$("#copy").find("h1:first").each(function(i) 
	{	
		if( $(this).next().attr( "class" ) == "" )
		{
			$(this).next().addClass( "intro" );
		}	
	});
 	
 	var col = 1;
 	$("#videogallery").find("a").each(function(i)
 	{	
 		
 		var vid = this.href;
		var width = 435;
		var height= 324;
		var autostart = "true"
		var video;
		
		if( vid.search("vimeo.com") > 0 )
		{
			vid = vid.substring( vid.search("vimeo.com") + 10 );
			video = '<object width="' + width + '" height="' + height + '">';
			video += '<param name="allowfullscreen" value="true" />';
			video += '<param name="allowscriptaccess" value="always" />';
			video += '<param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=' + vid + '&amp;server=vimeo.com&amp;autoplay=1&amp;show_title=01&amp;show_byline=0&amp;show_portrait=0&amp;color=&amp;fullscreen=1" />';
			video += '<embed src="http://vimeo.com/moogaloop.swf?clip_id=' + vid + '&amp;server=vimeo.com&amp;autoplay=1&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="' + width + '" height="' + height + '"></embed>';
			video += '</object>';
			
		} else {
		
			var vp = "/includes/videoplayer/player-licensed-viral.swf"; 
			video = '<object id="player" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="player" width="' + width + '" height="' + height + '">';
			video += '<param name="movie" value="' + vp + '" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" />';
			video += '<param name="flashvars" value="file=' + vid + '&autostart=' + autostart + '" />';
			video += '<embed type="application/x-shockwave-flash" id="player2" name="player2" src="' + vp + '" width="' + width + '" height="' + height + '" allowscriptaccess="always"  allowfullscreen="true" flashvars="file=' + vid + '&autostart=' + autostart + '" />';
			video += '</object>';
		}
 				
 		$(this).click(function() 
		{	
			
			$(this).addClass( "selected" );
			
			$("#videoplayer").empty();
			$("#videoplayer").append( video );
			
			return false;
		});
		
		
		
		
		////if( i == 0 )
		//{
			//$("#videoplayer").empty();
			//$("#videoplayer").append( video );
		//}
		
		
		if( col == 3 )
		{
			col = 1;
			$(this).parent().css( "border-right", "0" );
		} else {
		
			col++;
		}
 	});
 	
 	
 	
	$(window).resize( resizeHandler );
	resizeHandler();
	runPNGfix();
});

function resizeHandler()
{
	if( window.innerWidth < 1060 )
 	{
 		$("#wrapper").css( { "left" : "-0px", "margin-left" : "0" } );
 	
 	} else {
 		
 		$("#wrapper").css( { "left" : "50%", "margin-left" : "-515px" } );
 	}
}

if( document.images )
{
	/*preload_bg1 = new Image(660, 1200); 
	preload_bg1.src = "images/background-concrete.jpg";*/
}