var $j = jQuery.noConflict();
$j(document).ready(function(){
	
	$j(document).mainmenu();
	$j('#footerContainer .oneThirdCol:last').addClass('lastCol');
	
		// Toggle the slider section
		$j("#expandButton").hide();
		
		$j(".toggleButton").click(function(){
			$j("div#sliderContainer").slideToggle("slow");
			
			$j(".toggleButton").toggle();
		});

	
	$j("#leftContainer .sepContainerBlog:last-child ").css("background", "none");
	
	$j("ul.flickr_badge_image li, #small_images").hover(function(){
						$j(this).stop().animate({ "opacity" : 0.6 }, 400); 
						},function(){
						$j(this).stop().animate({ "opacity" : 1 }, 400);
						});
						
	
	// jQuery image opacity change on hover
	$j("#socialIcon ul li a").find("img").hover(function(){

				$j(this).stop().animate({ "opacity" : 0.3 }, 400);

			}, function() {

				$j(this).stop().animate({ "opacity" : 1 }, 400);

			});
			
	$j(".serviceBox").hover(function(){
		
				$j(this).find(".serviceBoxBottom").fadeIn('slow', function() {
        			$j(this).css("background-image", "url(images/comp/servicesBoxBottomHover.png)");  
				});
			}, function() {
				
				$j(this).find(".serviceBoxBottom").css("background-image", ""); 

			});
		
		$j('.tipsy').tipsy({fade: true, gravity: 's'});
		



			var $blogItem = $j('.post_list_img');
				$j('.zoom-icon').css('opacity','0');
				$j('.zoom-icon-video').css('opacity','0');
				
				$blogItem.hover(function(){
					$j(this).find('img').stop(true, true).animate({opacity: 0.2},500);
					$j(this).find('.zoom-icon').stop(true, true).animate({opacity: 1},400);
					$j(this).find('.zoom-icon-video').stop(true, true).animate({opacity: 1},400);
		
				}, function(){
					$j(this).find('img').stop(true, true).animate({opacity: 1},500);
					$j(this).find('.zoom-icon').stop(true, true).animate({opacity: 0},400);
					$j(this).find('.zoom-icon-video').stop(true, true).animate({opacity: 0},400);
				});







// Sorting Facilitity on portfolio page

			var $portfolioItem = $j('.portfolio_img_holder');
				$j('.zoom-icon').css('opacity','0');
				$j('.zoom-icon-video').css('opacity','0');
				$j('.zoom-icon-external').css('opacity','0');
				
				$portfolioItem.hover(function(){
					$j(this).stop(true, true).animate({top: -10}, 500).find('img').stop(true, true).animate({opacity: 0.2},500);
					$j(this).find('.zoom-icon').stop(true, true).animate({opacity: 1},400);
					$j(this).find('.zoom-icon-video').stop(true, true).animate({opacity: 1},400);
					$j(this).find('.zoom-icon-external').stop(true, true).animate({opacity: 1},400);
		
				}, function(){
					$j(this).stop(true, true).animate({top: 0}, 250).find('img').stop(true, true).animate({opacity: 1},500);
					$j(this).find('.zoom-icon').stop(true, true).animate({opacity: 0},400);
					$j(this).find('.zoom-icon-video').stop(true, true).animate({opacity: 0},400);
					$j(this).find('.zoom-icon-external').stop(true, true).animate({opacity: 0},400);
				});

	
	var $jdata = $j("#ourHolder").clone();
	var portfolio_slide_type = $j('#portfolio_slide_type').val();
	$j('.portfolioCategs li ').click(function(e) {
	
		$j(".filterOptions li ").removeClass("active");	
		// Use the last category class as the category to filter by. This means that multiple categories are not supported (yet)
		var filterClass=$j(this).attr('class').split(' ').slice(-1)[0];
		
		if (filterClass == 'all') {
			var $jfilteredData = $jdata.find('.portfolioItem');
		} else {
			var $jfilteredData = $jdata.find('.portfolioItem[data-type~=' + filterClass + ']');
		}
		$j("#ourHolder").quicksand($jfilteredData, {
			duration: 600,
			easing: portfolio_slide_type,
			useScaling: false,
			enhancement: function() {
				
				
			$j("a[rel^='prettyPhoto']").prettyPhoto({
				allow_resize: true,
                padding: 40, 
                opacity: 0.60,
                show_title: false,
                autoplay_slideshow: false,
                counter_separator_label: '/', 
                animation_speed:'normal',
                overlay_gallery: false,
                changepicturecallback: function(){},
                callback: function(){}
				});
				
				var $portfolioItem = $j('.portfolio_img_holder');
				$j('.zoom-icon').css('opacity','0');
				$j('.zoom-icon-video').css('opacity','0');
				$j('.zoom-icon-external').css('opacity','0');
				
				$portfolioItem.hover(function(){
					$j(this).stop(true, true).animate({top: -10}, 500).find('img').stop(true, true).animate({opacity: 0.2},500);
					$j(this).find('.zoom-icon').stop(true, true).animate({opacity: 1},400);
					$j(this).find('.zoom-icon-video').stop(true, true).animate({opacity: 1},400);
					$j(this).find('.zoom-icon-external').stop(true, true).animate({opacity: 1},400);
		
				}, function(){
					$j(this).stop(true, true).animate({top: 0}, 250).find('img').stop(true, true).animate({opacity: 1},500);
					$j(this).find('.zoom-icon').stop(true, true).animate({opacity: 0},400);
					$j(this).find('.zoom-icon-video').stop(true, true).animate({opacity: 0},400);
					$j(this).find('.zoom-icon-external').stop(true, true).animate({opacity: 0},400);
				});
				
				
				
			}
		});
		
		$j(this).addClass("active"); 
					
		return false;
	});
	
	
	
	$j("a[rel^='prettyPhoto']").prettyPhoto({
				allow_resize: true,
                padding: 40, 
                opacity: 0.60,
                show_title: false,
                autoplay_slideshow: false,
                counter_separator_label: '/', 
                animation_speed:'normal',
                overlay_gallery: false,
                changepicturecallback: function(){},
                callback: function(){}
	});



	
});
