// JavaScript Document
jQuery(document).ready(function() {
	
	_createRollOver('a.index_attivita_text');
	
	// ================================
	//   CARICAMENTO FACEBOOK FACES
	// ================================
	
	jQuery.ajax({
			url			:	"http://www.ilas.com/ilas2012/include/inc_facebook_index.php", //URL COMPLETO DI GET
			type		:	'GET',
			success		:	function(data){ //OPERAZIONI ALLA RICEZIONE DI DATI VALIDI
								//alert(2);
								var container = jQuery('.index_container_5');
								container.append(data).find('.index_container_5_pat, #all-fb-wrapper').stop().hide(0)
									.end().find('.index_container_5_pat').slideDown(400, function(){
											
											container.find('#all-fb-wrapper').slideDown(600);
											
										});
							}
		})
	
	
	// ================================
	
	jQuery('.index_linea165').css('backgroundColor',function(){
		return jQuery(this).parent().find('h3').next().css("backgroundColor");
	});
	
	
	jQuery(".myLink").css('background-color', function(){ return jQuery(this).parent().css("background-color"); })
		//.attr('rel', "EAEAEB");
	jQuery(".myLink").mouseenter(function(){
		color = '#'+jQuery(this).attr("rel");
		
		jQuery(this).stop().animate({
				backgroundPosition: '-10px 0px',
				backgroundColor: color
			  }, {
				duration: 150, 
				specialEasing: {
				  backgroundPosition: 'linear',
				  backgroundColor: 'linear'
				}
			  });
	}).mouseleave(function(){
		color = jQuery(this).parent().css("backgroundColor");
		jQuery(this).stop().animate({
				backgroundPosition: '-15px 0px',
				backgroundColor: color
			  }, {
				duration: 150, 
				specialEasing: {
				  backgroundPosition: 'linear',
				  backgroundColor: 'linear'
				}
			  });
	})
	
	

	jQuery('.index_area h3 a').hover(function(){
           jQuery(this).stop().animate({'color': '#D20000'}, 300);
       }, function(){
           jQuery(this).stop().animate({'color': '#F2F2F2'}, 300);
       });
	   
    if(!jQuery.browser.msie || (jQuery.browser.msie && parseInt(jQuery.browser.version) > 7) ) {
		
		jQuery('#index_gallery_mask').mouseenter(function(){
			window.clearInterval(my_gallery_interval);
		}).mouseleave(function(){
			my_gallery_interval = window.setInterval(gallery_slider, my_gallery_interval_time);
		})

		var my_gallery_interval_time = 5000;
		var my_gallery_interval = window.setInterval(gallery_slider, my_gallery_interval_time);
		
		
/*		jQuery('#index_docenti_mask').mouseenter(function(){
			window.clearInterval(my_docenti_interval);
		}).mouseleave(function(){
			my_docenti_interval = window.setInterval(docenti_slider_nClear, my_docenti_interval_time);
		})
		
		var my_docenti_interval_time = 9000;
		docenti_slider();
		var my_docenti_interval = window.setInterval(docenti_slider, my_docenti_interval_time);
		
*/
    } else {
		
	jQuery('.index_gallery_col')
		.each(function(j, contenitore){
			 
			jQuery(contenitore).children('.index_gallery_cont')
				.each(function(index,elem){
					
					if(index>=2){
						jQuery(this).remove();
					}
				})
		})
		
/*		jQuery('.index_docenti_col')
		.each(function(j, contenitore){
			 
			jQuery(contenitore).children('.docenteSingolo')
				.each(function(index,elem){
					
					if(index>=2){
						jQuery(this).remove();
					}
				})
		}) */
	}
	
	jQuery('.docenteSingolo:not(.disabled)').hover(function(){
			jQuery(this).stop().animate({
						opacity : .5
					}, 300);
		}, function(){
			jQuery(this).stop().animate({
						opacity : 1
					}, 300);
		})
});

function gallery_slider()
{
	jQuery('#index_gallery_mask').children('div.index_gallery_col').not(':last').each(function(index, elem){
		jQuery(elem).stop().delay(index*100).animate({
				top: '-'+(parseInt(jQuery(this).children('div:nth-child(1)').css('height'))*2)+'px'
			  }, {
				duration: 400, 
				specialEasing: {
				  top: 'linear'
				},
				
				complete: function() {
				 	jQuery(this).children('div:nth-child(1), div:nth-child(2)').each(function(index, elem){
						jQuery(elem).clone().appendTo(jQuery(elem).parent('div'));
						jQuery(elem).parent('div').css('top', 0);
						jQuery(elem).remove();
						
					});
				}				
		})
	});
}
/*
function docenti_slider_nClear()
{
	window.clearInterval(my_docenti_interval);
	docenti_slider();
	my_docenti_interval = window.setInterval(docenti_slider, my_docenti_interval_time);
}

function docenti_slider()
{
	//
	jQuery('#index_docenti_mask').children('div.index_docenti_col').not(':last').each(function(index, elem){
		
		jQuery(elem).stop().delay(index*1500).animate({
				top: '-'+(parseInt(jQuery(this).children('a:nth-child(1)').css('height'))*2)+'px'
			  }, {
				duration: 400, 
				specialEasing: {
				  top: 'linear'
				},
				
				complete: function() {
					jQuery(this).children('a:nth-child(1), a:nth-child(2)').each(function(index, elem){
						jQuery(elem).clone().appendTo(jQuery(elem).parent('div'));
						jQuery(elem).parent('div').css('top', 0);
						jQuery(elem).remove();
						
					});
					//my_docenti_interval = window.setInterval(docenti_slider, my_docenti_interval_time);
				}				
		})
	});
}
*/
