/*
jQUERY
--------------------------------------------------*/
$(document).ready (function() {
	
	// Navigation
	$('div#site-navigation ul li').hover(
		function() {
			$('a',this).addClass('hover');
			$('ul',this).css({
				left: 0,
				top: 18
			});
		},
		function() {
			$('a',this).removeClass('hover');
			$('ul',this).css({
				left: -9999,
				top: -9999
			});
		}
	);
	
	// Open external links in new window :P
	$('a.external').click(function() {
		window.open( $(this).attr('href') );
		
		return false;
	});
	
	// Header Flash
	/*$('body.home #site-branding').flash(
		{
	    	src: '/framework/swf/site-branding.home.swf',
	    	width: 800,
	    	height: 230,
	    	wmode: 'transparent'
		},
		{
			update: false,
			version: 7
		}
	);
	$('body.traditionFlash #site-branding').flash(
		{
	    	src: '/framework/swf/site-branding.tradition.swf',
	    	width: 800,
	    	height: 230,
	    	wmode: 'transparent'
		},
		{
			update: false,
			version: 7
		}
	);
	$('body.areaFlash #site-branding').flash(
		{
	    	src: '/framework/swf/site-branding.local_area.swf',
	    	width: 800,
	    	height: 230,
	    	wmode: 'transparent'
		},
		{
			update: false,
			version: 7
		}
	);
	$('body.state #site-branding').flash(
		{
	    	src: '/framework/swf/site-branding.state.swf',
	    	width: 800,
	    	height: 230,
	    	wmode: 'transparent'
		},
		{
			update: false,
			version: 7
		}
	);
	$('body.membershipFlash #site-branding').flash(
		{
	    	src: '/framework/swf/site-branding.membership.swf',
	    	width: 800,
	    	height: 230,
	    	wmode: 'transparent'
		},
		{
			update: false,
			version: 7
		}
	);
	$('body.villageFlash #site-branding').flash(
		{
	    	src: '/framework/swf/site-branding.village.swf',
	    	width: 800,
	    	height: 230,
	    	wmode: 'transparent'
		},
		{
			update: false,
			version: 7
		}
	);*/
	
	// Dropdown
	/*$('div#site-navigation ul li').hover(
		function() { $('ul',$(this)).show(); },
		function() { $('ul',$(this)).hide(); }
	);*/
	
	// Popup
	$('a.popup-lg').click(function() {
		$('<div id="popup-lg" class="popup"><img src="' + $(this).attr('href') + '" /><a href="#" class="popup-close">Close</a></div>').appendTo('body');
		
		$.BlockUI();
		
		return false;
	});
	/*$('a.popup-img-lg').click(function() {
		$('<div id="popup-img-lg" class="popup"><img src="' + $(this).attr('href') + '" height="400" width="600" border="0" /><a href="#" class="popup-close">Close</a></div>').appendTo('body');
		
		$.BlockUI();
		
		return false;
	});*/
	$('a.popup-iframe').click(function() {
		$('<div id="popup-lg" class="popup"><iframe src="' + $(this).attr('href') + '" height="382" width="680" frameborder="0" scrolling="no"></iframe><a href="#" class="popup-close">Close</a></div>').appendTo('body');
		
		$.BlockUI();
		
		return false;
	});
	$('div#UIBlock, a.popup-close').live('click',function() {
		$('div.popup').remove();
		
		$.unBlockUI();
		
		return false;
	});
	
});


/* BEGIN: vertical positioning in the viewport --------------------------------------------------*/
(function($){
	$.fn.vCenter = function() {
		return this.each(function(index) {
			var $this = $(this);
			$this.css({
				position: 'fixed',
				top: '50%',
				marginTop: '-' + ($this.outerHeight()/2) + 'px'
			});
			if ($.browser.msie && ($.browser.version < 7)) {
				$this.css({
					position: 'absolute',
					top: $(window).scrollTop() + ($(window).height()/2)
				});
			}
		});
	};
})(jQuery);
/* END: vertical positioning in the viewport --------------------------------------------------*/


/* BEGIN: UI Block --------------------------------------------------*/
$.BlockUI = function() {
	$('<div id="UIBlock"></div>').css({
		//background: '#000',
		height: '100%',
		left: 0,
		//opacity: '0.6',
		position: 'fixed',
		top: 0,
		width: '100%',
		zIndex: 900
	}).appendTo('body');
	if ($.browser.msie && ($.browser.version < 7)) {
		$('div#UIBlock').css({
			position: 'absolute',
			top: $(window).scrollTop()
		});
	}
};
$.unBlockUI = function() {
	$('#UIBlock').fadeOut(100,function() {
		$(this).remove();
	});
};
/* END: UI Block --------------------------------------------------*/