$(function(){
	$('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			var $target = $(this.hash);
			$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				if($target.attr("class")=='col'){
					var colorbg = $target.css("background-color");
					var colors = {
						aqua:true,
						azure:true,
						beige:true,
						black:true,
						blue:true,
						brown:true,
						cyan:true,
						darkblue:true,
						darkcyan:true,
						darkgrey:true,
						darkgreen:true,
						darkkhaki:true,
						darkmagenta:true,
						darkolivegreen:true,
						darkorange:true,
						darkorchid:true,
						darkred:true,
						darksalmon:true,
						darkviolet:true,
						fuchsia:true,
						gold:true,
						green:true,
						indigo:true,
						khaki:true,
						lightblue:true,
						lightcyan:true,
						lightgreen:true,
						lightgrey:true,
						lightpink:true,
						lightyellow:true,
						lime:true,
						magenta:true,
						maroon:true,
						navy:true,
						olive:true,
						orange:true,
						pink:true,
						purple:true,
						violet:true,
						red:true,
						silver:true,
						white:true,
						yellow:true
					};
					if(
						colorbg.substring(0,1)!='#'		&& 
						colors[colorbg]!=true			&& 
						colorbg.substring(0,3)!='rgb'
					){
						colorbg='#ffffff';
					}
					
					//alert($target.attr("id"));
					//$target.animate({backgroundColor:"#fff99"}, 2000);
					$('html,body').animate({scrollTop: targetOffset}, 1000, function(){
						$target
							.css("background-color","yellow")
							.animate({backgroundColor:colorbg}, 1000)
							.css("background-color",colorbg);
					});
				} else {
					$('html,body').animate({scrollTop: targetOffset}, 1000);
				}
				return false;
			}
		}
	});
});