$(document).ready(function(){

	$("#search").attr({value: "search our products" });
	$("#signUp"	).attr({value: "email signup" }); 
	
	$("#search").focus(function() {
		$(this).val('');
	});
	$("#search").blur(function() {
		$(this).attr({value: "search our products" });
	});
	
	$("#signUp").click(function() {
		$("#signUp").val('Enter Email'); 
		$("#signUp").select(); 
		
	});
	$("#nav ul li").mouseover(function(){
		$(this).addClass("sfhover");
	 });
	$("#nav ul li").mouseout(function(){
		$(this).removeClass("sfhover");
	 });
	/*
	$("#nav ul li").mouseover(function(){
		$(this).addClass("sfhover");
	    
		if (window.removing) {
			clearTimeout(removing);
		}
	 });
	$("#nav ul li").mouseout(function(){
		if (window.removing) {
			clearTimeout(removing);
			removing = window.setTimeout('$("#nav ul li").removeClass("sfhover");',2000);
		} else {
			removing = window.setTimeout('$("#nav ul li").removeClass("sfhover");',2000);
		}
	});
	*/
	$(".media").media( { 
		width: 300, 
		height: 20, 
		autoplay: true, 
		flashvars: { 
		        autostart: 'true'
		    }
	 } );
	$('#newsletterForm').submit(function(){

		email = $('#signUp').val();
		interestedIn = $('#interestedIn').val();

		if (email == "" || email == "email signup" || email == "Enter Email" || email == " " || email == "  " || email == "Sent, thank you." || email == "Error, try again.") {
			$("#signUp").val('Enter Email'); 
			$("#signUp").select();
		} else {
			$('#signUp').val('Sending...');

			$.ajax({
		   		type: "POST",
				  url: "/signup.php",
			   	  data: "email="+email+"&interestedIn="+interestedIn,
			      success: function(msg){ 
					if (msg == 'ok') {
						$('#signUp').val('Sent, thank you.');
					} else {
						$('#signUp').val('Error, try again.');
					}
					return false;

				}
			});	
		}

		return false;	
	});
	$("#surveyFormInsert").load("/customer-survey-form.html",function(){
		$('#surveyForm').submit(function(){
			$("#loader").fadeIn(500);

			$("#fillOut").css("display","none");
			$("#success").css("display","none");

			recommend = $("#recommend").val();
			mostImportant = $("#mostImportant").val();
			likeMost = $("#likeMost").val();


			if (likeMost == "" || mostImportant == "") {
				$("#fillOut").fadeIn(500);
				$("#loader").fadeOut(500);
			} else {

				$.ajax({
			   		type: "POST",
					  url: "/customer-survey-send.php",
				   	  data: "recommend="+recommend+"&mostImportant="+mostImportant+"&likeMost="+likeMost,
				      success: function(msg){ 
						if (msg == 'ok') {
							$("#loader").fadeOut(500);
							$("#success").fadeIn(500);
							mostImportant = $('#mostImportant').val("");
							likeMost = $('#likeMost').val("");
						} else {
							$("#loader").fadeOut(500);
						}
						return false;

					}
				});	
			}

			return false;	
		});
	});
	

	
	$("#commentsFormInsert").load("/comments-form.html",function(){
		$('#commentsForm').submit(function(){
			$("#loader").fadeIn(500);

			$("#fillOut").css("display","none");
			$("#success").css("display","none");

			email = $("#email").val();
			comments = $("#comments").val();


			if (comments == "") {
				$("#fillOut").fadeIn(500);
				$("#loader").fadeOut(500);
			} else {

				$.ajax({
			   		type: "POST",
					  url: "/comments-send.php",
				   	  data: "email="+email+"&comments="+comments,
				      success: function(msg){ 
						if (msg == 'ok') {
							$("#loader").fadeOut(500);
							$("#success").fadeIn(500);
							email = $("#email").val("");
							comments = $("#comments").val("");
						} else {
							$("#loader").fadeOut(500);
						}
						return false;

					}
				});	
			}

			return false;	
		});
	});
		

	
});




