/**
 * Project: Outdoor Illumination theme 
 * Version: 1
 */

jQuery(document).ready(function() {

	// load and run Galleria if found. Theme loaded in head/css includes.
	//Galleria.loadTheme('http://static.quillaja.net/galleria/themes/classic/galleria.classic.min.js');
	jQuery("#galleria").galleria({
        //width: 900,
        height: 700,
        transition: 'fade',
        transitionSpeed: 800
    });

	// show 'help' messages for 5s then fade and remove
	jQuery('.project-grid-table').before('<p class="page-help">Please move your mouse over the images to view content.</p>');
	jQuery('dl.word-cloud').before('<p class="page-help">Please move your mouse over the words to view details.</p>');
	jQuery('.page-help').delay(5000).fadeOut( function() {
		jQuery(this).remove();
	});
	
	// create the word-cloud effect desired in 'why choose us'
	jQuery('dl.word-cloud').after('<div class="word-cloud-textdisplay"></div>');
	jQuery('dl.word-cloud dt').mouseenter( function() {
		var details = '#' + this.id + 't';
		jQuery('div.word-cloud-textdisplay')
			.html(jQuery('dl.word-cloud ' + details).html())
			.fadeIn('fast');
	});
	
	//make social media buttons appear when the window is scrolled
	var isScrolling = false;
	jQuery(window).scroll( function() {
		if(!isScrolling) {
			isScrolling = true;
			jQuery('.social-media').fadeIn().delay(5000).fadeOut('slow', function() {
				isScrolling = false;
			});
		}
	}).scroll();
	
	
	// ajax contact form
	jQuery('#contact-form').submit( function(event) {
	
		// stop form from submitting normally
		event.preventDefault(); 
		
		// get some values from elements on the page: 
		var form = jQuery( this ),
			url = form.attr('action'),
			title = form.find('select[name="Title"]').val(),
			firstname = form.find('input[name="FirstName"]').val(),
			lastname = form.find('input[name="LastName"]').val(),
			email = form.find('input[name="EmailAddress"]').val(),
			homephone = form.find('input[name="HomePhone"]').val(),
			cellphone = form.find('input[name="CellPhone"]').val(),
			prefmethod = form.find('input[name="PrefMethod"]').val(),
			comments = form.find('textarea[name="Comments"]').val(),
			howfound = form.find('select[name="HowFound"]').val();
			
		var formdata = {
			Title: title,
			FirstName: firstname,
			LastName: lastname,
			EmailAddress: email,
			HomePhone: homephone,
			CellPhone: cellphone,
			PrefMethod: prefmethod,
			Comments: comments,
			HowFound: howfound,
			Ajax: true,
			Status: 'live',
			Submit: true
		};
		
		// Send the data using post and put the results in a div
		jQuery.post( url, formdata, function( data ) {
			jQuery('div.form-feedback').html( data );
		});
	});

});
