

$(document).ready(function() {

	/* This is basic - uses default settings */
	$("a#single_image").fancybox();

	/* Using custom settings */
	$("a#inline").fancybox({ 'hideOnContentClick': true });
	$("a.group").fancybox({ 'zoomSpeedIn': 200, 'zoomSpeedOut': 200, 'overlayShow': false});
	$("a.web").fancybox({ 'zoomSpeedIn': 200, 'zoomSpeedOut': 200, 'overlayShow': false, 'frameWidth':640, 'frameHeight':505});

	// PNG fix
	var ie6 = $.browser.msie && ( parseInt($.browser.version.substr(0,1)) < 7);
	if (ie6) { $("#logo").fixPNG(); }

	// Sifr
	$("#content h3").sifr({ version:3, font:'cssjs/dinc.swf', fontSize:20, overY:2, forceSingleLine:true /* ,overX:2 */ });



	if ($.browser.msie && ($.browser.version == 8)){
		$('.sIFR-alternate').css({color:'#fff', fontSize:1});
		var width = parseInt(new String($('.sIFR-flash object').css('width')).replace('px', ''));
		$('.sIFR-flash object').each(function(){
			$(this).css('width', $(this).parent().parent().parent().width() );
		});
	}

	// Immagini arrotondate
	if (!ie6) {
		$('img.round_big, img.round_small').each(function(){
			apply_round_corner(this);
		});
	}

	/*
		$("#header .site-nav span a").each(function(){
			var $this = $(this);
			
			$this.sifr({
				 version:3,
				 font:'cssjs/dinc.swf',
				 fontSize:13,
				 overX:2,
				 cursor:'pointer'
			});
		
	*/			

/*
			if ($.browser.msie){
				$this.hover(function(){
						$('span', this).hide();
						$( this).append('<div class="hoversifr">'+$(this).text()+'</div>');
					},
					function(){
						$('.hoversifr',this).remove();
						$('span', this).show();
					}
				);
			}
*/
	
	//}
});


function apply_round_corner(el){
	var $image = $(el).clone();

	var width = parseInt(new String($image.css('width')).replace('px',''));
	var height = parseInt(new String($image.css('height')).replace('px',''));

	if (isNaN(width) || (width == 0)){
		width = $image.attr('width');
		height = $image.attr('height');
		
		if (isNaN(width) || (width == 0)){
			setTimeout(function(){apply_round_corner(el), 5000});
			return;
		}
	}

	var $div = $(
		'<div class="round '+$image.attr('class')+'">'+
			'<span class="top_left"></span>'+
			'<span class="top_right"></span>'+
			'<span class="bottom_left"></span>'+
			'<span class="bottom_right"></span>'+
		'</div>');

	$div.append($image);


	$div.width(width);
	$div.height(height);
/*
	if ($.browser.msie && (($.browser.version == 7) || ($.browser.version == 8))){

		//if ($div.hasClass('round_big') && ($.browser.version == 7)){
			//$div.find('.bottom_right, .bottom_left').css('bottom', 18 );
			alert(height);
		//}

	}
*/
	$(el).replaceWith($div);
}


