/**
 * @author duncan austin
 */
function toggle_post(id){
    var more = "more...";
    var less = "less...";
    var height = ($('post' + id).offsetHeight != $('teaser' + id).offsetHeight) ? $('post' + id).offsetHeight + 'px;' : '4.5em;';
    
    $('teaser' + id).morph('height:' + height, {
        duration: 0.2
    });
    $('more' + id).innerHTML = ($('post' + id).offsetHeight != $('teaser' + id).offsetHeight) ? less : more;
    
}

function show_article(e){
	e = $(e);
	if (e.className=='news'){
		e.morph('news_full');
	}else{
		e.className='news';
	}
}

/*
Event.observe(window, 'load', function(){
    $$('a[href^=#]:not([href=#])').each(function(element){
        element.observe('click', function(event){
            new Effect.ScrollTo(this.hash.substr(1), {
                duration: 2
            });
            Event.stop(event);
        }
.bindAsEventListener(element))
    })
});
*/

function init_home_image_animation(prefix){
    var w = 20;
        
     $$('#title-image-home-wrapper img').each(function(e){
         w += e.offsetWidth;
     });
     $('title-image-home-wrapper').style.width = w + 'px';
}

var i = 0;

function home_image_animation(prefix){

    setTimeout(function(){
		var left = $('title-image-home-wrapper').offsetLeft-667;
		if(i==2){
			left=0;
			$('title-image-home-wrapper').style.left = left + 'px';
			i=0;
			
		}else{
			 $('title-image-home-wrapper').morph('left:'+left+'px;', {duration:0.5});
			 i++;
		}
      
        home_image_animation(prefix);
    }, 3000);
}

function init(prefix){
    init_home_image_animation(prefix);
    home_image_animation(prefix);
}



