$(document).ready( function() {			
			// Expanding and controlling header
			flipHeader=0;
			
			$.showHeader = function () {
				$.hideFooter();
				$("#about-holder").animate( { marginTop:"0" }, { queue:false, duration:510 } );
				$("#header-holder").animate( { marginTop:"326px" }, { queue:false, duration:510 } );
				$("#about-holder a#about-toggle").addClass("active");
				flipHeader=1;
			};
			
			$.hideHeader = function () {
				$("#about-holder").animate( { marginTop:"-326px" }, { queue:false, duration:510 } );
				$("#header-holder").animate( { marginTop:"0" }, { queue:false, duration:510 } );
				$("#about-holder a#about-toggle").removeClass("active");
				flipHeader=0;
			};			
			
			$("#about-holder a#about-toggle").click(function(){
				if(flipHeader!=1){
					$.showHeader();
				} else {
					$.hideHeader();
				}
			});
			
			$("#foot-toggle").click(function () {
				if(flipHeader==1){
					$.hideHeader();
				}
			});
			
			$("a#ie-ok").click(function () {
				$("#ie").fadeOut(2000);
			});
						
			$("#content").click(function () {
				if(flipHeader==1){
					$.hideHeader();
				}
			});
			// Expanding and controlling footer
			flipFooter=0;
			$('#message').hide();
			$.showFooter = function () {
				$.hideHeader();
				$("#footer-holder").animate( { margin:"-250px 0 0 0" }, { queue:false, duration:510 } );
				$("#footer-holder").animate( { height:"250px" }, { queue:false, duration:510 } );
				$("#footer div").fadeIn(300);
				$("#foot-toggle").addClass("active");
				if($("#contactForm:hidden")){
					$('#message').hide();
					$('form#contactForm :input').val("");
					$('form#contactForm :textfield').val("");
					$('form#contactForm :input').removeClass("filled");
					$('form#contactForm :input').removeClass("focus");
					$('form#contactForm :textfield').removeClass("filled");
					$('form#contactForm :textfield').removeClass("focus");
					$('#contactForm fieldset').show();
				}
				flipFooter=1;
			};
			$.hideFooter = function () {
				$("#footer-holder").animate( { margin:"-56px 0 0 0" }, { queue:false, duration:510 } );
				$("#footer-holder").animate( { height:"100px" }, { queue:false, duration:510 } );
				$("#footer div").fadeOut(500);
				$("#foot-toggle").removeClass("active");
				flipFooter=0;
			};			
			//$("#footer-holder").click(function(){
			//	if(flipFooter!=1){
			//		$.showFooter();
			//	} else {
			//		$.hideFooter();
			//	}
			//});
			//
			//$("#elsewhere").click(function(){
			//	if(flipFooter!=1){
			//		$.showFooter();
			//	} else {
			//		$.hideFooter();
			//	}
			//});
			$("a#foot-toggle").click(function () {
				if(flipFooter!=1){
					$.showFooter();
				} else {
					$.hideFooter();
				}
			});
			$("#header-holder").click(function () {
				if(flipFooter==1){
					$.hideFooter();
				}
				if(flipHeader==1){
					$.hideHeader();
				}
			});
			$("#content").click(function () {
				if(flipFooter==1){
					$.hideFooter();
				}
			});
			// Contact Form
			$("input, textarea").bind('focus', function() {
				$(this).addClass("focus");
			});
			$("input, textarea").bind('blur', function() {
				$theValue = $(this).val();
				if($theValue == ""){
					$(this).removeClass("focus");
				}else{
					$(this).removeClass("focus");
					$(this).addClass("filled");
					$(this).value($theValue);
				}
			});
			$("form#mail").validate({
			focusInvalid: false,
			  rules: {
				},
				highlight: function(element, errorClass) {
				     $(element).addClass(errorClass);
				     $(element.form).find("label[for=" + element.id + "]")
				                    .addClass(errorClass);
				  },
				  unhighlight: function(element, errorClass) {
				     $(element).removeClass(errorClass);
				     $(element.form).find("label[for=" + element.id + "]")
				                    .removeClass(errorClass);
				  },
			messages: {
			     name: "Please specify your name",
			     email: {
			       required: "Email address required",
			       email: "Must be a valid email address"
			     }
			   },
			});

			$("dl.case dt").fillContent();
		});