function displayMapRos() {
	var index, totalamount=10;
		$('#resultsMap').css('display', '');
		$('#linkDisplayMap').html('<a onclick="hideMapRos()" href="javascript:void(0)">nascondi mappa</a>');
		for (index=1; index<=totalamount; index++) {
			if (document.getElementById('summaryNumberID'+index)) {
				document.getElementById('summaryNumberID'+index).className = 'summaryNumber isVisible';
			}
		}
		$.cookie('showMap', '1', { expires: 7, path: '/'});
		initialize();
	} 
	
	
	
function hideMapRos() {
	var index, totalamount=10;
		$('#resultsMap').css('display', 'none');
		$('#linkDisplayMap').html('<a onclick="displayMapRos()" href="javascript:void(0)">mostra mappa</a>');
		for (index=1; index<=totalamount; index++) {
			if (document.getElementById('summaryNumberID'+index)) {
				document.getElementById('summaryNumberID'+index).className = 'summaryNumber isHidden';
			}
		}
		$.cookie('showMap', '0', { expires: 7, path: '/'});
}

function displaycookie() {
alert($.cookie('showMap'))
}
$(document).ready(function(){ 
	my_lightbox("a[rel^='prettyPhoto'], a[rel^='lightbox']");
	
	var indexbb;
if ($.cookie('showMap') == ''){
		$.cookie('showMap', '1', { expires: 7, path: '/'});
	
}	
if (($.cookie('showMap') == 1) || ($.cookie('showMap') == null)){
		$('#resultsMap').css('display', '');
		$('#linkDisplayMap').html('<a onclick="hideMapRos()" href="javascript:void(0)">nascondi mappa</a>');
	
} else {	
		$('#resultsMap').css('display', 'none');
		$('#linkDisplayMap').html('<a onclick="displayMapRos()" href="javascript:void(0)">mostra mappa</a>');
		for (indexbb=1; indexbb<=10; indexbb++) {
			if (document.getElementById('summaryNumberID'+indexbb)) {
				document.getElementById('summaryNumberID'+indexbb).className = 'summaryNumber isHidden';
			}
}

}
jQuery('#portfoliocont').kriesi_image_preloader({delay:400});	// activates preloader for non-slideshow images
	
	$("#tabs").tabs();
	$(".bottoneinvia").button();
	$("ul#navigation li:not('.current')").hover(
      function () {
        $(this).addClass("hover");
      }, 
      function () {
        $(this).removeClass("hover");
      }
    );
	
	$('.summaryNumber a').click(function(){
		$( 'html, body' ).animate( { scrollTop: 180 }, 'slow' );
		return false;
	});

});



// -------------------------------------------------------------------------------------------
// The Image preloader
// -------------------------------------------------------------------------------------------


(function($)
{
	$.fn.kriesi_image_preloader = function(options) 
	{
		var defaults = 
		{
			repeatedCheck: 500,
			fadeInSpeed: 1000,
			delay:600,
			callback: ''
		};
		
		var options = $.extend(defaults, options);
		
		return this.each(function()
		{
			var imageContainer = jQuery(this),
				images = imageContainer.find('img').css({opacity:0, visibility:'hidden'}),
				imagesToLoad = images.length;				
				
				imageContainer.operations =
				{	
					preload: function()
					{	
						var stopPreloading = true;
						
						images.each(function(i, event)
						{	
							var image = $(this);
							
							
							if(event.complete == true)
							{	
								imageContainer.operations.showImage(image);
							}
							else
							{
								image.bind('error load',{currentImage: image}, imageContainer.operations.showImage);
							}
							
						});
						
						return this;
					},
					
					showImage: function(image)
					{	
						imagesToLoad --;
						if(image.data.currentImage != undefined) { image = image.data.currentImage;}
												
						if (options.delay <= 0) image.css('visibility','visible').animate({opacity:1}, options.fadeInSpeed);
												 
						if(imagesToLoad == 0)
						{
							if(options.delay > 0)
							{
								images.each(function(i, event)
								{	
									var image = $(this);
									setTimeout(function()
									{	
										image.css('visibility','visible').animate({opacity:1}, options.fadeInSpeed);
									},
									options.delay*(i+1));
								});
								
								if(options.callback != '')
								{
									setTimeout(options.callback, options.delay*images.length);
								}
							}
							else if(options.callback != '')
							{
								(options.callback)();
							}
							
						}
						
					}

				};
				
				imageContainer.operations.preload();
		});
		
	}
})(jQuery);


function my_lightbox($elements)
{	
	var usedCSS = 1;
	jQuery('link').each(function()
	{	
		styleURL = jQuery(this).attr('href'); 
		CSSnumber = styleURL.match(/style(\d).css/);
		if(CSSnumber && CSSnumber.length > 0)
		{
			usedCSS = CSSnumber[1];
		}
	});
		
	
	var theme_selected = 'light_rounded';
	if (usedCSS == 2 || usedCSS == 4)
	{
		theme_selected = 'dark_rounded';
	}
	
	jQuery($elements).prettyPhoto({
			"theme": theme_selected /* light_rounded / dark_rounded / light_square / dark_square */																	});
	
	jQuery($elements).each(function()
	{	
		var $image = jQuery(this).contents("img");
		$newclass = 'lightbox_video';
		
		if(jQuery(this).attr('href').match(/(jpg|gif|jpeg|png|tif)/)) $newclass = 'lightbox_image';
			
		if ($image.length > 0)
		{	
			if(jQuery.browser.msie &&  jQuery.browser.version < 7) jQuery(this).addClass('ie6_lightbox');
			
			var $bg = jQuery("<span class='"+$newclass+" ie6fix'></span>").appendTo(jQuery(this));
			
			jQuery(this).bind('mouseenter', function()
			{
				$height = $image.height();
				$width = $image.width();
				$pos =  $image.position();		
				$bg.css({height:$height, width:$width, top:$pos.top, left:$pos.left});
			});
		}
	});	
	
	jQuery($elements).contents("img").hover(function()
	{
		jQuery(this).stop().animate({opacity:0.5},400);
	},
	function()
	{
		jQuery(this).stop().animate({opacity:1},400);
	});
}
function showText(text) {
	return unescape(text);
}



