// JavaScript Document


$(document).ready(function() {
	
	/*-- Form --*/	
	
	$('#contact').ajaxForm(function(data) {
		if (data==0){$('.contact-error').hide();$('.contact-success').fadeIn("slow");$('.contactForm').resetForm();}
		else if (data==1){$('.contact-success').hide(); $('.contact-error').fadeIn("slow");}
	});
	
	/*--Homepage Splash--*/
	
	$(function() {  
		$("#frame-splash").jMyCarousel({  
			visible: '100%'  
		});  
	});
	
	$(function() {
		$("#frame-splash li .splash-image").each(function(){
			var backgroundimage = $("img",this).attr("src")
			$(this).css('background','url('+ backgroundimage +') 0px -151px')
		});
	});  
	
	$('#frame-splash li img').click(function () {
		$(this).removeClass('active');
	});
			
	$('#frame-splash li img').hover(function () {
		$(this).fadeOut(0).addClass('active').fadeIn(300);
	},
	function () {
		$(this).fadeOut(100)
			.queue(function(){ $(this).removeClass('active').fadeIn(0).dequeue() });
	});
	
	$('#close-welcome,#welcome').click(function(){
		$('#welcome').fadeOut('slow');		
	});
	
	/*--Fonts--*/
	
	Cufon.replace('h1,h2,h3,#navigation-main li,#welcome p');
	Cufon.replace('.button-green a, button',{textShadow: '#599700 0px -1px'});
		
	/*-- Corners --*/	

	$(function(){ 
	
		smaller = {
			tl: { radius: 3 },
			tr: { radius: 3 },
			bl: { radius: 3 },
			br: { radius: 3 },
			autoPad: true,
			validTags: ["div"]
		}
		
		larger = {
			tl: { radius: 7 },
			tr: { radius: 7 },
			bl: { radius: 7 },
			br: { radius: 7 },
			autoPad: true,
			validTags: ["div"]
		}


		$('#navigation-main li a, .testimonial-container').corner(smaller);
		$('#welcome').corner(larger);
	
	});
	
	/*-- Fancybox --*/	

	$(".splash-image a, #office-photos a, #folio-items a").fancybox({
		'titlePosition' : 'over'
	});
	
	/*-- Filter --*/	
	
	$(document).ready(function() {
		$('#categories a').click(function() {

			
			$(this).css('outline','none');
			$('#categories .current').removeClass('current');
			$(this).parent().addClass('current');
	
			var filterVal = $(this).text().toLowerCase().replace(' ','-');
	
			if(filterVal == 'all') {
				$('.sorting li.hidden').fadeIn('slow').removeClass('hidden');
			} else {
				$('.sorting li').each(function() {
					if(!$(this).hasClass(filterVal)) {
						$(this).fadeOut('normal').addClass('hidden');
					} else {
						$(this).fadeIn('slow').removeClass('hidden');
					}
				});
			}
			
			
			return false;
		});
		
		
	});
	
});

