var fb_users;

jQuery(document).ready(function ($) {
    $('.life_insurance .pads .pad:first').css('display','block');
    $('.life_insurance .tabs .fl:first').addClass('active');
    $('.life_insurance .tabs .fl:last').addClass('last_element');
    
    $('.life_insurance .tabs .fl').click(function() {
        return false;
    });
    
    $('.life_insurance .tabs .fl').mouseover(function() {
        if ( $('.life_insurance .tabs .fl.active') ) {
            attr_id_old = $('.life_insurance .tabs .fl.active a').attr('href');
            $(attr_id_old).css('display','none');
            $('.life_insurance .tabs .fl.active').removeClass('active');
        }
        $(this).addClass('active');
        attr_id = $(this).children('a').attr('href');
        $(attr_id).css('display','block');
    });
    $('.life_insurance .tabs .fl').mouseleave(function() {
        //
    });
    
    $('.ft .inner .f_switch').click(function() {
        $(this).addClass('active');
        $('.ft .inner .t_switch').removeClass('active');
        $('.ft .inner .tweetter').hide();
        $('.ft .inner iframe').show();
        return false;
    });
    
    $('.ft .inner .t_switch').click(function() {
        $(this).addClass('active');
        $('.ft .inner .f_switch').removeClass('active');
        $('.ft .inner iframe').hide();
        $('.ft .inner .tweetter').show();
        return false;
    });
    
    $('.top_menu a').mouseover(function() {
        rel = $(this).attr('rel');
        $('.top_menu_description .description.' + rel).stop(true, true).slideDown('slow');
    });
    
    $('.top_menu a').mouseleave(function() {
        rel = $(this).attr('rel');
        $('.top_menu_description .description.' + rel).stop(true, true).slideUp('slow');
    });
    
    var curElement = 0;
    var totalElements = $('.rotator .fb_avatar').length;
    
    $('.rotator .right').click(function() {
    	var nextElement = curElement+1;
    	if(nextElement<0) {
    		nextElement=totalElements-1;
    	}
    	if(nextElement>totalElements-1) {
    		nextElement=0;
    	}

    	$('.rotator .fb_avatar').eq(curElement).css({'left': '0px', 'display':'block'}).animate({'left': '-100px'}, 'fast', function(){$(this).hide();});
		$('.rotator .fb_avatar').eq(nextElement).css({'left': '100px', 'display':'block'}).animate({'left': '0px'}, 'fast', function(){$('.rotator .title').html($(this).attr('title'));});

		curElement++;
		if(curElement<0) {
			curElement=totalElements-1;
    	}
    	if(curElement>totalElements-1) {
    		curElement=0;
    	}
    	return false;
    });
    
    $('.rotator .left').click(function() {
    	var nextElement = curElement-1;
    	if(nextElement<0) {
    		nextElement=totalElements-1;
    	}
    	if(nextElement>totalElements-1) {
    		nextElement=0;
    	}
    		
		$('.rotator .fb_avatar').eq(curElement).css({'left': '0px', 'display':'block'}).animate({'left': '100px'}, 'fast', function(){$(this).hide();});
		$('.rotator .fb_avatar').eq(nextElement).css({'left': '-100px', 'display':'block'}).animate({'left': '0px'}, 'fast', function(){$('.rotator .title').html($(this).attr('title'));});
		
		curElement--;
		if(curElement<0) {
			curElement=totalElements-1;
    	}
    	if(curElement>totalElements-1) {
    		curElement=0;
    	}
        return false;
    });
    
    $('.rotator .title').html($('.rotator .fb_avatar').eq(0).attr('title'));
    
    setInterval('$(".rotator .right").trigger("click");',3000);
    
//     $('.lifecalc').hide();
//     
//     $('.lifecalcactivate').click(function() {
//         $('.lifecalc').slideDown('slow');
//         return false;
//     });

});
