var tmo=null;
var loads= new Array();

function addToOnLoad(f){
  var old=window.onload;
  if (typeof f == "function"){
    if (typeof window.onload != "function") window.onload=f;
    else window.onload=function(){
      old();
      f();
    }
  }
  else {
    if (typeof window.onload != "function") window.onload=new Function(f);
    else window.onload=new Function(old+"; "+f);
  }
}

function setsize(id,t,b,e,h){
  var o=document.getElementById(id);
  var hh=h || b;
  if (b<e) hh+=Math.abs(hh/5); else if (b>e) hh-=Math.abs(hh/5);
  var val=Math.round(hh);
  if (t=='size') o.style.height=val+'px';
  else o.style.top=val+'px';
  if ((val>b && val<e) || (val<b && val>e)) {
    tmo=setTimeout(function(){setsize(id,t,b,e,hh)},10);
  }
  else {
    clearTimeout(tmo);
    if (b<e) o.setAttribute('anim',true);
    else o.setAttribute('anim',false);
  }
}

function openclose(id,max){
  var o=document.getElementById(id);
  if (o.getAttribute('anim')=='true' || o.getAttribute('anim')==true){
     setsize(id,'size',max,0,max-1);
     document.getElementById('winter_invitation').style.zIndex='10';
  }else{
     setsize(id,'size',0,max,1);
     document.getElementById('winter_invitation').style.zIndex='3';
  }
  
}

function floatin(){
  //var o=document.getElementById(id);s
  //if (o.getAttribute('anim')=='true' || o.getAttribute('anim')==true) setsize(id,'move',max,1,false);
  //else setsize(id,'move',1,max,false);
  setsize('fbd','move',-50,0,false);
}

function createLoads(lt){
  var loadok=lt;
  ls="";
  for (ol=0; ol<loadok.length; ol++) ls+=loadok[ol];
  return ls;
}

function setfbtexts(text){
    var response=text;
    labels=response.split('|');
    labelids=["FBCi","_jan","_feb","_mar","_apr","_may","_jun","_jul","_aug","_sept","_oct","_nov","_dec","FBNi","FBAd","FBAc","FBCu","FBCa","FBCc","FBMo","FBNc"];
    for (i=0; i<labels.length; i++){
      txt=document.createTextNode(labels[i]);
      if (document.getElementById(labelids[i])) document.getElementById(labelids[i]).appendChild(txt);
    }
    document.getElementById('fbload').style.display='none';
    document.getElementById('fbd').style.display='block';
    floatin();
}

