$(document).ready(function(){

  // Adds and removes search text

  $('#header #site-search input[type="text"]').addClass('watermark');

  $('#header #site-search input[type="text"]').focus(function(){

    $(this).filter(function(){

      return $(this).val() === '' || $(this).val() === 'Search';

    }).removeClass('watermark').addClass('text').val('');

  }).blur(function(){

    $(this).filter(function(){

      return $(this).val() === '';

    }).removeClass('text').addClass('watermark').val('Search');

  });

  

  // Cycle the home tabs

  $('#promo-tabs-container') 

    .after('<ul id="promo-tabs-selectors">') 

    .cycle({ 

    cleartype:  1, 

    timeout: 8000, 

    effect: 'fade',

    speed: 500,

    pause: true,

    pager:  '#promo-tabs-selectors',

    pagerEvent:   'click',

    pagerAnchorBuilder: function(idx, slide) { 

        return '<li class="' + ' "><a href="#"><span class="wrap">' + jQuery(slide).find("div.tab-text").html() + '</span><span class="extra"></span></a></li>'; 

    }

  });

  $('#promo ul').hover(function(){

    $('#promo-tabs-container').cycle("pause");

    }, function(){

    $('#promo-tabs-container').cycle("resume");

  });

  

    // go to the current slide's link

  $('#promo-tabs-container div.promo-image').click( 

    function() {

      window.location = $(this).find('a.more-info').attr('href');

  });
  
  
/*******************************************************************************
   * change language (jQuery Translate Plugin)
   */
  //$.translate.load('C4A97728B284535083FF131AFF83376C0790B431');
  
  $('.language').click(function(){
    var language = $(this).attr('rel');
    $('body').translate(language);
    $.cookie('language', language, { path: '/', expires: 365 });
    location.href = "/";
    // return false;
  });

  if($.cookie('language') && $.cookie('language') != 'en'){
    $('body').translate($.cookie('language'));
  }
  
    if($.cookie('language') && $.cookie('language') == 'es'){
      $('#nav') .css('width','1135px');
    }
   



});
