			$(document).ready(function() {
				var txt = navigator.userAgent;
				var browserIE7 = txt.match(/MSIE 7/);
				var afterImage = $('#project_images img.after.proj_1').attr('src');
				var beforeImage = $('#project_images img.before.proj_1').attr('src');
				var afterCaption = $('#project_images img.after.proj_1').attr('rel');
				var beforeCaption = $('#project_images img.before.proj_1').attr('rel');
				$('#proj_rightcol #proj_image').attr('src', afterImage);
				$('#proj_rightcol #proj_photoby').html(afterCaption);
				
				$('a[rel*=facebox]').facebox();
                
				$('#proj_rollover_square, #proj_rollover_horiz, #proj_rollover_vert').mouseenter(function() {
					$('#proj_rightcol #proj_image').attr('src', beforeImage);
                    $('#proj_rightcol #proj_photoby').toggle();		
				});
				$('#proj_rollover_square, #proj_rollover_horiz, #proj_rollover_vert').mouseleave(function() {
					$('#proj_rightcol #proj_image').attr('src', afterImage);
					$('#proj_rightcol #proj_photoby').toggle();
					if(browserIE7 == 'MSIE 7') {
						$('#proj_rightcol #proj_photoby').css('bottom', '30px');						
					}
				});
			});
            
            function validate_form() {
                var params = '';

               // validate fields
               var errorFlag = 0;
               if($('#facebox input[name=fname]').val() == '' | $('#facebox input[name=lname]').val() == '' ) {
                    $('#facebox #errorName').show();
                    errorFlag = 1;
               } else {
                     $('#facebox #errorName').hide();               
               }
               var x = $('#facebox input[name=from_email]').val();
               var atpos=x.indexOf("@");
               var dotpos=x.lastIndexOf(".");
               if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length) {
                    $('#facebox #errorEmail').show();
                    errorFlag = 1;
               } else {
                  $('#facebox #errorEmail').hide();
               }
               if(errorFlag == 1) {
                    alert('Please correct the indicated errors!');
                    return false;
               }

               
               // get fields for AJAX call
               $('#facebox input[type!=radio]').each(function() {
                    params += $(this).attr('name')+'='+$(this).val()+'&';                  
                });
               $('#facebox input[type=radio]:checked').each(function() {
                    params += $(this).attr('name')+'='+$(this).val()+'&';                  
                });                 
                $('#facebox textarea').each(function() {
                    params += $(this).attr('name')+'='+$(this).val()+'&';
                }); 
                $('#facebox select').each(function() {
                    params += $(this).attr('name')+'='+$(this).children('option:selected').val()+'&';
                });
                params = params.slice(0, -1);
                $.ajax({
                    type: "POST",
                    url: "/index.php/site/contact",
                    data: params,
                    success: function(html) {
                        console.log(html);
                    }
                });           
                
				$.facebox({ajax: '/index.php/site/partial/view/_email_thanks'});
				return false;
			}
