var rotate 			 = true;
var init				 = true;
var work_list 	 = [];
var work_details = {
	'bounce': 
	{ title:'Bounce', 
		desc:'Bounce needed to get their voice out into the world. We helped them do it with a new site and custom content management system.', 
		link:'http://wecanbounce.com'
	},
	'hannah': 
	{ title:'Hannah Keeley', 
		desc:'Hannah needed help getting results. We helped her do it with a fully custom application including e-commerce and social media integration.', 
		link:'http://hannahkeeley.com'
	},
	'ardentech':
	{ title:'Arden Technologies', 
		desc:'Arden Technologies needed a modern look to help sell software. We helped them do it with a refreshed look, and a more sales oriented design.', 
		link:'http://ardentech.com'
	},
	'guyslist':
	{ title:'GuysList', 
		desc:'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt.', 
		link:'http://guyslist.com'
	}
};

var cycle_options = {
	timeout:8000,
	speed:500,
	before:background_out,
	after:background_in,
	cleartypeNoBg:true
}

$(document).ready(function(){
	
	$('span.e-addy').each(function(e){
		$(this).wrap('<a class="mail_link" href="mailto:'+ $(this).text().split('').reverse().join('') +'"></a>')
	});
	
	create_list();
	$('#work').cycle(cycle_options);
	
	$('#recent_work a').click(function(e){
		e.preventDefault();
		var itm  = $(this).attr('href').replace('#','');
		var indx = work_list.indexOf(itm);
		$('#work').cycle(indx);
	});
	
});

function create_list(){
	$('#recent_work li').each(function(){
		var item = $(this).find('a').attr('href').replace('#','');
		work_list.push(item)
	});
	
	$('#work').empty();
	for(var i = 0; i < work_list.length; i++){
		var div  = $('<div class="info '+ work_list[i] +'" />').css('background-position', "0px 300px");
//	var head = $('<h2 />').text(work_details[work_list[i]].title);
		var lnk	 = $('<a href="'+ work_details[work_list[i]].link +'" />').html('&raquo; Visit Site');
		var txt  = $('<p />').html(work_details[work_list[i]].desc + "<br /><br />").append(lnk);
//	$(div).append(head).append(txt);
		$(div).append(txt);
		$('#work').append(div);
	}
	
}

function background_in(currSlideElement, nextSlideElement, options, forwardFlag){
	$('div.' + work_list[options.currSlide]).animate({backgroundPosition: '0px 50px'}, 500);
	$('#recent_work li.on').removeClass('on');
	$('#recent_work li:nth-child(' + (options.currSlide + 1) + ')').addClass('on');
}

function background_out(currSlideElement, nextSlideElement, options, forwardFlag){
	$('div.' + work_list[options.currSlide]).animate({backgroundPosition: '0px 300px'}, 500);
}
