
function followthismember(user_id){
	username=getCookie('textnovel');	
	if(username==null || username=="") {	
		alert('Please login to follow this author');
	} else {
		var submitTo = 'ajaxPages/follow_this_member.php?user_id='+user_id;
	   	http('POST', submitTo, ajax_response_follow, document.form1);
	}
}
function ajax_response_follow(data) { 
	if(data==null) {
		alert('The system understand your request but unable to process at this moment!');
	} else {
		if(data['follow_member']=='yes') {
			$("#author_score_"+data['author_id']).html(data['total_vote_subscription']);
			$("#follow_author_"+data['author_id']).removeClass();
			$("#follow_author_"+data['author_id']).addClass('stop-follow');
			$("#follow_author_"+data['author_id']).html('<a href="<?php if(!isset($_COOKIE['textnovel'])){?>window.location.href=signup.php<?php } else { ?>javascript:stopfollowthismember('+data['author_id']+');<?php }?>" title="Stop following this member" class="vtip"><img src="images/spacer.gif" alt="" height="20" width="45" /></a>');
			
			alert('You are now following this author');
		} else if(data['follow_member']=='no') {
			alert('An error occured during follow');
		} else {
			alert('The system is unable to process the request!')
		}
	}
}


function stopfollowthismember(user_id) {
	username = getCookie('textnovel');	
	if(username==null || username=="") {	
		alert('Please login to stop follow this author');
	} else {
		var submitTo = 'ajaxPages/follow_unfollow.php?user_id='+user_id;
	   	http('POST', submitTo, ajax_response_stop_follow, document.form1);
	}
}

function ajax_response_stop_follow(data) { 
	if(data==null) {
		alert('The system understand your request but unable to process at this moment!');
	} else {
		if(data['un_follow_member']=='yes') {
			$("#follow_author_"+data['author_id']).removeClass();
			$("#follow_author_"+data['author_id']).addClass('follow');
			$("#follow_author_"+data['author_id']).html('<a href="<?php if(!isset($_COOKIE['textnovel'])){?>window.location.href=signup.php<?php }else{?>javascript:followthismember('+data['author_id']+')<?php }?>" title="Follow this member"  class="vtip"><img src="images/spacer.gif" alt="" height="20" width="45" /></a>');
			alert('You stop following author successfully');
		} else if(data['un_follow_member']=='no') {
			alert('An error occured during follow');
		} else {
			alert('The system is unable to process the request!')
		}
	}
}

