
jQuery.fn.exists = function(){return this.length>0;}

$(function() {
	MM_preloadImages(
		'images/about-rollover.png',
		'images/employ-rollover.png',
		'images/faqs-rollover.png',
		'images/photos-rollover.png',
		'images/contact-rollover.png',
		'images/home-rollover.png',
		'images/dd-greenhouse-link-rollover.png',
		'images/dd-southern-link-rollover.png',
		'images/dd-mill-link-rollover.png'
	);
	
	
	
	
	if ($('#contactForm, #empForm').length > 0) {
		$('#contactForm, #empForm').ajaxForm({
			success: function(data) {
				$('body').append(data);
			}
		});
	}
	
	if ($("#imgCam2").exists()) {
		$('body').append('<a href="photos.php"><img id="photoHover" src="images/photosHover1.png" alt="" /></a>');
		
		function adjPhotoHover() {
		
			for(x = 0; x < 20; x++) {
				setTimeout(function() {
					$("#photoHover").css({
						"position" : "absolute",
						"top" : $("#imgCam2").offset().top + $("#imgCam2").height() - 95,
						"left" : $("#imgCam2").offset().left + 10,
						"z-index" : parseInt($("#imgCam2").css("z-index")) + 1
					});	
				}, 250 * x);
			}			
			
		}
		
		adjPhotoHover();
		
		var origImg = $("#photoHover").attr("src");
		var imgMO = "images/photosHover.png";
			
		$("#photoHover").bind({
			"mouseover" : function() {
				$("#photoHover").attr("src", imgMO);
			},
			"mouseout" : function() {
				$("#photoHover").attr("src", origImg);
			}
		});
		
		
		$(window).resize(function() {
			adjPhotoHover();
		});
		
	}
	
});




