$(document).ready( function() {
	$("p.bembo").css("font-size", "22px");
	
	$(".puff.image").find("img").css("margin-left", "-220px");
	

	
	$(".puff.image").hover( function() {
		if ($(this).hasClass("nofade")) {
			return;
		}
		$(this).find("img").fadeOut(200);
	}, function() {
		$(this).find("img").fadeIn(200);
	});
	
	$("a:not(.alt) img").hover( function() {
		$(this).animate({opacity: "0.8"}, 200 );
	}, function() {
		$(this).animate({opacity: "1"}, 200 );
	});

	$(".featured_tier a").hover( function() {
		$(this).find("img").animate({opacity: "0.8"}, 200 );
	}, function() {
		$(this).find("img").animate({opacity: "1"}, 200 );
	});

	
	$("a").click( function() {
		if( $(this).attr("href") == "#" ) return false;	
	});
	
	$(".slider_button").click( function() {
		if( $(this).attr("id") == "slider_button_next") {
			$("#featured_tier_1").animate({marginLeft: "-960px"}, 600 );
			$("#slider_button_next").addClass("disabled");
			$("#slider_button_prev").removeClass("disabled");
		} else {
			$("#featured_tier_1").animate({marginLeft: "0"}, 600 );
			$("#slider_button_prev").addClass("disabled");
			$("#slider_button_next").removeClass("disabled");
		}
	});
	
	$("#gallery_navigation .button_small").click( function() {
		$("#gallery_nav_prev").removeClass('disabled');
		$("#gallery_nav_next").removeClass('disabled');
		var pos = $("#gallery_nav_pos").val();
		var max = $(".single_large_image").size();
		if( $(this).attr("id") == "gallery_nav_next") {
			pos = parseInt(pos) + 1;
			if(pos >= max) { 
				pos = 0; 
			}
		} else {
			pos = parseInt(pos) - 1;
			if(pos < 0) { 
				pos = max - 1;
			}
		}
		new_position = -(pos * 940) + "px";
		$("#gallery_nav_pos").attr("value", pos);
		$("#large_image_slider").animate({marginLeft: new_position}, 600 );
	});			$("#gallery_navigation_med .button_small").click( function() {		$("#gallery_nav_prev").removeClass('disabled');		$("#gallery_nav_next").removeClass('disabled');		var pos = $("#gallery_nav_pos").val();		var max = $(".single_medium_image").size();		if( $(this).attr("id") == "gallery_nav_next") {			pos = parseInt(pos) + 1;			if(pos >= max) { 				pos = 0; 			}		} else {			pos = parseInt(pos) - 1;			if(pos < 0) { 				pos = max - 40;			}		}		new_position = -(pos * 700) + "px";		$("#gallery_nav_pos").attr("value", pos);		$("#medium_image_slider").animate({marginLeft: new_position}, 600 );	});
	$("#main_content p:first").addClass('bembosss');
	
	$("#client_list_container").hide();
	$("#client_list_toggle").click( function() {
		var t = $(this).text();
		t = ( t == "Show all clients" ) ? "Hide clients" : "Show all clients";
		$(this).text(t); 
		
		$("#client_list_container").slideToggle();
	});
	
	
	// Contact form
	$(".text").focus( function() {
		if ( $(this).attr("value") == $(this).attr("title") ) {
			$(this).attr("value", "");
		} 
	});
	$(".text").blur( function() {
		if ( $(this).attr("value") == "" ) {
			$(this).attr("value", $(this).attr("title"));
		}
	});
	
	var can_submit_form;
	$("form").submit( function() {
		can_submit_form = true;
		$("#contact_form .mandatory").each( function() {
			if( !$(this).attr("value") || $(this).attr("value") == $(this).attr("title")) {
				$(this).css("background", "#fee");
				can_submit_form = false;	
			} else {
				$(this).css("background", "#fff");
			}
		});
		return can_submit_form;
	});
	
	$("#work_filter").change( function() {
		var filter = $(this).val();
		if ( filter != "all" ) {
			$("."+filter).attr("style", "").removeClass("nofade");
			$(".puff:not(."+filter+")").animate({opacity: "0.2"}, 200 ).addClass("nofade");
		} else {
			$(".puff").attr("style", "").removeClass("nofade");
		}
	});
	
	

});

Cufon.replace('h1, h2', { fontFamily: 'Akzidenz-Grotesk Std Ext' });
Cufon.replace('h3', { fontFamily: 'Akzidenz-Grotesk Std Med Ext' });
Cufon.replace('p.bembo', { fontFamily: 'Bembo' });
