var DJEvents = function() {
		return {
			textShadowClass: 'textshadow',
			
			/**
			 * Init application
			 */
			init: function() {
				this.initMainMenu();
				this.initTools();
				this.initCallMe();
			},
			
			/**
			 * Initialize main menu
			 */
			initMainMenu: function() {
				if ($.browser.msie) {
					$('.menu-item p').each(function(index, el) {
							//console.log(arguments);
							$(el).addClass('textshadow');
						}
					);
					
					var textshadow = $('.' + this.textShadowClass); //replace with your own!
					textshadow.append("<em></em> ");
					textshadow.each(function() { var dupeText = $(this).text(); $(this).find("em").text(dupeText); });
				}
				
				if (!($.browser.msie && parseInt($.browser.version, 10) === 7)) {
					$('.menu-item').mouseenter(function () {
							if ( ! $(this).is(':animated') ) {
								
								if (window.menuItemBounceProcessId !== null) {
									clearTimeout(window.menuItemBounceProcessId);
								}
								
								var self = this;
								window.menuItemBounceProcessId = setTimeout(function()
									{
										$(self).effect('bounce', { times:3, distance: 8 }, 300);
									},
									450
								);
							}
						}
					);
					
					$('.menu-item').mouseleave(function () {
							if (window.menuItemBounceProcessId !== null) {
								clearTimeout(window.menuItemBounceProcessId);
							}
						}
					);	
					
					
					$('.menu-item').click(function () {
							if (window.menuItemBounceProcessId !== null) {
								clearTimeout(window.menuItemBounceProcessId);
							}
						}
					);
				}
			},
			
			/**
			 * Intialize tools
			 */
			initTools: function() {
				$('#btn-search-tool').click(function(el) {
						var active = !$('#main-menu-search-wrap').is(':visible');
						
						$('#main-menu-search-wrap').slideToggle(); 
						$('#btn-search-tool').removeClass(active ? 'inactive' : 'active');
						$('#btn-search-tool').addClass(active ? 'active' : 'inactive');
						return false;
					}
				);
			},
			
			/**
			 * Init call me
			 */
			initCallMe: function() {
				el = $('#call-me-input');
				this.callMeInitValue = el.val();
				
				el.click({initValue: this.callMeInitValue}, function(e) {
						var target = $(e.currentTarget);
						
						if (target.val() == e.data.initValue) {
							target.val('');
							
							target.one('blur', {initValue: e.data.initValue}, function(blurEvent) {
									var blurTarget = $(blurEvent.currentTarget);
									if (blurTarget.val() == '') {
										blurTarget.val(blurEvent.data.initValue);	
									}
								}
							);
						}
					}
				);
				
				el.blur({initValue: this.callMeInitValue}, function(e) {
						var target = $(e.currentTarget);
						if (target.val() == '') {
							target.val(e.data.initValue);	
						}
					}
				);
			}
		};
}();

(function($){
	
		$('#slides').slides({
			preload: true,
			preloadImage: '<?php echo bloginfo( "template_url" ); ?>/img/slides/loading.gif',
			play: 5000,
			pause: 2500,
			slideSpeed: 500,
			fadeSpeed: 1000,
			hoverPause: false,
			effect: 'fade',
			crossfade: true
		});
				
		DJEvents.init();

})(window.jQuery);
