$(document).ready(function() {
	xOffset = -120;
	yOffset = -220;	
	
	$('#PrsShpTv_Programming .channelsTabs .buttons li a').click(function() {
		$('#PrsShpTv_Programming .channelsTabs .buttons li').removeClass('selected');
		$(this).parent().addClass('selected');
	});
	
	$(".wrapChannels .bt_channel").mouseover(function(e) {
		var id = $(this).attr('id');
		id = id.replace('channelLogo', '');
		var infoChannelID = "#channel" + id;
		
		var leftOffset = $(this).position().left;
		var topOffset = $(this).position().top;
		
		$(infoChannelID).css("left", (leftOffset + xOffset) + "px");
		$(infoChannelID).css("top", (topOffset + yOffset) + "px");
		
		$('.channelInfo').hide();
		$(infoChannelID).show();
		//$(infoChannelID).customFadeIn(4, id);
	});
	
	$(document.body).click(function() {
		$('.channelInfo').hide();
	});
	
	$(".wrapChannels .bt_channel").mouseout(function() {
		var id = $(this).attr('id');
		id = id.replace('channelLogo', '');
		var infoChannelID = "#channel" + id;
		//$(infoChannelID).fadeOut("slow");
		$(infoChannelID).hide();
		//$(infoChannelID).css("display","none");
	});
	
	$.fn.customFadeIn = function(speed, callback) {
		$(this).fadeIn(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(typeof callback == 'function')
				callback();
		});
	};
	$.fn.customFadeOut = function(speed, callback) {
		$(this).fadeOut(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(typeof callback == 'function')
				callback();
		});
	};
});
