// ****************************************** Site

function initSiteCommon() {
  createNewWindowForExternalLinks();
  roundSubNav();
  mainNavLeftLines();
}

function mainNavLeftLines() {
  $('#navBtns > li:first a').css("border-left", "1px solid #868686");
}

function roundSubNav() {    
  $('.subNav > li:first a').addClass('subNav_first');
  $('.subNav > li:last a').addClass('subNav_last');
}

function subNavRolloverIcons(target) {
  var _this;
  $('.' + target + ' li a').hover(function(){
      _this = this.id;
      $("." + _this).css("background-position","bottom");
    },
      function () {
      $("." + _this).css("background-position","top");
  });
}


// ******************************************* Forms

function initializeForms() {
  $("input.default-value").css("color", inactive_color);
    $("input.default-value").focus(handleFocus);
    $("input.default-value").blur(handleBlur);
 }
 
function handleFocus() {
  if (!aFormDefaultValues[this.id]) {
    aFormDefaultValues[this.id] = this.value;
  }
  if (this.value == aFormDefaultValues[this.id]) {
    this.value = '';
    this.style.color = active_color;
  }    
}

function handleBlur() {
  if (this.value == '') {
    this.style.color = inactive_color;
    this.value = aFormDefaultValues[this.id];
  }
}

function focusLoginBox() {
  $(".smEmail").focus();
}

// ******************************************* Utilities (Create a general js file?)

function createNewWindowForExternalLinks() {
  $("a[@href^=http]").each(
  function(){
    if(this.href.indexOf(location.hostname) == -1) { 
      $(this).attr('target', '_blank');
      }
  })
}

/**
 * Div highlights when checkbox active.
 *
 * Note: To fetch all checkboxes: cbQuery = "input[type=checkbox]"
 */
function relateDivToCheckbox(cbQuery) {
  $(cbQuery).click(function(){
    divClass = $(this).attr("class");
      if ($(this).is(":checked")) {
        $("#" + divClass + ">" + ".destinationData").addClass('destinationSelected');
    }
      else if($(this).not(":checked")) {
        $("#" + divClass + ">" + ".destinationData").removeClass('destinationSelected');
    }
  });
}

// ***************************** Variable Declarations

// Forms
var aFormDefaultValues = new Array();
var active_color = '#333333'; // Color of user provided text
var inactive_color = '#C7C7C7'; // Color of default text
