var Devthought = {
	init: function() {
		this.setCodes();
	},

	setCodes: function() {
		if(window.ie)
			this.copyarea = new Element('textarea').setStyle('display', 'none').injectInside(document.body);
				
		$$('.contain_topic').each(function(el){
			var a = el.getElement('.topic'), pre = el.getElement('div');
			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('padding-right', {duration: 200, wait: false});
			a.addEvent('mouseover', function(){ a.fx.start(30);});
			a.addEvent('mouseout', function(){ a.fx.start(15);});
						
			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(''));
		}.bind(this));
	},

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

function expand_all() {
    $("expand-all").style.display="none";
    $("collapse-all").style.display="block";
    for(i = 0; i < $$(".slide").length; i++){
        slide = $$(".slide")[i];
        slide.style.height = "auto";
        slide.shown = true;
    }
}

function contract_all() {
    $("expand-all").style.display="block";
    $("collapse-all").style.display="none";
    for(i = 0; i < $$(".slide").length; i++){
        slide = $$(".slide")[i];
        slide.style.height = "0px";
        slide.shown = false;
    }
}

try { Window.disableImageCache(); } catch(e){}
window.addEvent('domready', function(){ Devthought.init() });