/**
 * @author Jose Manuel
 */
$(function(){

	$('#help_wrapper dd').hide().parent().children('dt').click(function(){
		var eq = $('#help_wrapper dt').index($(this));
		$('#help_wrapper dd:not(:eq(' + eq + '))').slideUp('slow');
		$('#help_wrapper dd:eq(' + eq + ')').slideToggle('slow', function(){
			if($('#help_wrapper dd:eq(' + eq + ')').children('.help_content').length == 0){
				$.get(noCache('help_ajax/' + $('#help_wrapper dt:eq(' + eq + ')').attr('class')), function(data) {
					$('#help_wrapper dd:eq(' + eq + ')').append(data);
					$('#help_wrapper dd img.loader:eq(' + eq + ')').fadeOut('slow', function(){
						$('#help_wrapper dd:eq(' + eq + ')').children('.help_content').slideDown('slow', function(){
							$(document).scrollTo($('#help_wrapper dt:eq(' + eq + ')'));
							$('#help_wrapper dd:eq(' + eq + ') .help_content p.index').click(function(){
								$('#help_wrapper dd:eq(' + eq + ')').slideToggle('slow', function(){
									$.scrollTo(0,0);
								});
							});
						});
					});	
				});
			}else{
				$.scrollTo($(this), {
					offset: {
						left: 0,
						top: -28
					}
				});
			}
		});
	});
});

