var PROJ_NAME = '/warrsc/'; 

$(document).ready(function() {
	
	$("a#donate").bind("click", function() {
		$("#donate_form").submit()
	});

	$("a#single_1").fancybox();
		
	$("a#single_2").fancybox({
		'zoomOpacity'			: true,
		'overlayShow'			: false,
		'zoomSpeedIn'			: 500,
		'zoomSpeedOut'			: 500
	});
	
	$("a#single_3").fancybox({
		'overlayShow'			: false,
		'zoomSpeedIn'			: 600,
		'zoomSpeedOut'			: 500,
		'easingIn'				: 'easeOutBack',
		'easingOut'				: 'easeInBack'
	}); 
	
	$("a.group").fancybox({		
		'hideOnContentClick': false
	});
	
	$("a.group").click(function(){     
      
   }); 
   
	//alert("ok");
});

function setViews(postid){
	//alert("/setviews.php?postid="+postid);
	
	$.ajax({
	   type: "GET",
	   url: PROJ_NAME+"setviews.php",
	   data: "postid="+postid,	   
	   success: function(html){		   	 
	     //$("#commentholder").html(html);
	     //setTimeout("displayNone(\'commentholder\')",2000);
	   }
	 });	
}

function addtonetwork(userid,friendid)
{
 var loaderimage = '';  
  loaderimage = '<img src="'+THEME_URL+'/images/loading.gif"> <span class="">Wait....</span>';
  
  $("#placeholder").html(loaderimage);
	
	  $.ajax({
	   type: "GET", 
	   url: PROJ_NAME+"friendadd.php",
	   data: "page_id=24&userid="+userid+"&friendid="+friendid,
	   success: function(html){
	     //alert( "Data Saved: " + html );
	     $("#placeholder").html(html);
	   }
	 });
  
}

function leaveReply(userid,friendid)
{
	
  var loaderimage = '';
  document.getElementById('commentholder').style.display = '';
  var commenttext = document.getElementById('commenttext').value;
  //alert(commenttext);
  loaderimage = '<img src="'+THEME_URL+'/images/loading.gif"> <span class="">Wait....</span>';
  $("#commentholder").html(loaderimage);
	
	  $.ajax({
	   type: "GET",
	   url: PROJ_NAME+"leavereply.php",
	   data: "userid="+userid+"&friendid="+friendid+"&msg="+commenttext,	   
	   success: function(html){	     
	     $("#commentholder").html(html);
	     document.getElementById('commenttext').value = '';
	     setTimeout("displayNone(\'commentholder\')",2000);
	   }
	 });	
}
function displayNone(divid)
{
 	//alert(divid);	
	document.getElementById(divid).style.display = 'none';	
	
}


function removeFriend(userid,friendid)
{
  //alert(userid);
	
  var loaderimage = '';
  document.getElementById('divremovemsg').style.display = '';
  
  var p = document.getElementById('div_main_friends');
  
  loaderimage = '<img src="'+THEME_URL+'/images/loading.gif"> <span class="">Wait....</span>';
  $("#divremovemsg").html(loaderimage);
	
	  $.ajax({
	   type: "GET",
	   url: "removeuser.php",
	   data: "userid="+userid+"&friendid="+friendid,
	   success: function(html){	   	
	   	if(html == 'succ'){
	   		$("#divremovemsg").html('<font color="red"><strong>Friend Deleted Successfully.</strong></font>');
	   		var curdiv = document.getElementById('div_friend_'+friendid);
	   		p.removeChild(curdiv);
	   		//document.getElementById('div_friend_'+friendid).style.display = 'none';	   		
	   	}else{
	   		$("#divremovemsg").html('<font color="red"><strong>Error in Deletion.Try Again.</strong></font>');	
	   	}	   	
	    setTimeout("displayNone(\'divremovemsg\')",3000);
	   }
	 });	
}


function removeComment(commentid)
{
  //alert(userid);
	
  var loaderimage = '';
  document.getElementById('divcommentmsg').style.display = '';
  
  var p = document.getElementById('main_comment');	
  
  loaderimage = '<img src="'+THEME_URL+'/images/loading.gif"> <span class="">Wait....</span>';
  $("#divcommentmsg").html(loaderimage);
	
	  $.ajax({
	   type: "GET",
	   url: "removecomment.php",
	   data: "commentid="+commentid,
	   success: function(html){	   	
	   		//alert(html);
	   	if(html == 'succ'){
	   		$("#divcommentmsg").html('<font color="red"><strong>Comment Deleted Successfully.</strong></font>');
	   		var curdiv = document.getElementById('div_comment_'+commentid);
	   		p.removeChild(curdiv);
	   		//document.getElementById('div_comment_'+commentid).style.display = 'none';	   		
	   	}else{
	   		$("#divcommentmsg").html('<font color="red"><strong>Error in Deletion.Try Again.</strong></font>');	
	   	}	   	
	    setTimeout("displayNone(\'divcommentmsg\')",3000);
	   }
	 });	
}
