/* Author: 

*/

$(function() {
  $('.front-banner ul').cycle({
      fx:      'scrollHorz',
      timeout:  5000,
      prev:    '#prev',
      next:    '#next'
  });
  $( ".front-tabs" ).tabs();
  $( ".product-tabs" ).tabs();
  $("a[rel=lightbox]").fancybox();
  $(".front-callout").click( function() {
    window.location = $(this).find('a').attr('href');
  });
  jQuery('#newsletter-banner-email').click( function() {
    if ( $(this).val() == 'enter your email address here' ) $(this).val('');
  });
  jQuery('#newsletter-banner-email').blur( function() {
    if ( $(this).val() == '' ) $(this).val('enter your email address here');
  });
  jQuery('#newsletter-banner-submit').click(function() {
    jQuery.post("/newsletter_catcher.php?action=process", { list: 'basic', email: jQuery('#newsletter-banner-email').val() },
      function(data){
        if (data == 'true') {
          window.location = '/newsletter_catcher.php?action=success&list=basic';
        } else {
          jQuery('#newsletter-banner-email').addClass('error');
        }
      }
    );
    return false;
  });
  var search_string = 'Search';
  jQuery('#header-search-text').click(function(event) {
    var el = $(this);
    //alert(event.x);
    if (el.val() == search_string) {
      el.val('');
    }
  });
  jQuery('#header-search-text').blur(function() {
    var el = $(this);
    if (el.val() == '') {
      el.val(search_string);
    }
  });
  jQuery('#header-search-submit').click(function(event) {
    var el = $(this);
    $('.search form').submit();
  });
  
  function updateSecurityPos() {
    $('.security').css('left', $('#main').offset().left + $('#main').width() + 20);
  }
  $(window).resize(function(){
    updateSecurityPos();
  });
  updateSecurityPos();
  /*
  $(".security img")
        .mouseover(function() { 
            var src = $(this).attr("src").match(/[^\.]+/) + "-over.jpg";
            $(this).attr("src", src);
        })
        .mouseout(function() {
            var src = $(this).attr("src").replace("-over", "");
            $(this).attr("src", src);
        });
  */
});
