
var animating = false;
var Initial = function(){

    var content = $('content');
    var new_content = $('new-content');
    var current_content = $('current-content');

    content.setStyle('overflow','hidden');
    content.setStyle('position','relative');
    // move new-content out of the way
    new_content.setStyles({
        'position' : 'absolute',
        'top' : 0,
        'left' : 984,
        'width': 984
    });
    // manually set the height of the content div
    content_dim = current_content.getSize();
    /*content.setStyles({
        'height' : content_dim.y,
        'width' : content_dim.x
        });*/
    current_content.setStyles({
        'position' : 'relative',
        'top' : 0,
        'left' : 0,
        'width': 984
    });
  
}

var slideShow = function (url,flag){
	if (animating) return false;
    animating = true;
    
    var content = $('content');
    var new_content = $('new-content');
    var current_content = $('current-content');
    
    url = url + "&layout=ajax";
    new Request.HTML({
        'url' : url,
        onSuccess : function(domTree,elements,html,js){
    		//response.tree, response.elements, response.html, response.javascript

            new_content.set('html',html);
            new_content.set('tween',{duration:400});
            current_content.set('tween',{duration:400,onComplete:function(){
                current_content.set('html','');
                current_content.set('id','new-content');
                new_content.set('id','current-content');
                Initial();
                
                animating = false;
            }});
            var ccl;
            if (flag){ // we're going from right to left
                new_content.setStyle('left',-984);
                cc_l = 984;
            } else { // going from left to right
                cc_l = -984;
            }
            current_content.tween('left',cc_l);
            new_content.tween('left',0);
        }
    }).send();
    
    return false;
}

window.addEvent('load',Initial);

