/**
 * File:         behaviour.css
 * Project:      Project name
 * Version:      1.0
 * Last change:  26/09/09
 * Assigned to:  Diego Lago (dl)
 * Primary use:  Website
 *
 */

/**
 * Global vars
 */


/**
 * jQuery on document ready 
 */
$(document).ready(function() {

/**
 * Animations & effects
 */
  // initial fade-in effect
  var docHeight = $(document).height();
  $('body').prepend('<div id="cover" style="background: #fff; width: 100%; height: 100%; position: absolute; left: 0; top: 0; z-index: 100;"></div>');
  $('#cover').fadeOut('slow');
 
  // font color animation 
    $('#navigation-local a').hover(function() {
    $(this).animate({ color: '#FF8A00' }, 200);
      },function() {
    $(this).animate({ color: '#D1D9DC' }, 200);
      });
  
  // background color animation
  $('a.btn').hover(function() {
    $(this).animate({ backgroundColor: '#FF8A00' }, 200);
      },function() {
    $(this).animate({ backgroundColor: '#959EA1' }, 200);
      });

/**
 * Twitter widget
 */
  $('#twitter .mod-main').getTwitter({
      userName: 'webproductive',
      numTweets: 3,
      loaderText: 'Loading tweets...',
      slideIn: true,
      slideDuration: 750,
      showHeading: true,
      headingText: '',
      showProfileLink: false,
      showTimestamp: true
    });

/**
 * Tabs
 */
  // setup ul.tabs to work as tabs for each div directly under div.panes
  $('ul.tabs').tabs('div.panes > div.pane');
  /* $('ul.tabs').tabs('div.panes > div.pane',{
    onClick: function(event, tabIndex) { 
      this.getCurrentPane().children().children('img').fadeIn('slow');
    }
  }); */

/**
 * Contact form overlay
 */
  // "contact" overlay setup - sans js shows form at the bottom of page
  $('#contact-form').addClass('overlay');
  
  // "contact" overlay trigger
  $('#contact[rel]').overlay({expose: '#C9D1D4'});

  // form focus
  $(':input:not(:submit)').bind('focus', function() {
    $(this).parents('li').addClass('focus')
    .end(); // end focus and move on to blur
    $(this).bind('blur', function() {
      $(this).parents('li').removeClass('focus');
    });
  });
  /* both events need consideration */
  $(':input:not(:submit)').bind('change', function() {
    $(this).parents('li').removeClass('error-wrap');
  });
  $(':input:not(:submit)').bind('keyup', function() {
    $(this).parents('li').removeClass('error-wrap');
  });
  
/**
 * Search form UI enhancement
 */
  var searchLabel = $('#search-form label').text();
  $('#search-input').addClass('placeholder').val(searchLabel).focus(function(){
    if (this.value === searchLabel) {
      $(this).removeClass('placeholder').val('');
    };
  }).blur(function(){
    if (this.value === '') {
      $(this).addClass('placeholder').val(searchLabel);
    }
  });
  /* don't submit placeholder text */
  $('#search-form').submit (function(){
    if ($('#search-input').val() == searchLabel) {
      $('#search-input').val('');
    }
  });

 /**
 * Tabs Scrollable. Slideshow plugin for the Tabs
 */
  $('div.tabs').tabs('.panes > div', {
    // enable "cross-fading" effect 
    effect: 'fade',
    fadeInSpeed: 2000,
    fadeOutSpeed: 2000,
    // start from the beginning after the last tab 
    rotate: true
    
  // use the slideshow plugin. It accepts its own configuration adding functionality on top of tabs
  }).slideshow({
    autoplay: true,
    interval: 6000
  });
  
});
