var is_mobile=false;var uagent=navigator.userAgent.toLowerCase();var MOBILE_AGENTS=["iphone","ipod","series60","symbian","android","windows ce","blackberry","palm"];for(var i=0;i<MOBILE_AGENTS.length;i++){if(uagent.indexOf(MOBILE_AGENTS[i])>-1){is_mobile=true;break;}}
var B_NUM=5;var B_ALPHAS=[0.10,0.20,0.40];var B_RATIOS=[0.15,0.75,0.95];var B_MIN_SIZE=80;var B_MAXSIZE=160;var BZ_LENGTH=40;var canvas;var stage;var bubbles=[];function deg2rad(a)
{return a*Math.PI/180;}
function random(range)
{return Math.floor(Math.random()*range);}
function Bubble(){this.vitality=Math.random()*2+0.7;this.rotationSpeed=Math.random()*0.6-0.3;this.raysNum=random(4)+3;this.rays=[];this.colors=[];this.drawBubble=function(xPos,yPos)
{var r=random(150)+100;var g=random(180)+40;var b=random(210);var i;for(i=0;i<B_ALPHAS.length;i++){this.colors.push(Graphics.getRGB(r,g,b,B_ALPHAS[i]));}
for(i=0;i<this.raysNum;i++){this.rays[i]={n:random(B_MAXSIZE-B_MIN_SIZE)+B_MIN_SIZE,d:Math.random()*this.vitality-this.vitality/2};}
var c=new Shape(new Graphics());c.x=xPos;c.y=yPos;this._sprite=c;stage.addChild(c);return c;};this.floatBubble=function()
{this._sprite.rotation+=this.rotationSpeed;var angle=360/this.raysNum;var xMove=0;var yMove=0;var i;for(i=0;i<this.raysNum;i++){if(random(50)===0){this.rays[i].d=Math.random()*this.vitality-this.vitality/2;}
if(this.rays[i].n>B_MAXSIZE){this.rays[i].d=-Math.random()*this.vitality;}
if(this.rays[i].n<B_MIN_SIZE){ this.rays[i].d=Math.random()*this.vitality;}
var directionAngle=deg2rad(angle*i-this._sprite.rotation);xMove+=Math.cos(directionAngle)*(this.rays[i].n/50);yMove+=Math.sin(directionAngle)*(this.rays[i].n/50);this.rays[i].n+=this.rays[i].d;}
var xc=(canvas.width/2-this._sprite.x)/(canvas.width/2);var yc=(canvas.height/2-this._sprite.y)/(canvas.height/2);this._sprite.x+=xMove+xc/4;this._sprite.y+=yMove+yc/4;if(this._sprite.x-B_MAXSIZE>canvas.width){this._sprite.x=-B_MAXSIZE;}
if(this._sprite.x+B_MAXSIZE<0){this._sprite.x=canvas.width+B_MAXSIZE;}
if(this._sprite.y-B_MAXSIZE>canvas.height){this._sprite.y=-B_MAXSIZE;}
if(this._sprite.y+B_MAXSIZE<0){this._sprite.y=canvas.height+B_MAXSIZE;}
var g=this._sprite.graphics;g.clear();g.beginRadialGradientFill(this.colors,B_RATIOS,0,0,0,0,0,B_MAXSIZE);g.moveTo(this.rays[this.raysNum-1].n,0);for(i=0;i<this.raysNum;i++){var xTo=this.rays[i].n*Math.cos(deg2rad(angle*(i+1)));var yTo=this.rays[i].n*Math.sin(deg2rad(angle*(i+1)));var angleToPerp=deg2rad(angle*(i+1)-90);var angleFromPerp=deg2rad(angle*i+90);var rayFrom=this.rays[i>0?i-1:this.raysNum-1].n;var xFrom=rayFrom*Math.cos(deg2rad(angle*i));var yFrom=rayFrom*Math.sin(deg2rad(angle*i));g.bezierCurveTo(xFrom+BZ_LENGTH*Math.cos(angleFromPerp),yFrom+BZ_LENGTH*Math.sin(angleFromPerp),xTo+BZ_LENGTH*Math.cos(angleToPerp),yTo+BZ_LENGTH*Math.sin(angleToPerp),xTo,yTo);}
g.endFill();};}
function resizeCanvas()
{canvas.width=this.window.innerWidth;canvas.height=this.window.innerHeight;}
function initBg()
{canvas=document.getElementById("bg_canvas");if(is_mobile){canvas.style.display="none";return;}
resizeCanvas();stage=new Stage(canvas);var i;for(i=0;i<B_NUM;i++){var bubble=new Bubble();bubble.drawBubble(random(canvas.width-B_MAXSIZE*2)+B_MAXSIZE,random(canvas.height-B_MAXSIZE*2)+B_MAXSIZE);bubbles.push(bubble);}
this.window.onresize=resizeCanvas;Tick.addListener(this);}
function tick()
{for(var i=0;i<B_NUM;i++){bubbles[i].floatBubble();}
stage.tick();}
function twitterCallbackZenoid(twitters){var statusHTML=[];for(var i=0;i<twitters.length;i++){var username=twitters[i].user.screen_name;var status=twitters[i].text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g,function(url){return'<a href="'+url+'" target="_blank">'+url+'</a>';}).replace(/\B@([_a-z0-9]+)/ig,function(reply){return reply.charAt(0)+'<a href="http://twitter.com/'+reply.substring(1)+'" target="_blank">'+reply.substring(1)+'</a>';});statusHTML.push('<li>'+status+'</li>');}
document.getElementById('twitter_update_list').innerHTML=statusHTML.join('');}
var kwords=[];var filter="";var transtime=800;function initPortfolio()
{$('#portfolio ul.keywords li').html(function(){var txt=$(this).text();$(this).hide();if(jQuery.inArray(txt,kwords)==-1)kwords.push(txt);});kwords.sort();var i=0;var keyword_link_function=function(count){var txt=kwords[count];var link=$('<a/>').attr('href','javascript:only("'+txt+'");').text(txt);return $('<li/>').append(link);};while(i<kwords.length){$('#keywords_menu').append(keyword_link_function(i));i++;}
$('#show_all_works').show();}
function only(f)
{filter=f||"";$('#keywords_menu a').each(function(){var a=$(this);var txt=a.text();if(txt=='SHOW ALL'){txt="";}
if(txt==filter){a.addClass('selected');}else{a.removeClass('selected');}});$('#portfolio article').each(function(){if($(this).find(':contains("'+filter+'")').length>0){$(this).show(transtime);}else{$(this).hide(transtime);}});$('html, body').animate({scrollTop:$('#portfolio').offset().top},transtime);}
$(document).ready(initPortfolio);
