var _commentid = '';

$(document).ready(function(){
	
	Cufon.replace('h1');
	Cufon.replace('h2');
	Cufon.replace('.menu ul li a');
	
	
	$('#wp-submit').click(doRegister);
	$('#comment_report').click(doReport);
	
	$('.share_twitter').each(function(){
			
			doTwitterCount($(this).attr('rel'), $(this));
	})
	
});

function doRegister(evt){
	
	$.ajax({
	
		url: _location+'/wp-login.php?action=register',
		type: "POST",
		data: ({user_login : $('#user_login').attr('value'), user_email : $('#user_email').attr('value')}),

		success: function(data){
				$('#registerform').css('display', 'none');
				$('#register_response').append('Thank you, a password has been emailed to you');
		}
		
		
	});
	
}



function doReport(evt){
		//_commentid = $(this).attr('title');
		//console.log($(this).attr('rel'));
		var _comment = $(this).attr('rel');
		//console.log(_comment);
		$.ajax({
	
		url: _location+'/ext/services/report.php',
		type: "POST",
		data: ({postid:_comment}),
		success: function(data){
			//	console.log(data);
				$('#comment_report').css('display', 'none');
				$('#report_content').html('Thank you, the administrator has been notified');
		}
		
		
	});
}

function doTwitterCount(_url, _target){
	//http://otter.topsy.com/trackbacks.js?url=http://topsy.com/
	
	$.getJSON('http://api.tweetmeme.com/url_info.jsonc?url='+_url+'&callback=?',
	    function(data) {
			if(data.status != 'failure'){
				_target.append(data.story.url_count);
			}
			else{
				_target.append('0');
			}
			
			
		});
	
}
