$(function(){

	if(typeof console === "undefined") {
		console = { log: function() { } };
	}

	var $ = jQuery;

	var STA	=	{

		ui: function(){

			// NAV DROPDOWNS
			if ($('#sta-nav ul li').length > 0) {
				$('#sta-nav ul li').hover(function() {
					$(this).addClass('over');
				}, function() {
					$(this).removeClass('over');
				});
			}

			//FORM VALIDATION
			if ($('form#entryform').length > 0) {
				$('form#entryform').validate();
			}

			// CAROUSELS
			if ($('#previous-honorees ul.jcarousel-skin-tango').length > 0) {
				$('#previous-honorees ul.jcarousel-skin-tango').jcarousel({
					scroll: 4
				});
			}

			// TOOLTIPS
			if ($('.sta-content a.tooltip').length > 0) {
				$('.sta-content a.tooltip').tooltip({ 
					track: true, 
					delay: 0, 
					showURL: false, 
					showBody: " - ", 
					fade: 100,
					top: -75,
					left: -210
				});
			}

			// NOMINEES
			if ($('.nominee-details').length > 0) {
				$('.nominee a.tooltip').click(function(){
					$('#nominees .active').removeClass('active');
					$(this).parent().addClass('active');
					return false;
				});
				$('.nominee a.close').click(function(){
					$('#nominees .active').removeClass('active');
					return false;
				});
			}

			// CLEARING FLOATS
			$('.cleared').append('<span class="clear"></span>');

			//FANCYBOX
			if ($('.map').length > 0) {
				$('.map').fancybox({
					'type' : 'iframe',
					'width' : '75%',
					'height' : '75%'
				});
			}

			//GALLERY
			if ($('#sta-photos ul li a').length > 0) {
				$('#sta-photos ul li a').click(function(e) {
					$href = $(this).attr('href');
					$caption = $(this).find('img').attr('title');
					$('#sta-current').find('img').attr('src', $href);
					$('#sta-current').find('p').replaceWith('<p>' + $caption + '</p>');
					e.preventDefault();
					return false;
				});
			}
		},

		init: function(){
			STA.ui();
		}

	};

	STA.init();

});
