$(function() {

var vechile = $('#content .vechile');

if (vechile.is('div')) {
	// Elements
	var thumbs = vechile.find('.thumbs a');
	var current_thumb = thumbs.find('img.current').parent();
	var current_img = vechile.find('img.current').eq(0);

	// If has no thumbs
	if (!current_thumb.is('a')) return;
	
	// Do the magic
	thumbs.click(function(evt) {
		evt.preventDefault();
	})
	.mousedown(function() {
		if ($(this).children('img').hasClass('current')) return;

		var next_img = $($(this).attr('rel'));

		current_thumb.children('img').removeClass('current');
		$(this).children('img').addClass('current');
		current_thumb = $(this);

		current_img.fadeOut(200, function() {
			current_img.removeClass('current');
		});

		next_img.fadeIn(200, function() {
			next_img.addClass('current');
		});

		current_thumb = $(this);
		current_img = next_img;
	});
}

// Reset
$.fn.reset = function(ref) {
	if (ref == undefined && $(this).is(':input')) ref = $(this).attr('title');
	else if (typeof ref == 'string' && $(this).attr(ref))
		ref = $(this).attr(ref);
	else if (typeof ref == 'string' && $(this).is(':input'))
		ref = '';

	if ($(this).is('input')) {
		$(this).val(ref);
		$(this).removeClass('invalid');
	}
	else if($(this).find('input, select').length > 0) {
		$(this).find('input, select').each(function() {
			$(this).reset(ref);
		});
	}

	if ($(this).is('tr')) $(this).removeAttr('class');

	return $(this);
}

// Move
$.fn.move = function(local, time) {
	if (time == undefined) time = 150;
	$(this).animate({left: local}, time);
}

// Get Id
$.fn.getId = function() {
	var id = '#' + $(this).attr('id');
	return id;
}

// Get Class
$.fn.getClass = function() {
	var classe = '.' + $(this).attr('class');
	return classe;
}

});
