/*!
 * PixlDrop JS
 * Yummy JQuery
 *
 * authors: J. Newing, A. Wynn
 *
 */
$(function () {

    /*!
     * kill this for now
     * on second thought, lets test something ~djekl
     */
    // ajax update every 5 seconds (5000ms)
    function updateCounter() {
        // new ajax request for gt pid
        $.ajax({
            type: 'GET',
            url: '/pixldrop/count/',
            dataType: 'html',
            success: function(response) {
                $('.captures').html("Total Uploads: <b>" + response + "</b>");
            },
        });
    };


    setInterval(updateCounter, 5000);
      updateCounter();
      // ------------------------------------------------------------------------

      /*!
       * scroll back to the top of the page
       */
    $('a[href=#top]').click(function(){
        $('html, body').animate({scrollTop:0}, 400);
        return false;
    });
    // ------------------------------------------------------------------------

    /*!
     * navigation drop down menus
     */
    $("li.navdropdown").hover(function(){
        $(this).children("ul").stop(true, true).slideDown(100);
    }, function(){
        $(this).children("ul").stop(true, true).slideUp(100);
    });
    // ------------------------------------------------------------------------

      // jQuery resize
    $('#theimg').click(function (e) {
        $('#theimg img').toggleClass("smallimg", "largeimg")
    });
    // ------------------------------------------------------------------------

    // jQuery Tipsy
    $('[rel=tooltip]').tipsy({
        gravity: 's',
        fade: true
    });

    $('.frmTip').tipsy({
        trigger: 'focus',
        gravity: 'w',
        fade: true
    });
    // ------------------------------------------------------------------------

    /*!
     * forum element background animation
     * on focus and blur
     */
    $("select, textarea, .textInput").focus(function(e) {
        $(this).animate({
            backgroundColor: '#f9f2ba',
            borderTopColor: '#e9d315',
            borderRightColor: '#e9d315',
            borderBottomColor: '#e9d315',
            borderLeftColor: '#e9d315'
        }, 500, function() {
            // done
        });
    });

    $("select, textarea, .textInput").blur(function(e){
        $(this).animate({
            backgroundColor: '#ffffff',
            borderTopColor: '#aaaaaa',
            borderRightColor: '#aaaaaa',
            borderBottomColor: '#aaaaaa',
            borderLeftColor: '#aaaaaa'
        }, 900, function() {
            // done
        });
    });
    // ------------------------------------------------------------------------

    /*!
     * close notification boxes
     */
    $('a.close-notification').click(function(e) {
        e.stopPropagation();
        $(this).parent().hide();
    });
    // ------------------------------------------------------------------------

    /*!
     * cross-browser opacity
     */
     $(".opac").fadeTo(0, 0.60);
     $(".opac1").fadeTo(0, 0.25);

     $(".opac, .opac1").mouseenter(function(e) {
         $(this).fadeTo("fast", 1)
     });

     $(".opac").mouseleave(function(e) {
        $(this).fadeTo("slow", 0.60)
     });

     $(".opac1").mouseleave(function(e) {
         $(this).fadeTo("slow", 0.25);
     });
     // ------------------------------------------------------------------------

});

