$(document).ready(function(){
	//$('#thumbbox a').lightBox();
	$('#thumbbox a, .lseFixLst, .lseRewCrd').lightBox();	
	
		if($('.bafF').length>0){
			 $.ajax({
			   type: "POST",
			   url: "media/scripts/dte.php",
			   data: "func=returnDate",
			   success: function(data){
				   $('.bafF .bafDab').html(data);
			   }
			 });

			
			$('.bafF h3').click(function(){
				elmObj=$('#bafC')
				bafHe=elmObj.height();
				if(bafHe==33){elmObj.animate({height:200},{duration:300,queue:false});}
				else{elmObj.animate({height:33},{duration:300,queue:false});}
			});
			
			$('.bafF p').formValidate().parent().submit(function(){
				thsForm=$(this).children('p');
				$('.bafF .bafFromReturn').text("Processing...");
				
				if(thsForm.frmSubmit()){
					houseName="The Botanist";
					ecpRes="";
					$('.bafF p').children('input[type="text"]').each(function(){ecpRes=ecpRes+$(this).val()+"{spl}";});
					$('.bafF p').children('select').each(function(){ecpRes=ecpRes+$(this).val()+"{spl}";});
					 ecpRes=ecpRes+houseName;				 
					 
					 $.ajax({
					   type: "POST",
					   url: "media/scripts/baf.php",
					   data: "func=conBaf&dta="+ecpRes,
					   success: function(data){
						   $('.bafF .bafFromReturn').text(data);
						   $('.bafF p').children('input[type="text"]').val("");
						   setTimeout(function(){elmObj.animate({height:33},{duration:300,queue:false});
							$('.bafF .bafFromReturn').text("");},3000);
					   }
					 });
				}
				else{
					$('.bafF .bafFromReturn').text("Please ensure you have filled all mandatory fields.");
				}
				return false;
			});

		}
});