$(document).ready(function() {		/*	TOOLTIP	*/	counter = 0;	$('.sc_tooltip').each(function() {		counter++;		// prelevo parametri		id = $(this).attr('id');		color = $(this).attr('color');				if (color == 'red') {			$(this).addClass('sc_tooltip_red');		} else {			$(this).addClass('sc_tooltip_green');		}				el = $(this);		$('*[tooltip=' + id + ']').hover(			function(e) {				//el.css('top', e.pageY-el.height()-26);				el.show();			},			function() {				el.hide();			}		);		$('*[tooltip=' + id + ']').mousemove(function(e) {			el.css('top', e.pageY-$('html').scrollTop()-el.height()-30);			el.css('left', e.pageX+5);		});	});		/*	HIGHLIGHT	*/	counter = 0;	$('.sc_highlight').each(function() {		counter++;		color = $(this).attr('color');		if (color == 'red') {			$(this).addClass('sc_highlight_red');		} else {			$(this).addClass('sc_highlight_green');		}	});		/*		BLOCK	*/	counter = 0;	$('.sc_block').each(function() {		counter++;		type = $(this).attr('type');		switch(type) {			case '2':				$(this).addClass('sc_block_2'); break;			case '3':				$(this).addClass('sc_block_3'); break;			case '1':			default:				$(this).addClass('sc_block_1'); break;		}	});		/*		LEGEND	*/	counter = 0;	$('.sc_legend').each(function() {		counter++;		title = $(this).attr('title');		content = $(this).html();		$(this).replaceWith('<div class="sc_legend"><div class="sc_legend_title">' + title + '</div><div class="sc_legend_content">' + content + '</div></div>');	});		/*		DROPCAP	*/	counter = 0;	$('.sc_dropcap').each(function() {		counter++;		content = $(this).html();		left = content.substr(0,1);		content = content.substr(1);		$(this).replaceWith('<div class="sc_dropcap"><div class="sc_dropcap_left">' + left + '</div><div class="sc_dropcap_content">' + content + '</div><div style="clear:both;"></div></div>');	});		/*		BLOCKQUOTE	*/	counter = 0;	$('.sc_blockquote').each(function() {		counter++;		content = $(this).html();		$(this).replaceWith('<div class="sc_blockquote"><div class="sc_blockquote_left">&quot;</div><div class="sc_blockquote_content">' + content + '</div><div style="clear:both;"></div></div>');	});		/* FLOATED */	counter = 0;	$('.sc_floated').each(function() {		counter++;		vFloat = $(this).attr('float');		if (vFloat != 'left' && vFloat != 'right') {			vFloat = 'left';		}		vWidth = $(this).attr('width');		if (vWidth == '' ||vWidth == undefined) {			vWidth = '200px';		}		content = $(this).html();		$(this).replaceWith('<div class="sc_floated" style="float: ' + vFloat + ';width: ' + vWidth + ';">' + content + '</div>');	});		/* COLUMNS */	counter = 0;	$('.sc_columns').each(function() {		counter++;		totale = 0;		$(this).children().each(function() {			vSize = $(this).attr('size');			if (vSize == '0' || vSize == '' || vSize == undefined) {				vSize = 1;			} else {				vSize = parseInt(vSize);			}			totale += vSize;		});		content = '';		$(this).children().each(function() {			vSize = $(this).attr('size');			if (vSize == '0' || vSize == '' || vSize == undefined) {				vSize = 1;			} else {				vSize = parseInt(vSize);			}			vContent = $(this).html();			width = parseInt((vSize/totale*100)+'');			content += '<div class="sc_column" style="width: ' + width + '%;"><div class="sc_column_content">' + vContent + '</div></div>';					});				$(this).replaceWith('<div class="sc_columns">' + content + '<div style="clear:both;"></div></div>');	});		/* TABS */	counter = 0;	$('.sc_tabs').each(function() {		tabs = '';		contents = '';		child = 0;		$(this).children().each(function() {			title = $(this).attr('title');			content = $(this).html();			classTab=(child==0)?'sc_tab_active':'sc_tab_inactive';			displayContent=(child==0)?'block':'none';			tabs += '<div class="sc_tab ' + classTab + '" childid="' + child + '"><div>' + title + '</div></div>';			contents += '<div class="sc_tab_content" style="display:' + displayContent + ';" childid="' + child + '">' + content + '</div>';			child++;		});		$(this).replaceWith('<div class="sc_tabs" tabid="' + counter + '">' + tabs + '<div style="clear:both;"></div>' + contents + '</div>');		$('.sc_tabs[tabid=' + counter + '] .sc_tab').each(function() {			$(this).click(function() {				tabid = $(this).parent().attr('tabid');				childid = $(this).attr('childid');				$('.sc_tabs[tabid=' + tabid + '] .sc_tab').removeClass('sc_tab_active');				$('.sc_tabs[tabid=' + tabid + '] .sc_tab').addClass('sc_tab_inactive');				$(this).removeClass('sc_tab_inactive');				$(this).addClass('sc_tab_active');				$('.sc_tabs[tabid=' + tabid + '] .sc_tab_content').hide();				$('.sc_tabs[tabid=' + tabid + '] .sc_tab_content[childid=' + childid + ']').show();			});		});					counter++;	});		/* ACCORDION */	counter = 0;	$('.sc_accordion').each(function() {		child = 0;		accordion = '';		$(this).children().each(function() {			title = $(this).attr('title');			content = $(this).html();			classTitle=(child==0)?'sc_accordion_title_active':'sc_accordion_title_inactive';			displayContent=(child==0)?'block':'none';			accordion += '<div class="sc_accordion_title sc_accordion_close" childid="' + child + '"><div>' + title + '</div></div>';			accordion += '<div class="sc_accordion_content" childid="' + child + '" style="display: none;">' + content + '</div>';			child++;		});		$(this).replaceWith('<div class="sc_accordion" accordionid="' + counter + '">' + accordion + '</div>');		$('.sc_accordion[accordionid=' + counter + '] .sc_accordion_title').each(function() {			$(this).click(function() {				accordionid = $(this).parent().attr('accordionid');				childid = $(this).attr('childid');				opened = $(this).hasClass('sc_accordion_open');				$('.sc_accordion[accordionid=' + accordionid + '] .sc_accordion_content').slideUp();				$('.sc_accordion[accordionid=' + accordionid + '] .sc_accordion_title').addClass('sc_accordion_close').removeClass('sc_accordion_open');				if (!opened) {					$('.sc_accordion[accordionid=' + accordionid + '] .sc_accordion_content[childid=' + childid + ']').slideDown();					$(this).removeClass('sc_accordion_close');					$(this).addClass('sc_accordion_open');				} else {					$(this).removeClass('sc_accordion_open');					$(this).addClass('sc_accordion_close');				}			});		});					counter++;	});	/* IMAGE */	$("a.sc_image").fancybox({		'transitionIn'	:	'elastic',		'transitionOut'	:	'elastic',		'speedIn'		:	600, 		'speedOut'		:	200, 		'overlayShow'	:	false	});	});
