﻿$(document).ready(function() {
						   

  // Social hover effect

  $('ul.socicon li').hover(function() {

    $(this).find('a').animate({
      marginTop: 5
    },
    {
      duration: 100,
      easing: 'easeOutExpo',
      complete: function() {
        //////
      }
    });
  },
  function() {
    $(this).find('a').animate({
      marginTop: 0
    },
    {
      duration: 100,
      easing: 'easeOutExpo',
      complete: function() {
        //////
      }
    });

  });
  
  // Tweets plugin

  $('.tweets').relatedTweets({
    debug: true,
    from_users: 'envato',
    status: 1,
    realtime: 0,
    n: 20,
    show_avatar: 0,
    show_author: 0,
    image_width: 32
  });
  
  // Rotate plugin

  if ($.browser.msie) {

    ///

  } else {

    $('a.close img').rotate({
      bind: {
        mouseover: function() {
          $(this).rotate({
            animateTo: 360,
            easing: $.easing.easeInOutSine
          });
        },
        mouseout: function() {
          $(this).rotate({
            animateTo: 0,
            easing: $.easing.easeInOutSine
          });
        }
      }
    });

  }

  $('span.rot img').rotate({
    bind: {
      mouseover: function() {
        $(this).rotate({
          animateTo: 360,
          easing: $.easing.easeInOutSine
        });
      },
      mouseout: function() {
        $(this).rotate({
          animateTo: 0,
          easing: $.easing.easeInOutSine
        });
      }
    }
  });

  $('span.rot img').trigger('mouseover');
  setTimeout(function() {
    $('span.rot img').trigger('mouseout');
  },
  1000);

  // Tipsy plugin

  $('[name=tipsy]').tipsy({
    fade: true,
    gravity: 's'
  });
  $('#form [title]').tipsy({
    trigger: 'focus',
    gravity: 'w'
  });

  // Nivo slider

  $('#nivo').nivoSlider({
    effect: 'random',
    slices: 15,
    boxCols: 8,
    boxRows: 4,
    animSpeed: 200,
    pauseOnHover: true,
    directionNavHide: false,
    controlNav: false // 1,2,3 
    //beforeChange: function (){},
    //afterChange: function (){}
    //controlNavThumbs:true
  });

  // prettyPhoto plugin

  $("a[rel^='prettyPhoto']").prettyPhoto();

  // Portfolio effect hover

  $('ul.portfolio li a').hover(function() {

    $(this).find('img').animate({
      width: "+=30px"
    },
    {
      duration: 500,
      specialEasing: {
        width: 'jswing'
      }
    });

  },

  function() {

    $(this).find('img').animate({
      width: "249px"
    },
    {
      duration: 500,
      specialEasing: {
        width: 'jswing'
      }
    });

    return false;
  });

  $('ul.portfolio li a').hover(function() {

    cap = $(this).find('span');

    cap.stop().animate({
      bottom: -450
    },
    500, 'easeInCubic',
    function() {});

  },
  function() {

    cap.stop().animate({
      bottom: 0
    },
    500, 'easeInCubic',
    function() {});

  });

  // Validator plugin

  $('#submit').formValidator({
    scope: '#form'
  });

  // Form plugin

  var options = {

    beforeSubmit: function() {
      $('.sending').show();

    },
    success: function() {
      $('.sending').hide();
      $('#form').hide();
      $(".mess").show().html('<h5>Thanks !</h5><h5>Your message has been sent.</h5>'); // Change Your message post send
      $('.mess').delay(3000).fadeOut(function() {

        $('#form').clearForm();
        $('#form').delay(3500).show();

      });
    },
    url: './php/contact.php'
  };

  $('#form').submit(function() {
    $(this).ajaxSubmit(options);
    return false;
  });

});
