// Custom Javascript by Tim Householder


// SAMPLE SCROLLER
$(function () {
		function onAfter() { 
    		$('#proj-desc').html("<h3><span class='colorMeBlue'>Client: </span>" + this.title + "</h3>") 
        .append('<p>' + this.alt + '</p>'); 
		}
		
		$('#billboard').cycle({ 
			fx:    'uncover',
			timeout: 6000,
			after:   onAfter, 
			pause:  1 
		});
});

// INFO ENTRY AJAX SCRIPT
$(document).ready(function() {

	$("#newletter").submit(function() {
	
		//remove all the class add the messagebox classes and start fading
		$("#msgbox").removeClass().addClass('messagebox').text('Validating....').fadeIn(1000);
		//check the username exists or not via ajax
		$.post("signup-submit.php",{ name:$('#name').val(),company:$('#company').val(),email:$('#email').val(),phone:$('#phone').val(),comments:$('#comments').val(),rand:Math.random() } ,function(data) {
			
			//IF CORRECT INFO SUBMITTED
			if(data=='1') {
				//start fading the messagebox
				$("#msgbox").fadeTo(200,0.1,function()	{
					//add message and change the class of the box and start fading
					$(this).html('Your information has been sent...').addClass('messageboxok').fadeTo(900,1,
					function() {
						//redirect to home
						document.location='/';
					});
				});
			}
			
			//IF EMAIL ALREADY EXISTS
			if(data=='2') {
				//start fading the messagebox
				$("#msgbox").fadeTo(200,0.1,function() {
					//add message and change the class of the box and start fading
					$(this).html('Your e-mail is already in our database...').addClass('messageboxerror').fadeTo(900,1);
				});
			}
			
			//IF BLANK FIELDS
			if(data=='3') {
				//start fading the messagebox
				$("#msgbox").fadeTo(200,0.1,function() {
					//add message and change the class of the box and start fading
					$(this).html('All fields are required for submission').addClass('messageboxerror').fadeTo(900,1);
				});
			}
	
		});
		return false; //not to post the form physically
	});
});		

