Cufon.replace('#top_bar a:not(.learn_more a', {
  fontFamily: 'Helvetica Neue Hv',
  textShadow: 'rgba(0,0,0,0.2) 0 1px 2px'
})

// TODO: if this is the only place the light version is 
// used in the whole site, maybe we should use an image instead to save calculations
Cufon.replace('h3.slogan', {
  fontFamily: 'Helvetica Neue LtCn'
});

// navig
$(document).ready(function() {
    var nav = navigator.appVersion;
    
    /* Add some body classes to make it easier to style for specificness */
    if($.browser.mozilla){
      $('body').addClass('firefox');

      var version = $.browser.version.substring(0,3), majorVersion;
    	if(version == '1.8') {
    		majorVersion = 2;
    	} else if (version == '1.9') {
    		majorVersion = 3;
    	}

    	$('body').addClass('firefox'+ majorVersion);
    }
    
    if(nav.indexOf("Win") != -1) {
      $('body').addClass('windows');
    }

    if(nav.indexOf("Mac") != -1) {
      $('body').addClass('mac');
    }

    if($.browser.webkit){
    	$('body').addClass('webkit');
    }
    
    // nav flyout
  	$('#header ul li').hover(function(event) {
		$(this).find('ul').show();
		$(this).addClass('over');
	}, function(event) {
		$(this).find('ul').hide();
		$(this).removeClass('over');
	});
	
    // setup timers
	if ($("abbr.timeago").length) {
        $("abbr.timeago").timeago();
	};    

    // droplet for searchbar
    // search form on every page
    var autocompleteType;
    $('#searchBar select').droplet({change: function(selected, index) {
        autocompleteType = selected.value;
        $('#search_keywords').autocomplete('option', 'source', '/search/classifications/type/'+autocompleteType);
    },
    parseSelectedOffset: false});
    autocompleteType = $('#searchBar input[name="type"]').val();
    
    
    $('#search_keywords').autocomplete({
     source: '/search/classifications/type/'+autocompleteType
    });
    
    $('#header #searchBar .input').click(function() {
		$(this).find('label').fadeOut();
		$(this).find('input').focus();
	})
	$('#header #searchBar .input input').focus(function() {
		$(this).prev('label').fadeOut();
	});
	$('#header #searchBar .input input').blur(function() {
		if (!$(this).val()) $(this).prev('label').fadeIn();
	});
	$('#header #searchBar .input input').each(function() {
		if ($(this).val()) {
			$(this).prev('label').css('display', 'none');
		}
	});
	
	$('#search-form input').each(function() {
		if ($(this).val()) {
			$(this).prev('label').css('display', 'none');
		}
	});

    // login dialog
	$('a.login, button.login').live('click', function(e) {	
		e.preventDefault();	
		$.ajax({
			url: '/login',
			success: function(data) {
				$('<div class="loginBox"></div>').html(data).appendTo('body').dialog({
					title: '<img src="/img/global/sm_logo.gif" /> Login to HardHatCity!',
					overlay: { background: "#000", opacity: 0.8},
					modal: true,
					resizable: false,
					draggable: false,
					width: '308px',
					open: function(item, ui) {
        			    $('.ui-widget-overlay').click(function() {
        			        $('.loginBox').dialog('close');
        			    });
        			}
				});
			}
		})
	});


    if ($('#promotions').length) {
        $('#promotions').cycle({
            fx: 'fade',
            speed: 5000,
            speedIn: 1000,
            speedOut: 1000
        });
    };

});
