/*	Photo functions	*/

function photoUploadDialogue() {
	if (jQuery("#photoUploadDialogue").css("display") == "none") {
		jQuery("#photoUploadDialogue").slideDown("fast");
	} else {
		jQuery("#photoUploadDialogue").slideUp("fast");
	}
}

function photoSetProfile() {
	jQuery("#photoSetProfile").fadeTo("slow", 0.1);
	var photo_id = jQuery('.active').attr('id');
	jQuery("#profile-picture-sidebar").load(root_url + "/controllers/scrappy.php?set=photos&cmd=profile_picture&photo_id=" + photo_id,
		function() {
			alert("Profile picture set.");
			jQuery("#photoSetProfile").fadeTo("slow", 1);
		}
	);
}

function photoDeleteThis() {
	jQuery("#photoDeleteThis").fadeTo("slow", 0.1);
	var photo_id = jQuery('.active').attr('id');
	jQuery.get(root_url + "/controllers/scrappy.php?set=photos&cmd=delete_photo&photo_id=" + photo_id,
		function() {
			jQuery(".active").remove();
			jQuery("#" + photo_id).remove();
			$.galleria.next();
/*			alert("Photo deleted.");
			jQuery("#photoDeleteThis").fadeTo("slow", 1);*/
			jQuery("body").fadeTo("slow", .2);
			window.location = root_url + "/profile/" + user_id + "/photos";
		}
	);
}

/*	Really?	All this is essentially depreciated. */

function collapseItem(element) {
	if (jQuery("#" + element + "-container").css("display") == "none") {
		jQuery("#" + element + "-container").slideDown("fast");
		jQuery("#" + element + " h4 span a").text('(collapse)');
	} else {
		jQuery("#" + element + "-container").slideUp("fast");
		jQuery("#" + element + " h4 span a").text("(expand)");
	}
}


function accountInfoCollapse() {
	if (jQuery("#account-container").css("display") == "none") {
		jQuery("#account-container").slideDown("fast");
		jQuery('#account h4 span a').text('(collapse)');
	} else {
		jQuery("#account-container").slideUp("fast");
		jQuery('#account h4 span a').text('(expand)');
	}
}

function connectionsCollapse() {
	if (jQuery("#p-connections-container").css("display") == "none") {
		jQuery("#p-connections-container").slideDown("fast");
		jQuery('#profile-connections h4 span a').text('(collapse)');
	} else {
		jQuery("#p-connections-container").slideUp("fast");
		jQuery('#profile-connections h4 span a').text('(expand)');
	}
}

function clearNetwork(user_id) {
	jQuery("#network-" + user_id).fadeOut("fast");
	jQuery.get(root_url + "/controllers/scrappy.php?set=network&cmd=clear&to_id=" + user_id);
}

function featureStory(command, user_id) {
	jQuery("#feature-story-link").fadeOut("fast", function() {
		jQuery("#feature-story-link").load(root_url + "/controllers/admin.php?command=" + command + "&user_id=" + user_id, function() {
			jQuery("#feature-story-link").fadeIn("fast")
		});
	});				
}
