
$(function(){
    $('.scroll').bind('click',function(event){
        var $anchor = $(this);                   
        $('html, body').stop().animate({
        scrollTop: $($anchor.attr('href')).offset().top
    }, 1500,'easeInOutQuad'); 
        event.preventDefault();
    });
});

$(function(){
  $('.hover').hover(function() { 
      $(this).stop().animate({'opacity': 0.6});
      },function() { 
      $(this).stop().animate({'opacity': 1});
  });

links = 'span.icon, a:not(#nav a , a.button, .no-effect, #logo,#carousel_container ul  li.item a, .notif a, a#left_scroll, a#right_scroll, .goleft, .goright)';
  $(links).hover(function() { 
      $(this).stop().animate({'opacity': 0.7}, 'fast');
      },function() { 
      $(this).stop().animate({'opacity': 1}, 'fast');
  });

links2 ='#nav a, #gallery a, #carousel_container ul  li.item a';
$(links2).hover(function() { 
      $(this).stop().animate({'opacity': 0.7}, 'fast');
      },function() { 
      $(this).stop().animate({'opacity': 1}, 'fast');
  });

  $('.notif .close').click(function() {
    $(this).parent().slideUp();
    return false;
  });

});

$(function(){
  
  $('.search input').focus(function(){
        $(this).animate({'color':'#000000'});
        $('.search').animate({'background-color': '#F4F4F4'});        
    });
    $('.search input').blur(function(){
        $(this).animate({'color':'#434448'});
        $('.search').animate({'background-color': '#b5b5b5'});        
    });

    $(".search input").each(function(){
        var defaultText = $(this).val();
        $(this).focus(function(){        
            if($(this).val()==defaultText){
                $(this).val("");
            }
        });
       
    $(this).blur(function(){
            if($(this).val()==""){
               $(this).val(defaultText);
            }
        });
    });


});


$(function(){
        $('#SearchIndexForm').submit(function(){
          valid = true;
          if($("#SearchIndexForm input").val()=='search a post...'){
            valid = false;
          }
          return valid;

        });

});

$(function() {
    
    $("#rotator .goleft").click( function(r) {
        var $active = $(".rot-active");
        var $next = $active.prev().length ? $active.prev() : $(".focusitem:last");
 
        $active.removeClass('rot-active');
        $active.addClass('notactive');
        $next.addClass('rot-active');
        $next.removeClass('notactive');
        return false;
    });
 
    $("#rotator .goright").click( function(r) {
        var $active = $(".rot-active");
        var $next = $active.next().length ? $active.next() : $(".focusitem:first");
 
        $active.removeClass('rot-active');
        $active.addClass('notactive');
        $next.addClass('rot-active');
        $next.removeClass('notactive');
        return false;
    });
 
});



$(function(){
     $('.circle').live('mouseenter', function() { // mousein
          $(this).find('.circle-meta').fadeIn(250);
        }).live('mouseleave', function() { // mouseout
          $(this).find('.circle-meta').fadeOut(250);
        });

});


$(function(){
  
        var items = $('#stage li'),
        itemsByTags = {};
  // Looping though all the li items:
  
  items.each(function(i){
    var elem = $(this),
      tags = elem.data('tags').split(',');
    
    // Adding a data-id attribute. Required by the Quicksand plugin:
    elem.attr('data-id',i);
    
    $.each(tags,function(key,value){
      
      // Removing extra whitespace:
      value = $.trim(value);
      
      if(!(value in itemsByTags)){
        // Create an empty array to hold this item:
        itemsByTags[value] = [];
      }
      
      // Each item is added to one array per tag:
      itemsByTags[value].push(elem);
    });
    
  });

  // Creating the "Everything" option in the menu:
  createList('All',items);

  // Looping though the arrays in itemsByTags:
  $.each(itemsByTags,function(k,v){
    createList(k,v);
  });
  
  $('#filter a').live('click',function(e){
    var link = $(this);
    
    link.addClass('active').siblings().removeClass('active');
    
    // Using the Quicksand plugin to animate the li items.
    // It uses data('list') defined by our createList function:
    
    $('#stage').quicksand(link.data('list').find('li'), 
                  {
                    duration: 1000
                  }, function() { 
                     /* Callback function */
                    $('.zoom img').hover(function() { 
                        $(this).stop().animate({'opacity': 0.4}, 'fast');
                        },function() { 
                        $(this).stop().animate({'opacity': 1}, 'fast');
                   });
                      
                      $(".fancybox").fancybox({
                        openEffect  : 'elastic',
                          closeEffect : 'elastic',
                          helpers : {
                            title : {
                              type : 'inside'
                            }
                          }
                      });
                    
                      /**/
                 
                  });
                        e.preventDefault();
  });
  
  $('#filter a:first').click();
  
  function createList(text,items){
    
    // This is a helper function that takes the
    // text of a menu button and array of li items
    
    // Creating an empty unordered list:
    var ul = $('<ul>',{'class':'hidden'});
    
    $.each(items,function(){
      // Creating a copy of each li item
      // and adding it to the list:
      
      $(this).clone().appendTo(ul);
    });

    ul.appendTo('#container');

    // Creating a menu item. The unordered list is added
    // as a data parameter (available via .data('list'):
    
    var a = $('<a>',{
      html: text,
      href:'#',
      data: {list:ul}
    }).appendTo('#filter');
  }
               
});


$(function(){
     $("#contactsubmit").click(function(){        
        valid = true;
        if(!$('input[name=antispam]').val()==""){
            valid = false;
        }
        
        if($("#inputsubject").val()==""){
            valid = false;
           $("#inputsubject").parent().parent().addClass('error'); 
           $("#inputsubject").next('div').css({visibility: "visible",display: "none"}).show(400);
               $("#inputsubject").focus(function(){
               $("#inputsubject").next('div').fadeOut();
               $("#inputsubject").parent().parent().removeClass('error');
           });
        }

        if($("#inputemail").val()==""){
            valid = false;
           $("#inputemail").parent().parent().addClass('error');
           $("#inputemail").next('div').css({visibility: "visible",display: "none"}).show(400);
           $("#inputemail").focus(function(){
               $("#inputemail").next('div').fadeOut();
               $("#inputemail").parent().parent().removeClass('error');
           });
        }
        else if(!$("#inputemail").val().match(/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/)){
           valid = false; 
           $("#inputemail").parent().parent().addClass('error');
           $("#inputemail").next().next('div').css({visibility: "visible",display: "none"}).show(400);
           $("#inputemail").focus(function(){
               $("#inputemail").parent().parent().removeClass('error');
               $("#inputemail").next().next('div').fadeOut(); 
           });
        }
        
        if($("#inputmessage").val()==""){
            valid = false;
           $("#inputmessage").parent().parent().addClass('error');
           $("#inputmessage").next('div').css({visibility: "visible",display: "none"}).show(400);
           $("#inputmessage").focus(function(){
               $("#inputmessage").next('div').fadeOut();
               $("#inputmessage").parent().parent().removeClass('error');
           });
        }
        
        return valid;
     });
});

$(function(){
  $('.zoom img').hover(function() { 
                        $(this).stop().animate({'opacity': 0.4}, 'fast');
                        },function() { 
                        $(this).stop().animate({'opacity': 1}, 'fast');
                   });
                      
                      $(".fancybox").fancybox({
                        openEffect  : 'elastic',
                          closeEffect : 'elastic',
                          helpers : {
                            title : {
                              type : 'inside'
                            }
                          }
                      });

});

jQuery(function($){  
  
    $('#blog .post div.separator').last().hide();

});
