var MikeBrown;

(function($)
{

	MikeBrown = {
		version: '0.1',
		website: 'http://www.mikebrownphotography.com/',
		init: function()
		{			
			MikeBrown.Dropdown();
			MikeBrown.Tabs();
			MikeBrown.Utilities.external();
			MikeBrown.Forms.focus();
		},
		Utilities:
		{
			external: function() {
				$('A[rel*="external"]').click(function(e) {
					var url = $(this).attr('href');
					window.open(url);
					e.preventDefault();
				});
			}
		},
		Forms:
		{
			focus: function() {
				var prevLabel = '';
				$('.focus').focus(function() {
					if ( $.trim($(this).val()) == $(this).attr('title') ) {
						prevLabel = $(this).val();
						$(this).val('');
					}
				});
				$('.focus').blur(function() {
					if ( $(this).val() == '' ) {
						$(this).val(prevLabel);
					}
				});
			}
		},
		Tabs: function() {
			if ( $('.services-tabs').length > 0 ) {
				$('.services-tabs').tabs();
			}
		},
		Dropdown: function() {
			if ( $('#nav').length > 0 ) {
				
				var searchPanel = $('#nav-search-panel');
				var browsePanel = $('#nav-browse-panel');
			
				$('#nav-search a').bind('click', function(e)
				{					
					if (searchPanel.hasClass('show')) {
						searchPanel.removeClass('show').hide();
					} else {
						searchPanel.addClass('show').show();
						browsePanel.removeClass('show').hide();
					}
					
					e.preventDefault();
				});
				
				$('.drop-panel-close', searchPanel).bind('click', function() {
					searchPanel.removeClass('show').hide();
				});
				
				$('#nav-browse a').bind('click', function(e)
				{					
					if (browsePanel.hasClass('show')) {
						browsePanel.removeClass('show').hide();
					} else {
						browsePanel.addClass('show').show();
						searchPanel.removeClass('show').hide();
					}
					
					e.preventDefault();
				});
				
				$('.drop-panel-close', browsePanel).bind('click', function() {
					browsePanel.removeClass('show').hide();
				});
				


				var currencyPanel = $('#nav-currency-panel');
				
				$('#nav-currency a').bind('click', function(e)
				{				
					if($(this).attr('href') == '#'){	
						if (currencyPanel.hasClass('show')) {
							currencyPanel.removeClass('show').hide();
						} else {
							currencyPanel.addClass('show').show();
						}
					
						e.preventDefault();
					}
				});
				
				
				$('.drop-panel-close', currencyPanel).bind('click', function() {
					currencyPanel.removeClass('show').hide();
				});

				
			}
		}
	}

	$(function() {
		MikeBrown.init();
		$(window).load(function() {
		if($('#slider').length !== 0){
			$('#slider').nivoSlider({pauseTime: 3000, effect: 'fade', directionNav:false});
		}
		});
	});

})(jQuery.noConflict());
