
var ie5 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.0") != -1);
var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);
var ie7 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 7.0") != -1);


var $j = new jQuery.noConflict();


Shadowbox.loadSkin('classic', root+'script/shadowbox/skin');
//Shadowbox.loadPlayer(['flv', 'html', 'iframe', 'img', 'qt', 'swf', 'wmp'], root+'script/shadowbox/player');
Shadowbox.loadPlayer(['iframe', 'img'], root+'script/shadowbox/player');


$j(function() {
			
	//$j('.content').equalHeights();

	Shadowbox.init();
	
	velocity=350;
	
	
	
	if($j('.galleriaTestata img').size()>1){
	
		/*$j('.navNews').css('opacity',0.8);
			
		$j('.contGalleria').hover(
			function() { $j('.navNews').fadeIn(); },
			function() { $j('.navNews').fadeOut(); }
		);		
		*/
		$j.fn.cycle.defaults.speed   = 900;
		$j.fn.cycle.defaults.timeout = 8000;
			
			
		$j('.galleriaTestata').cycle({ 
			fx:    'fade', 
			pause:  1, 
			delay: -2000,
			next:   '#next2', 
			prev:   '#prev2'
		});	
	}	
	
				
	velocity=350;

	$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.stop().animate(getBorderColor('#999'),velocity);
					roll.stop().animate({opacity:'.15'},velocity); 
				},
				function(){ 
					cornice.stop().animate(getBorderColor('#ccc'),velocity);
					roll.stop().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.stop().animate({'color':'#000'},velocity); 
					obj.stop().animate({'backgroundColor':'#ccc'},velocity); 
					if(isImg){
						cornice.stop().animate(getBorderColor('#000'),velocity);
						roll.stop().animate({opacity:'.15'},velocity); 
					}
				},
				function(){ 
					title.stop().animate({'color':'#666'},velocity); 
					obj.stop().animate({'backgroundColor':'#efefef'},velocity); 
					if(isImg){
						cornice.stop().animate(getBorderColor('#666'),velocity);
						roll.stop().animate({opacity:'0'},velocity); 
					}
				}		
			);
			
	});
	
			
});


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')
}


if (!Array.prototype.indexOf)
{
  Array.prototype.indexOf = function(elt /*, from*/)
  {
    var len = this.length >>> 0;

    var from = Number(arguments[1]) || 0;
    from = (from < 0)
         ? Math.ceil(from)
         : Math.floor(from);
    if (from < 0)
      from += len;

    for (; from < len; from++)
    {
      if (from in this &&
          this[from] === elt)
        return from;
    }
    return -1;
  };
}


