$(document).ready(
	function(){
		$.fn.search = function() {
			return this.focus(function() {
				if( this.value == this.defaultValue ) {
					this.value = "";
				}
			}).blur(function() {
				if( !this.value.length ) {
					this.value = this.defaultValue;
				}
			});
		};
		
		// newsletter IDs
		$("#s").search();
		$("#mb-name").search();
		$("#mb-njlw-njlw").search();
		
		$('.gallery_demo_unstyled li:first').addClass('active'); // adds new class name to maintain degradability
		
		$('.gallery_demo_unstyled').addClass('gallery_demo'); // adds new class name to maintain degradability

				$('ul.gallery_demo').galleria({
					history   : false, // activates the history object for bookmarking, back-button etc.
					clickNext : false, // helper for making the image clickable
					insert    : '#main_image', // the containing selector for our main image
					onImage   : function(image,caption,thumb) { // let's add some image effects for demonstration purposes

						// fade in the image & caption
						if(! ($.browser.mozilla && navigator.appVersion.indexOf("Win")!=-1) ) { // FF/Win fades large images terribly slow
							image.css('display','none').fadeIn(300);
						}
						caption.css('display','none').fadeIn(300);

						// fetch the thumbnail container
						var _li = thumb.parents('li');

						// fade out inactive thumbnail
						_li.siblings().children('img.selected').fadeTo(300,0.3);

						// fade in active thumbnail
						thumb.fadeTo('fast',1).addClass('selected');

						// add a title for the clickable image
						image.attr('title','Next image >>');
					},
					onThumb : function(thumb) { // thumbnail effects goes here

						// fetch the thumbnail container
						var _li = thumb.parents('li');

						// if thumbnail is active, fade all the way.
						var _fadeTo = _li.is('.active') ? '1' : '0.3';

						// fade in the thumbnail when finnished loading
						thumb.css({display:'none',opacity:_fadeTo}).fadeIn(500);

						// hover effects
						thumb.hover(
							function() { thumb.fadeTo('fast',1); },
							function() { _li.not('.active').children('img').fadeTo('fast',0.3); } // don't fade out if the parent is active
						)
					}
				});
		
		
		$("#nav ul li ul li a em:nth-child(1)").addClass("roundleft");
		$("#nav ul li ul li a span:nth-child(2)").addClass("roundright");		
		
		//toggle the componenet with class msg_body
 		$('#base-menu-btn a').click(function(e){
			e.preventDefault();
			
			if($(this).html() == 'Show'){ $(this).html('Hide Category Grid'); }else{ $(this).html('Show Category Grid'); }
			
			$('#base-menu').slideToggle(800);
		});

		$(".featured .box .inner").hover(function(){
		$(this).stop(true, true);
		$(this).animate( { paddingLeft: "18px" }, 200);
		},
		function(){
		$(this).animate( { paddingLeft: "15px" }, 200);
		});
		
		$(".view-all").hover(function(){
		$(this).stop(true, true);
		$(this).animate( { marginLeft: "0px" }, 200);
		},
		function(){
		$(this).animate( { marginLeft: "-4px" }, 200);
		});
		
		$(".cartlink a, #nav a").hover(function(){
		$(this).stop(true, true);
		$(this).animate( { marginTop: "2px" }, 200);
		},
		function(){
		$(this).animate( { marginTop: "0px" }, 200);
		});
		
		$(".headerimg").animate( { right: "0px" }, 500);
		
		
	}
);