$(document).ready(function() { 

	var back = ['backEaseIn', 'backEaseOut', 'backEaseInOut'];
	var bounce = ['bounceEaseIn', 'bounceEaseOut'];
	var circ = ['circEaseIn', 'circEaseOut', 'circEaseInOut'];
	var cubic = ['cubicEaseIn', 'cubicEaseOut', 'cubicEaseInOut'];
	var elastic = ['elasticEaseIn', 'elasticEaseOut'];
	var expo = ['expoEaseIn', 'expoEaseOut', 'expoEaseInOut'];
	var quad = ['quadEaseIn', 'quadEaseOut', 'quadEaseInOut'];
	var quart = ['quartEaseIn', 'quartEaseOut', 'quartEaseInOut'];
	var quint = ['quintEaseIn', 'quintEaseOut', 'quintEaseInOut'];
	var sine = ['sineEaseIn', 'sineEaseOut', 'sineEaseInOut'];

	var background_slide_easing = expo[1];
	var drop_easing = bounce[1];
	var drop_position = "0px";
	var rise_easing = expo[1];
	var rise_position = "-100px";
	var second_drop_easing = expo[1];
	var second_drop_position = "0px";
	var second_drop_delay = 4400;
	var rise_out_easing = expo[1];
	var rise_out_position = "-1000px";
	var rise_out_delay = 5900;
	var wilsons_logo = ['#w','#i','#l','#s','#o','#n','#apostrophy','#s_2'];
	var logo_all = ['#w','#i','#l','#s','#o','#n','#apostrophy','#s_2', '#of_redmond'];

	var browserName=navigator.appName; 
//skip the intro if IE... IE breaks... go figure.
	if (browserName=="Microsoft Internet Explorer") { 
		window.location="php/wilsons_home.php";
	};
	
	
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//animation sequence begins///////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	//sofa slides from off screen right to center screen
	backgroundSlider('#intro_container', 500, '1400px 0px', '(100px 0px)', background_slide_easing);
	
	//Wilson's falls onto sofa - - ends @ 1900ms
	for (i = 0, time = 1000; i < wilsons_logo.length; i++, time += 150) {
		var selector = wilsons_logo[i];
		logoAnimater(selector , time, drop_position, drop_easing);
	};
	
	//Wilson's "jumps" off sofa - - ends @ 4000ms
	for (j = wilsons_logo.length, time = 3100; j >= 0 ; j--, time += 100) {
		var selector = wilsons_logo[j];
		logoAnimater(selector , time, rise_position, rise_easing);
	};
	
	//sofa slides to left out of the screen
	backgroundSlider('#intro_container', 4000, '1400px 0px', '(-1400px 0px)', background_slide_easing);
	
	//of redmond img rises to center		
	logoAnimater('#of_redmond', 4200, '10px', rise_easing);	//of redmond img rises to center
	
	//letters begin fall to center
	for (k=0;k<wilsons_logo.length;k++) {
		var selector = wilsons_logo[k];
		logoAnimater(selector , second_drop_delay, second_drop_position, second_drop_easing);
	};
	
	//whole logo slides up out of screen
	for (l=0;l<logo_all.length;l++) {
		var selector = logo_all[l];
		logoAnimater(selector , rise_out_delay, rise_out_position, rise_out_easing);
	};
	
	//since 1962 img rises to center		
	logoAnimater('#since_1962', rise_out_delay, '-110px', rise_out_easing);
	logoAnimater('#since_1962', 7500, '-1200px', rise_out_easing);
	redirect('php/wilsons_home.php', 7700);
});
	
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// this function can animate and slide the background image horizontally /////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
function backgroundSlider(selector, delay, current_position, x_y, easing_type) {
	$(selector).css({backgroundPosition: current_position});
	$(selector).oneTime(delay, "background_move", function(){
		$(selector).animate(
			{backgroundPosition: x_y},
			{queue:false, duration:1500, easing:easing_type}
		);
	});
};
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// moves and animates the logo images - to move up = negative int. / down = positive int./////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
function logoAnimater(selector, delay, move_to_y, easing_type) {
	$(selector).oneTime(delay, "image_move", function(){
		$(selector).animate(
			{top: move_to_y},
			{queue:false, duration:1000, easing:easing_type}
		);
	});
};
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//um... redirects/////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
function redirect(location, delay) {
	$(document).oneTime(delay, "redirect", function(){
		document.location.href = location;
	});
};



