
	$().ready(function() {
		
		// LANDING
		$("div.landing div.next a").click(landing_frame_next);
		sIFR.replace(gotham_book, { selector:'div.firm div.feature div.next h3', selectable:false, transparent:true, css: '.sIFR-root { color: #ffffff; font-size: 14; letter-spacing: 0; }', thickness: -100, sharpness: 0, tuneWidth: 10, offsetTop: -2 });
		$("div.landing div.feature div.slides div.frame ul").append($("div.landing div.feature div.slides div.frame ul li:first").clone());
		
		// PEOPLE
		$("div.people_list ul li a").hover(function() {
			var li = $(this).parent();
			$(li).css("z-index","100");
			var left_pos = Math.floor($(this).width()+25)+"px";
			$(li).find("div.tooltip").css({left: left_pos, display: "block"});
			//sIFR.replace(gotham_book, { selector:'div.people_list ul li div h5', selectable:false, transparent: true, css: '.sIFR-root { color: #ffffff; font-size: 12; letter-spacing: 0; }', thickness: -120, sharpness: 100, tuneWidth: 10, tuneHeight: -3, offsetTop: 0 });
			//sIFR.replace(gotham_book, { selector:'div.people_list ul li div h6', selectable:false, transparent: true, css: '.sIFR-root { color: #cccccc; font-size: 12; letter-spacing: 0; }', thickness: -180, sharpness: 0, tuneWidth: 10, tuneHeight: -3, offsetTop: 0 });
		},function() {
			var li = $(this).parent();
			$(li).removeAttr("style");
			$(li).find("div.tooltip").css("display","none");
		});
		$("div.people_list ul li a").click(function() {
			var person_id = $(this).attr("href");
			person_id = person_id.replace(/#/,"");
			var li = $("div#bio_popup ul.bios li#person_"+person_id);
			var position = get_id($(li).attr("class"));
			go_to_bio(position);
			return false;
		});
		$("div#bio_popup ul.people_nav li.all").hover(function() {
			var desc = "<span>view all</span>";
			$("ul.people_nav li.desc").html(desc);
		},function() {
			$("ul.people_nav li.desc").html("");
		});
		$("div#bio_popup ul.people_nav li.previous").hover(function() {
			var desc = "<span>previous:</span> "+get_person_name(get_previous_person());
			$("ul.people_nav li.desc").html(desc);
		},function() {
			$("ul.people_nav li.desc").html("");
		});
		$("div#bio_popup ul.people_nav li.next").hover(function() {
			var desc = "<span>next:</span> "+get_person_name(get_next_person());
			$("ul.people_nav li.desc").html(desc);
		},function() {
			$("ul.people_nav li.desc").html("");
		});
		$("div#bio_popup ul.people_nav li.all a").bind("click",people_nav_all);
		$("div#bio_popup ul.people_nav li.previous a").bind("click",people_nav_previous);
		$("div#bio_popup ul.people_nav li.next a").bind("click",people_nav_next);
		$("ul.bios li div.column_1 a").click(function() {
			var address = $(this).attr("title");
			address = address.replace(/#/,"@");
			$(this).attr("href","mailto:"+address);
		});
	});
	
	function landing_frame_next() {
		landing_position++;
		animate_frame();
		return false;		
	}
	
	function animate_frame() {
		$("div.landing div.next a").unbind("click",landing_frame_next).bind("click",empty);
		var position = -564*Math.floor(landing_position-1);
		$("div.landing div.feature div.slides div.frame ul").stop().animate({left:position+"px"},700,function() {
			$("div.landing div.next a").unbind("click",empty).bind("click",landing_frame_next);
			if(landing_position>landing_total) {
				landing_position=1;
				$(this).css("left","0");	
			}
		});
	}

	function people_nav_all() {
		window.location.hash = "#all";
		$("div#bio_popup").css("display","none");
		return false;		
	}
	
	function people_nav_previous() {
		if(current_bio>1) {
			go_to_bio(get_previous_person());
		} else {
			var first = $("ul.bios li.bio_"+current_bio);
			var remove = $(first).clone();
			$(remove).removeAttr("class").addClass("remove").removeAttr("id");
			$("div#bio_popup ul.bios").append($(remove));
			var position = -938*total_bios;
			$("div#bio_popup ul.bios").css("left",position+"px");
			return_position = total_bios;
			go_to_bio(total_bios);
		}			
		var desc = "<span>previous:</span> "+get_person_name(get_previous_person());
		$("ul.people_nav li.desc").html(desc);
		return false;
	}
	
	function people_nav_next() {
		if(current_bio < total_bios) {
			go_to_bio(get_next_person());
		} else {
			var last = $("ul.bios li.bio_"+current_bio);
			var remove = $(last).clone();
			$(remove).removeAttr("class").addClass("remove").removeAttr("id");
			$("div#bio_popup ul.bios").prepend($(remove));
			$("div#bio_popup ul.bios").css("left","0");
			return_position = 1;
			go_to_bio(2);
		}
		var desc = "<span>next:</span> "+get_person_name(get_next_person());
		$("ul.people_nav li.desc").html(desc);
		return false;													   
	}
	
	function turn_on_people_nav() {
		$("div#bio_popup ul.people_nav li.all a").unbind("click",empty).bind("click",people_nav_all);
		$("div#bio_popup ul.people_nav li.previous a").unbind("click",empty).bind("click",people_nav_previous);
		$("div#bio_popup ul.people_nav li.next a").unbind("click",empty).bind("click",people_nav_next);		
	}
	
	function turn_off_people_nav() {
		$("div#bio_popup ul.people_nav li.all a").unbind("click",people_nav_all).bind("click",empty);
		$("div#bio_popup ul.people_nav li.previous a").unbind("click",people_nav_previous).bind("click",empty);
		$("div#bio_popup ul.people_nav li.next a").unbind("click",people_nav_next).bind("click",empty);			
	}
	
	function go_to_bio(position) {
		
		turn_off_people_nav();
		if(return_position) {
			current_bio = return_position;
		} else {
			current_bio = position;	
		}
		window.location.hash = get_id($("div#bio_popup ul.bios li.bio_"+current_bio).attr("id"));
		var ul_position = -938*(position-1);
		if($("div#bio_popup").is(":visible")) {
			$("div#bio_popup ul.bios").animate({left:ul_position+"px"},700,function() {
				turn_on_people_nav();
				if(return_position) {
					$("ul.bios li.remove").remove(); 
					var position = -938*(return_position-1);
					$(this).css("left", position+"px");
					return_position = false;
				}
			});
		} else {
			turn_on_people_nav();
			$("div#bio_popup ul.bios").css("left",ul_position+"px");
			$("div#bio_popup").css("display","block");
		}
		
	}
	
	function get_previous_person() {
		if(current_bio > 1) {
			return Math.floor(current_bio)-1;
		} else {
			return total_bios;
		}	
	}
	
	function get_next_person() {
		if(current_bio < total_bios) {
			return Math.floor(current_bio)+1;
		} else {
			return 1;
		}		
	}
	
	function get_person_name(position) {
		return $("div#bio_popup ul.bios li.bio_"+position+" h3").text();
	}