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 = "";


function albums(j){  //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();
 

  // $("<div style='margin-left:3px'><a class='standard' href='" + window.location.protocol + "//" + window.location.hostname+window.location.pathname+"'>Gallery Home</a> &gt; "+ j.feed.title.$t +"&nbsp;&nbsp;["+np+" item"+item_plural+"]</div><div style='text-align:right; margin-right:5px; margin-top:-14px'><a target=PICASA class='standard' href='"+album_link+"'>View this album in Picasa</a></div><br>");
 AllPics = ("<div class = 'picasawebalbum'>");

 for(i=0;i<j.feed.entry.length;i++){

  //var img_begin = j.feed.entry[i].summary.$t.indexOf('src="')+5;
  //var img_end = j.feed.entry[i].summary.$t.indexOf('?imgmax');
  //var img_base = j.feed.entry[i].summary.$t.slice(img_begin, img_end);

  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;


  // display the thumbnail (in a table) and make the link to the photo page, including the gallery name so it can be displayed.
  
  // (apparently the gallery name isn't in the photo feed from the Picasa API, so we need to pass it as an argument in the URL) - removed the gallery name 7/18/2007
  
  var link_url = "?albumid="+_GET['albumid']+"&photoid="+id_base; //+"&photoids="+photoids;
  // disable the navigation entirely for really long URLs so we don't hit against the URL length limit.
  // note: this is probably not necessary now that we're no longer passing the photoarray inside the URL. 7/17/2007
  // Not a bad idea to leave it in, though, in case something goes seriously wrong and we need to revert to that method.
  if (link_url.length > 2048) { link_url = link_url.slice(0, link_url.indexOf('&photoids=')+10)+id_base; }
  
  // link_url = 'http://picasaweb.google.com/data/entry/base/user/nick@theprimaryfocus.co.nz/albumid/5430851210732313537/photoid/' + id_base + '.jpg?alt=json&callback=photo';


  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 + (img_base + "<br />");
  // AllPics = AllPics + ("<a href='" + link_url + "' class='highslide' onclick='return hs.expand(this)'><img src='" + img_base + "?imgmax=160&crop=1'  /></a>");
  

  //$("<p><center><SPAN STYLE='font-size: 9px'>"+j.feed.entry[i].media$group.media$description.$t+"</span></center>");
  //AllPics = AllPics + "<p><center><SPAN STYLE='font-size: 9px'>" + j.feed.entry[i].media$group.media$description.$t + "</span></center>";
  
  AllPics = AllPics + "</div>";

  //if (i % columns == columns-1) {
      //AllPics = AllPics + ("</tr><tr><td><br></td></tr><tr>");
    //}
 }

//AllPics = AllPics +("</tr></table>");
AllPics = AllPics + ("</div>");


}


