// JavaScript Document



var h = {
	
	d : 2000,
	t : 'quart:out',
	imgs : {
		'home' :	
			[
			'images/chairs2.jpg',
			'images/photo-room.jpg'
			],
		'about' : 
			[
			 'galleries/home/cr-website-images-6.jpg',
			 'images/way-we-work.jpg',
			 'images/the-team.jpg',
			 'images/the-team-henri.jpg',
			 'images/the-team-aimee.jpg'
			],
		'news' :
			[
			 'images/news_bg3.jpg'
			],
		'contact' :
			[
			'images/contact2.jpg'
			]
	},
	fx : '',
	
	hideLeft: function(el){
		var x = el.getSize().x;
		el.setStyle('left', x - (x * 2) );
	},
	
	init: function(p){
		centre();
		if( p == 'home' ) $('content').setStyle('height', 0);
		if( p != 'portfolio'  && p != 'home' ){
			h.hideLeft( $('text-screen') );
			$('text-content').setStyle('left', -250);
			$('img').setOpacity(0);
		}
		h.hideLeft( $('logo') );
	    
        if( p == 'about' ){
            $('img').setStyle('background-image', 'url(' + h.imgs[p][0] + ')');
            h.fx = new Fx.Elements( [$('content'), $('text-screen'), $('logo'), $('img'), $('text-content')], {duration:h.d, transition:h.t, link:'chain'} ); 
            h.fx.start({
                '3' : {
                    'opacity' : 1
                }
            });
            h.fx.start({
                '1' : {
                    'left' : 0
                },
                '2' : {
                    'left' : 0
                },
                '4' : {
                    'left' : 170
                }
            });
        } else if( p != 'portfolio' && p != 'home' ){
            $('img').setStyle('background-image', 'url(' + h.imgs[p].getRandom() + ')');
            h.fx = new Fx.Elements( [$('content'), $('text-screen'), $('logo'), $('img'), $('text-content')], {duration:h.d, transition:h.t, link:'chain'} ); 
            h.fx.start({
                '3' : {
                    'opacity' : 1
                }
            });
            h.fx.start({
                '1' : {
                    'left' : 0
                },
                '2' : {
                    'left' : 0
                },
                '4' : {
                    'left' : 170
                }
            });
		}else{
			$('img').setStyle('background-image', 'none');
			h.fx = new Fx.Elements( [$('content'), $('logo'), $('text-screen')], {duration:h.d, transition:h.t, link:'chain'} ); 
			h.fx.start({
				'0' : {
					'height' : 490
				}
			});
			if( p == 'portfolio' ){
				h.fx.start({
                    '2' : {
                        'left' : 0
                    }
                }).start({
                    '1' : {
                        'left' : 0
                    }
				});
			}
			if( p == 'home' ){
				h.hideLeft( $('text-screen') );
				homePage.delay(2000);
			}
			
		}
		
	}
}


