$(function(){

	// external links
	$("a[rel='external']").click(function(){
		window.open($(this).attr("href"));
		return false;
	})

	// top navigation
	$("ul#topmenu").superfish(
		{
			autoArrows:false,
			disableHI: true,
			speed: 'fast',
			delay: 200
		}
	);
	$("ul li.topmenu").hover(
		function(){$(this).addClass('over')},
		function(){$(this).removeClass('over')}
	);

	// search focus
	$("#search-input").focus(function(){
		if($(this).val() == 'Search') $(this).val('');
	}).blur(function(){
		if($(this).val() == '') $(this).val('Search');
	})

	// newsticker
	if(typeof $().newsTicker == "function") {
		var options = {
			newsList: "#newsticker ul",
			tickerRate: 55,
			startDelay: 10,
			loopDelay: 4000,
			placeHolder1: " -",
			placeHolder2: ""
		}
		$().newsTicker(options);
	}

	// print page
	$("#print_page").click(function(){ window.print() });

	// alt languages
	$("#alt-lang").toggle(function() {
	  $("#languages").slideDown()
	}, function() {
	  $("#languages").slideUp()
	});

	// pretty photo
	$(".vidclick, a[rel^='prettyPhoto']").prettyPhoto({theme:'dark_square'});

	// carousels
	$('.jcarousel-skin-ebp').jcarousel({
        scroll: 1,
		auto: 5,
        wrap: 'last',
        initCallback: mycarousel_initCallback
    });

})

function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

