$(function(){
	navigation();
	request_a_quote_popup();
});

function navigation() {
	$('body>nav li').each(function(){
		var link = $('a', this).attr('href');
		$('span',this).css({'cursor':'pointer'}).click(function(){
			window.location.href = link;
		});
	}).hover(function(){
		$(this).addClass('hover-page');
	},function(){
		$(this).removeClass('hover-page');
	});
}

function request_a_quote_popup() {
	$("#request").click(function(){
		
		var centered = $("<div id=\"overlay\"/>").css({
			"position":"fixed",
			"width":"100%",
			"height":"100%",
			"z-index":9001,
			"top":0,
			"left":0
		});
	
		var translucent_overlay = $("<div id=\"overlay-transparency\"/>").css({
			"background":"#000",
			opacity:"0.5",
			"width":"100%",
			"height":"100%",
			"position":"absolute",
			"top":0,
			"bottom":0,
			"z-index":1
		}).click(function(){
			$("#overlay").fadeOut("slow");
		});
		
		var form_container = $("<div id=\"white-form-bg\" class=\"clearfix\"/>").css({
			"background":"#fff",
			"margin":"0 auto",
			"min-height":"300px",
			"position":"relative",
			"z-index":2,
			"width":"300px",
			"padding":"20px",
			"margin-top":"5%"
		});
		
		var form = $("#popup-form");
		
		$("#overlay").remove();
		
		centered.prependTo("body").html(translucent_overlay).append(form_container.html(form));		
		
		$("#popup-form").submit(function(e1){
			var email = $("input[name=\"email\"]").val();
		
			if(!email) {
				alert("Please enter your email address");
				e1.preventDefault();
			}
		});
		
	});
}
