﻿$(document).ready(function() {

    // ALL EXTERNAL LINKS OPEN NEW BROWSER WINDOW
    $('a[href^="http://"]').attr("target", "_blank");

    // CREATE PAGE SCROLLING ELEMENTS
    $('.scrollPage').click(function() {
        var elementClicked = $(this).attr("href");
        var destination = $(elementClicked).offset().top;
        $("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination - 20 }, 500);
        return false;
    });

    // CREATES FADEABLE ELEMENTS
    $('.featured1').append('<span class="hover"></span>').each(function() {
        var $span = $('> span.hover', this).css('opacity', 0);
        $(this).hover(function() {
            $span.stop().fadeTo(300, 1);
        }, function() {
            $span.stop().fadeTo(300, 0);
        });
    });

    $('.featured2').append('<span class="hover"></span>').each(function() {
        var $span = $('> span.hover', this).css('opacity', 0);
        $(this).hover(function() {
            $span.stop().fadeTo(300, 1);
        }, function() {
            $span.stop().fadeTo(300, 0);
        });
    });

    $('.featured3').append('<span class="hover"></span>').each(function() {
        var $span = $('> span.hover', this).css('opacity', 0);
        $(this).hover(function() {
            $span.stop().fadeTo(300, 1);
        }, function() {
            $span.stop().fadeTo(300, 0);
        });
    });

    $('#testimonialsFade').innerfade({
        animationtype: 'slide',
        speed: 1000,
        timeout: 9000,
        type: 'random',
        containerheight: '1em'
    });

});

$(function() {
    var tabContainers = $('div.tabs > div');
    tabContainers.hide().filter(':first').show();

    $('div.tabs ul.tabNavigation a').click(function() {
        tabContainers.hide();
        tabContainers.filter(this.hash).show();
        $('div.tabs ul.tabNavigation a').removeClass('selected');
        $(this).addClass('selected');
        return false;
        
    }).filter(':first').click();

});

//    UNUSED ANIMATION TECHNIQUES
//    $('div.footer a.top').mouseover(function() {
//      $(this).animate({ fontSize: "18px", opacity: 0.3 }, 150);
//    });
//    $('div.footer a.top').mouseout(function() {
//        $(this).animate({ fontSize: "14px", paddingLeft: "20px", opacity: 1 }, 50);
//    });


$(document).ready(function() {
var fadeDuration = 150; //time in milliseconds

    $('ul.tabNavigation li a').hover(function() {
        $(this).animate({ paddingLeft: '15px' }, fadeDuration);
        $(this).children('span').show().animate({ left: -5 }, fadeDuration);
      }, function() {
        $(this).animate({ paddingLeft: '0' }, fadeDuration);
        $(this).children('span').animate({ left: -20 }, fadeDuration).fadeOut(fadeDuration);          
      });
  });


  $(document).ready(function() {
      $('#rotator').before('<div id="nav" class="rotatornav">').cycle({
          fx: 'scrollHorz',
          speedIn: 400,
          speedOut: 400,
          timeout: 6000,
          prev: '#prev',
          next: '#next',
          pager: '#nav',
          before: function() { if (window.console) console.log(this.src); }

      });
  });




