/**
 * Adds rounded corners to all the items with the proper classes.
 */
function addRoundedCorners(){
  var settings = {
    tl: { radius: 5 },
    tr: { radius: 5 },
    bl: { radius: 5 },
    br: { radius: 5 },
    antiAlias: true,
    autoPad: true
  };
  
  $('.rounded').corner(settings);
  $('.rounded-search').corner(settings);
  
  var settings2 = {
    tl: { radius: 2 },
    tr: { radius: 2 },
    bl: { radius: 2 },
    br: { radius: 2 },
    antiAlias: true,
    autoPad: true
  };
  $('.rounded-inner').corner(settings2);
}

/**
 * Adds a required indicator after a required field in a form with the form-as-table class assigned. 
 */
function addRequiredIndicators(){
  $(".form-as-table .required").after('<span class="required-field">*</span>');
}

/**
 * Changes the page to view the chosen recipe.
 */
function changeRecipe(){
  var url = $('#recipeChoices').val();
  
  if(url !== ''){
    $('#recipesChanger').attr('action', url);
    $('#recipesChanger').submit();
  }
}

/**
 * Updates the text under the video for the featured recipes.
 * @param recipeId The id of the recipe to get the text from.
 */
function updateFeaturedRecipeText(recipeId){
  $('#replace-html').html($('#' + recipeId).html());
}

/**
 * Changes the page to view the chosen product.
 */
function changeProduct(){
  var url = $('#productChoices').val();
  
  if(url !== ''){
    $('#productChanger').attr('action', url);
    $('#productChanger').submit();
  }
}

/**
 * Changes the page to view the job listings by job type.
 */
function changeOpenPositionByType(){
  var url = $('#typeChoices').val();
  
  if(url !== ''){
    $('#openPositionByTypeChanger').attr('action', url);
    $('#openPositionByTypeChanger').submit();
  }
}

/**
 * Changes the page to view the job listings by location.
 */
function changeOpenPositionByLocation(){
  var url = $('#locationChoices').val();
  
  if(url !== ''){
    $('#openPositionByLocationChanger').attr('action', url);
    $('#openPositionByLocationChanger').submit();
  }
}

/**
  * Show and Hide Search Form.
  */
function showSearchForm(){
  $('#search-icon').click(function(){
    if ($('#search-wrapper').css('visibility') == 'visible') {
      $('#search-wrapper').css('visibility', 'hidden');
      } else {
      $('#search-wrapper').css('visibility', 'visible');
    }
  });
}

