(function() {
	$(function() {
		//for the intiating page
		if($.colorbox) {
			$('a.infographic').colorbox({
				transition: 'none',
				innerWidth: 810, 
				innerHeight: 800, 
				iframe: true,
				scrolling: false
			});
		}
		
		//for the xplane page
		$('.xplane').hide();
		$('map').each(function() {
			var name = $(this).attr('name');
			$('area', this).each(function() {
				var prefix = '#xplane-' + name + '-';
				$(this).qtip({
					overwrite: true,
		         	content: {
			         	text: $(prefix + $(this).attr('title') + ' div:first'),
			         	title: {
				         	text: $(prefix + $(this).attr('title') + ' h2').text(),
				         	button: 'Close'
				        }
				    },
				    hide: {
				    	event: 'unfocus'
				    },
				    position: {
				    	my: 'bottom middle',
				    	at: 'top middle',
				    	viewport: $(window),
				    	adjust: {
					    	method: 'flip'
					    }
				    },
				    show: {
				   		solo: true
				    },
				    style: {
				    	classes: 'ui-tooltip-shadow xplane-tip xplane-tip-' + name,
				    	tip: {
				    		border: 6,
				    		height: 6,
				    		width: 12
				    	}
				    },
				    events: {
						render: function(event, api) {
							$(this).qtip('reposition', event);
						}				    	
				    }
		      	});
			});
		});
	});
})();
