// our-experts carousel
jQuery(window).load(function () {
    //hack: if the "visible" below is set to more than the number of thumbnails it breaks the carousel
    var numExperts = jQuery("div.leaders .leader-carousel ul li").length;
    jQuery("div.leaders .leader-carousel").jCarouselLite({
        btnNext: ".next",
        btnPrev: ".prev",
        visible: (numExperts) > 3 ? 3 : numExperts,
        start: 1
    });
});


//// topics padding
//j$(document).ready(function() {
//  j$('ul.topics li:odd').css("padding-right", "0"); 
//});


// archive page accordion
j$(document).ready(function () {
    //archive collapsed init
    //j$('ul.panelgroup li div.panel-body').slideUp(600);
    j$('ul.panelgroup li div.panel-bar').each(function (index) {
        if (index == 0) {
            j$(this).addClass('btnActive');
        }
        else {
            j$(this).next(".panel-body").slideUp(600);
        }
    });

    //expand and collapse
    j$('ul.panelgroup li div.panel-bar').click(function () {
        if (j$(this).hasClass("btnActive") == false) {
            closeAllPanels();

            j$(this).next(".panel-body").slideDown(600);
            j$(this).addClass('btnActive');

        }
        else {
            j$(this).next(".panel-body").slideUp(600);
            j$(this).removeClass('btnActive');
        }
    });

    function closeAllPanels() {
        j$('ul.panelgroup li div.btnActive').each(function () {
            j$(this).next(".panel-body").slideUp(600);
            j$(this).removeClass('btnActive');
        });
    }
});


//// sidebar height
//j$(window).load(function() {
//	var biggestHeight = 0;
//	j$('.same-height').each(function(){
//		if(j$(this).height() > biggestHeight){
//			biggestHeight = j$(this).height();
//		}
//	});
//	j$('.same-height').height(biggestHeight);
//});


//// rounded corners
//j$(window).load(function () {
//    //curvycorners.js breaks in IE6 with curvyObject error popups (many, many of them) 
//    if (j$(".roundedCorners").length > 0 &&
//        !(j$.browser.msie == true && parseInt(j$.browser.version, 10) < 7)
//    ) {
//        var setting = {
//            tl: { radius: 6 },
//            tr: { radius: 6 },
//            bl: { radius: 6 },
//            br: { radius: 6 },
//            antiAlias: true
//        }
//        curvyCorners(setting, ".roundedCorners");
//    }
//});

//// input field clear
//j$(document).ready(function() {
//	j$('.clearField').clearField();
//});

//// print

//j$(document).ready(function(){ 
//    function print() { 
//        window.print(); 
//        return false;
//    } 

//    j$("a.print").click(function() { 
//            print(); 
//        });
//});

//j$(document).ready(function () {

//    function searchHeaderForm() {
//        var query = j$("#searchBox input.searchInput").val();
//        location.href = "/search/?q=" + encodeURIComponent(query) + "&pagenum=1";
//    }
//    j$("#searchBox input.searchInput").keypress(function (e) {
//        if (e.which == 13) {
//            e.preventDefault();
//            searchHeaderForm();
//        }
//    });
//    j$("#searchBox input.searchSubmit").click(function (e) {
//        e.preventDefault();
//        searchHeaderForm();
//    });
//});

//j$(document).ready(function () {

//    function searchPageForm() {
//        var query = j$("#search-page-q").val();
//        location.href = "/search/?q=" + encodeURIComponent(query) + "&pagenum=1";
//    }
//    j$("#search-page-q").keypress(function (e) {
//        if (e.which == 13) {
//            e.preventDefault();
//            searchPageForm();
//        }
//    });
//    j$("#search-page-button").click(function (e) {
//        e.preventDefault();
//        searchPageForm();
//    });
//});
