var fullSize		= 635;
var sizeInterval	= 5;
var currSize		= 0;

var currItem		= 1;
var numItems		= 5;

var sizeInterval	= false;


var currWord		= 0;
var words 			= new Array("Beautiful", "Effective", "Innovative", "Memorable", "Compliant", "Modern", "Ingenious", "Original", "Creative", "Compelling", "Alluring", "Appealing", "Dazzling", "Wonderful", "Stunning", "Sublime", "Impressive", "Striking", "Top-Notch", "Still?", "Terrific", "Fresh", "Stylish", "Cool", "Inspired", "Done Now?", "I Am!");
var numWords		= words.length;

function nextWord() {
	if(currWord >= numWords-1) {
		currWord = 0;
	} else {
		currWord++;
	}
	
	$('#word').html(words[currWord]);
}


function portfolioItem(n, l) {
	this.name	= n;
	this.link 	= l;
}


var portfolioItems = new Array();
portfolioItems[0]	= new portfolioItem('Jumper\'s Junction (with VisuGroup)', 'jumpers-junction');
portfolioItems[1]	= new portfolioItem('Behavioral Dynamics, Inc. (with VisuGroup)', 'bdi');
portfolioItems[2]	= new portfolioItem('McKean Plumbing', 'mckean');
portfolioItems[3]	= new portfolioItem('The Insider on Pittsburgh Sports', 'tiops');
portfolioItems[4]	= new portfolioItem('Pathways of Southwestern Pennsylvania', 'pathways');
portfolioItems[5]	= new portfolioItem('Sandman-Up', 'sandman-up');

function updateTimer() {
	if(currSize < fullSize) {
		currSize += 5;
		$('#indicator').css('width', currSize);
	
	} else {
		clearInterval(sizeInterval);
		nextItem();
	}
}

function nextItem() {
	$('#item'+currItem).attr('src', 'http://vernerwebstudio.com/wp-content/themes/vws2011/images/ico-progress-off.gif');
	$('#indicator').css('width', 0);
	currSize = 0;
	
	if(currItem < numItems) {
		currItem++
	} else {
		currItem = 1;
	}
	
	changeItem(currItem);
	sizeInterval = setInterval('updateTimer()', 50);
	$('#slideshow-img').cycle('next');
	
	changeItemInfo(currItem-1)
}

function changeItem(itemno) {
	$('#item'+itemno).attr('src', 'http://vernerwebstudio.com/wp-content/themes/vws2011/images/ico-progress-on.gif');
}

function clickItem(itemno) {
	$('#indicator').css('width', 0);
	clearInterval(sizeInterval);
	$('#item'+currItem).attr('src', 'http://vernerwebstudio.com/wp-content/themes/vws2011/images/ico-progress-off.gif');
	
	currItem = itemno;
	$('#item'+currItem).attr('src', 'http://vernerwebstudio.com/wp-content/themes/vws2011/images/ico-progress-on.gif');
	
	$('#slideshow-img').cycle(itemno-1);
	changeItemInfo(itemno-1);
	
	return false;
}

function changeItemInfo(x) {
	$('#slideshow .controller p strong').html(portfolioItems[x].name);
	$('#slideshow .controller a').attr('href', '/portfolio/'+portfolioItems[x].link+'/');
}


$(document).ready(function(){
	var username	= 'vernerwebstudio'; 
	var format		= 'json';
	var url			= 'http://api.twitter.com/1/statuses/user_timeline/'+username+'.'+format+'?callback=?';
	
	$.getJSON(url,function(tweet){
		$("#tweet").html(tweet[0].text);
	});

	sizeInterval = setInterval('updateTimer()', 50);
	
	$('#slideshow-img').cycle({
		fx: 'fade',
		timeout: 0
	});
	
	changeItemInfo(0);
});
