$(document).ready(function() {
  
  $('.category_list, .category_list_main').hide();
  
  $("#new_user input:visible:enabled:first").focus();
	$("#new_user_session input:visible:enabled:first").focus();
	
  //   $('ul#categories_menu .show_more').click(function() {
  //  $('.category_list_main').toggle('fast');
  //  return false
  // });
	
	$('form#search_query #query').focus(function() {
		v = $(this).val();
		if(v == "Search for Vents")
			$(this).val("");
	});
	$('form#search_query #query').blur(function() {
		v = $(this).val();
		if(v == "")
			$(this).val("Search for Vents");
	});
	
	
	setTimeout('remove_flash_msg()',4000);
	
  $.facebox.settings.opacity = 0.5;
    $("a.facebox").click(function() {
      return false;
    }).facebox();

	
	// Rounded corners for thumbnails
	$("img.rounded").load( function () {
		var img = $(this);

		// build wrapper
		var wrapper = $('<div class="rounded_wrapper"></div>');
		wrapper.width(img.width());
		wrapper.height(img.height());

		// move CSS properties from img to wrapper
		wrapper.css('float', img.css('float'));
		img.css('float', 'none')

		wrapper.css('margin-right', img.css('margin-right'));
		img.css('margin-right', '0')

		wrapper.css('margin-left', img.css('margin-left'));
		img.css('margin-left', '0')

		wrapper.css('margin-bottom', img.css('margin-bottom'));
		img.css('margin-bottom', '0')

		wrapper.css('margin-top', img.css('margin-top'));
		img.css('margin-top', '0')

		wrapper.css('display', 'block');
		img.css('display', 'block')

		// wrap image
		img.wrap(wrapper);

		// add rounded corners
		img.after('<div class="tl"></div>');
		img.after('<div class="tr"></div>');
		img.after('<div class="bl"></div>');
		img.after('<div class="br"></div>');
	});
	
	// Calling up jCarouselLite
	$(function() {
		$('.video_info').jCarouselLite({
			btnNext: ".video_vents .next",
			btnPrev: ".video_vents .prev",
			auto: 2000,
			hoverPause: true
			// circular: false
		});
	});
	
	
	$(function() {
		$('.photo_info').jCarouselLite({
			btnNext: ".photo_vents .next",
			btnPrev: ".photo_vents .prev",
			auto: 2000,
			hoverPause: true
			// circular: false
		});
	});
	
});

function toggle_main_categories()
{
  $('.category_list_main').slideToggle("fast");
}

function remove_flash_msg()
{
	$('.flash').fadeOut('slow');
}

function toggle_comment_form()
{
	$('#comment_form').toggle();
	$('#advice_form').hide();
}

function toggle_advice_form()
{
	$('#advice_form').toggle();
	$('#comment_form').hide();
}
