var ifiller = new Image(200, 150);
ifiller.src = "graphics/photofill.png";

var imt = new Image(1, 1);
imt.src = "graphics/empty.png";


function readGet(){var _GET = new Array();var uriStr  = window.location.href.replace(/&amp;/g, '&');var paraArr, paraSplit;if(uriStr.indexOf('?') > -1){var uriArr  = uriStr.split('?');var paraStr = uriArr[1];}else{return _GET;}if(paraStr.indexOf('&') > -1){paraArr = paraStr.split('&');}else{paraArr = new Array(paraStr);}for(var i = 0; i < paraArr.length; i++){paraArr[i] = paraArr[i].indexOf('=') > -1 ? paraArr[i] : paraArr[i] + '=';paraSplit  = paraArr[i].split('=');_GET[paraSplit[0]] = decodeURI(paraSplit[1].replace(/\+/g, ' '));}return _GET;}var _GET = readGet();
//requestVars end

function resize(which, max) {
// not used anymore! was scaling photos after they were loaded. using browser-native inline scaling instead,
// until google fixes their image size request to work with any imgmax, rather than just 800 :-(
  var elem = document.getElementById(which);
  if (elem == undefined || elem == null) return false;
  if (max == undefined) max = 658;
  if (elem.width > elem.height) {
    if (elem.width > max) elem.width = max;
  } else {
    if (elem.height > max) elem.height = max;
  }
}

//$Update: May 10, 2007$

function $(a) { document.write(a); }


var photosize;
if(!photosize){photosize = 800;}

var columns;
if(!columns || isNaN(columns) || columns < 1) {columns = 4;}


//Global variables
var photolist = new Array(); //this is used globally to store the entire list of photos in a given album, rather than pass the list around in a URL (which was getting rediculously long as a result)
var album_name = ""; //this is used globally to store the album name, so we don't have to pass it around in the URL anymore either.
var my_numpics = ""; //this is used globally to store the number of items in a particular album, so we don't have to pass it around in the URL anymore either.
var prev = ""; //used in the navigation arrows when viewing a single item
var next = "";//used in the navigation arrows when viewing a single item
var username = "";
var AllPics = "";
var j;

function albumsa(){  //returns all photos in a specific album

    //get the number of photos in the album
    var np = j.feed.openSearch$totalResults.$t;    
    var item_plural = "s";
    if (np == "1") { item_plural = ""; }

     var album_begin = j.feed.entry[0].summary.$t.indexOf('href="')+6;
     var album_end = j.feed.entry[0].summary.$t.indexOf('/photo#');
     var album_link = j.feed.entry[0].summary.$t.slice(album_begin, album_end);
     var photoids = new Array();
     
    AllPics = ("<div class = 'picasawebalbum'>");
    for(i=0;i<j.feed.entry.length;i++){
        var img_base = j.feed.entry[i].media$group.media$content[0].url;
        var id_begin = j.feed.entry[i].id.$t.indexOf('photoid/')+8;
        var id_end = j.feed.entry[i].id.$t.indexOf('?');
        var id_base = j.feed.entry[i].id.$t.slice(id_begin, id_end);
        photoids[i]=id_base;

        var link_url = "?albumid="+_GET['albumid']+"&photoid="+id_base; //+"&photoids="+photoids;
        if (link_url.length > 2048) { link_url = link_url.slice(0, link_url.indexOf('&photoids=')+10)+id_base; }
        AllPics = AllPics + ("<div class='pwimg' style = 'background-image:url(" + img_base + ");'>");
        AllPics = AllPics + "<a href='" + img_base + "' onclick='return hs.expand(this)' ><img src='graphics/photofill.png' style = 'border-style:none;' onmouseover = 'this.src=imt.src;' onmouseout = 'this.src = ifiller.src;' /></a>";
        AllPics = AllPics + "</div>";
     }
    AllPics = AllPics + ("</div>");    
    document.getElementById("divgallery").innerHTML = AllPics;
}

function albums(js) {
    j = js;
    setTimeout("albumsa();", 1000);
}


