var ajaxCount=1;window.addEvent('domready',function(){myScroll=new Fx.SmoothScroll({duration:400},window);if(Browser.Platform.ios){$('wrapper').addClass('ios');}
milkbox=new Milkbox({centered:false,autoSize:false,imageOfText:"/"});if($$('html')[0].get('id')){$$('.nav a').append($$('#footerbox menu a')).addEvent('click',function(event){event.preventDefault();$$('.nav li').removeClass('active');if($(this.parentNode).get('id')){$(this.parentNode).addClass('active');}else{$$('.nav a[href="'+$(this).get('href')+'"]')[0].parentNode.addClass('active');}
var url=$(this).get('href');var c=url.slice(0,url.length).substr(ajaxCount-1);processAJAX(c);});$$('.footer a').addEvent('click',function(event){event.preventDefault();$$('.nav li').removeClass('active');$$('.nav a[href="/blog"]')[0].parentNode.addClass('active');var url=$(this).get('href');var c=url.slice(0,url.length).substr(ajaxCount-1);processAJAX(c,'/blog');});}
runFSE();});function processAJAX(c,override){var ajaxrequest='ajax'+c;if(override){c=override;}
var req=new Request({method:'get',url:ajaxrequest,onRequest:function(){new Asset.image('http://static.aarongray.com.au/images/ajax-loader.gif',{id:'loader2'}).inject($$('header')[0]).show();var t=c.substr(1);$$('html').set('id',(t=='')?'index':t);var n=$$('title')[0].get('html').split(' - ');if(t==''){document.title='AARON GRAY // web developer + whitewater kayaking enthusiast';}else{document.title='AARON GRAY // web developer + whitewater kayaking enthusiast - '+t;}
headers.shuffle();var h=$('himg').get('src').split('/');h.pop();$('himg').set('src',h.join('/')+'/'+headers[0]);},onComplete:function(response){(function(){if(typeof reinvigorate=='object'){reinvigorate.ajax_track($$('base')[0].get('href')+c.substr(1));}
$('loader2').dispose();var container=$('container');((container)?container.empty():new Element('div')).set('html',response).firstChild;milkbox.reloadPageGalleries();runFSE();new Fx.Scroll(window).toElement('top');}).delay(100);}}).send();if(req){return false;}}
function runFSE(){$$('a[rel="external"]').append($$('a.external')).set('target','_blank');$$('.share').addEvent("click",function(event){event.preventDefault();window.open($(this).get('href'),"Share","menubar=0,location=0,status=0,toolbar=0,resizable=0,width=800,height=600");});if(Browser.ie){var objs=$$('button');objs.addEvent("mouseover",function(event){this.addClass('hover');});objs.addEvent("mouseout",function(event){this.removeClass('hover');});var objs=$$('input').append($$('textarea'));objs.addEvent("focus",function(event){this.addClass('focus');});objs.addEvent("blur",function(event){this.removeClass('focus');});}
var tips=$$('#gallery a, .image, .limage, .right a, a.fn');tips.each(function(element,index){var ftitle=element.get('title');var content=ftitle.split('-');element.set('ftitle',ftitle);if(content[1]){element.store('tip:title','<strong>'+content[0]+'</strong>');element.store('tip:text',content[1]);}else{element.store('tip:title',content[0]);element.store('tip:text','');}});var tipz=new Tips(tips,{className:'tool-tip',showDelay:0,hideDelay:0,offset:{'x':-20,'y':20}});tipz.addEvents({'show':function(tip){tip.set('tween',{duration:500});tip.tween('opacity',1);},'hide':function(tip){tip.show();tip.set('tween',{duration:500});tip.tween('opacity',0);}});$$('.email').each(function(el){el.set('href','mailto:'+el.get('rel').replace('|','@').replace('/',''));});var slideshow=false;if($('bar')){var imagesDir='/images/slideshow/';var images=['04.jpg','02.jpg','06.jpg','03.jpg','01.jpg','05.jpg'];var imageWidth=393;var imageHeight=201;var imageTop=0;var imageLeft=0;var holder=$('slideshow');images.shuffle();slideshow=true;var flInterval=750;fobj=new Swiff('http://application.aarongray.com.au/swf/fl.swf',{id:'fObject',width:588,height:201,version:10,container:'fl',params:{wMode:'transparent',bgcolor:'#000000',allowScriptAccess:'always'},vars:{flInterval:flInterval}});$$('.right a').each(function(obj,i){obj.addEvent("mouseover",function(event){$$('.right a').each(function(item,i){if(obj!==item){var img=item.getElements('img')[0];img.get('tween').cancel();img.set('tween',{duration:300});img.tween('opacity',0.5);}});if($('image')){$('image').dispose();}
var ext=$(this).get('href').split('l');var src=ext[0]+'.jpg';var ftext=String($(this).get('ftitle')).split(' - ');var img=new Asset.image(src,{id:'image',width:588,height:201,onLoad:function(){if($('fObject')){img.set('tween',{duration:flInterval});img.tween('opacity',1);Swiff.remote(fobj.toElement(),'updateText',ftext[0],ftext[1]);}else{img.setStyles({zIndex:1,position:'absolute'});img.set('tween',{duration:flInterval});img.tween('opacity',1);}}}).inject($('fl'),'top').set('opacity',0);});obj.addEvent("mouseout",function(event){$$('.right a').each(function(item,i){if(obj!==item){var img=item.getElements('img')[0];img.get('tween').cancel();img.set('tween',{duration:100});img.tween('opacity',1);}});$('image').dispose();if($('fObject')){Swiff.remote(fobj.toElement(),'resetText');}});obj.addEvent("click",function(event){event.preventDefault();});});}
if($('about')){var imagesDir='/images/about/';var images=['02.jpg','03.jpg','01.jpg'];var imageWidth=250;var imageHeight=330;var imageTop=20;var imageLeft=20;var holder=$('aboutshow');images.shuffle();slideshow=true;}
if($('services')){var imagesDir='/images/services/';var images=['02.jpg','01.jpg'];var imageWidth=250;var imageHeight=330;var imageTop=20;var imageLeft=20;var holder=$('servicesshow');images.shuffle();slideshow=true;}
if($('contactshow')){var imagesDir='/images/contact/';var images=['04.jpg','02.jpg','03.jpg','01.jpg'];var imageWidth=423;var imageHeight=282;var imageTop=0;var imageLeft=0;var holder=$('contactshow');images.shuffle();slideshow=true;}
if(slideshow==true){var fadeInterval=1500;var showInterval=5000;var delayInterval=500;holder.empty();new Asset.image('http://static.aarongray.com.au/images/loader.gif',{id:'loader'}).inject(holder).show();images.each(function(img,i){images[i]=imagesDir+''+img;});var loader=new Asset.images(images,{onComplete:function(){var slides=[];images.each(function(im){slides.push(new Element('img',{src:im,width:imageWidth,height:imageHeight,styles:{opacity:0,top:imageTop,left:imageLeft,position:'absolute','z-index':10}}).inject(holder));});var index=0;(function(){slides[index].set('tween',{duration:fadeInterval});slides[index].tween('opacity',1);$('loader').hide();}).delay(delayInterval);var start=function(){(function(){holder.setStyle('background','');slides[index].set('tween',{duration:fadeInterval});slides[index].tween('opacity',0);++index;index=(slides[index]?index:0);slides[index].set('tween',{duration:fadeInterval});slides[index].tween('opacity',1);}).periodical(showInterval);};start();}});}
$$('#blognav a').addEvent('click',function(event){event.preventDefault();$$('.nav li').removeClass('active');$$('.nav a[href="/blog"]')[0].parentNode.addClass('active');var url=$(this).get('href');var c=url.slice(0,url.length).substr(ajaxCount-1);processAJAX(c,'/blog');});}
