var cbOrgsCollection;
var cbOrgsCurrent = 0;
var cbOrgsTimer;
/*
function cbOrgsInit ()
{
  if(! document.getElementById('frontLowerRight')) return;
  cbOrgsCollection = document.getElementById('frontLowerRight').getElementsByTagName('div');
  for(i = 0; i < cbOrgsCollection.length; i++)
  {
    cbOrgsCollection[i].style.display = 'none';
    cbOrgsCollection[i].className = 'frontOrg';
  }
  cbOrgsCurrent = Math.floor(Math.random() * cbOrgsCollection.length);
  cbOrgsCollection[ cbOrgsCurrent ].style.display = 'block';
  cbOrgsCollection[ cbOrgsCurrent ].className = 'frontOrg';
  cbOrgsTimer = setTimeout(cbOrgsFlip, 5000); 
}
function cbOrgsFlip ()
{
  oldFrame = cbOrgsCollection[cbOrgsCurrent % cbOrgsCollection.length];
  newFrame = cbOrgsCollection[++cbOrgsCurrent % cbOrgsCollection.length];
  if (!(navigator.appName=="Microsoft Internet Explorer"))
  {
    new Effect.DropOut(oldFrame.id);
    new Effect.Appear(newFrame.id);
  }
  else
  {
    oldFrame.style.display = 'none';
    newFrame.style.display = 'block';
  }
  cbOrgsTimer = setTimeout(cbOrgsFlip, 7000); 
}
Event.observe(window, 'load', cbOrgsInit);
*/

var cbMenuCount = -1;
var cbMenuTimer;

function cbMenuIn()
{
  if(! document.getElementById('frontSceneFarmLightOn')) return;
  if(cbMenuCount < 0)
  {
    document.getElementById('frontSceneFarmLightOn').style.opacity = 0;
    document.getElementById('frontSceneFarmLightOn').className = 'frontSceneFarmLight';
    cbMenuCount = 0;
  }
  if(!cbMenuCount++)
  {
    if (!(navigator.appName=="Microsoft Internet Explorer"))
      new Effect.Appear('frontSceneFarmLightOn', { duration: 0.1 });
    else
    {
      document.getElementById('frontSceneFarmLightOn').style.opacity = 100;
      document.getElementById('frontSceneFarmLightOn').style.display = 'block';
    }
    if(cbMenuTimer) clearTimeout(cbMenuTimer);
  }
}

function cbMenuOut()
{
  if(! document.getElementById('frontSceneFarmLightOn')) return;
  if(!--cbMenuCount)
  {
    clearTimeout(cbMenuTimer);
    cbMenuTimer = setTimeout(cbMenuOff, 500);
  }
}

function cbMenuOff()
{
  if(!cbMenuCount)
  {
    if (!(navigator.appName=="Microsoft Internet Explorer"))
      new Effect.Fade('frontSceneFarmLightOn', { duration: 0.1 });
    else
      document.getElementById('frontSceneFarmLightOn').style.display = 'none';
  }
}

function cbAdjustVertical()
{
  if(! document.getElementById('frontScene')) return;

  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }

  if(myHeight < 700)
  {
    document.getElementById('frontSceneImage').src = '/images/scene_farm_bg_small.jpg';
    document.getElementById('frontSceneImage').style.height = 373+'px';
    document.getElementById('frontScene').style.height = 373+'px';
    //document.getElementById('frontLowerArea').style.top = 479+'px';
  }
  else
  {
    document.getElementById('frontSceneImage').src = '/images/scene_farm_bg.jpg';
    document.getElementById('frontSceneImage').style.height = 573+'px';
    document.getElementById('frontScene').style.height = 573+'px';
    //document.getElementById('frontLowerArea').style.top = 679+'px';
  }
  Event.observe(window, 'resize', cbAdjustVertical);
}
Event.observe(window, 'load', cbAdjustVertical);
