$(document).ready(function(){
	
	// contact form 
	$('#contact_submit').live('click',function(event){
		event.preventDefault();
		$.ajax({
			url:"/about_me/contact/",
			type:"post",
			cache:false,
			data:{
				'contact.name':$('#contact_name').val(),
				'contact.email':$('#contact_email').val(),
				'contact.message':$('#contact_message').val()
			},
			beforeSend:function(){
				$('#ajax_contact').show()
			},
			success:function(html){
				$("#contact_c").html(html);
			},
			complete:function(){
				$('#ajax_contact').hide();
			}
		});
	})
	
	// social links 
	$('a.social_link').mouseover(function(event){$('#social_label').text(this.title)});
	$('a.social_link').mouseout(function(event){$('#social_label').text('')});
	
	// look for the comments link
	$('a.comments_anc_link').click(function(event){
		if($('#comments').length){
			// found the comments anchor, send them there nicely
			event.preventDefault();
			jump_anchor('#comments');
		}else if($('#post_comment_anc').length){
			// no comments, so jump to the post comment instead 
			event.preventDefault();
			jump_anchor('#post_comment_anc');
		}
	});
	
	// anchor jumps
	$('a.jump_anchor').live('click',function(event){
		event.preventDefault();
		jump_anchor(get_anchor(this.href))
	});
	
})

// disect the url for the anchor
function get_anchor(path){
	var url_path=path;
	if(url_path.match('#')){
		// click the navigation item corresponding to the anchor
		var url_anchor='#'+url_path.split('#')[1];
	}else{
		var url_anchor='';
	}
	return url_anchor;
}
//document.location.toString();

// simple anchor jump call
function jump_anchor(el){
	$.scrollTo(el,800);
}