
// overlay and easing effects
$(function() {

    // one page scroll effect
    $('a[href*=#]').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
        && location.hostname == this.hostname) {
            var $target = $(this.hash);
            $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
            if ($target.length) {
                var targetOffset = $target.offset().top;
                $('html,body').animate({scrollTop: targetOffset}, 1000);
                return false;
            }
        }
    });

    
 // create custom animation algorithm for jQuery called "drop" 
    $.easing.drop = function (x, t, b, c, d) {
        return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
    };
    

    // loading animation
    $.tools.overlay.addEffect("drop", function(css, done) { 

       // use Overlay API to gain access to crucial elements
       var conf = this.getConf(),
           overlay = this.getOverlay();           

       // determine initial position for the overlay
       if (conf.fixed)  {
          css.position = 'fixed';
       } else {
          css.top += $(window).scrollTop();
          css.left += $(window).scrollLeft();
          css.position = 'absolute';
       } 

       // position the overlay and show it
       overlay.css(css).show();

       // begin animating with our custom easing
       overlay.animate({ top: '+=55',  opacity: 1,  width: '+=20'}, 400, 'drop', done);

       /* closing animation */
       }, function(done) {
          this.getOverlay().animate({top:'-=55', opacity:0, width:'-=20'}, 300, 'drop', function() {
             $(this).hide();
             done.call();      
          });
       }
    );
    

    // overlay js code
    $("a[rel]").overlay({
      // effects
      effect: 'drop',
      mask: '#fff',
      left: 'center',
      top: '10%',

      // grab our wrapper and stuff
      onBeforeLoad: function() {
        // grab wrapper element inside content
        var wrap = this.getOverlay().find(".contentWrap");

        // load the page specified in the trigger
        wrap.load(this.getTrigger().attr("href"));
      },
      
      onLoad: function() {
          $('.slider').cycle({
            timeout: 0,
            fx:     'scrollLeft', 
            speed:  'fast', 
            next:   '#next', 
            prev:   '#prev'
          });
      }
    });
  });
// end of code for overlays

// google tracking code
var _gaq = _gaq || [];
 _gaq.push(['_setAccount', 'UA-5080926-1']);
 _gaq.push(['_setDomainName', 'linyingdesign.com']);
 _gaq.push(['_trackPageview']);

 (function() {
   var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
   ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
   var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
 })();
