var email;
$(document).ready(function(){
	
	/*if($('#baf').length){
		$('#baf').submit(function(){
			window.location = "offers.htm#" + $('#baf input[type=text]').val();
			return false;
		});
	} */ 
	
	
	/*
	CHKEML
*/
(function(a){a.fn.checkEmail=function(){var b;this.each(function(){var c=a(this).val();b=c.indexOf("@")==-1||c.lastIndexOf(".")==-1?false:true});return b}})(jQuery);

$('#baf_return').hide();
	$('#baf').submit(function(){
		chkeml = $('#baf_eml').checkEmail();
		if(chkeml)
		{
			$.ajax({
				type: "POST",
				url:"media/baf/process.php",
				data: "emailadd=" + $('#baf_eml').val(),
				success: function(data){
					$('#baf_return').html(data).fadeIn();
					$('#baf_eml').val("");
				}
			});
		}
		else
		{
			$('#baf_return').html("Please enter a valid email address.").fadeIn();
		}
		return false;
	});		
	
	/* INPUT CLEAR */
	
	$(window).bind("load", function(){
			//clear form inputs (add & uses rel attributes for comparison)
			$('.inputClear').focus(function(){
				if(!$(this).attr('rel')) {
					$(this).attr('rel',$(this).val()).val('');
				} else {
					if($(this).val()==$(this).attr('rel')) $(this).val('');
				}
			}).blur(function(){
			   if($(this).val()=="") $(this).val($(this).attr('rel'));
			});
});
	
	
	

/*
	SITE FUNCTIONS
*/
		
	$('#offerfocus div') 
	.after('<div id="offer_nav">') 
	.cycle({ 
		fx:     'fade', 
		speed:  'slow', 
		timeout: 5000, 
		pager:  '#offer_nav' 
	});
	
	$('#whatson').cycle({ 
		fx:     'fade', 
		speed:  'slow', 
		timeout: 5000
	});
	
	//GALLERY
	
	$('.gallery a, a.fb').fancybox({
		overlayOpacity:0.8,
		overlayColor:'#000',
		showNavArrows:true
	});
	
	//CARLS ACCORDION BOSS
	
	$('.acc_content').each(function(){
		$(this).attr('rel', $(this).height()).css('height', 0);
	});
	
	$('.acc_head').click(function(){
		next = $(this).next();
		var status = $(this).children('.acc_status');
		if(next.height() == next.attr('rel'))
		{
			next.animate({height: 0});
			status.text('Show').addClass('show').removeClass('hide');
		} else {
			next.animate({height: next.attr('rel')});
			status.text('Hide').addClass('hide').removeClass('show');
		}
	});
	
	
});
