var signup = false;
var spot = false;
var curr_sub = 0;

function toggleSignup() {
	if (!signup) {
			$("#signup").animate({top:'-40px'},800,'easeInOutBack',function() {
				signup = true;
			});
		} else {
			$("#signup").animate({top:'-249px'},800,'easeInOutBack',function() {
				$("#signup_name").val('Your Name');
				$("#signup_email").val('Enter your email address...');
				signup = false;
			});
		}
}


function toggleSpot() {
	if (!spot) {
			$("#spot_guide").animate({top:'-50px'},800,'easeInOutBack',function() {
				spot = true;
			});
		} else {
			$("#spot_guide").animate({top:'-240px'},800,'easeInOutBack',function() {
				spot = false;
			});
		}
}



$(function() {
	
	
	$("#spot_guide_download").click(function() {toggleSpot();});

	
	$("#name").val('Your Name');
	$("#email").val('Your Email');
	$("#msg").val('Your Message');
	$("#signup_switch").click(function() { toggleSignup(); });
	$("#spot_guide_switch").click(function() { toggleSpot(); });

	$("#signup_form").submit(function() {

		var name = $("#signup_name").val();
		var email = $("#signup_email").val();
		
		$.post("ajax_signup.php", { name: name, email: email}, function(d) {
			toggleSignup();			
		});
		return false;
		
	});
	
	$("#contact_form").submit(function() {

		var name = $("#name").val();
		var email = $("#email").val();
		var msg = $("#msg").val();
		
		$.post("ajax_contact.php", { name: name, email: email, msg:msg}, function(d) {
			thanks();		
		});
		return false;
		
	});
	
	
	$("#signup_name").focus(function() { if ($(this).val() == 'Your Name') { $(this).val(''); } }).blur(function() { if ($(this).val() == '') { $(this).val('Your Name'); }});
	$("#signup_email").focus(function() { if ($(this).val() == 'Enter your email address...') { $(this).val(''); } }).blur(function() { if ($(this).val() == '') { $(this).val('Enter your email address...'); }});
	
	
	$("#name").focus(function() { if ($(this).val() == 'Your Name') { $(this).val('').removeClass('contact_title'); } }).blur(function() {  if ($(this).val() == '') { $(this).val('Your Name').addClass('contact_title'); }  });
	$("#email").focus(function() { if ($(this).val() == 'Your Email') { $(this).val('').removeClass('contact_title'); } }).blur(function() {  if ($(this).val() == '') { $(this).val('Your Email').addClass('contact_title'); }  });
	$("#msg").focus(function() { if ($(this).val() == 'Your Message') { $(this).val('').removeClass('contact_title'); } }).blur(function() {  if ($(this).val() == '') { $(this).val('Your Message').addClass('contact_title'); }  });
	
	
	
	$("#homeslide_menu a").click(function(e) {
		var where = $(this).attr('rel');
		var curr = $(this);
		where = 0 - (where * 1027) + "px";
		$("#homeslide_filmstrip").animate({left: where}, 1000, 'easeInOutExpo', function() {
			$("#homeslide_menu a").removeClass('homeslide_current');
			curr.addClass('homeslide_current');
		});
	});	
	
	$("#products_link_001").click(function() {
		var t = $(this);
		$("#microseal").fadeOut(function() {
			$("#products_links a").removeClass('product_link_current');
			t.addClass('product_link_current');
		});
	});
	
	$("#products_link_002").click(function() {
		var t = $(this);
		$("#microseal").fadeIn(function() {
			$("#products_links a").removeClass('product_link_current');
			t.addClass('product_link_current');
		});
	});
	
	
	$(".current_special").click(function() {
		var c = this.id.replace("current_special_","");
		var t = $(this);
		$(".current_special_image").fadeOut(function() {
			$(".current_special_image").css('background-image','url("images/special_' + c + '.png")');
			$("#print_hover").attr('src','images/special_'+c+'_hover.png');
			$("#special_link").attr('href','pdf/special' + c + '.pdf');
			$(".current_special").removeClass('current_special_current');
			t.addClass('current_special_current');
		}).delay(300).fadeIn(function() {
			
		});
	});

	$('.current_special_image').hover(function() { $("#print_hover").fadeIn(); }, function() {$("#print_hover").fadeOut();});
	
	$(".product_slide").click(function() {
		
		$(".product_slide").animate({width:'112px'},{ queue: false, duration: 600});
		$(this).animate({width: '275px'},{ queue: false, duration: 600});
		
	});
	
	$(".cert_sub").click(function() {
		if ($(this).hasClass('plus')) { $(".cert_sub").removeClass('minus').addClass('plus').children('p').slideUp(); }
		var t = $(this);
		if (t.hasClass('plus')) {
			t.removeClass('plus').addClass('minus');
			t.children('p').slideDown();
		} else {
			t.removeClass('minus').addClass('plus');
			t.children('p').slideUp();
		}
		
	});
	
	$(".cert_sub p").click(function(e) {
		e.stopPropagation();
	});
	
	
	//$("#footer_social img").fadeTo(0,0.8).hover(function(){$(this).fadeTo(100,1);},function(){$(this).fadeTo(100,0.8);});
	
});

function thanks() {
	$("#thankyou").fadeIn();
}
