$(document).ready(function() {
	$().localScroll();
});

// Form Script
$(function() {
	$('#images').cycle({ 
		fx:     'fade', 
		speed:  'fast', 
		timeout: 0, 
		pager:  '#project-nav',
		before:   onAfter
	});
	function onAfter() { 
		var project1 = "NightSeeker - King of Promotions";
		var project2 = "Uncorrupted Hosting";
		var project3 = "LamboFaces";
		var project4 = "KH Accounts";
		
		var para1 = "Nightseeker is a site where people can search, download and print promotions for venues, clubs and pubs in the U.K.";
		var para2 = "Uncorrupted is a high demand webhosting company that approached us to give them a makeover";
		var para3 = "Lambofaces is a philanthropic venture to help the lives of thousands of people in Zanzibar!";
		var para4 = "A High detail, themed design for a small World of Warcraft account trading business.";
		
			if (this.alt == 1) {
				$("#project h2").hide().text(project1).fadeIn();
				$("#project p").hide().text(para1).fadeIn();
			} 
			else if (this.alt == 2) {
				$("#project h2").hide().text(project2).fadeIn();
				$("#project p").hide().text(para2).fadeIn();
			}
			else if (this.alt == 3) {
				$("#project h2").hide().text(project3).fadeIn();
				$("#project p").hide().text(para3).fadeIn();
			}
			else if (this.alt == 4) {
				$("#project h2").hide().text(project4).fadeIn();
				$("#project p").hide().text(para4).fadeIn();
			}
	}
	
	$('input#name').val("Type your name..");
	$('input#company').val("Type your company..");
	$('input#email').val("Type your e-mail..");
	$('textarea#message').val("Type your message..");
	
	$("input#name").click(function () { 
      if ($('input#name').val() == "Type your name..") {
		  $('input#name').val("");
	  }
    });
	$("input#name").blur(function () { 
      if ($('input#name').val() == "") {
			$('input#name').val("Type your name.."); 
	  }
    });
	
	$("input#company").click(function () {
		if ($('input#company').val() == "Type your company..") {
      		$('input#company').val("");
		}
    });
	$("input#company").blur(function () { 
      if ($('input#company').val() == "") {
			$('input#company').val("Type your company.."); 
	  }
    });
	
	$("input#email").click(function () {
		if ($('input#email').val() == "Type your e-mail..") {
      		$('input#email').val("");
		}
    });
	$("input#email").blur(function () { 
      if ($('input#email').val() == "") {
			$('input#email').val("Type your e-mail.."); 
	  }
    });
	
	$("textarea#message").click(function () { 
      if ($('textarea#message').val() == "Type your message..") {
	  		$('textarea#message').val("");
	  }
    });
	$("textarea#message").blur(function () { 
      if ($('textarea#message').val() == "") {
			$('textarea#message').val("Type your message.."); 
	  }
    });
	
	$("#submit").click(function() {
		
		var name = $("input#name").val();
		var email = $("input#email").val();
		var company = $("input#company").val();
		var message = $("textarea#message").val();
		
		if (name == "" || name == "Type your name..") {
			
			$("#contact h2").fadeOut("fast", function () {
				$("#contact h2").text("Please enter your name.");
			});
			$("#contact h2").fadeIn("fast");
      		return false;
		}
		else if (company == "" || company == "Type your company..") {
			$("#contact h2").fadeOut("fast", function () {
				$("#contact h2").text("Can you tell us your company name?");
			});
			$("#contact h2").fadeIn("fast");
      		return false;
		}
		else if (email == "" || email == "Type your e-mail..") {
			$("#contact h2").fadeOut("fast", function () {
				$("#contact h2").text("Oops! We need your e-mail so we can get back to you!");
			});
			$("#contact h2").fadeIn("fast");
      		return false;
		}
		else if (message == "" || message == "Type your message..") {
			$("#contact h2").fadeOut("fast", function () {
				$("#contact h2").text("Please write us a message, and we will get back to you.");
			});
			$("#contact h2").fadeIn("fast");
      		return false;
		}
	
		var dataString = 'name='+ name + '&email=' + email + '&company=' + company + '&message=' + message;
		//alert (dataString);return false;
	
		$.ajax({
			type: "POST",
			url: "contact.php",
			data: dataString,
			success: function() {
				$('#contact').html("<h2>Contact Form Submitted!</h2>").append("<p class='submit'>We will be in touch soon.</p>").hide().fadeIn();
			}
		});
		return false;
	});
});