//VARIABLES

var mCtimout=6000;
var mCanispeed=1000;
var Mci=0;




$(document).ready(function(){

	//rel link

	$('a').click(function(){
		thisLink=$(this).attr('href');
		thisRel=$(this).attr('rel');
		if(thisLink!="" && thisLink!=" " && thisLink!="#")
		{
			if(thisRel=="nw"){window.open(thisLink);}
			else{window.location=thisLink;}
		}
		return false;
	});
						   
	$('#images').show();
	
	//blockquote handler
	
	if($('blockquote').length > 0) {
		
		
		var bq_array = new Array();
		
		$('blockquote')
		.each(function(i){
			bq_array[i] = $(this).height();	   
		})
		.animate({
			height: 35
		})
		.children('p').hide();
		
		$('blockquote').click(function(){
			$('blockquote').animate({
			height: 35
		},{queue: false})
		.children('p').fadeOut();
		
		bq_ind = $('blockquote').index($(this));
		
		$(this).animate({
			height: bq_array[bq_ind]
		},{queue: false}).children('p').fadeIn();
		
		});
		
	}
	
	
	//mycycle
	$('#images div').children('img').hide().eq(0).show();
	$(window).bind("load",function(){
		$('#images div').MyCycle();
		$('#bafC').baf({
			desc: "enter your email to receive news and special offers, and be entered into our free prize draw for a meal for 2 people"
		});
	});
	
	
	//showhide link
	$('#showhide').click(function(){
		$(this).hide();
		current = $(this).html();

		if (current == "show text") {
			$('#showhide').css('background-image', 'url(media/layout/hidearrow.gif)');
			$('#content').animate({
				height: fullheight,
				paddingTop: 20,
				paddingBottom: 20,
				top: 25				
			},500, 'linear',function(){ $('#showhide').show(); });
			
			$(this).html("hide text");

			
		} else {
			fullheight = $('#content').height();
			$('#showhide').css('background-image', 'url(media/layout/showarrow.gif)');
			$('#content').animate({
				height: 0,
				paddingTop: 0,
				paddingBottom: 0,
				top: 0
			},500, 'linear',function(){ $('#showhide').show(); });
			
			$(this).html("show text");

		}
		return false;
	});
	


	
	
});




//FUNCTIONS

$(function(){
	$.fn.MyCycle = function(){
		imgcount=$(this).children('img').size()-1;
		if(Mci==imgcount)
		{
			mCanimate(Mci,0,$(this));
			Mci=0;
		}
		else
		{
			mCanimate(Mci,Mci+1,$(this));
			Mci++;
		}
	};
})

function mCanimate(mCout, mCin, mCelement)
{
	mCelement.animate({
		opacity:1				  
	},mCtimout,function(){
		$(this).children('img').eq(mCout).fadeOut(mCanispeed);
		$(this).children('img').eq(mCin).fadeIn(mCanispeed);
		mCelement.MyCycle();
	});
}
function CheckEmail(inputemail) {
	AtPos = inputemail.indexOf("@");
	StopPos = inputemail.lastIndexOf(".");

	if (AtPos == -1 || StopPos == -1)
	{
		return false;
	}
	else
	{
		return true;	
	}
}