// JavaScript Document





$(document).ready(function() {
	reSizer();
	$('.homeHeading').stop().fadeTo(300, 0.75);
	$('.box, .right-col').fadeTo(0, 0.7);

	

	
$("#wrapper").masonry
({
	columnWidth: 20, 
	itemSelector: '.box, .leftnav1_spacer, .portfolio_header', animate: true });
$(function() {
$.fn.showdelay = (function() {
	var delay = 0;
	$(this).hide();
	return this.each(function() {
		$(this).delay(delay).fadeIn(200);
      				delay += 80;
    			});
			});
			});
	
	
	
$(".box, .right-col, .portfolio_header").showdelay();



//jQuery('.box').animate({"opacity": "0.75"}, 0);
//jQuery('.box h1 .homeHeading').animate({"opacity": ".65"}, 0);



// Boxes animations = fade in & out





/* External Links */	

jQuery(document).ready(function() { 
							   
    $('a.external').click( function() {
        window.open(this.href);
        return false;
    });

});




//// Box hover
jQuery(".box").hoverIntent(
	function() {
		if(!jQuery(this).hasClass('.box')) {
			if(!jQuery(this).hasClass('.homeHeading')) {
				jQuery(this).stop().animate({"opacity": "1"}, "fast");
				jQuery(this).find('h1').animate({"opacity": "1", "top": "0"}, "fast");
			}
			jQuery(this).children('h1').animate({"opacity": "1"}, "fast");
		}
	}
);
jQuery(".box").hover(
	function() {
		jQuery(this).find('h1').stop().animate({"opacity": "1", "top": "0px"}, "fast");
		jQuery(this).animate({"opacity": "1"}, "fast");
	},
	function() {
		jQuery(this).find('h1').stop().animate({"top": "-50px"}, "fast");
		jQuery(this).animate({"opacity": "0.7"}, "fast");
	}
);




//  $(document).ready(function() {
//	$('a.portfolioTile img').fadeTo(0, 0.6);
//	$('a.portfolioTile img').hover(function(){
//		$(this).fadeTo('10', 1);
//	}, function() {
//		$(this).fadeTo('10', 0.6);
//	});
//});



	
	
//------------- hasClass DIMMED ---------
	
	

	//
//
//$(".box").hover(
//	function(){
//		if ($(this).stop().hasClass(".dimmed")) {
//			$(this).stop().fadeTo("fast", 0.45);
//			$(this).find('h1').animate({"opacity": "1", "top": "0"}, "fast");
//		}
//		else {
//			$(this).fadeTo("fast", 1);
//			$(this).find('h1').animate({"opacity": "1", "top": "0"}, "fast");
//	}
//},
//	function () {
//	  if($(this).stop().hasClass(".dimmed")){
//		   $(this).stop().fadeTo("fast", 0.15);
//		   $(this).find('h1').stop().animate({"opacity": "1", "top": "0px"}, "fast");
//		}
//		else {
//		   $(this).stop().fadeTo("fast", 0.7);
//		   $(this).find('h1').stop().animate({"top": "-50px"}, "fast");
//	}
//});	
	
	
	

//	 $(".box").hover(function(){
//		if ($(this).stop().hasClass(".dimmed")) {
//			$(this).stop().fadeTo("fast", 1);
//		}
//		else {
//			$(this).fadeTo("fast", 0.15);
//		}
//	},function () {
//	if($(this).stop().hasClass(".dimmed")){
//	  $(this).stop().fadeTo("fast", 0.15);
//	}else {
//	  $(this).stop().fadeTo("fast", 1);
//	}
//});






//
//$(document).ready(function() {
//	$('.box').hover(function(){
//		$(this).fadeTo('10', 1);
//		$(this).children('span').fadeTo(300, 1);
//	}, function() {
//		$(this).fadeTo('10', 0.7);
//		$(this).children('span').fadeTo(300, 1);
//	});
//});






//// Hover effect for each block on mouseover
//$(".box img").hover(function(){
//	if ($(this).hasClass(".dimmed")) {
//		$(this).stop().fadeTo("fast", 1);
//	}
//	else {
//		$(this).stop().fadeTo("fast", 0.5);
//		$(".homeHeading").stop().fadeTo("fast", 1);
//	}
//},function () {
//	if($(this).hasClass(".dimmed")){
//	  $(this).stop().fadeTo("fast", 0.5);
//	}else {
//	  $(this).stop().fadeTo(500,1);
//	  $(".homeHeading").stop().fadeTo("fast",  0.75);
//}
//});

  
  
  
  
  
$(".filter_view_all").click(function(){
	$("#filters a").removeClass("active");
		$(this).addClass("active");
	$(".box").fadeTo("medium", 1).removeClass("dimmed");
	return false;
});  






$(".filter_new_featured").click(function(){
	if ($(this).hasClass("active")) {
		return false;
	}
	else {
		$("#filters a").removeClass("active");
		$(this).addClass("active");
		// If this filter link is clicked, fade THESE categories to 20% opacity			
			$(".box:not(.new_featured)").fadeTo("medium", 0.15).addClass("dimmed");
			//$(".media_entertainment, .corporate_cpg, .e_commerce, .social_media, .photoshoots, .online_mkting, .case_studies, .other1, .web_dev, .fineart").fadeTo("medium", 0.15).addClass("dimmed");
		//And fade THIS category to 100% opacity
			$(".new_featured").fadeTo("medium", 1).removeClass("dimmed");
  return false;
	}
});



$(".filter_media_entertainment").click(function(){
	if ($(this).hasClass("active")) {
		return false;
	}
	else {
		$("#filters a").removeClass("active");
		$(this).addClass("active");
		// If this filter link is clicked, fade THESE categories to 20% opacity		
		$(".box:not(.media_entertainment)").fadeTo("medium", 0.15).addClass("dimmed");	
			//$(".new_featured, .corporate_cpg, .e_commerce, .social_media, .photoshoots, .online_mkting, .case_studies, .other1, .web_dev, .fineart").fadeTo("medium", 0.15).addClass("dimmed");
		//And fade THIS category to 100% opacity
			$(".media_entertainment").fadeTo("medium", 1).removeClass("dimmed");
  return false;
	}
});



$(".filter_corporate_cpg").click(function(){
	if ($(this).hasClass("active")) {
		return false;
	}
	else {
		$("#filters a").removeClass("active");
		$(this).addClass("active");
		// If this filter link is clicked, fade THESE categories to 20% opacity			
		$(".box:not(.corporate_cpg)").fadeTo("medium", 0.15).addClass("dimmed");
			//$(".new_featured, .media_entertainment, .e_commerce, .social_media, .photoshoots, .online_mkting, .case_studies, .other1, .web_dev, .fineart").fadeTo("medium", 0.15).addClass("dimmed");
		//And fade THIS category to 100% opacity
			$(".corporate_cpg").fadeTo("medium", 1).removeClass("dimmed");
		return false;
	}
});



$(".filter_e_commerce").click(function(){
	if ($(this).hasClass("active")) {
		return false;
	}
	else {
		$("#filters a").removeClass("active");
		$(this).addClass("active");
		// If this filter link is clicked, fade THESE categories to 20% opacity			
			$(".box:not(.e_commerce)").fadeTo("medium", 0.15).addClass("dimmed");
			//$(".new_featured, .media_entertainment, .corporate_cpg, .social_media, .photoshoots, .online_mkting, .case_studies, .other1, .web_dev, .fineart").fadeTo("medium", 0.15).addClass("dimmed");
		//And fade THIS category to 100% opacity
			$(".e_commerce").fadeTo("medium", 1).removeClass("dimmed");
		return false;
	}
});



$(".filter_social_media").click(function(){
	if ($(this).hasClass("active")) {
		return false;
	}
	else {
		$("#filters a").removeClass("active");
		$(this).addClass("active");
		// If this filter link is clicked, fade THESE categories to 20% opacity			
			$(".box:not(.social_media)").fadeTo("medium", 0.15).addClass("dimmed");
			//$(".new_featured, .media_entertainment, .corporate_cpg, .e_commerce, .photoshoots, .online_mkting, .case_studies, .other1, .web_dev, .fineart").fadeTo("medium", 0.15).addClass("dimmed");
		//And fade THIS category to 100% opacity
			$(".social_media").fadeTo("medium", 1).removeClass("dimmed");
		return false;
	}
});



$(".filter_photoshoots").click(function(){
	if ($(this).hasClass("active")) {
		return false;
	}
	else {
		$("#filters a").removeClass("active");
		$(this).addClass("active");
		// If this filter link is clicked, fade THESE categories to 20% opacity			
			$(".box:not(.photoshoots)").fadeTo("medium", 0.15).addClass("dimmed");
			//$(".new_featured, .media_entertainment, .corporate_cpg, .e_commerce, .social_media, .online_mkting, .case_studies, .other1, .web_dev, .fineart").fadeTo("medium", 0.15).addClass("dimmed");
		//And fade THIS category to 100% opacity
			$(".photoshoots").fadeTo("medium", 1).removeClass("dimmed");
		return false;
	}
});



$(".filter_online_mkting").click(function(){
	if ($(this).hasClass("active")) {
		return false;
	}
	else {
		$("#filters a").removeClass("active");
		$(this).addClass("active");
		// If this filter link is clicked, fade THESE categories to 20% opacity			
			$(".box:not(.online_mkting)").fadeTo("medium", 0.15).addClass("dimmed");
			//$(".new_featured, .media_entertainment, .corporate_cpg, .e_commerce, .social_media, .photoshoots, .case_studies, .other1, .web_dev, .fineart").fadeTo("medium", 0.15).addClass("dimmed");
		//And fade THIS category to 100% opacity
			$(".online_mkting").fadeTo("medium", 1).removeClass("dimmed");
		return false;
	}
});



$(".filter_case_studies").click(function(){
	if ($(this).hasClass("active")) {
		return false;
	}
	else {
		$("#filters a").removeClass("active");
		$(this).addClass("active");
		// If this filter link is clicked, fade THESE categories to 20% opacity			
			$(".box:not(.case_studies)").fadeTo("medium", 0.15).addClass("dimmed");
			//$(".new_featured, .media_entertainment, .corporate_cpg, .e_commerce, .social_media, .photoshoots, .online_mkting, .other1, .web_dev, .fineart").fadeTo("medium", 0.15).addClass("dimmed");
		//And fade THIS category to 100% opacity
			$(".case_studies").fadeTo("medium", 1).removeClass("dimmed");
		return false;
	}
});



$(".filter_creative_direction").click(function(){
	if ($(this).hasClass("active")) {
		return false;
	}
	else {
		$("#filters a").removeClass("active");
		$(this).addClass("active");
		// If this filter link is clicked, fade THESE categories to 20% opacity			
			$(".box:not(.other1)").fadeTo("medium", 0.15).addClass("dimmed");
			//$(".new_featured, .media_entertainment, .corporate_cpg, .e_commerce, .social_media, .photoshoots, .online_mkting, .case_studies, .web_dev, .fineart").fadeTo("medium", 0.15).addClass("dimmed");
		//And fade THIS category to 100% opacity
			$(".other1").fadeTo("medium", 1).removeClass("dimmed");
		return false;
	}
});



$(".filter_web_dev").click(function(){
	if ($(this).hasClass("active")) {
		return false;
	}
	else {
		$("#filters a").removeClass("active");
		$(this).addClass("active");
		// If this filter link is clicked, fade THESE categories to 20% opacity			
			$(".box:not(.web_dev)").fadeTo("medium", 0.15).addClass("dimmed");
			//$(".new_featured, .media_entertainment, .corporate_cpg, .e_commerce, .social_media, .photoshoots, .online_mkting, .case_studies, .other1, .fineart").fadeTo("medium", 0.15).addClass("dimmed");
		//And fade THIS category to 100% opacity
			$(".web_dev").fadeTo("medium", 1).removeClass("dimmed");
		return false;
	}
});



$(".filter_fineart").click(function(){
	if ($(this).hasClass("active")) {
		return false;
	}
	else {
		$("#filters a").removeClass("active");
		$(this).addClass("active");
		// If this filter link is clicked, fade THESE categories to 20% opacity			
			$(".box:not(.fineart)").fadeTo("medium", 0.15).addClass("dimmed");
			//$(".new_featured, .media_entertainment, .corporate_cpg, .e_commerce, .social_media, .photoshoots, .online_mkting, .case_studies, .other1, .web_dev").fadeTo("medium", 0.15).addClass("dimmed");
		// And fade THIS category to 100% opacity
			$(".fineart").fadeTo("medium", 1).removeClass("dimmed");
		return false;
	}
});
		







$(window).resize(function() {	
	reSizer();
});

function reSizer() {
	
	var TotalWidth = $(window).width();
	var cols = Math.floor(TotalWidth / 160);
	var boardWidth = cols * 160;
	var margin = (TotalWidth - boardWidth) / 2;
	var width = $(window).width();
	$("#content-area").css({ width: boardWidth + "px" })
		.stop()
		.animate({marginLeft: margin + 'px'}, 500);
	$(".header").stop().animate({marginLeft: margin + 'px'}, 500);
	$(".header").css({width: (boardWidth - 10) + 'px'});	
	$("#footer").stop().animate({marginLeft: margin + 'px'}, 500);
	$("#footer").css({width: (boardWidth - 180) + 'px'});	
	$(".portfolio_header").stop().animate({marginLeft: margin + 'px'}, 500);
	$(".portfolio_header").css({width: (boardWidth - 180) + 'px'});
			
}






// Boxes click
//
//$('.box').click(function(){
//   // panel expands
//   $(this).animate({
//       width: 780,
//       height: 460
//   }, function(){
//       // masonry call back, to rearrange layout after new panel
//       // has been expanded
//       $('#wrapper').masonry();
//	  // $(this).fadeTo("fast", 1).addClass("box_open");
////	   $(this).fadeTo("fast", 1).removeClass("box");
//   });
//});







 // $("#wrapper").infinitescroll({
//  navSelector  : '#ditto_pages',  // selector for the paged navigation 
//  nextSelector : 'a.ditto_next_link',  // selector for the NEXT link (to page 2)
//  itemSelector : '.boxScroll',     // selector for all items you'll retrieve
//  loadingImg : '/assets/js/x.gif',
//  donetext  : '',
//  debug: true,
//  errorCallback: function() { 
//  
//    // fade out the error message after 2 seconds
//    //$("#infscr-loading").animate({opacity: .8},2000).fadeOut("normal");   
//  }
//  },
//
//  // call masonry as a callback
//  function( newElements ) { 
//	 $(this).masonry({ appendedContent: $( newElements ).showdelay() });
//		
//	 $(".box").hover(function(){
//		if ($(this).stop().hasClass(".dimmed")) {
//			$(this).stop().fadeTo("fast", 1);
//		}
//		else {
//			$(this).fadeTo("fast", 0.15);
//		}
//	},function () {
//	if($(this).stop().hasClass(".dimmed")){
//	  $(this).stop().fadeTo("fast", 0.15);
//	}else {
//	  $(this).stop().fadeTo("fast", 1);
//	}
//});
//  
//	if ($(".filter_new_featured").hasClass("active")) {
//		$(".media_entertainment, .corporate_cpg, .e_commerce, .social_media, .photoshoots, .online_mkting, .case_studies, .other1, .web_dev, .fineart").fadeTo("fast", 0.5).addClass("dimmed");
//	}
//	if ($(".filter_media_entertainment").hasClass("active")) {
//		$(".new_featured, .corporate_cpg, .e_commerce, .social_media, .photoshoots, .online_mkting, .case_studies, .other1, .web_dev, .fineart").fadeTo("fast", 0.5).addClass("dimmed");
//	}
//	if ($(".filter_corporate_cpg").hasClass("active")) {
//		$(".new_featured, .media_entertainment, .e_commerce, .social_media, .photoshoots, .online_mkting, .case_studies, .other1, .web_dev, .fineart").fadeTo("fast", 0.5).addClass("dimmed");
//	}
//	if ($(".filter_e_commerce").hasClass("active")) {
//		$(".new_featured, .media_entertainment, .corporate_cpg, .social_media, .photoshoots, .online_mkting, .case_studies, .other1, .web_dev, .fineart").fadeTo("fast", 0.5).addClass("dimmed");
//	}
//	if ($(".filter_social_media").hasClass("active")) {
//		$(".new_featured, .media_entertainment, .corporate_cpg, .e_commerce, .photoshoots, .online_mkting, .case_studies, .other1, .web_dev, .fineart").fadeTo("fast", 0.5).addClass("dimmed");
//	}
//	if ($(".filter_photoshoots").hasClass("active")) {
//		$(".new_featured, .media_entertainment, .corporate_cpg, .e_commerce, .social_media, .online_mkting, .case_studies, .other1, .web_dev, .fineart").fadeTo("fast", 0.5).addClass("dimmed");
//	}
//	if ($(".filter_online_mkting").hasClass("active")) {
//		$(".new_featured, .media_entertainment, .corporate_cpg, .e_commerce, .social_media, .photoshoots, .case_studies, .other1, .web_dev, .fineart").fadeTo("fast", 0.5).addClass("dimmed");
//	}
//	if ($(".filter_case_studies").hasClass("active")) {
//		$(".new_featured, .media_entertainment, .corporate_cpg, .e_commerce, .social_media, .photoshoots, .online_mkting, .other1, .web_dev, .fineart").fadeTo("fast", 0.5).addClass("dimmed");
//	}
//	if ($(".filter_creative_direction").hasClass("active")) {
//		$(".new_featured, .media_entertainment, .corporate_cpg, .e_commerce, .social_media, .photoshoots, .online_mkting, .case_studies, .web_dev, .fineart").fadeTo("fast", 0.5).addClass("dimmed");
//	}
//	if ($(".filter_web_dev").hasClass("active")) {
//		$(".new_featured, .media_entertainment, .corporate_cpg, .e_commerce, .social_media, .photoshoots, .online_mkting, .case_studies, .other1, .fineart").fadeTo("fast", 0.5).addClass("dimmed");
//	}
//	if ($(".filter_fineart").hasClass("active")) {
//		$(".new_featured, .media_entertainment, .corporate_cpg, .e_commerce, .social_media, .photoshoots, .online_mkting, .case_studies, .other1, .web_dev").fadeTo("fast", 0.5).addClass("dimmed");
//	}
	

//  }
//);
//
//window.onunload = function(){}; 

});

/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:50,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);
    





      
            $(function() {
                $(window).scroll(function(){
					var scrollTop = $(window).scrollTop();
					if(scrollTop != 0)
						$('.header').stop().animate({'opacity':'0.2'},400);
					else	
						$('.header').stop().animate({'opacity':'1'},400);
				});
				
				$('.header').hover(
					function (e) {
						var scrollTop = $(window).scrollTop();
						if(scrollTop != 0){
							$('.header').stop().animate({'opacity':'1'},400);
						}
					},
					function (e) {
						var scrollTop = $(window).scrollTop();
						if(scrollTop != 0){
							$('.header').stop().animate({'opacity':'0.2'},400);
						}
					}
				);
            });
        












