function confirmDeleteLink(link_id)
{
	if (confirm("Delete?"))
	{
		
		var ajaxRequest;  // The variable that makes Ajax possible!
		
		try{
			// Opera 8.0+, Firefox, Safari
			ajaxRequest = new XMLHttpRequest();
		} catch (e){
			// Internet Explorer Browsers
			try{
				ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try{
					ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e){
					// Something went wrong
					alert("Your browser broke!");
					return false;
				}
			}
		}
		
		// Create a function that will receive data sent from the server
		ajaxRequest.onreadystatechange = function(){
			if(ajaxRequest.readyState == 4){
				$("#link_"+link_id).fadeOut("slow");
			}
		}
		
		var queryString = "?link_id="+link_id;
		ajaxRequest.open("GET", "/global/ajax/groups_delete_link.php" + queryString, true);
		ajaxRequest.send(null);
	}
}



function confirmDeleteBlog(blog_id)
{
	if (confirm("Delete?"))
	{
		
		var ajaxRequest;  // The variable that makes Ajax possible!
		
		try{
			// Opera 8.0+, Firefox, Safari
			ajaxRequest = new XMLHttpRequest();
		} catch (e){
			// Internet Explorer Browsers
			try{
				ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try{
					ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e){
					// Something went wrong
					alert("Your browser broke!");
					return false;
				}
			}
		}
		
		// Create a function that will receive data sent from the server
		ajaxRequest.onreadystatechange = function(){
			if(ajaxRequest.readyState == 4){
				$("#blog_"+blog_id).fadeOut("slow");
				
			}
		}
		
		var queryString = "?blog_id="+blog_id;
		ajaxRequest.open("GET", "/global/ajax/groups_delete_blog.php" + queryString, true);
		ajaxRequest.send(null);
	}
}




function joinGroup(group_id)
{
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function()
	{
		if(ajaxRequest.readyState == 4)
		{
			$("#join_button").css("display",'none');
			$("#join_confirm").fadeIn("slow");
		}
	}
	
	var q = "?gid="+group_id;
	ajaxRequest.open("GET", "/global/ajax/group_join.php"+q, true);
	ajaxRequest.send(null);
}



function checkGroupInvite()
{
	var friends = document.getElementsByName("name[]");
	var emails = document.getElementsByName("email[]");
	var pass = false;
	var temp = "";
	var c =0;
	
	for(x=0;x<friends.length;x++)
	{
		temp = emails[x].value;
		if (friends[x].value!="")
		{
			
			if (temp!="" && temp.indexOf(".")!=-1 && temp.indexOf("@")!=-1)
			{
				$("#friend"+x).fadeOut("slow");
				pass = true;
				c++;
			} else 
			{
				$("#friend"+x).fadeIn("slow");
			}
		} else 
		{
			if (temp!="")
			{
				$("#friend"+x).fadeIn("slow")
			}	
		}
	}
	
	if (c==0 || pass==false)
	{
		if (c==0) $("#friend0").fadeIn("slow");
		return false;
	} else
	{
		return true;
	}
	
}


function checkBrowseGroups()
{
	var chks = document.getElementsByName("browse_cats[]");
	var pass = false;
	for(x=0;x<chks.length;x++) if (chks[x].checked) pass = true;
	
	return pass;
}


function chkBrowseGroups(x)
{
	var chks = document.getElementsByName("browse_cats[]");
	
	if (chks[x].checked == true)
	{
		chks[x].checked = false;
	} else 
	{
		chks[x].checked = true;
	}
}



function groupLoadWall(group_id)
{
	
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			$("#group_wall_inner").html(ajaxRequest.responseText);
		}
	}
	
	var queryString = "?action=load&group_id="+group_id;
	ajaxRequest.open("GET", "/global/ajax/group_wall.php" + queryString, true);
	ajaxRequest.send(null);
}





function postWall(group_id, parent_id, txt)
{
	
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4)
		{
			var r = ajaxRequest.responseText;
			document.getElementById("wall_post").value = "post something to this wall";
			if (r.indexOf("not-a-member")>-1)
			{
				alert("Only members can post to this wall");
			} else 
			{
				groupLoadWall(group_id);
			}
			
			
			
		}
	}
	
	var queryString = "?action=post&group_id="+group_id+"&parent_id="+parent_id+"&post="+escape(encodeURI(txt));
	ajaxRequest.open("GET", "/global/ajax/group_wall.php" + queryString, true);
	ajaxRequest.send(null);
}



function resetWallText(ele)
{
	if (ele.value=='post something to this wall')
	{
		ele.value = "";
	}
}






function postWallReply(group_id, parent_id)
{
	
	var ajaxRequest;  // The variable that makes Ajax possible!
	var txt = $("#reply-post-"+parent_id).val();
	
	
	if (txt=="")
	{
		
		return false;
	}
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4)
		{
			$("#reply-post-"+parent_id).val("");
			var r = ajaxRequest.responseText;
			if (r.indexOf("not-a-member")>-1)
			{
				alert("Only members can post to this wall");
			} else 
			{
				groupLoadWall(group_id);
			}
		}
	}
	
	
	
	
	
	var queryString = "?action=reply&group_id="+group_id+"&parent_id="+parent_id+"&post="+escape(encodeURI(txt));
	ajaxRequest.open("GET", "/global/ajax/group_wall.php" + queryString, true);
	ajaxRequest.send(null);
}






function confirmDeleteWallPost(gid, wpid)
{
	
	if (confirm("Delete this wall post?"))
	{
		var ajaxRequest;  // The variable that makes Ajax possible!
		
		try{
			// Opera 8.0+, Firefox, Safari
			ajaxRequest = new XMLHttpRequest();
		} catch (e){
			// Internet Explorer Browsers
			try{
				ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try{
					ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e){
					// Something went wrong
					alert("Your browser broke!");
					return false;
				}
			}
		}
		
		// Create a function that will receive data sent from the server
		ajaxRequest.onreadystatechange = function(){
			if(ajaxRequest.readyState == 4)
			{
				$("#wall_entry_"+wpid).fadeOut("slow");
			}
		}
		
		var queryString = "?action=delete&group_id="+gid+"&wall_post_id="+wpid;
		ajaxRequest.open("GET", "/global/ajax/group_wall.php" + queryString, true);
		ajaxRequest.send(null);
	}
}

function confirmDeleteAlbum(group_id, album_id)
{
	if (group_id=="" || album_id=="") return false;
	
	if(confirm("Delete this entire album?"))
	{
		window.location.href = "/global/controls/group_album_delete.php?action=delete&group_id="+group_id+"&album_id="+album_id;
	}
}

function confirmDeleteAlbumImage(group_id, album_id, image_id)
{
	if (group_id=="" || image_id=="") return false;
	
	if(confirm("Delete this image?"))
	{
		window.location.href = "/global/controls/group_image_delete.php?action=delete&group_id="+group_id+"&album_id="+album_id+"&image_id="+image_id;
	}
}



function resetImageComment(ele)
{
	if (ele.value=="Post an image comment...")
	{
		ele.value = "";
	}
}

function checkPostImageComment()
{
	if ($("#image_comment_post").val()=="" || $("#image_comment_post").val()=='Post an image comment...')
	{
		return false;
	} else 
	{
		return true;
	}
}


function confirmDeleteImageComment(group_id,album_id,image_id, image_comment_id)
{
	
	if(confirm("Delete this image comment?"))
	{
		window.location.href = "/global/controls/group_image_comment_delete.php?action=delete&group_id="+group_id+"&album_id="+album_id+"&image_id="+image_id+"&image_comment_id="+image_comment_id;
	}
}


function checkLoginGroup()
{
	if (document.getElementById("login_username_group").value=="" || document.getElementById("login_password_group").value=="")
	{
		alert("Please enter username and password");
		return false;
	} else 
	{
		return true;
	}
}