jQuery(document).ready(function() {
	jQuery(".ancora").ancora();
});
	
jQuery.fn.ancora = function() {
		
	jQuery(this).click(function () {
								 
		if(jQuery(this).attr("href") == null){
			var elementClick = jQuery(this).attr("name");
		}else{
			var elementClick = jQuery(this).attr("href");
		}
		
		var ir = jQuery(elementClick).offset().top;
		var tempo = jQuery(this).attr("rel");
					
		if(tempo == "1"){
			tempo = 1000;
		}else if(tempo == "2"){
			tempo = 2000;
		}else if(tempo == "3"){
			tempo = 3000;
		}else if(tempo == "4"){
			tempo = 4000;
		}else if(tempo == "5"){
			tempo = 5000;
		}else if(tempo == "6"){
			tempo = 6000;
		}else if(tempo == "7"){
			tempo = 7000;
		}else if(tempo == "8"){
			tempo = 8000;
		}else if(tempo == "9"){
			tempo = 9000;
		}else if(tempo == "10"){
			tempo = 10000;
		}else{
			tempo = 2500;	
		}
					
		jQuery('html,body').animate({ scrollTop: ir}, tempo);
		
	})
}
