//jQuery.noConflict();

jQuery(document).ready(function() {
	// Filterable Portfolio
	jQuery('ul#filter a').click(function() {
		jQuery(this).css('outline','none');
		jQuery('ul#filter .current').removeClass('current');
		jQuery(this).parent().addClass('current');
		
		var filterVal = jQuery(this).text().toLowerCase().replace(' ','-');
				
		if(filterVal == 'all') {
			jQuery('div#portfolio div.hidden').fadeIn('slow').removeClass('hidden');
		} else {
			
			jQuery('div#portfolio div').each(function() {
				if(!jQuery(this).hasClass(filterVal)) {
					jQuery(this).fadeOut('normal').addClass('hidden');
				} else {
					jQuery(this).fadeIn('slow').removeClass('hidden');
				}
			});
		}
		return false;
	});

	var url = window.location.pathname;
	if (url.indexOf("work")!=-1) {
    	jQuery("body").addClass("work");
    }
    else {
    	jQuery("body").removeClass("work");
    }


	// View Switcher
    jQuery('ul#view li.swap a').click(function(){
		jQuery('ul#view .switch_thumb').removeClass('current');
		jQuery(this).parent().addClass('current');
        jQuery("div#portfolio").fadeOut("fast", function() {
            jQuery(this).fadeIn("fast").removeClass("thumb_view");
        });
       return false; 
    });
    jQuery('ul#view li.switch_thumb a').click(function(){
		jQuery('ul#view .swap').removeClass('current');
		jQuery(this).parent().addClass('current');
        jQuery("div#portfolio").fadeOut("fast", function() {
            jQuery(this).fadeIn("fast").addClass("thumb_view");
        });
        return false;
    });

	// jQuery Rotator
		//Show Banner
	//Click and Hover events for thumbnail list
	jQuery(".image_thumb ul li:first").addClass('active'); 
	jQuery(".image_thumb ul li").click(function(){ 

		//Set Variables
		var imgAlt = jQuery(this).find('img').attr("alt"); //Get Alt Tag of Image
		var imgTitle = jQuery(this).find('a').attr("href"); //Get Main Image URL
		//var imgDesc = $(this).find('.block').html(); 	//Get HTML of block
		//var imgDescHeight = $(".main_image").find('.block').height();	//Calculate height of block	

		if (jQuery(this).is(".active")) {  //If it's already active, then...
			return false; // Don't click through
		} else {
			//Animate the Teaser
			jQuery(".main_image img").attr({ src: imgTitle , alt: imgAlt});
			jQuery(".main_image a").attr({ href: imgTitle});
			//$(".main_image").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() {
				//$(".main_image .block").html(imgDesc).animate({ opacity: 0.85,	marginBottom: "0" }, 250 );
			//});
		}

		jQuery(".image_thumb ul li").removeClass('active'); //Remove class of 'active' on all lists
		jQuery(this).addClass('active');  //add class of 'active' on this list only
		return false;

	}) .hover(function(){
		jQuery(this).addClass('hover');
		}, function() {
		jQuery(this).removeClass('hover');
	});
	
	//Toggle Teaser
		jQuery("a.collapse").click(function(){
		jQuery(".main_image .block").slideToggle();
		jQuery("a.collapse").toggleClass("show");
	});
});