/*
 * Text description over images in articles
 * by Yiyi Liu
 */


$(document).ready(function(){ 
						   
	// Type 1: Images with text description	
	$('img.title-on-image').each(function () {
		$(this).wrap('<span style="width:' + $(this).attr("width") + 'px; ' + $(this).attr("style") + '"></span>').after('<span style="width:' + ($(this).attr("width") - 6) + 'px;" class="' + $(this).attr("class") + '">' + $(this).attr("title") + '</span>');
		$(this).attr({ style: "float:left;", title: "" });
	}); 
	
	var themePlusIcon = '/emissions/_img/decoration/btn_plus_b.gif';
	
	if( $('#content').attr("class") == 'THEMA_CUISINE' ){ themePlusIcon = '/emissions/_img/cuisine/btn_plus_b.gif'; }
	else if( $('#content').attr("class") == 'THEMA_MARIAGE' ){ themePlusIcon = '/emissions/_img/vie-de-couple/btn_plus_b.gif'; }
														   
	$('a.thickbox span.title-on-image').each(function () {
													   
		$(this).parent().hover(
		  function () {
			$(this).append('<span class="title-on-image-enlarge" style="margin-top:-' + ($(this).find('img.title-on-image').attr("height") - 5) + 'px;"><img width="13" src="' + themePlusIcon + '"/></span>');
		  }, 
		  function () {
			$(this).find('span.title-on-image-enlarge').remove();
		  }
		);
	}); 

	// Type 2: Images without text description
	$('img.plus-on-image').each(function () {
		$(this).wrap('<span style="width:' + $(this).attr("width") + 'px; ' + $(this).attr("style") + '"></span>');
		$(this).attr({ style: "float:left;" });
		$(this).hover(
		  function () {
			$(this).after('<span class="title-on-image-enlarge" style="margin-top:-' + ($(this).attr("height") - 5) + 'px;"><img width="13" src="' + themePlusIcon + '"/></span>');
		  }, 
		  function () {
			$(this).next().remove();
		  }
		);
	}); 
}); //end document ready 