var chanPlayer = {
 pause:function() {
  this.switchingActive=false;
  document.getElementById('GUIselect').className='paused';
  document.getElementById('DYNBOX').className='selected area214';
 },
 play:function() {
  this.switchingActive=true;
  document.getElementById('GUIselect').className='';
  document.getElementById('DYNBOX').className='area214 yellow';
 },
 aswitch:function() {
  if (this.switchingActive) {
   this.idx = (this.idx + 1) % this.chan.length;
   this.switchNow();
  } else {
   this.bigloop = setTimeout('chanPlayer.aswitch()',5000);
  }
 },
 switchNext:function() {
  this.idx = (this.idx + 1) % this.chan.length;
  return this.switchNow();
 },
 switchPrev:function() {
  if (this.idx == 0) this.idx = this.chan.length;
  this.idx--;
  return this.switchNow();
 },
 switchNow:function() {
  this.switcher(this.chan[this.idx]);
  clearTimeout(this.bigloop);
  this.bigloop = setTimeout('chanPlayer.aswitch()',5000);
  return false;
 },
 mouseover:function(id) {
  if (window.event) {
   window.event.returnValue=false;
   window.event.cancelBubble = true;
  }
  this.pause();
  delayTime = 400;
  eval("chanPlayer.timeout = setTimeout('chanPlayer.switcher(\"" + id + "\")',delayTime)");
 },
 mouseout:function(id) {
  if (window.event) {
   window.event.returnValue=false;
   window.event.cancelBubble = true;
  }
  this.play();
  clearTimeout(this.timeout);
 },
 switcher:function(id) {
  if (window.event) {
   window.event.returnValue=false;
   window.event.cancelBubble = true;
  }
  var guiSelectLinks = document.getElementById('GUIselect').getElementsByTagName('a');
  for (var i=0;this.chan.length>i && guiSelectLinks.length>i;i++) {
   if (this.chan[i]==id) {
    this.idx = i;
    guiSelectLinks[i].className='gui-on';
   } else {
    guiSelectLinks[i].className='';
   }
  }
  var hidden = document.getElementById('FMDYN'+id);
  var t = hidden.cloneNode(true);
  t = t.innerHTML;
  var visible = document.getElementById('DYNTX');
  visible.innerHTML = t;
  visible.className=id;
  return false;
 },
 chan:['favs','world','us','people','sports','science','math','wordwise','life','homework','games','animals'],
 favs:void 0,
 idx:0,
 switchingActive:true,
 timeout:'',
 bigloop:''
}

function startLoop () {
 setTimeout('chanPlayer.aswitch()',5000);
}

function fbreg (email,campaign) {
 if(!campaign) campaign='FactMonster';
 var re = /^ *(.*)@([a-zA-Z0-9.-]+) *$/;
	 var e = document.getElementById('AD-FUNBUZZ-1').getElementsByTagName('p')[0];
 if (re.test(email)) {
  var local = RegExp.$1;
  var host = RegExp.$2;
  var reg0 = /(@.*@)|(\.@)|(^\.)/; // not valid
  var reg1 = /^[a-zA-Z0-9,!#$%&'*+/=?^_`.{|}~.-]+/;
  var reg2 = /(([a-zA-Z0-9-]+[.])+[.]?|\[?([0-9]{1,3}){4}\]?)/; // valid
  if (!reg0.test(email) && reg1.test(local) && reg2.test(host)) {
   e.className = '';
   e.innerHTML = 'Sign up to hear about movies and games <em>first</em>!';
   window.open('http://www.funbrain.com/newsletters/FunBuzzRegistration.html?campaign='+campaign+'&ScreenedEmail='+local+'@'+host);
   return;
	}
 }
 e.className = 'alert';
 e.innerHTML = 'You did not enter a valid email address!';
}

if (typeof(window.onload) != 'function') {
 window.onload = startLoop;
} else {
 var oldonload = window.onload;
 window.onload = function() {
  oldonload;
  startLoop;
 }
}

var page_id=Math.round(Math.random() * 10000000);
