$(document).ready(function(){
	var locked = false;


	//function for contact form dropdown
	function wereLive() {

		if(locked) return;
		if ($("#wereLiveForm").is(":hidden")){
			$("#headerLogoAndNav").hide(); 
			$("#wereLiveForm").slideDown("slow");
			$("#backgroundPopup").css({"opacity": "0.5"});
			$("#backgroundPopup").fadeIn("slow"); 
			
			
		}
		else{
			hideWereLive();
		}
		locked = true;
		setTimeout(clearLock, 1000);
	}

	function clearLock(){
		locked = false;
	}

	function hideWereLive() {
		if(locked) return;
		$("#headerLogoAndNav").show(); 
		$("#wereLiveForm").slideUp("slow");
		$("#backgroundPopup").fadeOut("slow");  
	}
	 
	
	//run contact form when any contact link is clicked
	$(".wereLiveBtn").mouseover(function(){wereLive()});
	$("#wrapper").mouseover(function(){hideWereLive()});





	//animation for same page links #
	$('a[href*=#]').each(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
		&& location.hostname == this.hostname
		&& this.hash.replace(/#/,'') ) {
		  var $targetId = $(this.hash), $targetAnchor = $('[name=' + this.hash.slice(1) +']');
		  var $target = $targetId.length ? $targetId : $targetAnchor.length ? $targetAnchor : false;
			if ($(this.hash).length) {
				$(this).click(function(event) {
					var targetOffset = $(this.hash).offset().top;
					var target = this.hash;
					event.preventDefault();			   
					$('html, body').animate({scrollTop: targetOffset}, 500);
					return false;
				});
			}
		}
	});




	//only need force for IE6  
	$("#backgroundPopup").css({  
		"height": document.documentElement.clientHeight 
	});  








});




