(function($, jQuery) {

 $(document).ready(function() {
	doHrefOverlays("[jqueryoverlayfixhref]") ;
	addBrowserToHtml();
	fixCompanyHovers();
})


function addBrowserToHtml() {
	if ($.browser.msie)
		$("html").addClass("ie");//+ parseInt($.browser.version, 10))
	else if ($.browser.mozilla)
		$("html").addClass("moz");//+ parseInt($.browser.version, 10))
	else if ($.browser.webkit)
		$("html").addClass("wkit");//+ parseInt($.browser.version, 10))
}

function toggleOverCMCG()
{
		if ($("#overCmcgContainer").hasClass("overCmcgContainerHidden"))
		{
				$("#overCmcgContainer").removeClass("overCmcgContainerHidden");
				$("#overCmcg").animate({"bottom": "+=229px"}, 500, function() {
					$("#overCmcgContainer").addClass("overCmcgContainerVisible");
					$("#overCmcgTitelBalk").css("background-image", "url('"+_relativeTemplate+"images/pijlte_beneden.png')");
				});
		}
		else
		{
				$("#overCmcgContainer").removeClass("overCmcgContainerVisible");
				$("#overCmcg").animate({"bottom": "-=229px"}, 500, function() {
					$("#overCmcgContainer").addClass("overCmcgContainerHidden");
					$("#overCmcgTitelBalk").css("background-image", "url('"+_relativeTemplate+"images/pijltjeboven.png')");
				});
		}
}
	$(function() {
		return; //This function is obsolete... I think
//$("#"+excerptId).css('display', '');
		$('ul.postSummary').delegate('li div', 'mousemove', function(e){

//			var ms = new Date().getTime();

			var me = $(this);
			var offset = me.offset();
			var x = e.pageX - offset.left + 5;
			var y = e.pageY - offset.top - 30;
			var maxX = $(window).width() - 505;		// houd rekening met kleiner scherm zodat de tooltip niet buiten beeld valt
			//this points to the LI

			// maximale X positie om altijd binnen beeld te lbijven
			if (e.pageX > maxX) x = maxX-me.offset().left + 5;
			if (y < -28) y = -28;
			if (y > 10) y = 10;

			me.children('.postExcerpt').css( { 
				left: x , 
				top: y
			});
	}); 
	 
	$('ul.postSummary').delegate('li div', 'mouseover', function() {
		$(this).children('.postExcerpt').show()
			.end()
			.find('img')
			.removeAttr('title')
			.removeAttr('alt');
	});
	$('ul.postSummary').delegate('li div', 'mouseout', function() {
	 	$(this).children('.postExcerpt').hide();  
	}); 
});


function doHrefOverlays(search) {
	$(search).each(function(i) {
		var overlay =  $('<span/>', {  
			style: "position:absolute; left:0px; top:0px; width:0px; height:0px;"
		});
		$(overlay).css("left", $(this).attr('overlay_left'));
		$(overlay).css("top", $(this).attr('overlay_top'));
		$(overlay).css("width", $(this).width());
		$(overlay).css("height", $(this).innerHeight());
		$(overlay).css("z-index", "60");
		if ($(this).attr("target") == "_blank")
			$(overlay).attr("onclick", "window.open=' "+$(this).attr('href')+"'");
		else
			$(overlay).attr("onclick", "window.location=' "+$(this).attr('href')+"'");
		$(this).prepend(overlay);
	})
}

function fixCompanyHovers() {
	$('a.nw12Link').hover(function() {
		$('div.nw12Block').show();
	}, function() {
		$('div.nw12Block').hide();
	});
	$('a.v12Link').hover(function() {
		$('div.v12Block').show();
	}, function() {
		$('div.v12Block').hide();
	});
	$('a.clickqLink').hover(function() {
		$('div.clickqBlock').show();
	}, function() {
		$('div.clickqBlock').hide();
	});
	$('a.leadqLink').hover(function() {
		$('div.leadqBlock').show();
	}, function() {
		$('div.leadqBlock').hide();
	});
}



window.addBrowserToHtml = addBrowserToHtml;
window.toggleOverCMCG= toggleOverCMCG;
window.fixCompanyHovers= fixCompanyHovers;
window.doHrefOverlays= doHrefOverlays;

})(jQuery,jQuery);
