
	// BROWSER DETECTIONS
	if(!$.browser.msie||Math.round($.browser.version)!=6) {
		document.write('<script type="text/javascript" src="/js/shadows.js"></script>');
		$().ready(function() { apply_shadows(); setTimeout("apply_shadows()",1000); });
	} else {
		document.write('<link type="text/css" rel="stylesheet" href="/css/ie6.css" />');
	}
	
	// SIFR INCLUDES
	document.write('<link type="text/css" rel="stylesheet" href="/css/sifr_screen.css" media="screen" />');
	document.write('<link type="text/css" rel="stylesheet" href="/css/sifr_print.css" media="print" />');
	
	// GLOBAL JS
	$().ready(function() {
					   
		// SIFR REPLACEMENTS
		if(typeof sIFR == "function"){
			sIFR.replaceElement(named({sSelector:"div#header p", sFlashSrc:"/swf/helvetica.swf", sColor:"#ffffff", sWmode:"transparent"}));
			sIFR.replaceElement(named({sSelector:"div.tout h3", sFlashSrc:"/swf/helvetica.swf", sColor:"#999999", sWmode:"transparent"}));
		}
		
		// global nav
		$("ul.global_nav li.follow").hover(function() { $(this).find("div.dropdown").slideDown(200); $(this).find("a:last").addClass("hover"); },function() { $(this).find("div.dropdown").slideUp(100); $(this).find("a.hover").removeClass("hover"); });
		
		// remove far margin
		$("div#footer ul").each(function() { $(this).find("li:last").css("margin-right","0"); });
	
		// add bottom image
		if(Math.floor($("div#content").height())>1000) {
			var bottom = $("<div class=\"bottom\">&nbsp;</div>");
			$("div#content").append(bottom);	
		}
		
		// bio select
		$("ul.bio_images li a").click(function() {
			$("ul.bio_images li a.active").removeClass("active");
			$(this).addClass("active");
			$("div.bio").css("display","none");
			$("div#"+$(this).parent().attr("class")).css("display","block");
			return false;
		});
		
		// contact button in footer
		$("div#footer ul.info a").click(function() {
			open_popup("contact_popup");
			return false;
		});
		
		// contact button in footer
		$("div#sitemap a.contact").click(function() {
			open_popup("contact_popup");
			return false;
		});
		
		$("div#contact_popup a.submit").click(function() {
			$("div#contact_popup div.loading").css("display","block");
			var name = $("input#contact_name").val();
			var email = $("input#contact_email").val();
			var comment = $("textarea#contact_comment").val();
			if(name.length>0&&email.length>0&&comment.length>0) {
				$.ajax({
					type: "POST",
					url: "/ajax/contact_popup.php",
					data: "name="+name+"&email="+email+"&comment="+comment,
					success: function(response){
						if(response==1) {
							$("div#contact_popup div.contact_comment").html("<strong>Your message has been sent</strong>Thank you for contacting us and letting us know what you think of our project!");
						} else {
							$("div#contact_popup div.errors").css("display","block");
						}
						$("div#contact_popup div.loading").css("display","none");
					},
					error: function (XMLHttpRequest, textStatus, errorThrown) {
						$("div#contact_popup div.errors").html("There was an error submitting your information. Please try again later.").css("display","block");
						$("div#contact_popup div.loading").css("display","none");
					}
				});				
			} else {
				$("div#contact_popup div.errors").css("display","block");
				$("div#contact_popup div.loading").css("display","none");
			}
			return false;											   
		});
		
		// team emw 08 hovers
		$("div#team_emw ul li").hover(function() {
			$(this).css("z-index","200");
			$(this).find("a.photo").addClass("active");
			$(this).find("div").stop().slideDown(300);
		},function() {
			$(this).css("z-index","1");
			$(this).find("a.photo").removeClass("active");
			$(this).find("div").stop().slideUp(150,function() { $(this).css("height","99px"); });
		});
		
		$("div#team_emw ul").each(function() {
			$(this).find("li:last div").css({top:"auto",bottom:"99px",borderTop:"none",borderBottom:"solid 5px #212121"});								   
		});
		
	});
	
	// PHOTO VARIABLES
	var current_photo=null;
	var photos=new Array();
	photos[1] = "Tony and Trevor laying out the rear end geometry.";
	photos[2] = "Engine is strapped in a ready for the trip to the West Coast.";
	photos[3] = "Trevor welding the jungle gym.";
	photos[4] = "Bottom detail.";
	photos[5] = "Bottom detail.";
	photos[6] = "Starting to look like it'll float right over the silt...";
	photos[7] = "Bottom work detail.";
	photos[8] = "Turning the cage upside down to start.";
	photos[9] = "Starting to work on the bottom of the car...";
	photos[10] = "The body panels that go on the front of the car...";
	photos[11] = "Close-up on the body panels that Shaun has been working on...";
	photos[12] = "Dash finished without the GPS in there...";
	photos[13] = "Some final grinding being done on the dash.";
	photos[14] = "Kyle placing a side piece of the dash.";
	photos[15] = "Shaun lining up all the plates prior to welding.";
	photos[16] = "Shaun starting on the dashboard.";
	
	function load_photo(photo_id) {
		
		current_photo = photo_id;
		$("div#photo_popup div.caption").html("");
		$("div#photo_popup div.nav").html("");
		$("div#photo_popup img").remove();
		$("div#photo_popup div.loading").css("display","block");
		if($("div#photo_popup").is(":hidden")) { open_popup("photo_popup"); photos_open=true; }
		var image = $("<img src=\"/images/what_is_emw/photos/large/build_"+photo_id+".jpg\" />");
		$("div#photo_popup").append(image);
		$("div#photo_popup img").load(function() {
			$("div#photo_popup div.loading").css("display","none");		
			set_photo_nav();
			set_photo_caption();
		});
		return false;
		
	}
	
	function set_photo_nav() {
		var nav_html = "Image "+current_photo+" of "+Math.floor(photos.length-1)+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
		var prev = 0; var next = 0;
		if(current_photo==1) { prev=(photos.length-1); } else { prev=Math.floor(current_photo-1); }
		if(current_photo==(photos.length-1)) { next=1; } else { next=Math.floor(current_photo+1);	}
		nav_html += "<a href=\"#previous\" class=\"previous\" onclick=\"load_photo("+prev+"); return false;\">Previous</a>&nbsp;&nbsp;&nbsp;/&nbsp;&nbsp;&nbsp;<a href=\"#next\" class=\"next\" onclick=\"load_photo("+next+"); return false;\">Next</a>";
		$("div#photo_popup div.nav").html(nav_html);
	}
	
	function set_photo_caption(el) {
		$("div#photo_popup div.caption").text(photos[current_photo]);
	}
	