
var index = 0;
var totalPictures = 0;
var picasa;

function picture(j)
{
	picasa = j;
    totalPictures = parseInt(picasa.feed.openSearch$totalResults.$t);

    document.getElementById("myPicture").src = picasa.feed.entry[index].media$group.media$content[0].url;
    var picIndex = index + 1;
    document.getElementById('label').innerHTML = picIndex+" of " +totalPictures;
    document.getElementById('desc').innerHTML = picasa.feed.entry[index].media$group.media$title.$t;
    document.getElementById('title').innerHTML =picasa.feed.entry[index].media$group.media$description.$t;
}

function next()
{
	if (index == totalPictures - 1)
       index = 0;
    else
       index = index + 1;
    picture(picasa);
}

function prev()
{
	if (index > 0)
       index = index - 1;
    else
       index = totalPictures -1;
    picture(picasa);
}
function photoAlbum()
{
    var url = " http://picasaweb.google.com/data/feed/base/user/"+username+"/album/"+albumname+"/?kind=photo&alt=json&callback=picture&imgmax=640";
	document.write ("<scr"+"ipt language='javascript' src='"+url+"'>"+"</scr"+"ipt>");    
}

