/**
 * @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 = 25;
        
     $$('#'+prefix+'image-wrapper img').each(function(e){
         w += e.offsetWidth;
     });
     $(prefix+'image-wrapper').style.width = w + 'px';
}
var anim_i = 0;
function home_image_animation(prefix){

    setTimeout(function(){
		var left = $(prefix+'image-wrapper').offsetLeft-$(prefix+'image-container').offsetWidth;
		if(anim_i ==3){
			left=0;
			$(prefix+'image-wrapper').style.left = left + 'px';
			anim_i =0;
		}else{
			 $(prefix+'image-wrapper').morph('left:'+left+'px;', {duration:0.5});
			 anim_i ++;
		}
      
        home_image_animation(prefix);
    }, 6000);
}

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



