$(function(){
	// carousel

	$('#company_slider ul li')
		.not('li.current')
		.css({
			left: -1000,
			opacity: 0
		});
	$('#company_slider')
		.addClass('enhanced')
		.append(
			$('<a id="slider_arrow_left"></a>')
				.click(function() {
					var old_li = $('#company_slider li.current').first();
					var new_li = old_li.prev().length ? old_li.prev() : old_li.siblings().last();
					old_li
						.removeClass('current')
						.animate({
								left: 1000,
								opacity : 0
						}, 500);
					new_li
						.css({
								left: -200,
								opacity: 0
						})
						.addClass('current')
						.animate({
							left: 150,
							opacity: 1
						}, 500);
				}))
		.append(
			$('<a id="slider_arrow_right"></a>')
				.click(function() {
					var old_li = $('#company_slider li.current').first();
					var new_li = old_li.next().length ? old_li.next() : old_li.siblings().first();
					old_li
						.removeClass('current')
						.animate({
								left: -1000,
								opacity : 0
						}, 500);
					new_li
						.css({
								left: 500,
								opacity: 0
						})
						.addClass('current')
						.animate({
							left: 150,
							opacity: 1
						}, 500);
				}))

	// preload images
	$([
	   '_app/img/slider_arrow_left_ro.png',
	   '_app/img/slider_arrow_right_ro.png'])
	.each(function() {
		 (new Image()).src = this;
	})

	// create mailto: links
	$('span.email-protector').each(function() {
		var local_part = $(this).attr('class').split(' ')[1];
		var email = $(this).text();
		email = email.replace(/^.+@/, local_part + '@');
		$(this).replaceWith('<a href="mailto:' + email + '">' + email + '</a>');
	});

});	
