var myAppId = '/guid/9202a8c04000641f8000000005fef4a0';
var urlTestArgs = { 'interest_group_id':'/guid/9202a8c04000641f8000000005f56ad2'};

// TEMPLATE:sample_header.js
// Written by Will Moffat for Metaweb Technologies
mjt.error_reporting.developer = "Will";
mjt.error_reporting.email     = "will_mjt_bugs@hamstersoup.com";
mjt.error_reporting.enabled   = true; // mjt errors will be reported
mjt.error_reporting.app_id = myAppId; // create your own topic on Freebase for your app
mjt.sanitytest.set_query( urlTestArgs ); 
// END:sample_header.js
    
mjt.sanitytest.verify = function() { return $('.fbFullName:contains(Will Moffat)').length == 1; };

var q;

$(document).ready(init);

function init() {
    mjt.run('top');
    if (mjt.urlquery.interest_group_id) {
	// select the group specified in the url
	$('option[value='+mjt.urlquery.interest_group_id+']').attr('selected','selected')
	// and show the group members
	mjt.run('bottom');
    }	
}

function setSelected() {
    $('option[value='+mjt.urlquery.interest_group_id+']').attr('selected','selected');
}

var queryListJson = [{
    "name":null,
    "id":null,
    "freebase_users":[],
    "type":"/freebase/freebase_interest_group"
}];

function getInterestGroupJson() {
return [{
    "freebase_users":[{
	"type":"/freebase/user_profile",
	"/common/topic/article":{
	    "id":null,
	    "optional":true
	},
	"/common/topic/image":[{
	    "guid":null,
	    "limit":2,
	    "name":null,
	    "optional":true
	}],
	"biography":{
	    "id":null,
	    "optional":true
	},
	"birthday":null,
	"hometown":[],
	"my_full_name":null,
	"personal_quote":null,
	"id":null,
	"name":null,
	"timestamp":null
    }],
    "id":mjt.urlquery.interest_group_id,
    "type":"/freebase/freebase_interest_group"
}];
}

function addImage(image) {
    var width = 300;
    var height = 300;
    if (!image) { return ''; } //no image found
    var imageGuid = image.guid;
    var title = image.name || '';
    var html='';
    html +='<span style="float:left; margin-right:5px; width:'+width+'px; height:'+height+'px;" >';
    html += "<img src='http://www.freebase.com/api/trans/image_thumb/"+encodeURIComponent(imageGuid)+"?maxwidth="+width+"&maxheight="+height+"' title='"+title+"' style='border:thin solid black;'></a>";
    html += "</span>";
    return html;
}


