// Back to Top Scroll

	jQuery(document).ready(function(){
	
		// add elements to interact with
		// top anchor
		jQuery('body').prepend('<span id="bm-top" />');
		// back to top link
		jQuery('body').append('<a href="#bm-top" id="bm-arrow-top">Back To Top</a>');
		//set the link
		jQuery('#bm-arrow-top').bm_topLink({
			min: 200,
			fadeSpeed: 500
		});
		
		//smoothscroll
		jQuery('#bm-arrow-top').click(function(e) {
			e.preventDefault();
		});
		
		jQuery('a[href*=#]').click(function() {
			if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			
				var $target = jQuery(this.hash);
				$target = $target.length && $target || jQuery('[name=' + this.hash.slice(1) +']');
				
				if ($target.length) {
					var targetOffset = $target.offset().top;
					jQuery('html,body').animate({scrollTop: targetOffset}, 1000);
					return false;
				}
			}
		});
		
	});
	
	//plugin
	jQuery.fn.bm_topLink = function(settings) {
		settings = jQuery.extend({
			min: 1,
			fadeSpeed: 200
		}, settings);
		return this.each(function() {
			//listen for scroll
			var el = jQuery(this);
			el.hide(); //in case the user forgot
			jQuery(window).scroll(function() {
				if (jQuery(window).scrollTop() >= settings.min) {
					el.fadeIn(settings.fadeSpeed);
				} else {
					el.fadeOut(settings.fadeSpeed);
				}
			});
		});
	};
// End Back to Top Scroll


// Search Form Script
	function do_search(submit) {
		var searchText = document.getElementById('query');
		var searchForm = document.getElementById('search');
		if (searchText.value == "") {
			searchText.focus();
			alert('Please enter search text');
			return false
		} else {
			var searchValue = searchText.value.replace(/[^A-Za-z0-9+-]/g, "-");
			searchForm.action = searchForm.action + '/' + searchValue + '.html';
			document.location.href = searchForm.action;
			return false
		}
	}
// End Search Form Script


// OverLabel - Mouse Over Remove Label Text 
	(function(a) {
		a.fn.overlabel = function() {
			this.each(function() {
				var b = a(this),
				c = a("#" + b.attr("for"));
				b.addClass("overlabel").bind("click",
				function(d) {
					c.focus()
				});
				c.bind("focus blur",
				function(d) {
					b.css("display", (d.type == "blur" && !c.val() ? "": "none"))
				}).trigger("blur")
			})
		}
	})(jQuery);
// End OverLabel - Mouse Over Remove Label Text 

