$(document).ready(function(){
	//$('#thumbbox a').lightBox();
	$('#thumbbox a, .lseFixLst, .lseRewCrd').lightBox();
	
	if($('#promotion').length>0){
	$(window).bind("resize",function(){
		$('.pgecontainer').pgeConCen();					   
	});
	$(window).bind("load",function(){
			$('#promotion').PgeMask(function(){
			$('.pgecontainer img, .pgewrapper .pgemask').click(function(){
				$(this).PgeUnloadmask();					
			});				
		});
	});
	}
	
	$('.nextfixture .trans').animate({opacity:.9},{duration:10,queue:false});
	
	$(window).bind("load",function(){
            
		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 Barley Mow";
					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;
			});

		}
		
		
		
		/*
		$('.nextfixture .content').html("<h2>Next live fixture</h2><p>Refreshing...</p>");
		 $.ajax({
		   type: "POST",
		   url: "media/scripts/fixture.php",
		   data: "func=refix",
		   success: function(data){
			 $('.nextfixture .content').html(data);
		   }
		 });
		 */
	});
});