CH.ns(function() {with(CH) {
	Item = {
		saveTitle: function (id, type, title) {
			new Req.ajax({
				url: '/ajax/media/save_title/',
				options: {
					parameters: 'id='+id+'&type='+type+'&title='+title
				}
			});
		},
		
		saveDesc: function(id, type, desc) {
			new Req.ajax({
				url: '/ajax/media/save_description/',
				options: {
					parameters: 'id='+id+'&type='+type+'&description='+desc
				}
			});
		},
		
		deleteItem: function(id, type) {
			conf = confirm('Are you sure you want to delete this upload?\nIt will be removed from the site permanently.');
		 		
		 	if(conf) {
				new Req.ajax({
					url: '/ajax/media/delete/',
					options: {
						parameters: 'id='+id+'&type='+type
					}
				});
			}
		},
		
		sendToFriend: function() {
			var validator = new email_validator($('frmSendToFriend').share_to.value, ',');
			if (!validator.check()){
				var msg = "Hi! The following email addresses that\n";
				msg += "you entered are not correctly formatted. If you\n";
				msg += "entered multiple addresses, please make sure that\n";
				msg += "they are seperated using a comma\n\n";
		
				while (validator.invalid.length)
					msg += validator.invalid.pop() + "\n";			
				alert(msg);
				return false;
			} else {
				new Req.ajax({
					url: '/ajax/media/email_friend/',
					div: 'shareItem',
					options: {
						parameters: Form.serialize('frmSendToFriend')
					}
				});
													
				urchinTracker('_gTrack/new_share/email/submit/' + $('frmSendToFriend').share_item_type.value + ':' + $('frmSendToFriend').share_item_id.value);
			}
		}
	};

}});