﻿// REQUIRES dojo

// stylesheet set function on current document
function loadStylesheet(styleFile) 
{
	var link = document.createElement('link');
	link.rel = 'stylesheet';
	link.type = 'text/css';
	link.href = styleFile;
	document.getElementsByTagName('head')[0].appendChild(link);
}

// response handler for dojo.io.script.get
function handleResponse(data) 
{
    var targetNode = dojo.byId('anobiiMiniShelf');
    targetNode.innerHTML = data;
}

// calls the url using dojo.io.script.get
function ajaxGET(pId, tagId, pageNum) 
{   
    var targetNode = dojo.byId('anobiiMiniShelf');
    targetNode.innerHTML = '<span class="anobiiLoading">loading...</span>';
    
    // passes the parameters the url, how to handle it, and the callbacks
    var jsonpArgs = {
                url: 'http://www.otherbit.com/modules/anobii/filterbytag.aspx',
                content: {
                     personId: pId,
                     tag: tagId,
                     page: pageNum,
                     callback: 'handleResponse'
                }
     };
    dojo.io.script.get(jsonpArgs);
}

// dojo requirement
dojo.require("dojo.io.script");

// set stylesheet
loadStylesheet('http://www.otherbit.com/modules/anobii/Styles/miniShelf.css');
