// page fade in part one
$('html').animate({opacity: 0.0}, 0);

// when dom is ready
$(document).ready(function() {
	
	// ajax navigation
	ajaxNav();
	
	// pade fade in part two
	$('html').animate({opacity: 1.0}, 500);

});

// ajax navigation
function ajaxNav() {
	
	// change nav links
	ajaxNavMakeLinks();
	
	// init bbq
	ajaxNavInitBbq();
	
}

// ajax navigation
function ajaxNavMakeLinks() {
	
	// change main title link
	$('.header a').attr('href', '#index');
	
	// go through nav links
	$('.nav a').each(function () {
		
		// create tmp variable for site type
		var tmpLink = $(this).html();
		
		// home = index
		if (tmpLink == 'home') {tmpLink = 'index'}
		
		// make new links
		$(this).attr('href', '#' + tmpLink);
		
	});

}

// init bbq
function ajaxNavInitBbq() {
	
	$(window).bind('hashchange', function(e) {
		
		// fade out content
		$('.content').animate({opacity: 0.0}, 125, function() {
			
			// variable for current hash
			var currentSite = $.param.fragment();
			
			// load new content
			$('#wrap .content').load(currentSite + '.html #wrap .content .inner', function() {
				
				// change body id to current site type
				$('body').attr('id', currentSite || 'index');
				
				// if its the work site, load tooltips
				if ($('body#work').length != 0) {
					ttipCreation();
				}
				
				// if its the tweets site, load twitter javascript files
				if ($('body#tweets').length != 0) {
					$.getScript('http://twitter.com/javascripts/blogger.js');
					$.getScript('http://twitter.com/statuses/user_timeline/hyaho_dot_ch.json?callback=twitterCallback2&count=7');
				}
				
				// fade new content in
				$('.content').animate({opacity: 1.0}, 125);
				
			});
			
		});
		
	});
	
}

// create the work tooltips
function ttipCreation() {

	var ttipContent1 = '<p class="worktitle">visualpun.ch</p><p>drupal based portfolio blog</p><p>php/mysql, drupal theming, cms programming, html/css/js implementation</p><p>2009</p>'
	$('.article .workbox.one').qtip({content: ttipContent1, position: {target: 'mouse'}, show: {delay: 140, effect: {length: 125}}});
	
	var ttipContent2 = '<p class="worktitle">wma-transport.ch</p><p>fluxcms based company website</p><p>html/css/js implementation</p><p>2009 with L//P team during internship</p>'
	$('.article .workbox.two').qtip({content: ttipContent2, position: {target: 'mouse'}, show: {delay: 140, effect: {length: 125}}});
	
	var ttipContent3 = '<p class="worktitle">senn-transport.ch</p><p>fluxcms based company website</p><p>html/css/js implementation</p><p>2009 with L//P team during internship</p>'
	$('.article .workbox.three').qtip({content: ttipContent3, position: {target: 'mouse'}, show: {delay: 140, effect: {length: 125}}});
	
	var ttipContent4 = '<p class="worktitle">buhlmannlabs.ch</p><p>fluxcms based company website</p><p>html/css/js implementation</p><p>2009 with L//P team during internship</p>'
	$('.article .workbox.four').qtip({content: ttipContent4, position: {target: 'mouse'}, show: {delay: 140, effect: {length: 125}}});
	
	var ttipContent5 = '<p class="worktitle">infoclio.ch</p><p>drupal based organization website</p><p>php/mysql, drupal theming, cms programming, html/css/js implementation</p><p>2009 with L//P team during internship</p>'
	$('.article .workbox.five').qtip({content: ttipContent5, position: {target: 'mouse'}, show: {delay: 140, effect: {length: 125}}});
	
	var ttipContent6 = '<p class="worktitle">download-schnitzer.ch</p><p>band music download site</p><p>php/mysql, html/css/js implementation</p><p>2009</p>'
	$('.article .workbox.six').qtip({content: ttipContent6, position: {target: 'mouse'}, show: {delay: 140, effect: {length: 125}}});
	
	var ttipContent7 = '<p class="worktitle">luminaris.ch</p><p>drupal based corporate website</p><p>web design, php/mysql, drupal theming, cms programming, html/css/js implementation</p><p>2011</p>'
	$('.article .workbox.seven').qtip({content: ttipContent7, position: {target: 'mouse'}, show: {delay: 140, effect: {length: 125}}});
	
	var ttipContent8 = '<p class="worktitle">mindband.ch</p><p>drupal based corporate website</p><p>corporate identity design, web design, php/mysql, drupal theming, cms programming, html/css/js implementation</p><p>2011</p>'
	$('.article .workbox.eight').qtip({content: ttipContent8, position: {target: 'mouse'}, show: {delay: 140, effect: {length: 125}}});
	
	var ttipContent9 = '<p class="worktitle">aquaboot.com</p><p>drupal based corporate website</p><p>flash port to open standards, php/mysql, drupal theming, cms programming, online shop, html/css/js implementation</p><p>2011</p>'
	$('.article .workbox.nine').qtip({content: ttipContent9, position: {target: 'mouse'}, show: {delay: 140, effect: {length: 125}}});
	
	var ttipContent10 = '<p class="worktitle">geistundbauch.ch</p><p>drupal based private website</p><p>php/mysql, drupal theming, cms programming, html/css/js implementation</p><p>2012</p>'
	$('.article .workbox.ten').qtip({content: ttipContent10, position: {target: 'mouse'}, show: {delay: 140, effect: {length: 125}}});

}
