// JavaScript Document


//do ajax call to add friend
function addFriendReq(id, network) {
	
	new Ajax.Request('/friendadd.php', {
  	method: 'get',
	parameters: {id: id, fj215sk: 2, ajax:1, network:network},
	onSuccess: 
		function(t){ 
				reloadFriendReq(id, network)
				}
  	});	
}

function reloadFriendReq(id, network) {
	new Ajax.Request('/_landing/mod_friendrequests.php', {
  	method: 'get',
	parameters: {network: network},
	onSuccess: 
		function(t){ 
				var result=t.responseText;
				$('friendReq').innerHTML = result;
				}
  	});	
}
// end friend req

//community invite
function approveInviteReq(dname, id, network, ln) {

	new Ajax.Request('/_landing/inviteapprove.php', {
  	method: 'get',
	parameters: {dname: dname, id: id, network: network, ln: ln, ajax:1},
	onSuccess: 
		function(t){ 
				reloadInviteReq();
				}
  	});	
}

function rejectInviteReq(dname, id, network, user) {
	if(confirm('Are you sure you don\'t want to join '+network+'?')) 
	{
		new Ajax.Request('/_landing/invitereject.php', {
		method: 'get',
		parameters: {dname: dname, id: id, network: network, ajax:1},
		onSuccess: 
			function(t){ 
					reloadInviteReq();
					refreshMessages(user);
					}
		});	
	}
}

function refreshMessages(user) {
	new Ajax.Request('/_landing/mod_message.php', {
  	method: 'get',
	parameters: {id: user, ajax:1},
	onSuccess: 
		function(t){ 
				var result=t.responseText;
				$('messages').innerHTML = result;
				}
  	});	
		
}

function reloadInviteReq() {
	new Ajax.Request('/_landing/mod_inviterequests.php', {
  	method: 'get',
	onSuccess: 
		function(t){ 
				var result=t.responseText;
				$('inviteReq').innerHTML = result;
				}
  	});	
}
//end community invite

//photo comments
function approvePhotoComment(id, folderid, network) {
	new Ajax.Request('/_photo/commentapprove.php', {
  	method: 'get',
	parameters: {id: id, folderid: folderid, image: 0, network: network, ajax:1},
	onSuccess: 
		function(t){ 
				reloadPhotoComments(network);
				}
  	});	
}

function rejectPhotoComment(id, folderid, network, giver) {
	if(confirm('Are you sure you wish to delete '+giver+'\'s comment?')) 
	{
		new Ajax.Request('/_photo/commentreject.php', {
		method: 'get',
		parameters: {id: id, folderid: folderid, image: 0, network: network, ajax:1},
		onSuccess: 
			function(t){ 
					reloadPhotoComments(network);
					}
		});	
	}
}

function reloadPhotoComments(network) {
	new Ajax.Request('/_landing/mod_photocomments.php', {
  	method: 'get',
	parameters: {network: network, ajax:1},
	onSuccess: 
		function(t){ 
				var result=t.responseText;
				$('photoComments').innerHTML = result;
				}
  	});	
}
//end photo comments

//profile comments
function approveProfileComment(commentid) {
	new Ajax.Request('/commentaccept.php', {
  	method: 'get',
	parameters: {id: commentid, ajax:1},
	onSuccess: 
		function(t){ 
				reloadProfileComments();
				}
  	});	
}

function rejectProfileComment(commentid, giver) {
	if(confirm('Are you sure you wish to delete '+giver+'\'s comment?')) 
	{
		new Ajax.Request('/commentrejectconfirm.php', {
		method: 'get',
		parameters: {id: commentid, ajax:1},
		onSuccess: 
			function(t){ 
					reloadProfileComments();
					}
		});	
	}
}


function reloadProfileComments() {
	new Ajax.Request('/_landing/mod_profilecomments.php', {
  	method: 'get',
	onSuccess: 
		function(t){ 
				var result=t.responseText;
				$('profileComments').innerHTML = result;
				}
  	});	
}
//end profile comments


//profile comments
function approveBlogComment(commentid) {
	new Ajax.Request('/_weblog/blogcommentapprove.php', {
  	method: 'get',
	parameters: {id: commentid, ajax:1},
	onSuccess: 
		function(t){ 
				reloadBlogComments();
				}
  	});	
}

function rejectBlogComment(commentid, giver) {
	if(confirm('Are you sure you wish to delete '+giver+'\'s comment?')) 
	{
		new Ajax.Request('/_weblog/blogcommentreject.php', {
		method: 'get',
		parameters: {id: commentid, ajax:1},
		onSuccess: 
			function(t){ 
					reloadBlogComments();
					}
		});	
	}
}

function reloadBlogComments() {
	new Ajax.Request('/_landing/mod_blogcomments.php', {
  	method: 'get',
	onSuccess: 
		function(t){ 
				var result=t.responseText;
				$('blogComments').innerHTML = result;
				}
  	});	
}
//end profile comments





