window.addEvent('domready', function() {
	var t = $$("a[rel=external]");
	t.each(function(lnk, nr){
		lnk.set({'target':'_blank'});									
	});
	
// highlights ticker
	var request = new Request.JSON({
		url: '/index.htm?action=ajax_highlight',
		onComplete: function(rJSON, response) {					
			var json = $H(JSON.decode(response, true));
			if(json["status"] == 1){				
				if(json["highlights"].length>0){
					var l = $('hl_wrapper').getElement('ul');
					json["highlights"].each(function(q){
						l.adopt(new Element('li', {'html':q["title"]}).setStyle('opacity', 0));												 												 
					});					  									
					hl_timer = hl.delay(2500);		
				}
		   } else {
			   
		   }
		}
   }).post();
	
// add play btn (movie lnk)
	ml = $$('.movie_lnk_img');
	ml.each(function(el){
		span = new Element('img', {'src':'/btn_play_overlay.png', 'width':16, 'height':19, 'class':'btn'});
		span.inject(el);					 
	});
	



});

var current_hl = 0;
var hl_timer;

function hl(){
	var previous = $('hl_wrapper').getElements('li')[current_hl];
	previous.fade('out').retrieve('tween').chain(function(){
		current_hl++;
		if(current_hl >= $('hl_wrapper').getElements('li').length){ current_hl = 0; }	
		$('hl_wrapper').getElements('li')[current_hl].fade('in').retrieve('tween').chain(function(){			
			hl_timer = hl.delay(3000);
		});
	});	
}
