 // Init unica variable globally
var NTPT_PGEXTRA = '';
var NTPT_IMGSCR = 'http://analytics.belgacom.be/analytics.gif';

// forced for CLEOPATRA
document.domain="belgacom.be";

jQuery.fn.outerHtml = function() {
	var o = jQuery(this[0]);
	return jQuery('<div></div>').append(o).html();
};

(function($){
	
	$(function(){
		
		//Displace Footer
		var $footer = $(".pf-footer");
		$("body").append($footer);
		$footer.find(".om-bd").width($("#pf-container").width()).addClass("pf-container");
		
		//Compute sizes in main navigation
		if($.browser.msie && parseInt($.browser.version, 10) < 8){
			var totalWidth = $(".pf-mainNav .pf-navLine").innerWidth();
			var itemWidth = 0,
			$navItems = $(".pf-mainNav .pf-navItem");
			$navItems
				.each(function(){
					itemWidth += $(this).outerWidth();
				});
			
			var rest = totalWidth - itemWidth;
			
			$navItems
				.each(function(){
					var $this = $(this);
					$this.width((rest/$navItems.length)+$this.width());
				})
				.find("a").css("display", "block");
		}
		
		$( "#draggable" ).draggable();
		
		// Remove empty img tags
		var arr = $("img");
		if (arr.length){
			arr.each(function(i, item){
				if ($(item).attr("src")!==undefined && !$(item).attr("src").length){
					$(item).css("display", "none");
				}
				if ($(item).attr("src")===undefined){
					$(item).attr("src", "clear.gif").css({"height":"0","width":"0"});
					$(item).attr("alt", "");
				}
			});
		}

		$.fn.ucmsTooltip = function(title,content){
			$(this).simpletip({
				baseClass : 'oms-ucmsTooltip', 
				fixed : false,
				offset : [-150, -50],
				content : '<div class="title">' + title + '</div><div class="content">' + content + '</div>'
			});
		};

		// Init categorization tooltips
		$('.pb-cm-bullet-withTooltip').each(function(idx, item) {
			var $i = $(item), $titleContent = $i.children();
			$i.html('&nbsp;');
			$i.ucmsTooltip($titleContent.filter(':first').text(), $titleContent.filter(':last').text());
		});

		// Init stickers tooltips
		$('.pb-cm-stickers-withTooltip').each(function(idx, item) {
			var $i = $(item), $titleContent = $i.children();
			// $i.html('&nbsp;');
			$i.ucmsTooltip($titleContent.filter('.title').text(), $titleContent.filter('.description').text());
		});
		
		// Highlight opened left nav
		$('.oms-leftNav .pf-open').each(function(i,n){
			var $t = $(this);
			if ( $t.find('.pf-current').length === 0 ) {
				$t.addClass('pf-current');
			}
		});
	});
})(jQuery);
