function panophotos(json) {
    for (var i = 0; i < json.photos.length; i++) {
      var photo = json.photos[i];
      $("pano_photo_"+i).update(
        '<a href="'+photo.photo_url+'"><img alt="'+photo.photo_title+'" src="'+photo.photo_file_url+'"/></a>' );
      $("pano_author_"+i).update( 'Author: <a href="'+photo.owner_url+'">'+photo.owner_name+'</a>');
    }
    for (var i = json.photos.length; i < 8; i++) {
      $("pano_photo_"+i).ancestors().first().hide();
    }
}

loadpanophotos = function(lat,lon) {

  minx = lon - 0.1;
  maxx = lon + 0.1;
  miny = lat - 0.1;
  maxy = lat + 0.1;
  var url = "http://www.panoramio.com/map/get_panoramas.php?order=popularity&set=public&from=0&to=8&minx="+minx+"&miny="+miny+
    "&maxx="+maxx+"&maxy="+maxy+"&size=thumbnail&callback=panophotos";
  var script = document.createElement('script');
  script.setAttribute('src', url);
  script.setAttribute('id', 'jsonScript');
  script.setAttribute('type', 'text/javascript');
  document.documentElement.firstChild.appendChild(script);

}

