$(document).ready(function() {
	// Manipolazione titolo
	var el = $('body')
		string2find = /([a-zA-Z\à]{7})+( Design)/ig
		string2find = new RegExp("([a-zA-Z\u00E0]{7})+( Design)",'ig');
		;
	el.html(el.html().replace(string2find, 'Sandon&agrave;<span class="design">design</span>'));

	// Colore testo
	if ($('.post p').length > 0) {
		$('.post p').each(function() {
			var txt = $(this).text();
			$(this).text('');
			$(this).html('<span class="bgColor">' + txt + '</span>');
		});
	}
	if ($('.pageContent p').length > 0) {
		$('.pageContent p').each(function() {
			var txt = $(this).html();
			$(this).html('');
			$(this).html('<span class="bgColor2">' + txt + '</span>');
		});
	}
	if ($('.entry-content li').length > 0) {
		$('.entry-content li').each(function() {
			var txt = $(this).html();
			$(this).html('');
			$(this).html('<span class="bgColor2">' + txt + '</span>');
		});
	}
	if ($('.entry-content h2').length > 0) {
		$('.entry-content h2').each(function() {
			var txt = $(this).html();
			$(this).html('');
			$(this).html('<span class="bgColor2">' + txt + '</span>');
		});
	}
	if ($('.entry-content p').length > 0) {
		$('.entry-content p').each(function() {
			var txt = $(this).html();
			$(this).html('');
			$(this).html('<span class="bgColor2">' + txt + '</span>');
		});
	}
	/*if ($('.current_page_item').length > 0) {
		var questo = $('.current_page_item')
		  , txt = $('.current_page_item').text()
		  , first = txt.substr(0, 1)
		  , rest = txt.substr(1, txt.length - 1)
			;
		questo.text('').html('<span style="color:#FE1113; font-weight:bold;">' + first.toUpperCase() + '</span>' + rest);
	}
	if ($('.current-cat').length > 0) {
		var questo = $('.current-cat')
		  , txt = questo.text()
		  , first = txt.substr(0, 1)
		  , rest = txt.substr(1, txt.length - 1)
			;
		questo.text('').html('<span style="color:#FE1113;">' + first.toUpperCase() + '</span>' + rest);
	}*/

	// Menu post homepage
	if ($('.attsList li').length > 0) {
		// gestione immagini selezione post
		var opa = 0.5;
		$('.attsList li').css({ opacity: opa });
		$('.attsList li').mouseover(function() {
			$(this).addClass('imgShadow');
			$(this).stop().animate({opacity: 1}, 200);
		}).mouseout(function() {
			$(this).stop().animate({opacity: opa}, 500, function() {
				$(this).removeClass('imgShadow');
			});
		});

		// Gestione visualizzazione post
		$('.post').hide(); //$('.post:not(:first)').hide();
		$('.post:first').show();
		/*$('.attsList li a').click(function(e) {
			var postId = $(this).attr('href')
				postId = postId.split("#") //postId = postId.replace("#", "")
				totPost = (postId.length)-1
				parentLi = $(this).parent('li')
				;
				$('.attsList li').removeClass('selected');
				parentLi.addClass('selected').css({opacity: 1});
			$('.post').hide();
			$('#' + postId[totPost]).show(); //$('#' + postId).show();

			e.preventDefault();
			return false;
		});*/
	}

	if ($('#scrollbar').length > 0) {
		/*var overviewH = $('.overview').height()
		  , newH = Math.round(((overviewH*20)/100) + overviewH)
		  ;
		$('.overview').height(newH);*/
		$('#scrollbar').tinyscrollbar({sizethumb: 100});
		$('#scrollbar .scrollbar').css({ opacity: 0.5 });
		if (!$('.scrollbar').hasClass('disable')) {
			$('.post .entry-content, .page .entry-content, .category .entry-content, .pageContent .entry-content, .categoryContent .entry-content').css({'top': '0', 'bottom': 'auto'});
		}
	}

    $('.attsList').jcarousel({
        scroll: 5
    });

	$('#nav .back').click(function() {
		history.go(-1);
		//e.preventDefault();
		return false;
	});
});
