
// set for how long to hold slide before switching
var seconds_to_display = 15;


var image_left_1="recipes_left.png";
var image_right_1="recipes_right.png";
var image_link_1="store/";

var image_left_2="jazz_left.png";
var image_right_2="jazz_right.png";
var image_link_2="";


var image_left_3="brunch_left.png";
var image_right_3="brunch_right.png";
var image_link_3="saturday-brunch-menu";




var total_images=3;
var current_image= 1;




window.onload = function(){
	new Effect.Morph('header', {
	  style: 'height:554px;', // CSS Properties
	  duration: .5, // Core Effect properties
	  transition: Effect.Transitions.EaseTo,
	  queue: 'front'
	});
	for (var x=1;x<=total_images;x++)
	{
		image_left=eval('image_left_'+x);
		image_right=eval('image_right_'+x);
		
		var i1='<img id="ileft_'+x+'" src="/images/promos/'+image_left+'" alt="" />';
		var i2='<img id="iright_'+x+'" src="/images/promos/'+image_right+'" alt="" />';
		
		
		$('image_cache').insert(
			{'bottom' : i1 }
		);
		$('image_cache').insert(
			{'bottom' : i2 }
		);
	}
			setTimeout("start_anim()",1000);

}
window.onload2 = function(){
	

}
function start_anim(){
	
	image_left=$('ileft_'+current_image).src;
	image_right=$('iright_'+current_image).src;
	
	
	var chicken_people='<img onclick="" id="header_left_image"  src="'+image_left+'" alt="" />';
	var chicken_text='<img onclick="" id="header_right_image" src="'+image_right+'" alt="" />';
	
	var insert_stuff='<div id="insert_stuff"><a href="" id="promo_link">'+chicken_people+chicken_text+'</a></div>'
	$('header').insert(
		{'bottom' : insert_stuff}
	);
	
	show_image();
	
}
function show_image(){

	

	
	image_link=eval('image_link_'+current_image);
	
	if(image_link !=''){
		$('promo_link').href=image_link;
		$('promo_link').setStyle({
			cursor: 'pointer'
		});
	}else{
		$('promo_link').href='javascript:;';
		$('promo_link').setStyle({
			cursor: 'default'
		});
		
	}
	
	new Effect.Morph('header_left_image', {
	  style: 'top:0px', // CSS Properties
	  duration: .8, // Core Effect properties
	  transition: Effect.Transitions.BouncePast,
	  queue: 'end'
	});
	new Effect.Morph('header_right_image', {
	  style: 'top:0px', // CSS Properties
	  duration: .8, // Core Effect properties
	  transition: Effect.Transitions.Bounce,
	  queue: 'end'
	  
	});
	
		
	setTimeout("remove_image()",seconds_to_display*1000)


}

function remove_image(){
	
	//slide out current images 
	
	
	new Effect.Morph('header_left_image', {
	  style: 'top:545px', // CSS Properties
	  duration: .5
	 
	});
	new Effect.Morph('header_right_image', {
	  style: 'top:545px', // CSS Properties
	  duration: .5
	 });
	setTimeout("next_image()",1000);
	
}
function next_image(){
	reset_em();
	
	
	//switch to new images
	current_image++;
	if(current_image > total_images){current_image=1;}
	image_left=$('ileft_'+current_image).src;
	image_right=$('iright_'+current_image).src;
	
	$('header_left_image').src=image_left;
	$('header_right_image').src=image_right;
	//$('header_left_image').onclick='document.location="'+image_link+'"';
	//$('header_right_image').onclick='document.location="'+image_link+'"';
	
	show_image();
	

}
function reset_em(){

	

	$('header_right_image').style.top='-555px';
	
	$('header_left_image').style.top='545px';	
	
	$('header_left_image').src='';
	$('header_right_image').src='';

}

Effect.Transitions.Bounce = function(pos) {
if (pos < (1/2.75)) {
return (7.5625*pos*pos);
} else if (pos < (2/2.75)) {
return (7.5625*(pos-=(1.5/2.75))*pos + .75);
} else if (pos < (2.5/2.75)) {
return (7.5625*(pos-=(2.25/2.75))*pos + .9375);
} else {
return (7.5625*(pos-=(2.625/2.75))*pos + .984375);
}
};
Effect.Transitions.BouncePast = function(pos) {
if (pos < (1/2.75)) {
return (7.5625*pos*pos);
} else if (pos < (2/2.75)) {
return 2 - (7.5625*(pos-=(1.5/2.75))*pos + .75);
} else if (pos < (2.5/2.75)) {
return 2 - (7.5625*(pos-=(2.25/2.75))*pos + .9375);
} else {
return 2 - (7.5625*(pos-=(2.625/2.75))*pos + .984375);
}
};
Effect.Transitions.EaseTo = function(pos) {
return Math.pow(pos,0.3);
};
