$(function() {
	
		/* LAVALAMP MENU */
	$("#lavalamp").lavaLamp({
		fx: "linear",
		speed: 300,
		click: function(event, menuItem) {
			return true;
     		}
  		});
	});
	
	
	/* Fancy Box */
	$(document).ready(function() {
		$("p.fancy a").fancybox();
	});
	
	/* Table Soter */
	$(document).ready(function() { 
    // call the tablesorter plugin 
    $("table").tablesorter({ 
        // sort on the first column and third column, order asc 
        sortList: [[0,0],[2,0]] 
  	  }); 
	}); 
	
	/* Email script */
	
	$(function() {
    // These first three lines of code compensate for Javascript being turned on and off. 
    // It simply changes the submit input field from a type of "submit" to a type of "button".

    var paraTag = $('input#submit').parent('span');
    $(paraTag).children('input').remove();
    $(paraTag).append('<input class="button" type="button" name="submit" id="submit" value="Submit" />');

    $('#form_fields input#submit').click(function() {
        $('#form_fields').append('<img src="images/ajax-loader.gif" class="loaderIcon" alt="Loading..." />');

        var name 			= $('input#name').val();
        var email 			= $('input#email').val();
		var subject 		= $('input#subject').val();
        var message 		= $('textarea#message').val();
		var verification 	= $('input#verification').val();
		var string 			= $('input#string').val();

        $.ajax({
            type: 'post',
            url: 'php/sendEmail.php',
            data: 'name=' + name + '&email=' + email + '&subject=' + subject + '&message=' + message + '&verification=' + verification  + '&string=' + string,

            success: function(results) {
                $('#form_fields img.loaderIcon').fadeOut(1000);
                $('ul#response').html(results);

				if ( $("li.email_succes").length > 0 ) {
					$('input#name').attr({ value: '' });
					$('input#email').attr({ value: '' }); 
					$('input#subject').attr({ value: '' }); 
					$('textarea#message').attr({ value: '' }); 
					$('input#verification').attr({ value: '' }); 
					$('#form_fields').fadeOut(1000);
					}
            	}
        	}); // end ajax
    	});
	});
