function format(mail) {
	return mail.name;
}
$().ready(function() {
	$("#video_tags").autocomplete('/video/tags', {
		multiple: true,
			parse: function(data) {
				return $.map(eval(data),
					function(row) {
						return {
							data: row,
							value: row.name,
							result: row.name
							}
						});
					},
					formatItem: function(item) {
						return format(item);
					}
				})
});

function showSpinner() {
	$('#spinnerdiv').slideDown();
}

function jqdeletevideo(id, page) {
	var answer = confirm("Are you sure ?");
		if (answer) {
			xhtmlresponse = '';
				jQuery.get("/video/delete/", {
					vid: id
				},
				function(data) {
					xhtmlresponse = data;
						//alert(xhtmlresponse);
						$('#videolistitem' + id).remove();
						$('#content-main').replaceWith(xhtmlresponse);
					});
				}
}

function jqsendcomment(id,model)
{
	commenttext = $('#text').val();
	$('#comment-it').replaceWith('<div id="progress" style="text-align:center;"><img src="/images/spinner1.gif"/></div>');
	jQuery.post("/comment/add/", {
		comment: commenttext,
		nid: id,
		model: model
    },
	function(data){$('#comment-list').replaceWith(data); });
	$('#progress').replaceWith('<div id="message" class="news" style="display:none;text-align:center;"><strong>Comment is added successfully</strong></div>');
	$('#message').fadeIn('slow');
}

function setpage(url)
{
        
	jQuery.post(url, {}, function(data){
	$('#comment-list').replaceWith(data);    
	});
}
$().ready(function() {
	$("#address").autocomplete('/video/shareaddressess', {
    	multiple: true,
		parse: function(data) {
			return $.map(eval(data),
			function(row) {
				return {
					data: row,
					value: row.name,
					result: row.name
					}
				});
			},
			formatItem: function(item) {
				return format(item);
				}
			});
});

function sharecontent(movieid)
{
	mails = $('#test').val();
	url="/video/sendshareinfo/";
	jQuery.post(url, { mailaddresses: mails, movieid: movieid }, function(data){
	$('#sbutton').before('<h3>Thanks for sharing this!</h3>').fadeOut('slow');
	});
}

function selecttree()
{
	$.nyroModalManual({
	url: "/tree/treeSelection",
	autoSizable: true,
	minHeight: 200
	});
}

function getmembersselection(x)
{
	$.nyroModalManual({
	url: "/tree/treeMembersList/?id=" + x,
	autoSizable: true,
	minHeight: 100
	});
}
function associateid(x)
{
	$('#assoc').val(x);
	$.nyroModalRemove();
	return false;     
}