$(function()
{

	resizeBG();
	$(window).resize(resizeBG).scroll(resizeBG);
	
	$('#palladio-flash').flash({
		src: webroot+"/workspace/img/gallery.swf",
	    width: 631,
	    height: 363, 
		wmode: 'transparent'			
	});


	$.each($('.external-link span'), function()
	{	
		// var linkWidth = $('.external-link span').width();
		
		if($(this).height() > 14)
		{
			var _height = 19;
			var _width = 18;
		}
		
		else
		{
			var _height = 5;
			var _width = $(this).width()+5;
		}

		$(this).parent().css('background-position', (_width)+'px '+_height+'px');
	});

	// Removes dotted border from around links
	$('a').click(function(){$(this).blur()});
	
	// Google Maps - Palladio
	$('.GMapEZ>div>span + a, .GMapEZ>div>span, .gmnoprint').hide();
	
	//Year of Palladio -Timeline
	if ($('#slider-container').length > 0)
	{
		var timelineSize = $('#sizer').innerWidth();	
		var sliderSize = $('#slider-container').innerWidth();
		var scrollSpace = Math.abs(timelineSize - sliderSize);		

		$('#slider-container').slider({
			handle: '#slide-handle',
			steps: 100,
			slide: function(e,ui)
			{			
				$('#panels').css('left', '-'+(scrollSpace/100)*ui.value+'px');
			}			
		});
	}


	$('a.yop-img img').each(function(){
		$(this).parent().parent().css({
			'background-image' : 'url(' + $(this).attr('src') + ')'
		});
	});
	$('#yop-homelist li').hover(function(){
		$(this).find('h2').css('color', '#b35c0a')
	},
	function(){
		$(this).find('h2').css('color', '#463729')
	});	
	
	$('#usa area').mouseover(function(){
		var id = $(this).attr('id');
		var ida = ['default','ne','se','mw','sw','w', 'international'];
			
		if (ida.indexOf) {
			var index = ida.indexOf(id);
		}
		else {
			for(var i=0; i<ida.length; i++){
	            if(ida[i]==id){
	                var index = i;
	            }
	        }
		};
				
		$('#map-overlay').css('background-position', ' 0px -' + (index * 416) + 'px');
	});
	
	$('#usa area').mouseout(function()
	{
		$('#map-overlay').css('background-position', '0px 0px');
	});
});

function returnRolloverToAS(id){
	var pageID = id;	
	var flashID = document.getElementById('rollovers');
	flashID.rolloverMC(id);
}

function resizeBG(){
	var wh = $(window).height();
	var dh = $(document).height();
	var ph = (wh > dh) ? wh : dh;
	$('.container').css('height', ph);
}