var projekte = ['welcome', 'durchblicker', 'sessions', 'gps', 'vino55', 'epos4', 'basic', 'pizza'];
var current = 0;

var Content = {};

Content.welcome = [document.getElementById('topleft').innerHTML];
Content.durchblicker = ['<h3>durchblicker.at</h3><p>Derzeitige Hauptarbeit als Front-End Entwickler und zuständig für Conversion-Testing und Optimierung.</p>Link: <a href="https://durchblicker.at" target="_blank">durchblicker.at</a>', 'HTML5, CSS3, Memcached, CouchDB, NGINX, Node.JS'];
Content.sessions = ['<h3>The SAE Sessions</h3><p>Hoch-Experimentelles Fachbereich-übergreifendes Projekt im Zuge des SAE Bachelor Studiums.</p>Link: <a href="http://sessions.sae.at" target="_blank">sessions.sae.at</a>', 'HTML5, CSS3, jQuery, Canvas, WebM, Modernizr'];
Content.gps = ['<h3>GPS Geschichte</h3><p>Geschichte über GPS. Projekt im Zuge des SAE Bachelor Studiums.</p>Link: <a href="https://tiefenb.com/gps" target="_blank">tiefenb.com/gps</a>','jQuery, jQuery Templating, HTML5, CSS3, SessionStore, Google Maps API, Hyphenator, massiv JS'];
Content.epos4 = ['<h3>EPOS4 events</h3><p>Screendesign für Microsite von EPOS4 Community</p>Link: <a href="https://www.epos4.at" target="_blank">epos4.at</a>','Adobe Photoshop'];
Content.basic = ['<h3>BASIC Motors</h3><p>Abschlussprojekt des SAE-Diplom-Kurs.</p>Link: <a href="https://tiefenb.com/basic" target="_blank">tiefenb.com/basic</a>','jQuery, Flash, ActionScript, Maya, HTML, CSS, JavaScript, PHP, Twitter API, Facebook API'];
Content.pizza = ['<h3>Hot n Fresh</h3><p>Zwischenprojekt des SAE-Diplom-Kurs.</p>Link: <a href="https://tiefenb.com/pizza" target="_blank">tiefenb.com/pizza</a>','HTML, CSS, PHP, JavaScript, Twitter API, Google Latitude/Maps API'];
Content.vino55 = ['<h3>Weinbar v1no55</h3><p>Website für die Weinbar v1no55 in Wien.</p>Link: <a href="https://www.v1no55.at" target="_blank">v1no55.at</a>','HTML, CSS, PHP, jQuery, OpenLayers, Facebook API'];

function GetRandom( min, max ) {
	if( min > max ) {
		return( -1 );
	}
	if( min == max ) {
		return( min );
	}
 
        return( min + parseInt( Math.random() * ( max-min+1 ) ) );
}

var Nav = {};
Nav.change = function(site) {
	if(site === 'welcome') {
		lifestream();
		setFlickr();
		$('body').removeClass('projekt');
		$('#topleft').unbind('click').html(Content[site][0]);
	} else {
		$('body').addClass('projekt');
		$('#topleft').bind('click', function() { current=0; document.body.className = "welcome"; Nav.change('welcome'); }).html('Home');
	}
	window.setTimeout(function() {
		$('#bottomleft').html(Content[site][0] +'<br/><h4>Techniken</h4>'+  Content[site][1]);
	},300);
};
Nav.next = function() {
	if(current === (projekte.length-1)) {
		document.body.className = projekte[0];
		current = 0;
	} else {
		document.body.className = projekte[current+1];
		current++;
	}
	Nav.change(projekte[current]);
};
Nav.prev = function() {
	if(current === 0) {
		document.body.className = projekte[projekte.length-1];
		current = projekte.length-1;
	} else {
		document.body.className = projekte[current-1];
		current--;
	}
	Nav.change(projekte[current]);
};

$('#next').click(function() {	
	Nav.next();
});

$('#prev').click(function() {	
	Nav.prev();
});
$(document).bind('keydown', 'right', Nav.next);
$(document).bind('keydown', 'left', Nav.prev);


function lifestream() {
	$("#bottomleft").lifestream({
	      limit: 20,
	      list:[
	        {
	          service: "flickr",
	          user: "55282970@N00"
	        }, 
	        {
	          service: "github",
	          user: "tiefenb"
	        },
	        {
	          service: "lastfm",
	          user: "xtrusion"
	        }, 
	        {
	          service: "twitter",
	          user: "tiefenb"
	        },
	        {
	          service: "youtube",
	          user: "xtrusion"
	        },
			/*{
				service: 'googlereader',
				user: '02023310107744319986'
			}*/
	      ]
	});
}

var Flickr = [];
$.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?",
	{
		id: "55282970@N00",
	    format: "json"
	},
	function(data){
	$.each(data.items, function(i,item){
		Flickr.push(item.media.m);
	});
});

function setFlickr() {
	var element = Flickr[GetRandom(0,Flickr.length-1)];
	element = element.replace("_m","_b","gi");
	$('div.welcome.bg').css('background-image','url('+element+')');
}

window.setTimeout(function(){
	setFlickr();
},1000);





