/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
*/

// t: current time, b: begInnIng value, c: change In value, d: duration
jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuad',
	swing: function (x, t, b, c, d) {
		//alert(jQuery.easing.default);
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	easeInQuad: function (x, t, b, c, d) {
		return c*(t/=d)*t + b;
	},
	easeOutQuad: function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	},
	easeInExpo: function (x, t, b, c, d) {
		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
	},
	easeInOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
	}
});

 
function countdown() {
	var cd = setInterval(function(){
		$("#loading").fadeOut(50)}, 7000);	
	}

function nopopup(){
	$("#loading").hide();
	}
	
	/*	$.fn.image = function(fn) {
var total = this.length;
if(total>20) fn();
};*/

/*$.fn.image = function(fn) {
var total = this.length, loaded = 0;
this.each(function() {
var i = new Image();
i.src = this.src;
$(i).load(function(){
loaded++;
if(loaded>total/4) fn();
});
});
};*/

$(document).ready(function(){

if ($.cookie('lang')=='ita'){
 $(".ita").show();
 $(".eng").hide();
} else if ($.cookie('lang')=='eng'){
 $(".ita").hide();
 $(".eng").show();
} else if (!$.cookie('lang')){
 $(".ita").show();
 $(".eng").hide();
 $.cookie('lang','ita',{'path':'/'});
};
$('#toita').click(function(){
 $('.ita').show();
 $('.eng').hide();
  $.cookie('lang','ita',{'path':'/'});
});
$('#toeng').click(function(){
 $(".ita").hide();
 $(".eng").show();
  $.cookie('lang','eng',{'path':'/'});
});
 
 
 // funzione show/hide cataloghi
 $(".titolo-thumbox:gt(0)").next().hide();
 $(".titolo-thumbox:first").addClass("tit_on");
 $(".titolo-thumbox").click(function(){
 	$(".titolo-thumbox.tit_on").next().slideUp("normal");
	$(".tit_on").removeClass("tit_on");
	$(this).addClass("tit_on").next().slideDown("normal");
 });

	
	/*//POPUP
		$("body .page-1").append("<div id='loading'><div id='popup' style='background:transparent url(http://www.scalfino.com/ndxz-studio/site/sample/popup-bg.png);'><img id='popup-close' src='http://www.scalfino.com/ndxz-studio/site/sample/popup-close.gif' onClick='javascript:nopopup();'/><div id='popup-odessa'><a href='http://www.scalfino.com/unique/'>odessa</a></div><div id='popup-lista'><a href='http://www.pittimmagine.com/it/fiere/touchneozonecloudnine/espositori/temp.php#cloudnine' target='_blank'><img src='http://www.scalfino.com/ndxz-studio/site/sample/popup-espositori.gif' /></a></div></div></div>");
	
		*/
		
		$(".primaimg_collezione").load(function(){
//centra immagini catalogo
var widthe = $("#id-2").width();
$("#id-2").css({'margin-left': -(widthe-300)/2});
});

});