
var $j = new jQuery.noConflict();


$j.fn.cycle.defaults.speed   = 900;
$j.fn.cycle.defaults.timeout = 8000;

$j(function() {
			
			
	$j('.galleriaTestata').cycle({ 
		fx:    'fade', 
		random:  1,
		pause:  1, 
		delay: -2000
	});			
			
			
	velocity=350;
	
	/*$j('.menu1 li').not(".active").find('a').hover(
		function(){ $j(this).animate({color:'#fff'},velocity); },
		function(){ $j(this).animate({color:'#344D54'},velocity); }			
	)*/	
	
	
	$j('.thumb').each(function(intIndex){		
			
			var obj = $j(this);	
			
			var cornice = obj.parent();
			var w=obj.width();
			var h=obj.height();
			var roll = $j('<div style="width:'+w+'px; height:'+h+'px; background-color:#fff;position:absolute;z-index:2;"></div>').css({opacity:'0'}).appendTo( obj );
						
			obj.hover(
				function(){ 
					cornice.animate(getBorderColor('#999'),velocity);
					roll.animate({opacity:'.15'},velocity); 
				},
				function(){ 
					cornice.animate(getBorderColor('#ccc'),velocity);
					roll.animate({opacity:'0'},velocity); 
				}		
			);
	});
	
	
		$j('.block').each(function(intIndex){		
					
			var obj = $j(this);	
			
			var cornice = obj.find('.cornice');
			var isImg = cornice.hasClass('cornice');
			var title = obj.find('a');
				
			obj.css('cursor', 'pointer').click(function(){location.href = title.attr('href');});
			
			if(isImg){		
				var w=cornice.find('div').width();
				var h=cornice.find('div').height();
				var roll = $j('<div style="width:'+w+'px; height:'+h+'px; background-color:#fff;position:absolute;z-index:2;"></div>').css({opacity:'0'}).appendTo( cornice.find('div') );				
			}
			
			obj.hover(
				function(){ 
					title.animate({'color':'#000'},velocity); 
					obj.animate({'backgroundColor':'#ccc'},velocity); 
					if(isImg){
						cornice.animate(getBorderColor('#000'),velocity);
						roll.animate({opacity:'.15'},velocity); 
					}
				},
				function(){ 
					title.animate({'color':'#666'},velocity); 
					obj.animate({'backgroundColor':'#efefef'},velocity); 
					if(isImg){
						cornice.animate(getBorderColor('#666'),velocity);
						roll.animate({opacity:'0'},velocity); 
					}
				}		
			);
			
	});
	
			
});


window.addEvent('domready', function(){
	new MultiBox('mb', {descClassName: 'multiBoxDesc'});
	new MultiBox('mbGallery', {offset: {x:0, y:-20}});
	new MultiBox('mbDesc', {descClassName: 'multiBoxDesc', offset: {x:0, y:-20}});	
});



function getBorderColor(color){
		
	var obj = {
			borderBottomColor:color,
			borderLeftColor:color,
			borderRightColor:color,
			borderTopColor:color
		}
	return obj;
}

function isValidEmail(str) {
   return (str.indexOf(".") > 0) && (str.indexOf("@") > 0);
}		


function popupWindow(url) {
	window.open(url,'popupWindow','fullscreen=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width='+screen.width+',height='+screen.height+',screenX=0,screenY=0,top=0,left=0')
}