function popitup(url) {
    leftPos = 0;
    topPos = 0;
    if (screen) {
        leftPos = (screen.width / 2) - 250;
        topPos = (screen.height / 2) - 287;
    }

	newwindow=window.open(url,'About Me','height=574,width=500,left='+leftPos+',top='+topPos);
	if (window.focus) {newwindow.focus()}
	return false;
}

$(window).load(function() {
    $('#slider').nivoSlider({
        effect: 'fade', // Specify sets like: 'fold,fade,sliceDown'
        slices: 15, // For slice animations
        boxCols: 8, // For box animations
        boxRows: 4, // For box animations
        animSpeed: 1000, // Slide transition speed
        pauseTime: 5000, // How long each slide will show
        startSlide: 0, // Set starting Slide (0 index)
        directionNav: false, // Next & Prev navigation
        directionNavHide: true, // Only show on hover
        controlNav: false, // 1,2,3... navigation
        controlNavThumbs: false, // Use thumbnails for Control Nav
        controlNavThumbsFromRel: false, // Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', // Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
        keyboardNav: false, // Use left & right arrows
        pauseOnHover: false, // Stop animation while hovering
        manualAdvance: false, // Force manual transitions
        captionOpacity: 0.8, // Universal caption opacity
        prevText: 'Prev', // Prev directionNav text
        nextText: 'Next', // Next directionNav text
        beforeChange: function(){}, // Triggers before a slide transition
        afterChange: function(){}, // Triggers after a slide transition
        slideshowEnd: function(){}, // Triggers after all slides have been shown
        lastSlide: function(){}, // Triggers when last slide is shown
        afterLoad: function(){} // Triggers when slider has loaded
    });
});

$(document).ready(function() {

  $(function() {  
    $(".button").click(function() {
      var name = $("input#name").val();   
      var email= $("input#email").val();
      var msg  = $("textarea#message").val();
      
      var dataString = 'name='+name+'&email='+email+'&message='+msg;  
      
      $.ajax({  
        type: "POST",  
        url: "http://www.kostarakicevic.com/home/sendemail",  
        data: dataString,  
        success: function() {  
          /*$('form#contact').html("<div id='message'></div>");  
          $('#message').html("<h2>Thank you for contacting us!</h2>")  
          .append("<p>We will be in touch soon.</p>")  
          .hide()  
          .fadeIn(1500, function() {  
            $('#message').append("<img id='checkmark' src='images/check.png' />");  
          });*/
          
          alert('Thank you for contacting us!\n\rWe will be in touch soon!');
                
        }  
      });  
      
      return false;
    });  
  });  


  $('.about-link').fancybox();
  
  /* Sakrivanje poruke "creative work of Kosta Rakicevic" */
  $("h1.logo").hover(
    function () {
      $("h2.logo").animate({
        opacity: 1
      }, 750);
    },
    function () {
      $("h2.logo").animate({
        opacity: 0
      }, 750);
    }
  );
  
  /* promena aktivnih radova preko menija */
  $('.menu-filter').click(function() {

    var opacity = $('#start-page').css("opacity");
    
    if(opacity == 1)
    {
      $("#start-page").animate({
        opacity: 0
      }, 750).addClass("hidden");
      
      $("#sub-page").removeClass("hidden").animate({
        opacity: 1
      }, 750);
    }
    
    var tip_bre = $(this).attr("href"); // options: identity, logo, print, web, illustration, concepts
    var photo = '';

    // active menu
    // ---------------------------------------
    // remove all "active" classes
    $(".menu-filter").each(function(i){
      $(this).removeClass('active');
    });
                                      
    // add active class to clicked menu
    $(this).addClass("active");
    // ---------------------------------------


    // gray every photo to default
    $("div.photo-holder a").each(function(i){
      $(this).addClass('right');
      $(this).removeClass('center');

      // remove all "hover" classes
      $(this).removeClass('hover-ok');

      // fancybox unbind
      //$(this).unbind('fancybox');
    });
    
    $("div.photo-holder p").each(function(i){
      $(this).addClass('alpha');
    });


    // now switch to WHITE only chosen type
    $("div.photo-holder a").each(function(i){
      if ($(this).attr("class").lastIndexOf(tip_bre) > -1) {
      $(this).removeClass('right');
      $(this).addClass('center');

      // add "hover" classes
      $(this).addClass('hover-ok');

      // fancybox bind
      //$(this).fancybox();
      }
    });
    
    $("div.photo-holder p").each(function(i){
      if ($(this).attr("class").lastIndexOf(tip_bre) > -1) {
        $(this).removeClass('alpha');
      }
    });

    return false;
  }); 
  
  // HOVER COLOR EFFECT !
  $('div.photo-holder a').hover(
    function () {
      if ($(this).attr("class").lastIndexOf("hover-ok") > -1) {
        //$(this).stop().queue([]).animate({opacity: 0.6}, "duration: fast", "", function(){ $(this).removeClass('center'); $(this).addClass('left'); });
        $(this).stop().removeClass('center').addClass('left');
        //$(this).animate({opacity: 1}, "duration: fast", "");
        
        var id = $(this).attr('id');
        $('.slide-'+id).animate({marginTop: '-45px'}, 200);
      }
    },
    function () {
      if ($(this).attr("class").lastIndexOf("hover-ok") > -1) {
        //$(this).stop().animate({opacity: 0.6}, "duration: fast", "", function(){ 
          //$(this).removeClass('left'); $(this).addClass('center'); 
          $(this).stop().removeClass('left').addClass('center'); 
        /*});
        $(this).animate({opacity: 1}, "duration: fast");*/
        
        var id = $(this).attr('id');
        $('.slide-'+id).animate({marginTop: '0px'}, 200);
      }
    }
  );  
  
  /* prikazivanje content stranica */  
  $('div.photo-holder a').click(function(){    
    $("#sub-page").animate({
      opacity: 0
    }, 750).addClass("hidden");
    
    $("#content-page").removeClass("hidden").animate({
      opacity: 1
    }, 750);
    
    var id = $(this).attr('id');
    $('.content-'+id).removeClass("hidden");
  });
  
  /* gasenje content stranica */
  $('a.back').click(function(){    
    $("#content-page").animate({
      opacity: 0
    }, 750).addClass("hidden");
    
    $("#sub-page").removeClass("hidden").animate({
      opacity: 1
    }, 750);
    
    $(".contentpages").each(function(i){
      $(this).addClass('hidden');
    });
  });
  
});
