/* helper function to load multiple functions, courtesy Simon Wilson */
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function popup(url,w,h,scroll)
{
  var l = (screen.width-w)/2;
  var t = (screen.height-h)/2;

  window.open(url,'_blank','resizable=yes,location=no,menubar=no,scrollbars='+scroll+',status=no,toolbar=no,fullscreen=no,dependent=no,width='+w+',height='+h+',left='+l+',top='+t);
}

//get basepath
var site_base = "";
if(a=document.getElementsByTagName("link")[0])
{
  site_base = a.href.substr(0,a.href.indexOf('/resources'));
}


function showImg(image, obj)
{
  if($(obj).fx)
  {
    $(obj).fx.stop();
  }

  $(obj).fx = $(obj).effect('opacity',{duration: 300}).start(1,0).chain(
    function() {
      new Asset.image(image, {
                      onload: function()
                      {
                        $(obj).src = this.src;
                        var myEffects = new Fx.Styles($('previewcontainer'), {duration: 300, transition: Fx.Transitions.linear});
                        myEffects.start({
                            'height': [$('previewcontainer').offsetHeight, this.height]
                          });
                        
                        
                        $(obj).fx = $(obj).effect('opacity',{duration: 300}).start(0,1);
                      }
      })
    }
  );
}