
var cartella_web = "lions/";
$(document).ready(function(){


initStructure();



});/*ready*/



function initStructure(){
colEquity('#article','#aside');

/*catsliders();

findactivelink();*/


if ( $('.fancylink').length >0) {
 $('.fancylink').fancybox();	
}


if ( $('#article a>img').length >0) {
 $('#article a>img').each(function(){
 	if ($(this).attr('src') == $(this).parent('').attr('href') ){
 		$(this).parent('').addClass('autofancy');
 	}
 });
 $('.autofancy').fancybox();	
}

cyclebg(); 

};/**/

function cyclebg() {
	
$('.rimgslide').cycle({
    after:         null,   // transition callback (scope set to element that was shown) 
    before:        null,   // transition callback (scope set to element to be shown) 
    delay:         4000,      // additional delay (in ms) for first transition (hint: can be negative) 
    fit:           0,      // force slides to fit container 
    fx:           'fade',  // name of transition function 
    height:       'auto',  // container height 
    metaAttr:     'cycle', // data- attribute that holds the option data for the slideshow 
    next:          null,   // id of element to use as click trigger for next slide 
    pause:         0,      // true to enable "pause on hover" 
    prev:          null,   // id of element to use as click trigger for previous slide 
    timeout:       8000,   // milliseconds between slide transitions (0 to disable auto advance) 
    speed:         1000,   // speed of the transition (any valid fx speed value) 
    slideExpr:     null,   // expression for selecting slides (if something other than all children is required) 
    sync:          1,      // true if in/out transitions should occur simultaneously 
 
    // the following options let you create transitions other than fade 
    cssBefore:     {},     // properties that define the initial state of the slide before transitioning in 
    cssAfter:      {},     // properties that defined the state of the slide after transitioning out 
    animIn:        {},     // properties that define how the slide animates in 
    animOut:       {}      // properties that define how the slide animates out 	
});
	
};/**/


function findactivelink(){
	pageurl = this.location.href;
	
	$('a').each(function(index, element) {
        if ( $(this).attr('href') == pageurl ){
			$(this).addClass('active');	
		}
    });
	
};/**/



function nlbox(){
	
	var orpos = $('#nlbox').css('left');
	var oppos = -8 ;
	
	$('#nlbox').children('h3').toggle(function(){
		
		$(this).addClass('open');	
		$('#nlbox').animate({'left': oppos },200);
		
	},function(){
		
		$(this).removeClass('open');	
		$('#nlbox').animate({'left': orpos },200);
		
	});
	
};/**/



function catsliders(){
	
if ( $('ul.galleria').length > 0 ) {		
$('ul.galleria').each(function(index, element) {
$(this).find('br').remove();
$(this).children('li').each(function(){ $(this).children('a').wrap('<span />').fancybox();  });

$(this).bxSlider({		
mode: 'horizontal',                 // 'horizontal', 'vertical', 'fade'
infiniteLoop: false,                 // true, false - display first slide after last
hideControlOnEnd: true,            // true, false - if true, will hide 'next' control on last slide and 'prev' control on first
controls: true,                     // true, false - previous and next controls
speed: 350,                         // integer - in ms, duration of time slide transitions will occupy
easing: 'swing',                    // used with jquery.easing.1.3.js - see http://gsgd.co.uk/sandbox/jquery/easing/ for available options
pager: false,                        // true / false - display a pager
pagerSelector: null,                // jQuery selector - element to contain the pager. ex: '#pager'
pagerType: 'short',                  // 'full', 'short' - if 'full' pager displays 1,2,3... if 'short' pager displays 1 / 4
pagerLocation: 'bottom',            // 'bottom', 'top' - location of pager
pagerShortSeparator: 'di',           // string - ex: 'of' pager would display 1 of 4
pagerActiveClass: 'pager-active',   // string - classname attached to the active pager link
nextText: 'next',                   // string - text displayed for 'next' control
nextImage: cartellaWeb+'/i/slidenext.png',                      // string - filepath of image used for 'next' control. ex: 'images/next.jpg'
nextSelector: null,                 // jQuery selector - element to contain the next control. ex: '#next'
prevText: 'prev',                   // string - text displayed for 'previous' control
prevImage: cartellaWeb+'/i/slideprev.png',                      // string - filepath of image used for 'previous' control. ex: 'images/prev.jpg'
prevSelector: null,                 // jQuery selector - element to contain the previous control. ex: '#next'
captions: false,                    // true, false - display image captions (reads the image 'title' tag)
captionsSelector: null,             // jQuery selector - element to contain the captions. ex: '#captions'
auto: false,                        // true, false - make slideshow change automatically
autoDirection: 'next',              // 'next', 'prev' - direction in which auto show will traverse
autoControls: false,                // true, false - show 'start' and 'stop' controls for auto show
autoControlsSelector: null,         // jQuery selector - element to contain the auto controls. ex: '#auto-controls'
autoStart: false,                    // true, false - if false show will wait for 'start' control to activate
autoHover: false,                   // true, false - if true show will pause on mouseover
autoDelay: 0,                       // integer - in ms, the amount of time before starting the auto show
pause: 3000,                        // integer - in ms, the duration between each slide transition
startText: 'start',                 // string - text displayed for 'start' control
startImage: '',                     // string - filepath of image used for 'start' control. ex: 'images/start.jpg'
stopText: 'stop',                   // string - text displayed for 'stop' control
stopImage: '',                      // string - filepath of image used for 'stop' control. ex: 'images/stop.jpg'
ticker: false,                      // true, false - continuous motion ticker mode (think news ticker)
                                    // note: autoControls and autoControlsSelector apply to ticker!
tickerSpeed: 5000,                  // integer - has an inverse effect on speed. therefore, a value of 10000 will 
                                    // scroll very slowly while a value of 50 will scroll very quickly.
tickerDirection: 'next',            // 'next', 'prev' - direction in which ticker show will traverse
tickerHover: false,                 // true, false - if true ticker will pause on mouseover
wrapperClass: 'contain',         // string - classname attached to the slider wraper
startingSlide: 0,                   // integer - show will start on specified slide. note: slides are zero based!
displaySlideQty: 4,                 // integer - number of slides to display at once
moveSlideQty: 4,                    // integer - number of slides to move at once
randomStart: false               // true, false - if true show will start on a random slide

	});			
});		

}
	
	
};/**/



function colEquity(cols){
/* 	pareggia l'altezza di due o più elementi nel DOM 
	Es. colEquity('.colonna1','.colonna2','.colonna3');
*/
var maxh = 0;
thish = new Array();

for (var i = 0; i < arguments.length; i++)
  { 

	thish[i] = $(arguments[i]).height() + parseInt( $(arguments[i]).css('marginTop') ) + parseInt( $(arguments[i]).css('marginBottom') ) + parseInt( $(arguments[i]).css('paddingTop') ) + parseInt( $(arguments[i]).css('paddingBottom') ); 
	
	if ( thish[i] > maxh ){	  
		maxh = thish[i]; 
	} else {
		
	}
  }

for (var i = 0; i < arguments.length; i++)
  { 
	  if ( thish[i] < maxh ) {
		 var thath = maxh - parseInt( $(arguments[i]).css('marginTop') ) - parseInt( $(arguments[i]).css('marginBottom') ) - parseInt( $(arguments[i]).css('paddingTop') ) - parseInt( $(arguments[i]).css('paddingBottom') ); 
		 $(arguments[i]).css('minHeight',thath); 
	  }
  }

};/**/

