$(document).ready(function()
{
    
  $(".iframe").livequery(function(){
        
    $(".iframe").fancybox({
            'titlePosition'		: 'outside',			
    		'width'				: 950,
    		'height'			: 500,
            'autoScale'     	: true,
            'transitionIn'		: 'slow',
    		'transitionOut'		: 'slow',
    		'type'				: 'iframe'
            });
  })

  $("a[rel=example_group]").fancybox({
    	'transitionIn'		: 'elastic',
    	'transitionOut'		: 'elastic',
    	'titlePosition' 	: 'over',
        'width'         	: 350,
        'height'        	: 'auto',
        'cyclic':true,
        'onStart': function() {
            var time = false;
            if(!time){ time = setTimeout(function(){ $.fancybox.next(); }, 5000);
             //alert('indietro');
             }
              $('#fancybox-outer').bind('mouseover',function(){ clearTimeout(time); time=false; });
              $('#fancybox-outer').bind('mouseout',function(){ 
                 if(!time){ time = setTimeout(function(){ $.fancybox.next(); }, 5000);
                  //alert('avanti');
                  }
              });
            },
    	'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
   		 return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
    	}
  });
  $("a[rel=group]").fancybox({
    	'transitionIn'		: 'elastic',
    	'transitionOut'		: 'elastic',
    	'titlePosition' 	: 'over',
        'width'         	: 350,
        'height'        	: 'auto',
        'cyclic':true
    	/*'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
   		 return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
    	}*/
  });
  
  $("a[rel=group2]").fancybox({
    	'transitionIn'		: 'elastic',
    	'transitionOut'		: 'elastic',
    	'titlePosition' 	: 'over',
        'width'         	: 350,
        'height'        	: 'auto',
        'cyclic':true,
    	'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
   		 return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
    	}
  });

  $("a[rel=group3]").fancybox({
    	'transitionIn'		: 'elastic',
    	'transitionOut'		: 'elastic',
    	'titlePosition' 	: 'over',
        'width'         	: 350,
        'height'        	: 'auto',
        'cyclic':true,
    	'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
   		 return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
    	}
  });

  $("a[rel=group03]").fancybox({
    	'transitionIn'		: 'elastic',
    	'transitionOut'		: 'elastic',
    	'titlePosition' 	: 'over',
        'width'         	: 350,
        'height'        	: 'auto',
        'cyclic':true
  });

  $(".iframe_tour").fancybox({
        'titlePosition'		: 'outside',			
        'width'        	    : 620,
        'height'        	: 400,
        'autoScale'     	: true,
        'transitionIn'		: 'slow',
		'transitionOut'		: 'slow',
		'type'				: 'iframe'
        });

  $(".iframe_video").click(function() {
          $.fancybox({
            'padding' : 0,
            'autoScale' : false,
            'transitionIn' : 'none',
            'transitionOut' : 'none',
            'title' : this.title,
            'width' : 640,
            'height' : 385,
            'href' : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
            'type' : 'swf',
            'swf' : {
            'wmode' : 'transparent',
            'allowfullscreen' : 'true'
            }
            });             
          return false;
          });
  
});


