$(document).ready(function() {
	
	//if submit button is clicked
	$('#submit').click(function () {		
		
		//Get the data from all the fields
		var name = $('input[name=name]');
		var email = $('input[name=email]');
		var company = $('input[name=company]');
		var website = $('input[name=website]');
		var comment = $('textarea[name=comment]');

		//Simple validation to make sure user entered something
		//If error found, add hightlight class to the text field
		if (name.val()=='Full Name') {
			name.addClass('hightlight');
			return false;
		} else name.removeClass('hightlight');
		
		if (email.val()=='Email Address') {
			email.addClass('hightlight');
			return false;
		} else email.removeClass('hightlight');
		
		if (company.val()=='Company Name') {
			company.addClass('hightlight');
			return false;
		} else company.removeClass('hightlight');
		
		//if (comment.val()=='') {
			//comment.addClass('hightlight');
			//return false;
		//} else comment.removeClass('hightlight');
		
		//organize the data properly
		var data = 'name=' + name.val() + '&email=' + email.val() + '&company=' + 
		company.val() +  '&website=' + 
		website.val() + '&comment='  + encodeURIComponent(comment.val());
		
		//disabled all the text fields
		$('.text').attr('disabled','true');
		
		//show the loading sign
		$('.loading').show();
		
		//start the ajax
		$.ajax({
			//this is the php file that processes the data and send mail
			url: "process.php",	
			
			//GET method is used
			type: "GET",

			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {				
				//if process.php returned 1/true (send mail success)
				if (html==1) {					
					//hide the form
					$('.form').fadeOut(800);					
					
					//show the success message
					$('.done').fadeIn(800);
						$("#superhide").delay(3000).fadeOut(500);
$('#cont2').pause(3000).fadeOut(500, function(){
    $(this)
        .html("<div id='slides2'><div class='slides_container'><div><p class='white normal'>I was flicking through DigitalArts Magazine, as I was looking for the very best Digital Artists/ Illustrators, and I came across his work. It stood out a mile and was and is amazing.<br/><br/>I found him extremely hard working, talented and very easy to work with. He went above and beyond the call of duty and his services were on time, on budget and exemplary.<br/><br/>In the end the Olympic presentation we put together looked amazing and therefore, I would highly recommend Adam to anyone and I look forward to working with him again in the near future.</p><p class='btm accentblue'>Saatchi &amp; Saatchi Design London<br/>David Gilligan, Creative Director</p></div><div>  <p class='white normal'>Woodhouse is a featured artist on the Adobe Design Gallery and has also worked for some big international brands. Not bad for someone who's entirely self-taught.</p><p class='btm accentblue'><img src='images/quotes/digitalarts.png' width='129' height='30' class='quote' alt='digital arts'/><br/>Digital Arts - Best of new British talent<br/><br/><br/></p></div><div><p class='white normal'>Adam's unique styles push the boundaries of modern design, with abstract shapes and spacing, yet keeping the design focused and in context to its surroundings.</p><p class='btm accentblue'><img src='images/quotes/visitadobe.png' width='30' height='34' class='quote' alt='Visit Adobe'/><br/>Adobe Design Gallery - Featured Artist<br/><br/><br/></p></div><div>  <p class='white normal'>Adam Woodhouse is a extremely well rounded designer out of the United Kingdom. Adam is fluent in many of the designing programs we all know and he has been using them all to create his art. Adams illustrations consist of amazing 3D work mixed with Photoshop.</p><p class='btm accentblue'><img src='images/quotes/psdtutsplus.png' width='100' height='30' class='quote' alt='tutsplus'/><br/>psd.tutsplus.com</p><br/><br/></div></div></div>")
             .fadeIn(500);Cufon.refresh();

	 if ( $.browser.msie ) {
		 $(document).ready(function() {
			$('#slides2').slides({
				generateNextPrev: true,
			    fadeSpeed: 1,
				play: 7000,
				autoHeight: true,
				hoverPause: true,
				effect: 'fade'
				});
			
		});
 } else {
$(document).ready(function() {
			$('#slides2').slides({
				generateNextPrev: true,
			    fadeSpeed: 800,
				play: 7000,
				autoHeight: true,
				hoverPause: true,
				effect: 'fade'
				});
		}); }	

		  Cufon.refresh();


});
					
				//if process.php returned 0/false (send mail failed)
				} else alert('Sorry, unexpected error. Please try again later.');				
			}		
		});
		
		//cancel the submit button default behaviours
		return false;
	});	
});	

