/*
 * Text description over images in articles
 * by Yiyi Liu
 */


$(document).ready(function(){ 

	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'; }
	else if( $('#content').attr("class") == 'THEMA_BEAUTE' ){ themePlusIcon = '/beaute/_img/btn_plus.gif'; }
	else if( $('#content').attr("class") == 'THEMA_PARENT' ){ themePlusIcon = '/emissions/_img/etre-parent/btn_plus.gif'; }
	else if( $('#content').attr("class") == 'THEMA_SANTE' ){ themePlusIcon = '/emissions/_img/sante/btn_plus.gif'; }
	
	// Image type 1: with thickbox, 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: "" });
		if( $(this).parent().parent().attr('class') == 'thickbox' ){ $(this).after('<span class="title-on-image-enlarge icon-plus-transparent" style="margin-top:-' + ($(this).attr("height") - 5) + 'px;"><img width="13" src="' + themePlusIcon + '"/></span>'); }
	}); 
															   
	$('a.thickbox span.title-on-image').each(function () {										   
		$(this).parent().hover(
		  function () {
			$(this).find('span.title-on-image-enlarge').removeClass("icon-plus-transparent");
		  }, 
		  function () {
			$(this).find('span.title-on-image-enlarge').addClass("icon-plus-transparent");
		  }
		);
	}); 

	// Image type 2: with thickbox, 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).after('<span class="title-on-image-enlarge icon-plus-transparent" style="margin-top:-' + ($(this).attr("height") - 5) + 'px;"><img width="13" src="' + themePlusIcon + '"/></span>');
		$(this).hover(
		  function () {
			$(this).next().removeClass("icon-plus-transparent");
		  }, 
		  function () {
			$(this).next().addClass("icon-plus-transparent");
		  }
		);
	}); 
	
}); //end document ready 
