window.onload = function () {
   load();
   setScreenLayout();
}
function setScreenLayout() { 
   var dims = getScreenSize();
   var sidebars = 220;
   resizeContentImages(dims[0] - (2*(sidebars+1)) -  60);   
   document.getElementById('sidebar-left').style.width = sidebars + 'px';       
   document.getElementById('sidebar-right').style.width = sidebars + 'px';       
   document.getElementById('main').style.width = dims[0] - (2*(sidebars+1)) + 'px';
   return true;       
}
function resizeContentImages(maximgwidth) {
   var imgs = document.getElementsByTagName('IMG');
   var i,img,par,imageincontent,wid;
   for (i=0;i<imgs.length;i++) {
      img = imgs[i];
      par = img.parentNode;
      imageincontent = false;
      while (par) {
         if (par.id == 'content') {
            imageincontent = true;
            break;
         } else if (par.id == 'bannerdiv')  {
            imageincontent = false;
            break;
         }      
         par = par.parentNode;
      }
      if (imageincontent) {
         wid = (img.style.width)?parseInt(img.style.width):parseInt(img.width);
         if (!wid || wid > maximgwidth) {
            img.width = null;
            img.height = null;
            img.style.width = maximgwidth + 'px';
            img.style.height = 'auto';
         }         
      }      
   }
   return true; 
}

function load(cat) {
   flickr = new FlickrAPI('760306ba991e4bcb125e9887e2400e76', '');
   if (!cat) {cat = window.location.href.replace(/.*\//,"");} 
   categories = cat.split(/_/); 
   //if (categories[0] != 'edit' && categories[0] != 'admin') {
   if (!(categories[0] in {'edit':'', 'admin':'','gallery':''})) {
      asyncFlickrThumb();
   }
   return true;
}
