/*
 * jQuery Easing Plugin
 *
 * website:			http://gsgd.co.uk/sandbox/jquery/easing/
*/
jQuery.easing['jswing']=jQuery.easing['swing'];jQuery.extend(jQuery.easing,{def:'easeOutQuad',swing:function(x,t,b,c,d){return jQuery.easing[jQuery.easing.def](x,t,b,c,d)},easeInQuad:function(x,t,b,c,d){return c*(t/=d)*t+b},easeOutQuad:function(x,t,b,c,d){return-c*(t/=d)*(t-2)+b},easeInOutQuad:function(x,t,b,c,d){if((t/=d/2)<1)return c/2*t*t+b;return-c/2*((--t)*(t-2)-1)+b},easeInCubic:function(x,t,b,c,d){return c*(t/=d)*t*t+b},easeOutCubic:function(x,t,b,c,d){return c*((t=t/d-1)*t*t+1)+b},easeInOutCubic:function(x,t,b,c,d){if((t/=d/2)<1)return c/2*t*t*t+b;return c/2*((t-=2)*t*t+2)+b},easeInQuart:function(x,t,b,c,d){return c*(t/=d)*t*t*t+b},easeOutQuart:function(x,t,b,c,d){return-c*((t=t/d-1)*t*t*t-1)+b},easeInOutQuart:function(x,t,b,c,d){if((t/=d/2)<1)return c/2*t*t*t*t+b;return-c/2*((t-=2)*t*t*t-2)+b},easeInQuint:function(x,t,b,c,d){return c*(t/=d)*t*t*t*t+b},easeOutQuint:function(x,t,b,c,d){return c*((t=t/d-1)*t*t*t*t+1)+b},easeInOutQuint:function(x,t,b,c,d){if((t/=d/2)<1)return c/2*t*t*t*t*t+b;return c/2*((t-=2)*t*t*t*t+2)+b},easeInSine:function(x,t,b,c,d){return-c*Math.cos(t/d*(Math.PI/2))+c+b},easeOutSine:function(x,t,b,c,d){return c*Math.sin(t/d*(Math.PI/2))+b},easeInOutSine:function(x,t,b,c,d){return-c/2*(Math.cos(Math.PI*t/d)-1)+b},easeInExpo:function(x,t,b,c,d){return(t==0)?b:c*Math.pow(2,10*(t/d-1))+b},easeOutExpo:function(x,t,b,c,d){return(t==d)?b+c:c*(-Math.pow(2,-10*t/d)+1)+b},easeInOutExpo:function(x,t,b,c,d){if(t==0)return b;if(t==d)return b+c;if((t/=d/2)<1)return c/2*Math.pow(2,10*(t-1))+b;return c/2*(-Math.pow(2,-10*--t)+2)+b},easeInCirc:function(x,t,b,c,d){return-c*(Math.sqrt(1-(t/=d)*t)-1)+b},easeOutCirc:function(x,t,b,c,d){return c*Math.sqrt(1-(t=t/d-1)*t)+b},easeInOutCirc:function(x,t,b,c,d){if((t/=d/2)<1)return-c/2*(Math.sqrt(1-t*t)-1)+b;return c/2*(Math.sqrt(1-(t-=2)*t)+1)+b},easeInElastic:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(a<Math.abs(c)){a=c;var s=p/4}else var s=p/(2*Math.PI)*Math.asin(c/a);return-(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b},easeOutElastic:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(a<Math.abs(c)){a=c;var s=p/4}else var s=p/(2*Math.PI)*Math.asin(c/a);return a*Math.pow(2,-10*t)*Math.sin((t*d-s)*(2*Math.PI)/p)+c+b},easeInOutElastic:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d/2)==2)return b+c;if(!p)p=d*(.3*1.5);if(a<Math.abs(c)){a=c;var s=p/4}else var s=p/(2*Math.PI)*Math.asin(c/a);if(t<1)return-.5*(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b;return a*Math.pow(2,-10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p)*.5+c+b},easeInBack:function(x,t,b,c,d,s){if(s==undefined)s=1.70158;return c*(t/=d)*t*((s+1)*t-s)+b},easeOutBack:function(x,t,b,c,d,s){if(s==undefined)s=1.70158;return c*((t=t/d-1)*t*((s+1)*t+s)+1)+b},easeInOutBack:function(x,t,b,c,d,s){if(s==undefined)s=1.70158;if((t/=d/2)<1)return c/2*(t*t*(((s*=(1.525))+1)*t-s))+b;return c/2*((t-=2)*t*(((s*=(1.525))+1)*t+s)+2)+b},easeInBounce:function(x,t,b,c,d){return c-jQuery.easing.easeOutBounce(x,d-t,0,c,d)+b},easeOutBounce:function(x,t,b,c,d){if((t/=d)<(1/2.75)){return c*(7.5625*t*t)+b}else if(t<(2/2.75)){return c*(7.5625*(t-=(1.5/2.75))*t+.75)+b}else if(t<(2.5/2.75)){return c*(7.5625*(t-=(2.25/2.75))*t+.9375)+b}else{return c*(7.5625*(t-=(2.625/2.75))*t+.984375)+b}},easeInOutBounce:function(x,t,b,c,d){if(t<d/2)return jQuery.easing.easeInBounce(x,t*2,0,c,d)*.5+b;return jQuery.easing.easeOutBounce(x,t*2-d,0,c,d)*.5+c*.5+b}});

/*
 * @author Alexander Farkas
 * v. 1.02
*/
(function($) {
	$.extend($.fx.step,{
	    backgroundPosition: function(fx) {
            if (fx.state === 0 && typeof fx.end == 'string') {
                var start = $.curCSS(fx.elem,'backgroundPosition');
                start = toArray(start);
                fx.start = [start[0],start[2]];
                var end = toArray(fx.end);
                fx.end = [end[0],end[2]];
                fx.unit = [end[1],end[3]];
			}
            var nowPosX = [];
            nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
            nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];           
            fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];
            
           function toArray(strg){
               strg = strg.replace(/left|top/g,'0px');
               strg = strg.replace(/right|bottom/g,'100%');
               strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
               var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
               return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
           }
        }
	});
})(jQuery);


/*
 * jQuery PDM Hint v0.1
 * 
 * desc:	Simple hint box, follows mouse when hovered over specified elements
 *			Can be applied multiple times per page, just pass text
 *
 * author: 	Chris Gonzales - Provenance Digital
 *
 * example:	$('ele').hint('hint text here');
 *
*/
hintstarted = false;
jQuery.fn.hint = function(txt){
		
	var hint = $('#hint');
	intv = 0;		
	this.data('text', txt);
	
	if($('#hint').length == 0){
		var hint = $('<div id="hint">this is a hint</div>').css({
			maxWidth: '300px',
			position: 'absolute',
			padding: '5px 10px',
			//border: '1px solid #f00',
			fontSize: '12px',
			color: '#fff',
			zIndex: 110,
			opacity: 0,
			backgroundColor: '#4f4944'//'rgba(79, 73, 68, .9)'//'#4F4944'
		});			
		
		$(document.body).prepend(hint);
		
		hint.css({width: hint.width()});	
	}
	
	this.hover(
		function(evt){
			
			clearTimeout(intv);
			
			if(!hintstarted){
				var offset_left = evt.pageX + 5;
				var offset_top = evt.pageY - hint.outerHeight() - 1;
				
				if(evt.pageY - $(document).scrollTop() < hint.outerHeight()){
					offset_top = evt.pageY + 20;	
				}				
				if(evt.pageX + hint.outerWidth() - $(document).scrollLeft() > $(window).width()){
					offset_left = evt.pageX - hint.outerWidth();	
				}
				hint.css({left: offset_left, top: offset_top});
				hintstarted = true;
			}
			
			hint.css({width: 'auto'})
			.text($(this).data('text'))
			.css({width: hint.width()})
			.animate({opacity: 1},{duration: 300, queue: false});
			
			$(document.body).bind('mousemove', moveHint);	
			
			
		},
		function(){	
			intv = setTimeout(hideHint, 300);
		}
	);
	
	function hideHint(){		
		hint.animate({opacity: 0},{duration: 300, queue: false});	
		$(document.body).unbind('mousemove', moveHint);		
	}
	
	function moveHint(evt){
		
		var offset_left = evt.pageX + 5;
		var offset_top = evt.pageY - hint.outerHeight() - 1;
		
		if(evt.pageY - $(document).scrollTop() < hint.outerHeight()){
			offset_top = evt.pageY + 20;	
		}				
		if(evt.pageX + hint.outerWidth() - $(document).scrollLeft() > $(window).width()){
			offset_left = evt.pageX - hint.outerWidth();	
		}
		
		hint.animate({left: offset_left, top: offset_top}, {duration: 100, ease: 'easeInOutQuad', queue: false});
	}	
	
	return this; 
	
}

$(document).ready(function(){	
			
//variables
	var center		= 0;
	var contents 	= {};	
	var timeline	= $('#timeline');
	var scrollbar 	= $('<div id="scrollbar"><a href="#home" class="home" title="home">home</a></div>');
	var timeline_margin_left = 0;
	var previous;
	var item_length;
	var item_width;
	var ripple;
	var selected_nav;
	var form_built = {strategy: false, technology: false, development: false};
  	
	
//functions

	function activateContactForm(){
			$('<div><div>').insertAfter('#contact form');
			
			$('#contact form').html('<div class="border_grey"></div><div class="border"></div><div class="contents_grey"><div></div>' + $('#contact form').html() + '</div><div class="contents">' + $('#contact form').html() + '</div>');			
			$('#contact form .border, #contact form+div>div, #contact form .contents, #social').css({opacity: 0, display: 'block', visibility: 'hidden'});			
			$('#contact form, #contact form+div').css({display: 'block', opacity: 0});
			$('.contact-form').click(function(){
				buildForm(0);
				slideTimeline(0);
				return false;
			});		
			$('#contact form').submit(function(){
				var overlay = $('<div class="overlay">');
				overlay.css({opacity: 0, zIndex: 10});
				$(this).append(overlay);
				
				var r = true;
				
				//validate 		
				if($(this).find('div:not(.contents_grey) input[name=name]').val() == ''){
					$(this).find('div:not(.contents_grey) input[name=name]').prev().css({fontWeight: 'bold'});
					overlay.append('<p>Name is required</p>');
					r = false;
				}
				
				if($(this).find('div:not(.contents_grey) input[name=email]').val() == ''){
					$(this).find('div:not(.contents_grey) input[name=email]').prev().css({fontWeight: 'bold'});
					overlay.append('<p>Email Address is required</p>');
					r = false;
				}else{
					if($(this).find('div:not(.contents_grey) input[name=email]')[0].value.search(/([^\/.]+)@([^\/.]+)\.([^\/.]+)/) == -1){
						$(this).find('div:not(.contents_grey) input[name=email]').prev().css({fontWeight: 'bold'});
						overlay.append('<p>Invalid Email Address</p>');
						r = false;
					}
				}
				
				if(!r){
					//display error
					overlay.animate({opacity: .95}).animate({opacity: .95},{duration: 1400}).animate({opacity: 0}, {duration: 300, complete: function(){$(this).remove()}});
				}else{
					//send data
					$.ajax({
						type		: 'POST',
						url			: '/contact',
						data		: $(this).serialize(),
						dataType	: 'json',
						success		: function(json){
							overlay.append('<p>Contact submission Successful.</p>')
							.animate({opacity: .95})
							.animate({opacity: .95},{duration: 300})
							.animate({opacity: 0}, {duration: 300, complete: function(){
								  $(this).remove();
								  $('#contact form')[0].reset();
							  }});
						}
					});		
				}
				
				return false;
			});
			
			$('#contact form .close').click(function(){ buildForm(-1)});
	}

	function activateNavigation(){
			$('#methods>h2').each(function(){
				
					var idx		= $('#methods>h2').index($(this));
					var toggler = $(this);
					var togglee = $(this).next('div');
					var visible = false;
					var id		= $(this).attr('id');
					var btn_close 	= $('<a href="#close" class="close">&times;</a>');			
					
					btn_close.css({opacity: 0});
					
					toggler.append(btn_close);
					
					switch(id){
						case 'strategy':
							toggler.css({backgroundPosition: '10px 5px'});
						break;
						
						case 'technology':
							toggler.css({backgroundPosition: '10px -142px'});
						break;
						
						case 'development':
							toggler.css({backgroundPosition: '10px -289px'});
						break;
					}
					
					toggler.click(function(){
							clearInterval(ripple);
							if(visible){
								$(this).animate({left: 535}, {duration: 400, queue: false, ease: 'easeInOutQuad'});
								togglee.css({zIndex: 2}).animate({left: 535}, {duration: 400, queue: false, ease: 'easeInOutQuad'});
								
								switch(id){
									case 'strategy':
										$(this).animate({backgroundPosition: '(10px 5px)'}, {duration: 1000, queue:false});
									break;
									
									case 'technology':
										$(this).animate({backgroundPosition: '(10px -142px)'}, {duration: 1000, queue:false});
									break;
									
									case 'development':
										$(this).animate({backgroundPosition: '(10px -289px)'}, {duration: 1000, queue:false});
									break;
								}
								
								btn_close.animate({opacity: 0}, {duration: 1000, queue: false});
								
								setTimeout(function(){
													$('#header').css({zIndex: 51});
													$('#content').css({zIndex: 50});
													}, 500);
								
								changeAbout('default');
								
								selected_nav = null;
								
							}else{					
								$(this).animate({left: 0}, {duration: 400, queue: false, ease: 'easeInOutQuad'});
								togglee.css({zIndex: 10}).animate({left: 0}, {duration: 400, queue: false, ease: 'easeInOutQuad'});
								
								switch(id){
									case 'strategy':
										$(this).animate({backgroundPosition: '(10px 32px)'}, {duration: 400, queue:false});
									break;
									
									case 'technology':
										$(this).animate({backgroundPosition: '(10px -129px)'}, {duration: 400, queue:false});
									break;
									
									case 'development':
										$(this).animate({backgroundPosition: '(10px -278px)'}, {duration: 400, queue:false});
									break;
								}
								
								btn_close.animate({opacity: 1}, {duration: 2000, queue: false});
								
								$('#content').css({zIndex: 51});
								
								changeAbout(id);
								
								selected_nav = $(this);
							}							
							
							visible = !visible;
							
							buildForm(idx+1);
							
							return false;
					});
					
					$(this).animate({left:535}, {duration: idx*100}).animate({left:520}, {duration: 300}).animate({left:535}, {duration: 450});
					
			});
			ripple = setInterval(rippleNavigation, 4000);
	}
	
	function activateProjects(){
			$('.projects').each(function(){
					
					// wrap child div's in a container div, will be used to contain overflow
					$(this).find('>div').wrapAll('<div/>');
					
					// div that will hold content for slider
					var slider = $(this).find('>div');
					// navigation buttons for above slider
					var btn_prev = $('<a href="#prev" class="previous">previous</a>').css({fontSize: '0px', lineHeight: '0px', textIndent: '-1000px'});
					var btn_next = $('<a href="#next" class="next">next</a>').css({fontSize: '0px', lineHeight: '0px', textIndent: '-1000px'});
										 
					var left = 0;
					var width = slider.find('>div').first().outerWidth();
					var amt = slider.find('>div').length;
					
					$(this).prepend(btn_prev);
					$(this).append(btn_next);
					
					slider.css({width: width * amt});
					
					btn_prev.css({opacity: .1, cursor: 'default'}).click(function(){
							if(left < 0){
								left += width;
								slider.animate({left: left}, {duration: 300, queue: false, easing: 'easeInOutQuad'});
								if(left == 0){
									$(this).css({cursor: 'default'}).animate({opacity: .1}, {duration: 200, queue: false});	
								}
							}
							
							if(left > -width * (amt-1) + 1){
								btn_next.css({cursor: 'pointer'}).animate({opacity: .8}, {duration: 200, queue: false});	
							}	
							
							return false;
					});
					
					btn_next.css({opacity: .8}).click(function(){
							if(left > -width * (amt-1) + 1){
								left -= width;
								slider.animate({left: left}, {duration: 300, queue: false, easing: 'easeInOutQuad'});
								if(left == -width * (amt-1)){
									$(this).css({cursor: 'default'}).animate({opacity: .1}, {duration: 200, queue: false});
								}
							}
							
							if(left < 0){
								btn_prev.css({cursor: 'pointer'}).animate({opacity: .8}, {duration: 200, queue: false});	
							}
							
							return false;
					});
					
			});
	}
		
	function activateScrollbar(){
			scrollbar.insertAfter('#timeline');
			
			var items = timeline.find('h3')
			item_length = items.length;
			item_width = 24;
			
			var bottom = ($(window).height() < 680) ? 20 : ($(window).height() - 680) / 2 + 10;
			var marginRight = Math.floor( ($(window).width() - (40+item_width) - item_width*(item_length+4)) / item_length );
			
			for(i=0; i<item_length; i++){
				var link = $('<a href="#"><span>' + items.eq(item_length-1-i).text() + '</span></a>');
				link.css({marginRight: marginRight});
				link.insertBefore(scrollbar.find('a:last'));
				link.click(function(){
						$('#scrollbar a.selected').removeClass('selected');
						slideTimeline($(this).index()+1, item_length);
						$(this).addClass('selected');
						
						return false;
				});
				
			}
			
			scrollbar.css({bottom: bottom, paddingLeft: marginRight-30}).find('.home').click(function(){
				slideTimeline(0);
				$('#scrollbar a.selected').removeClass('selected');
			});
			$('#logo').click(function(){
				slideTimeline(0);
				$('#scrollbar a.selected').removeClass('selected');				
				return false;
			});		
	}
	
	function activateTimeline(){		
		$('#timeline').wrapInner('<div>');
		$('#timeline').css({display: 'block'})
		timeline_contents = $('#timeline>div');
		
		$('#timeline>div>div').each(function(){
						
			$(this).click(function(){
				
				if($(this).hasClass('selected')) return true;
				
				var total = $(this).siblings().length + 1;
				var pos = total - $(this).index();
				
				slideTimeline(pos, total);
				
				$('#scrollbar a.selected').removeClass('selected');
				$('#scrollbar a').eq(pos-1).addClass('selected');
								   
				$(this).addClass('selected');
				
				return false;
			});
		});
	}
		
	function adjustDim(init){		
			//set width & height of main container and contents container
			$('#container').css({
				width	: $(window).width(), 
				height	: $(window).height()
			});
			
			$('#contents').css({
				width	: $(window).width(), 
				height	: $(window).height()
			});
			
			
			var marginRight = Math.floor( ($(window).width() - (40+item_width) - item_width*(item_length+2)) / item_length );			
			var bottom = ($(window).height() < 680) ? 20 : ($(window).height() - 680) / 2 + 10;	
				timeline_margin_left = ($(window).width() - 910)/2;		
				center = ($(window).width() - 455) / 2;			
			
			scrollbar.find('a:not(.home)').css({marginRight: marginRight});
			
			var width = (timeline_margin_left + $('#timeline>div>div').first().outerWidth()) * $('#timeline>div>div').length - timeline_margin_left;			
				
			scrollbar.css({ bottom: bottom});		
			$('#timeline>div>div').filter(':not(:last)').css({marginLeft: timeline_margin_left});
			timeline_contents.css({width: width});	
			
			if(init == true){	
				$('#timeline>div>div').css({opacity: .2, marginTop: 0});
				timeline_contents.css({left: -width});
			}else{
				if(scrollbar.find('a.selected').length > 0){
					var total = scrollbar.find('a').length - 1;
					var pos = scrollbar.find('a.selected').index() + 1;
					var offset = -timeline_contents.width() + (455 * (total-pos+1)) +  center + (total-pos) * timeline_margin_left; 
					timeline_contents.animate({left: offset}, {duration: 800, queue: false, easing: 'easeInOutQuad'});
				}else{
					
					timeline_contents.css({left: -width});
				}
			}
	}	
	
	function buildForm(stage){		
							
			if(stage == -1){
				$('#contact form, #contact form+div').animate({opacity: 0});
				$('#contact form .border, #contact form .contents, #contact form+div>div, #social').css({visibility: 'visible'}).animate({opacity: 0}, {duration: 300});	
				return false;
			}else{
				$('#contact form, #contact form+div').animate({opacity: 1});	
			}
	
			switch(stage){
							
				case 0:			
					$('#contact form .border, #contact form .contents, #contact form+div>div, #social').css({visibility: 'visible'}).animate({opacity: 0}, {duration: 300}).animate({opacity: 1}, {duration: 300});			
				break;			
			
				case 1:
					$('#contact form .border, #contact form+div>div').css({visibility: 'visible'}).animate({opacity: 1}, {duration: 300});	
					form_built.strategy = true;
				break;			
				
				case 2:
					$('#social').css({visibility: 'visible'}).animate({opacity: 1}, {duration: 300});	
					form_built.technology = true;
				break;			
				
				case 3:
					$('#contact form .contents').css({visibility: 'visible'}).animate({opacity: 1}, {duration: 300});
					form_built.development = true;
				break;
			
			}			
	}
	
	function cancelRipple(){ clearTimeout(ripple);}
	
	function changeAbout(id){
			$('#about').animate({opacity: 0}, {duration: 300, queue: false, complete: function(){
																								
				$(this).html(contents[id].find('description').text());
								
				if(id == 'default'){
					$(this).animate({opacity: 1}, {duration: 300, queue: false});
					return;
				}
				var services = $('<div id="services"><h2>Services</h2><ul></ul>');
				contents[id].find('service').each(function(){
					var li = $('<li>' + $(this).attr('title') + '</li>')
					services.find('ul').append(li);
					
					if($(this).attr('desc')) li.hint($(this).attr('desc'));
				});
				
				$(this).append(services);		
				
				$(this).delay(500).animate({opacity: 1}, {duration: 1000});
				
			}});
	}
		
	function loadXML(){
			$.ajax({
				type		: 'GET',
				url			: 'content.xml',
				dataType	: 'xml',
				success		: loadContent
			});
	}
	
	function loadContent(xml){
			$(xml).find('content').each(function(){
				var id = $(this).attr('id');
				var div = $('<div class="projects"></div>');
				div.insertAfter($('#' + id));
				
				contents[id] = $(this);
				
				$(this).find('project').each(function(){
					var html = $('<div/>');
					html.append( $('<h3>' + $(this).attr('title') + '</h3>') );
					html.append( $('<h4>' + $(this).attr('subtitle') + '</h4>') );
					html.append( $(this).text() );
					div.append(html);
				});
										
			});
			
			activateNavigation();
			activateProjects();		
			activateScrollbar();
			activateContactForm();
	}
	
	function rippleNavigation(){
		$('#methods>h2').each(function(){		
			var idx		= $('#methods>h2').index($(this));
			$(this).animate({left:535}, {duration: idx*100}).animate({left:520}, {duration: 300}).animate({left:535}, {duration: 450});
		});
	}
	
	function slideTimeline(pos, total, dur){
			//slide nav in if one is selected			
			if(selected_nav) selected_nav.trigger('click');
		
			var dur = dur ? dur : 1000;
			var total = total ? total : false;	
			
						
			if(pos > 0){
				buildForm(-1);
				var offset = -timeline_contents.width() + (455 * (total-pos+1)) +  center + (total-pos) * timeline_margin_left; 
				timeline_contents.animate({left: offset}, {duration: 800, queue: false, easing: 'easeInOutQuad'});
				$('#content').animate({right: -$('#content').width()}, {duration: dur, queue: false});
				if(previous) previous.animate({opacity: .2, marginTop: 0}, {duration: 600, queue: false}).removeClass('selected');
				$('#timeline>div>div').eq(total-pos).addClass('selected').delay(600).animate({opacity: 1, marginTop: -30}, {duration: 300});
				previous = $('#timeline>div>div').eq(total-pos);
			}else{
				timeline_contents.animate({left: -timeline_contents.width()});
				$('#content').animate({right: 0}, {duration: dur, queue: false});	
				$('#scrollbar a.selected').removeClass('selected');
			}
	}
	
	
	
//listeners
	$(window).resize(adjustDim);
	
	
//init funcyion calls
	loadXML();
	activateTimeline();
	adjustDim(true);
	
	//decode rot13 emails - helps prevent bots from reading
	$('a[href^=mailto:]').each(function(){
		$(this).text($(this).text().rot13());	
		$(this).attr('href', "mailto:" + $(this).text());
	});
	//end of decode rot13
	
	$('#methods .projects .next, #methods .projects .previous').each(function(){ console.log($(this));});
	//css fixes
	$('#services h2, #social li a').css({
		fontSize: '0px',
		lineHeight: '0px',
		textIndent: '-1000px'
	});
		
});


String.prototype.rot13 = function rot13() {
	return this.toString().replace(/[a-zA-Z]/g, function(ch) {
		return String.fromCharCode((ch <= "Z" ? 90 : 122) >= (ch = ch.charCodeAt(0) + 13) ? ch : ch - 26);
	});
}