
/**
* Global settings
*/
$(function(){
    $('.prevent').live('click', function(e) { e.preventDefault(); });
    
    $.ajaxSetup({
        type: "post"
    });

});


/**
* Carousel
*/
$(function(){
	
	$('ul.resps').show();
	
	liLength = $('ul.resps li').length;
	
	$('div.jInf').html('1/' + liLength);
	
	maxLi = -1;
	$('div.jcarousellite li').each(function(){
		if ( $(this).height() > maxLi ) {
			maxLi = parseInt($(this).height()) + 5;
		}
	});
	
	$('div.jcarousellite')
		.jCarouselLite({
	        btnNext: "a.rButton-next",
	        btnPrev: "a.rButton-prev",
	        auto: 7000,
	        speed: 300,
	        autoDelay: 10000,
	        visible: 1,
	        afterEnd: function(a){
				$('div.jInf').html(( a.index() > liLength ? 1 : ( a.index() < 1 ? liLength : a.index() ) ) + '/' + liLength);
	        }
	    })
	    .find('li')
	    	.css('height', maxLi)
	    	.find('div.rInf')
	    		.css({
					'position' : 'absolute',			
					'right' : '5px',			
					'bottom' : '2px'			
	    		})
	    	
	$('a.rButton').css('margin-top', parseInt(maxLi) / 2 - 5);
	
});

/**
* Feedback
*/
$(function(){
    	
    $('input.bFeedback')
    	.click(function(e){
    		e.preventDefault();
    		
			$.ajax({
                url : 'send.php?action=send_mail',
                data : $(this).parents('form').serialize() + '&sha=asdf',
                dataType: "json",
                context : $(this),
                beforeSend : function(){
					$(this).attr('disabled', true);
                },
                success : function(re){
                	$('div.bNotice span').remove();
                	
                	$('div.bNotice').css('visibility', 'visible');
                	
                    if ( !re.success ) {
                    	$('div.bNotice')
                    		.removeClass('bOk')
                    		.addClass('bError');
                    	
                    	$(this).attr('disabled', false);
                    	
						$('div.bNotice').append('<span>' + re.errors[0] + '</span>');
						
						return;
                    }
                    
                    $('div.bNotice')
                    	.addClass('bOk')
                    	.removeClass('bError')
                    	.html(re.msg);
                    	
                    $(this).addClass('bDisabled');
                }
            });
    	});
    	
});









