var btns;
var divElements;
window.addEvent('load', function() {
	btns = $$('#main .center .tabs td a');
	divElements = $$('.tabContent');

	btns.each(function(el, index){
		el.addEvent('mousedown',function(e){
			switchTabs(index);
		});
		el.addEvent('click',function(e){
			this.hideFocus=true;
			new Event(e).stop();
		});
	});

});

function switchTabs(clickedIndex) {
	divElements.each(function(el, index) {
		if (index == clickedIndex) {
			el.setStyle('display','block');
		} else {
			el.setStyle('display','none');
		};
	});
	btns.each(function(el, index) {
		var tdEl = el.getParent();
		if (index == clickedIndex) {
			el.addClass('btnActive');
			tdEl.addClass('active');
		} else {
			el.removeClass('btnActive');
			tdEl.removeClass('active');
		}
	});
};


document.addEvent('domready', function(){

  // Embed the TV Ad video if we're on the press-room page
  if(window.location.search.match('page_id=2324')) {
    swfobject.embedSWF('/wp-content/themes/grky/flash/player_flv_mini.swf', 'tv_ad', '350', '250', '9.0.0', false, {
      flv: '/wp-content/themes/grky/video/grkytimc.flv',
      width: '350',
      height: '250',
      autoload: '1',
      loadingcolor: 'ff0000'
    });
  }

});
