/* Carousel */
jQuery(function() {
    var blackBackground = $('div.slideShowBox');
    var onlyOnce = true;
	var cLiteInits = new Array();
	
	//blackBackground.addClass('logoGlow_bottom');
	$("ul.slideShow").each(function(){
        //check if ajax is enabled and create dummy entries
        var root = $(this);
        if ( isHiddenAction("_hiddenFSHomepageFlash", root) ) {
            var hidden = getHiddenActionInput("_hiddenFSHomepageFlash", root);
            var count = hidden.attr("itemCount");
            //if not enough li-s, add more
            var currentCount = $(">li", root).size();
            if ( currentCount < count ) {
                var i=0;
                for(i=0; i<count-currentCount; i++)
                    root.append("<li/>");
            }
        }
        root.slideShow({
            index:"div.slideShowIndex", 
            time:15000,
            onShow: function (currentLi,currentIndex){
                if ( !cLiteInits[currentIndex] || cLiteInits[currentIndex]!=1 ) {
                    cLiteInits[currentIndex]=1;
                    function applyCarousel() {
                        currentLi.find('.scroll-br div.jCarouselLite').jCarouselLite({
                            btnNext: currentLi.find('.scroll-br a.scroll-br-right'),
                            btnPrev: currentLi.find(".scroll-br a.scroll-br-left")
                        });
                    }
                    //if li is empty, bring ajax content
                    if ( currentLi.html()=="" ) {
                        //currentLi.loading(true, { img: '/images/dock-loading.gif', align: 'center', mask: false })
                        root.data("actionOkParams",{startIndex:currentIndex});
                        ajaxActionOk(root, {
                            hiddenField: "_hiddenFSHomepageFlash", 
                            okFunc: function(data){
                                currentLi.html(data);
                                //apply carousel
                                applyCarousel();
                            },
                            loadingParam: { img: '/images/banner-loading.gif', align: 'center', mask: false }
                        });
                    } else {
                        //apply carousel
                        applyCarousel();
                    }
                };
                // add black background after the first banner appears
                if ( onlyOnce ) {
                    onlyOnce = false;
                    if ( !blackBackground.hasClass('blackBackground') )
                        blackBackground.addClass('blackBackground');
                }
            }
		})
	});
});
/* Scroll Bar Articles */

jQuery(function(){
	$('.article-list-content:visible').jScrollPane();
});

//jQuery(function() {
//    $("ul.horizSlider").horizSlider(
//  { randomStart: true,
//      onShow: function(li) { $(li).find('div.hpPersonDescr').jScrollPane(); }
//  });
//});

		
/* Dock Bar */

/*jQuery(function(){
   $('#dock-nae').Fisheye({
	   maxWidth: 50,
	   items: 'a',
	   itemsText: 'span',
	   container: '.dock-container',
	   itemWidth: 155,
	   proximity:70,
	   alignment : 'left',
	   valign: 'bottom',
	   halign : 'center'
		})
});*/





jQuery(function() {
    $('div.box1 div.box-content div.mostRecentTplBridge:eq(1)').addClass('col2').removeClass('col1');
    $('div.box1 div.box-content div.mostRecentTplBridge:eq(2)').addClass('col3').removeClass('col1');

});

// Latest widget
jQuery(function() {
   $('div.box1 div.box-content ul.LS_slideShow').slideShow({
		index:"div.LS_slideShowIndex",
		time:10000,
		onShow: (function(){
		    
		})
		// set display for section's title  
   });	
});

// Latest speech
jQuery(function() {
   var cLiteInits = new Array();
   $('div.box1 div.box-content ul.LSpeech_slideShow').slideShow({
		index:"div.LSpeech_slideShowIndex",
		time:10000,
		onShow: (function(currentLi,currentIndex){
		    if ( !cLiteInits[currentIndex] || cLiteInits[currentIndex]!=1 ) {
		        cLiteInits[currentIndex]=1;
		    // set height for description
                var root = currentLi;
                var Hroot = root.height();
                var Htop = root.find('div.LSpeech-top').height();
                var descr = root.find('div.LSpeech_description');
                var Hdescr = descr.height();
                var Hmore = root.find('div.LSpeech_qLinks').height();
                var Hdescr = Hroot - Htop - Hmore;
                descr.css({'max-height': Hdescr, 'overflow' : 'hidden'});
           };
		})
   });	
});


/*jQuery(function() {
    $('div.box1 div.box-content ul.LS_slideShow').cycle({ cleartype:  1});
 })*/
