//////////////////////////////////////////////////////////////
//              		 Portfolio v2					    //
//////////////////////////////////////////////////////////////
/*															*/
/*															*/
/*															*/
/*															*/
/*															*/
/*															*/
/*															*/
//////////////////////////////////////////////////////////////

var Site = {

	start : function (){
		
	},
	
	checkCurrent : function(currentLink){
		
	}
	
};







//window.addEvent('load', Site.start);


var SlideList = new Class({
	initialize: function(menu, options) {
		this.setOptions(this.getOptions(), options);
		
		this.menu = $(menu), this.current = this.menu.getElement('li.current');
		
		this.menu.getElements('li').each(function(item){
			item.addEvent('mouseover', function(){ this.moveBg(item); }.bind(this));
			item.addEvent('mouseout', function(){ this.moveBg(this.current); }.bind(this));
			item.addEvent('click', function(event){ this.clickItem(event, item); }.bind(this));
		}.bind(this));
				
		this.back = new Element('li').addClass('background').adopt(new Element('div').addClass('left')).injectInside(this.menu);
		this.back.fx = this.back.effects(this.options);
		if(this.current) this.setCurrent(this.current);
	},
	
	setCurrent: function(el, effect){
		this.back.setStyles({left: (el.offsetLeft)+'px',top: (el.offsetTop)+'px', width: (el.offsetWidth)+'px'});
		(effect) ? this.back.effect('opacity').set(0).start(1) : this.back.setOpacity(1);
		this.current = el;
	},
	
	getOptions: function(){
		return {
			transition: Fx.Transitions.sineInOut,
			duration: 500, wait: false,
			onClick: Class.empty
		};
	},

	clickItem: function(event, item) {
		if(!this.current) this.setCurrent(item, true);
		this.current = item;
		this.options.onClick(new Event(event), item);
	},

	moveBg: function(to) {
		if(!this.current) return;
		this.back.fx.custom({
			top: [this.back.offsetTop, to.offsetTop],
			left: [this.back.offsetLeft, to.offsetLeft],
			width: [this.back.offsetWidth, to.offsetWidth],
			opacity: '1'
		});
	}
});

SlideList.implement(new Options);


var Devthought = {
	init: function() {
		new SlideList($E('ul', 'menu'));
		
		this.setCodes();
	},

	

	setCodes: function() {
		if(window.ie)
			this.copyarea = new Element('textarea').setStyle('display', 'none').injectInside(document.body);
				
		$$('.code').each(function(el){
			var a = el.getElement('.seecode'), pre = el.getElement('ol');
			pre.h = pre.offsetHeight;
			pre.fx = pre.effect('height', {onComplete: function(){ pre.shown = ! pre.shown; }}).set(0);
						
			a.addEvent('click', function(event){
				new Event(event).stop();
				(!pre.shown) ? pre.fx.start(pre.h) : pre.fx.start(0);
			});
			
			a.fx = a.effect('margin-left', {duration: 200, wait: false});
			a.addEvent('mouseover', function(){ a.fx.start(5);});
			a.addEvent('mouseout', function(){ a.fx.start(0);});
						
			if(window.ie) $(a.parentNode).adopt(new Element('a').setProperties({
				href: '#',
				onclick: function(ev){ new Event(ev).stop(); this.copyCode(pre); }.bind(this)
			}).addClass('copycode').setHTML('Copy'));
		}.bind(this));
	},

	copyCode: function(el) {
		this.copyarea.innerText = el.innerText;
		this.copyarea.createTextRange().execCommand("Copy");
	}
}

try { Window.disableImageCache(); } catch(e){}


