$(document).ready(function() {

	/* ridimensiona homepage */
	if (location.pathname.length <= 1) {
		$('#main').css({ width: '950px' });
		$('#sub1').css({ width: '700px' });
		$('#footer-left div').css({ width: '230px' });
	}

	/* marca i menu selezionati */
	$('#column-external a').each(function() {
		var h = $(this).attr('href');
		if (location.pathname.indexOf(h)>-1) {
			$(this).addClass('selected-item');
		}
	});

	/* banda laterale dx */
	if (location.pathname.indexOf('/promozione-e-sviluppo/')>-1 && !location.pathname.endsWith('cmd-view')) {
		$('#main').css({ background: '#fff url(/images/public/images/promozione.jpg) no-repeat right top', width: '500px', paddingRight: '250px' });
	}
	if (location.pathname.indexOf('/aree-di-intervento/')>-1 && !location.pathname.endsWith('/mappa') && !location.pathname.endsWith('cmd-view')) {
		$('#main').css({ background: '#fff url(/images/public/images/aree-intervento.jpg) no-repeat right top', width: '500px', paddingRight: '250px' });
	}
	if (location.pathname.indexOf('/press-news-pubblicazioni/')>-1 && !location.pathname.endsWith('cmd-view')) {
		$('#main').css({ background: '#fff url(/images/public/images/press.jpg) no-repeat right top', width: '500px', paddingRight: '250px' });
	}
	if (location.pathname.indexOf('/promozione-e-sviluppo/calcio')>-1 && !location.pathname.endsWith('cmd-view')) {
		$('#main').css({ background: '#fff url(/images/public/images/calcio.jpg) no-repeat right top', width: '500px', paddingRight: '250px' });
	}

	if (jQuery.browser.version=='6.0') {
		$('#navigation-bar a:not(.active), .homelinks a')
			.mouseover(function(){
				$(this).stop().animate(
					{backgroundColor:'#F3EEE5'}, 
					{duration:300})
			})
			.mouseout(function(){
				$(this).stop().animate(
					{backgroundColor:'#FFF'}, 
					{duration:300})
			})
			.click(function() {
				$(this).stop().css({color: '#F29400'});
			});
	} else {
		$('#navigation-bar a:not(.active)')
			.css( {background: '#fff url(/nav.png) no-repeat -500px 0'} )
			.mouseover(function(){
				$(this).stop().animate(
					{backgroundPosition:"(0px 0)"}, 
					{duration:500})
			})
			.mouseout(function(){
				$(this).stop().animate(
					{backgroundPosition:"(-500px 0)", color: "#535353"}, 
					{duration:300})
			})
			.click(function() {
				$(this).stop().css({color: '#F29400'});
			});
		$('.homelinks a')
			.css( {background: '#fff url(/nav_long.png) no-repeat -1500px 0'} )
			.mouseover(function(){
				$(this).stop().animate(
					{backgroundPosition:"(0px 0)"}, 
					{duration:500})
			})
			.mouseout(function(){
				$(this).stop().animate(
					{backgroundPosition:"(-1500px 0)", color: "#535353"}, 
					{duration:300})
			})
			.click(function() {
				$(this).stop().css({color: '#F29400'});
			});
	}

	if (jQuery.browser.version=='6.0') {
		$('#column-external a')
			.mouseover(function(){
				if (!$(this).is('.selected-item')) {
					$(this).stop().animate(
						{backgroundColor:'#F3EEE5'}, 
						{duration:500});
				}
			})
			.mouseout(function(){
				if (!$(this).is('.selected-item')) {
					$(this).stop().animate(
						{backgroundColor:'#FFF'}, 
						{duration:500});
				}
			})
			.click(function() {
				if (!$(this).is('.selected-item')) {
					$('#column-external a').removeClass('selected-item').css( {backgroundColor:'#FFF'} );
					$(this).stop().addClass('selected-item');
				}
			});
	} else {
		$('#column-external a')
			.css( {background: '#fff url(/nav.png) no-repeat -500px 0'} )
			.mouseover(function(){
				if (!$(this).is('.selected-item')) {
					$(this).stop().animate(
						{backgroundPosition:"(0px 0)"},
						{duration:700});
				}
			})
			.mouseout(function(){
				if (!$(this).is('.selected-item')) {
					$(this).stop().animate(
						{backgroundPosition:"(-500px 0)", color: "#535353"}, 
						{duration:400});
				}
			})
			.click(function() {
				if (!$(this).is('.selected-item')) {
					$('#column-external a').css( {background: '#fff url(/nav.png) no-repeat -500px 0'} ).removeClass('selected-item');
					$(this).stop().addClass('selected-item');
				}
			});
	}

	if ($('#politiche').length) {
		if (jQuery.browser.version=='6.0') {
			$('#g0').show();
		} else {
			$('#g0').fadeIn(1500);
		};
		$('#lipsum').css('background','#F3EEE5');
	}

  
  /* slideshow */
  $('.gallery a').lightBox();

});

function show(group, obj) {
	$('#politiche > li').each(function(){
		$(this).hide();
	});
	if (jQuery.browser.version=='6.0') {
		$(group).show();
	} else {
		$(group).fadeIn(1500);
	}
};
