
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 ie8 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 8.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');

velocity=350;
$j(function() {
			
	$j('.el1, .el2').equalHeightsByGroup(false,40);
				
	Shadowbox.init();	
	
		//$j('.jqueryslidemenu ul ul').css('opacity',0.95);

		
	if (!ie6) $j().UItoTop({ easingType: 'easeOutQuart' });
	
	
	/*$j('.menu1 li').not(".active").find('a').hover(
		function(){ $j(this).stop().animate({color:'#fff'},velocity); },
		function(){ $j(this).stop().animate({color:'#344D54'},velocity); }			
	)*/	
				
	 
	/* if(ie8 || ie7 || ie6 || ie55 || ie5) $j('#container-1').tabs();
	 
	 else $j('#container-1').tabs({ fxFade: true, fxSpeed: 'fast' });
	 */
	
			
		
	/*$j("div.scrollable").scrollable({
		size:3
	});*/
	
	
	
	/*$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'
	});	*/
	
	
	$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('#ccc'),velocity);
					roll.stop().animate({opacity:'.15'},velocity); 
				},
				function(){ 
					cornice.stop().animate(getBorderColor('#fff'),velocity);
					roll.stop().animate({opacity:'0'},velocity); 
				}		
			);
	});
	
	
	$j('.thumbCatalogo').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('#888'),velocity);
					roll.stop().animate({opacity:'.15'},velocity); 
				},
				function(){ 
					cornice.stop().animate(getBorderColor('#ccc'),velocity);
					roll.stop().animate({opacity:'0'},velocity); 
				}		
			);
	});	
	

	
	//$j("body").append($j("<ul>"));
	
	/*$j(".cornice a").each(function(){
		var _this = $j(this), text = ""; 
		
		
		if (_this.attr("rev") === ""){
			//text = " has an empty alt attribute";
		}else{
			var link=_this.attr("rev");
			//text = " has an alt attribute of '"+link+"'";
			//$j("<li>").text($this.attr("id")+text).appendTo($j("ul")); 
			
			$j(this).parent().qtip(
			  {
				 content: '<a href="'+link+'" title="Autore" target="blank" class="tooltipSmall"><img src="'+root+'img/info.jpg" /></a>', // Give it some content
				 position: 'topRight', // Set its position
				 hide: {
					fixed: true // Make it fixed so it can be hovered over
				 },
				 style: {
					background:'none',
					border: 'none',
					padding: '10px 10px', // Give it some extra padding
					name: 'light' // And style it with the preset dark theme
				 }
			  });
		}
	});   */

			
});




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;
  };
}
