var Nouincolor=new Class({
	initialize:function(options){
		this.nav=$$("#this-is-soooocial a");
		this.wrapper=$("content");
		 this.imageAssets=["static/img/me.png","static/img/full-sprites.png"];
		 this.folio=$$(".folio")[0];
		 this.wbb=$$(".wbb")[0];
		 this.wbf=$$(".wbf")[0];
		 this.wbec=$$(".wbec")[0];
		 this.wbd=$$(".wbd")[0];
		 this.wbsm=$$(".wbsm")[0];
		 this.pf=$("portfolio");
		 this.pfc=$("portfolio-cont");
		 this.pwbb=$("wbb");
		 this.pwbbc=$("wbb-cont");
		 this.pwbf=$("wbf");
		 this.pwbfc=$("wbf-cont");
		 this.pwbec=$("wbec");
		 this.pwbecc=$("wbec-cont");
		 this.pwbd=$("wbd");
		 this.pwbdc=$("wbd-cont");
		 this.pwbsm=$("wbsm");
		 this.pwbsmc=$("wbsm-cont");
		 this.logo=$$("h1");
		 this.social;
		 this.prepareTurkey();
		 this.getAssets()
	},
	
	prepareTurkey:function(){
		 this.wrapper.fade("hide");
		 this.pfc.set("opacity",0);
		 this.pwbbc.set("opacity",0);
		 this.pwbfc.set("opacity",0);
		 this.pwbecc.set("opacity",0);
		 this.pwbdc.set("opacity",0);
		 this.pwbsmc.set("opacity",0);
		 this.tip=this.createTip();
		 this.tip.set("morph",{duration:330});
		 this.tip.getElement("span").set("tween",{link:"cancel",transition:"quad:out"});
		 this.tip.setStyles({opacity:0,left:-175,top:90});
		 this.nav.fade("hide");
		 this.social=this.nav.getParent();
		 this.nav.addEvents({mouseover:this.toggleTip.bind(this),mouseout:this.toggleTip.bind(this)});
		 this.portfolio();
		 this.portwbb();
		 this.portwbf();
		 this.portwbec();
		 this.portwbd();
		 this.portwbsm();
		 this.logo.set("tween",{duration:600,transition:"back:out"});
		 this.folio.addEvent("click",this.moveSplash.bind(this));
		 this.wbb.addEvent("click",this.moveSplashwbb.bind(this));
		 this.wbf.addEvent("click",this.moveSplashwbf.bind(this));
		 this.wbec.addEvent("click",this.moveSplashwbec.bind(this));
		 this.wbd.addEvent("click",this.moveSplashwbd.bind(this));
		 this.wbsm.addEvent("click",this.moveSplashwbsm.bind(this));
	},
	
	showAll:function(){
		 this.wrapper.fade("in");
		 this.toggleSocial.delay(500,this)
	},
		 
	moveSplash:function(e){e.stop();
		 this.logo.tween("margin-top",370);
		//this.hidePortfolio.delay(700,this);
		 this.hidewbb.delay(700,this);
		 this.hidewbf.delay(700,this);
		 this.hidewbec.delay(700,this);
		 this.hidewbd.delay(700,this);
		 this.hidewbsm.delay(700,this);
		 this.showPortfolio.delay(700,this);
		 
	},
	
	moveSplashwbb:function(e){e.stop();
		 this.logo.tween("margin-top",370);
		this.hidePortfolio.delay(700,this);
		// this.hidewbb.delay(700,this);
		 this.hidewbf.delay(700,this);
		 this.hidewbec.delay(700,this);
		 this.hidewbd.delay(700,this);
		 this.hidewbsm.delay(700,this);
		 this.showwbb.delay(700,this)
	},
	
	moveSplashwbf:function(e){e.stop();
		 this.logo.tween("margin-top",370);
		 this.hidePortfolio.delay(700,this);
		 this.hidewbb.delay(700,this);
		 //this.hidewbf.delay(700,this);
		 this.hidewbec.delay(700,this);
		 this.hidewbd.delay(700,this);
		 this.hidewbsm.delay(700,this);
		 this.showwbf.delay(700,this)
	},
	
	moveSplashwbec:function(e){e.stop();
		 this.logo.tween("margin-top",370);
		 this.hidePortfolio.delay(700,this);
		 this.hidewbb.delay(700,this);
		 this.hidewbf.delay(700,this);
		 //this.hidewbec.delay(700,this);
		 this.hidewbd.delay(700,this);
		 this.hidewbsm.delay(700,this);
		 this.showwbec.delay(700,this)
	},
	
	
	moveSplashwbd:function(e){e.stop();
		 this.logo.tween("margin-top",370);
		this.hidePortfolio.delay(700,this);
		 this.hidewbb.delay(700,this);
		 this.hidewbf.delay(700,this);
		 this.hidewbec.delay(700,this);
		 //this.hidewbd.delay(700,this);
		 this.hidewbsm.delay(700,this);
		 this.showwbd.delay(700,this)
	},
	
	moveSplashwbsm:function(e){e.stop();
		 this.logo.tween("margin-top",370);
		 this.hidePortfolio.delay(700,this);
		 this.hidewbb.delay(700,this);
		 this.hidewbf.delay(700,this);
		 this.hidewbec.delay(700,this);
		 this.hidewbd.delay(700,this);
		 //this.hidewbsm.delay(700,this);
		 this.showwbsm.delay(700,this)
	},
	
	showwbb:function(){
			 if( Browser.Engine.webkit&&Browser.Engine.version>=525)
			 	{
					 this.pwbbc.set("opacity",1);
					 this.pwbbc.className="omg"
				}
			else{
				this.pwbbc.morph({opacity:1,top:[30,0]})
			}
	},
	
	showwbf:function(){
			 if( Browser.Engine.webkit&&Browser.Engine.version>=525)
			 	{
					 this.pwbfc.set("opacity",1);
					 this.pwbfc.className="omg"
				}
			else{
				this.pwbfc.morph({opacity:1,top:[30,0]})
			}
	},
	
	showwbec:function(){
			 if( Browser.Engine.webkit&&Browser.Engine.version>=525)
			 	{
					 this.pwbecc.set("opacity",1);
					 this.pwbecc.className="omg"
				}
			else{
				this.pwbecc.morph({opacity:1,top:[30,0]})
			}
	},
	
	
	showwbd:function(){
			 if( Browser.Engine.webkit&&Browser.Engine.version>=525)
			 	{
					 this.pwbdc.set("opacity",1);
					 this.pwbdc.className="omg"
				}
			else{
				this.pwbdc.morph({opacity:1,top:[30,0]})
			}
	},
	
	showwbsm:function(){
			 if( Browser.Engine.webkit&&Browser.Engine.version>=525)
			 	{
					 this.pwbsmc.set("opacity",1);
					 this.pwbsmc.className="omg"
				}
			else{
				this.pwbsmc.morph({opacity:1,top:[30,0]})
			}
	},
	
	showPortfolio:function(){
			 if( Browser.Engine.webkit&&Browser.Engine.version>=525)
			 	{
					 this.pfc.set("opacity",1);
					 this.pfc.className="omg"
				}
			else{
				this.pfc.morph({opacity:1,top:[30,0]})
			}
	},
	
	hidePortfolio:function(){
			 if( Browser.Engine.webkit&&Browser.Engine.version>=525)
			 	{
					 this.pfc.set("opacity",0);
					 this.pfc.className="omg"
				}
			else{
				this.pfc.morph({opacity:0,top:[0,30]})
			}
	},
	hidewbb:function(){
			 if( Browser.Engine.webkit&&Browser.Engine.version>=525)
			 	{
					 this.pwbbc.set("opacity",0);
					 this.pwbbc.className="omg"
				}
			else{
				this.pwbbc.morph({opacity:0,top:[0,30]})
			}
	},
	hidewbf:function(){
			 if( Browser.Engine.webkit&&Browser.Engine.version>=525)
			 	{
					 this.pwbfc.set("opacity",0);
					 this.pwbfc.className="omg"
				}
			else{
				this.pwbfc.morph({opacity:0,top:[0,30]})
			}
	},
	hidewbec:function(){
			 if( Browser.Engine.webkit&&Browser.Engine.version>=525)
			 	{
					 this.pwbecc.set("opacity",0);
					 this.pwbecc.className="omg"
				}
			else{
				this.pwbecc.morph({opacity:0,top:[0,30]})
			}
	},
	hidewbd:function(){
			 if( Browser.Engine.webkit&&Browser.Engine.version>=525)
			 	{
					 this.pwbdc.set("opacity",0);
					 this.pwbdc.className="omg"
				}
			else{
				this.pwbdc.morph({opacity:0,top:[0,30]})
			}
	},
	hidewbsm:function(){
			 if( Browser.Engine.webkit&&Browser.Engine.version>=525)
			 	{
					 this.pwbsmc.set("opacity",0);
					 this.pwbsmc.className="omg"
				}
			else{
				this.pwbsmc.morph({opacity:0,top:[0,30]})
			}
	},
									
	portfolio:function(){
			var i=0;
			var items=$$("#portfolio li");
			var els=$$("#portfolio-pagination a");
			var that=this;
			var back=els[0];
			var next=els[1];
			this.pf.set("tween",{duration:750,transition:"back:out"});
			back.fade(0.5);
			els.each(
					 function(el){
						 el.addEvents({
									click:function(e){
										  e.stop();
										  if(this.get("rel").contains("next")){i-=1}
										  else{i+=1}
										 
										 if((items.length+i)-1<=0){next.fade(0.5)}
										  else{next.fade(1)}
										 
										 if((items.length+i)<=0){i=i+1}
										 
										 if(i>=0){back.fade(0.5);i=0}
										  else{back.fade(1)}that.pf.tween("left",430*i)
									},
										  
									mouseenter:function(){},
									mouseleave:function(){}
							})
					}
			)
	},
	
	portwbb:function(){
			var i=0;
			var items=$$("#wbb li");
			var els=$$("#wbb-pagination a");
			var that=this;
			var back=els[0];
			var next=els[1];
			this.pwbb.set("tween",{duration:750,transition:"back:out"});
			back.fade(0.5);
			els.each(
					 function(el){
						 el.addEvents({
									click:function(e){
										  e.stop();
										  if(this.get("rel").contains("next")){i-=1}
										  else{i+=1}
										 
										 if((items.length+i)-1<=0){next.fade(0.5)}
										  else{next.fade(1)}
										 
										 if((items.length+i)<=0){i=i+1}
										 
										 if(i>=0){back.fade(0.5);i=0}
										  else{back.fade(1)}that.pwbb.tween("left",430*i)
									},
										  
									mouseenter:function(){},
									mouseleave:function(){}
							})
					}
			)
	},
	
	portwbf:function(){
			var i=0;
			var items=$$("#wbf li");
			var els=$$("#wbf-pagination a");
			var that=this;
			var back=els[0];
			var next=els[1];
			this.pwbf.set("tween",{duration:750,transition:"back:out"});
			back.fade(0.5);
			els.each(
					 function(el){
						 el.addEvents({
									click:function(e){
										  e.stop();
										  if(this.get("rel").contains("next")){i-=1}
										  else{i+=1}
										 
										 if((items.length+i)-1<=0){next.fade(0.5)}
										  else{next.fade(1)}
										 
										 if((items.length+i)<=0){i=i+1}
										 
										 if(i>=0){back.fade(0.5);i=0}
										  else{back.fade(1)}that.pwbf.tween("left",430*i)
									},
										  
									mouseenter:function(){},
									mouseleave:function(){}
							})
					}
			)
	},
	
	portwbec:function(){
			var i=0;
			var items=$$("#wbec li");
			var els=$$("#wbec-pagination a");
			var that=this;
			var back=els[0];
			var next=els[1];
			this.pwbec.set("tween",{duration:750,transition:"back:out"});
			back.fade(0.5);
			els.each(
					 function(el){
						 el.addEvents({
									click:function(e){
										  e.stop();
										  if(this.get("rel").contains("next")){i-=1}
										  else{i+=1}
										 
										 if((items.length+i)-1<=0){next.fade(0.5)}
										  else{next.fade(1)}
										 
										 if((items.length+i)<=0){i=i+1}
										 
										 if(i>=0){back.fade(0.5);i=0}
										  else{back.fade(1)}that.pwbec.tween("left",430*i)
									},
										  
									mouseenter:function(){},
									mouseleave:function(){}
							})
					}
			)
	},
	
	portwbd:function(){
			var i=0;
			var items=$$("#wbd li");
			var els=$$("#wbd-pagination a");
			var that=this;
			var back=els[0];
			var next=els[1];
			this.pwbd.set("tween",{duration:750,transition:"back:out"});
			back.fade(0.5);
			els.each(
					 function(el){
						 el.addEvents({
									click:function(e){
										  e.stop();
										  if(this.get("rel").contains("next")){i-=1}
										  else{i+=1}
										 
										 if((items.length+i)-1<=0){next.fade(0.5)}
										  else{next.fade(1)}
										 
										 if((items.length+i)<=0){i=i+1}
										 
										 if(i>=0){back.fade(0.5);i=0}
										  else{back.fade(1)}that.pwbd.tween("left",430*i)
									},
										  
									mouseenter:function(){},
									mouseleave:function(){}
							})
					}
			)
	},
	
	portwbsm:function(){
			var i=0;
			var items=$$("#wbsm li");
			var els=$$("#wbsm-pagination a");
			var that=this;
			var back=els[0];
			var next=els[1];
			this.pwbsm.set("tween",{duration:750,transition:"back:out"});
			back.fade(0.5);
			els.each(
					 function(el){
						 el.addEvents({
									click:function(e){
										  e.stop();
										  if(this.get("rel").contains("next")){i-=1}
										  else{i+=1}
										 
										 if((items.length+i)-1<=0){next.fade(0.5)}
										  else{next.fade(1)}
										 
										 if((items.length+i)<=0){i=i+1}
										 
										 if(i>=0){back.fade(0.5);i=0}
										  else{back.fade(1)}that.pwbsm.tween("left",430*i)
									},
										  
									mouseenter:function(){},
									mouseleave:function(){}
							})
					}
			)
	},
	
	getAssets:function(){
		new Asset.images(
			this.imageAssets,{onComplete:this.showAll.bind(this)})
	},
	
	toggleSocial:function(){
		this.nav.each(function(el,i){this.toggleDrop.delay(100*i,el)},this)
	},
	
	toggleDrop:function(){
		this.set("morph",{transition:"bounce:out",duration:1300});
		this.fade("in");
		this.morph({top:0})
	},
	createTip:function(){
		var wrapper=new Element("span",{id:"oskar-says","class":"sprite"});
		var inner=new Element("span",{"class":"sprite"}).inject(wrapper);
		var top=new Element("em",{"class":"osTop sprite"}).inject(inner);
		var bottom=new Element("em",{"class":"osBottom sprite"}).inject(inner);
		wrapper.inject(this.nav.getParent("ul")[0],"after");
		return wrapper
	},
	
	toggleTip:function(e){
		/*var target=$(e.target);
		var type=target.getParent().get("class");
		var mode=e.type.contains("over");
		if(mode&&target.get("tag").contains("a")){this.tip.getElement("span").tween("background-position","-524px "+target.get("rel").toString()+"px")}
		this.tip.morph({
			opacity:(mode?1:0),
			left:(mode?-160:-175),
			top:(mode?75:90)})*/
	}
});


window.addEvent("domready",function(){new Nouincolor()});