	var options = { 
			insert : '#main_image', 
			history : true,
			onImage   : function(image,caption,thumb) {
				if(! ($.browser.mozilla && navigator.appVersion.indexOf("Win")!=-1) ) { // FF/Win fades large images terribly slow 
					image.css('display','none').fadeIn(1000);
					image.css('height','470').fadeIn(1000);
				}
				thumb.parent().fadeTo(200, 1).siblings().fadeTo(200, 0.4)
				
				$('#main_image')
                .hover(
                    function(){ $('.caption').stop().animate({height: 65}, 250) },
                    function(){ 
                            $('.caption').stop().animate({height: 0}, 250);
                    }
                );
				$('.caption').fadeTo(0, 0.8, function() {
				});
			}
			
	}; 
	
	$(document).ready(function(){ $('ul.gallery').galleria(options); })

	$(document).ready(function() {  
							   
		var options = { 
			beforeSubmit:  validate,  // pre-submit callback 
			success:       showResponse,  // post-submit callback 
			clearForm: true
		}; 
		$('#email-form').submit(function() { 
			$(this).ajaxSubmit(options);
			return false; 
		}); 
		$('#contact-form').submit(function() { 
			$(this).ajaxSubmit(options);
			return false; 
		});
		
		$('#phone-form').submit(function() { 
			$(this).ajaxSubmit(options);
			return false; 
		});
		
		$("img").click(function () {
			var text = $(this).attr("title");
			$("#refinput").val(text);
		});


		
	}); 

	function showResponse(responseText, statusText, xhr, $form)  { 		
		Sexy.error('<h1>Response</h1><p>'+ responseText + '</p>');
	}
	
	function validate(formData, jqForm, options) { 
		for (var i=0; i < formData.length; i++) { 
			if (!formData[i].value) { 
				//alert('Please enter a value for both Username and Password');
				Sexy.error('<h1>Alert</h1><p>All fields must be filled in before the form can be submitted.</p>');
				return false; 
			} 
		}  
	}
		
	$(document).ready(
		function() {
			$("#table1").ingrid({ 
				url: 'remote.php',
				height: 300,
				colWidths: [340,90,90,150],		// width of each column
				resizableCols: false,
				sorting: false,
				totalRecords: 2
			});
		}
	);
