$(function(){
	$('#tabs-container').tabs({ fxFade: true, fxSpeed: 'fast', selectedClass: 'selected' });
	
	$('#rating-slider').slider({
		min: -5,
		max: 5,
		step: 1,
		slide: function(e, ui){
			$('#rating-label').text(ui.value);
		},
		stop: function(e, ui){
			$("input[name=urec_rate]").val(ui.value);
		}
	});
	
	//Validation
	
	//Append status images to input elements
	$('#add-rec > :input[type!=hidden]').each(function(){		
		if($(this).hasClass('required') && $(this).val() == ''){
			$(this).after('&nbsp;<img src="/images/false.gif" />');
		}else{
			$(this).after('&nbsp<img src="" />');
			$(this).next('img').hide();
		}
	});
	
	//Validate options
	var options = {
		highlight: function(el,errorClass){
			if($(el).next('img'))
				$(el).next('img').attr('src','/images/false.gif').show();
			
		},
		
		unhighlight: function(el,errorClass){
			if($(el).next('img'))
				$(el).next('img').attr('src','/images/true.gif').show();
		},
		
		errorPlacement: function(){}

	}
	
	
	$('#add-rec').validate(options);
	
	var recFormContainer = $('#rec-form-container').hide().data('collapsed',true);
	
	$('#leave-rec').click(function(){
		if(recFormContainer.data('collapsed'))
			recFormContainer.data('collapsed',false).show();
		else
			recFormContainer.data('collapsed',true).hide();
			
		return false;
	});
});