

CD3.Behaviors({
	'#top_menu li':{
		mouseover: function(){
			var lito = this;
			if (lito.down('div')){
				lito.down('div').style.display = 'block' ;
			}
			lito.addClassName('overa');
		},
		mouseout: function(){
			var lito = this;
			if (lito.down('div')){
				lito.down('div').style.display = 'none' ;
			}
			lito.removeClassName('overa');
		}
	},
	'#bubal tr':{
		mouseover: function(){
				this.addClassName('bblack');
		},
		mouseout: function(){
			this.removeClassName('bblack');
		},
		click: function(){
			
				$$('#bubal tr').each(function(all){
						all.removeClassName('bblack23');
					})
					this.addClassName('bblack23');
				
				if( this.down('img.small')){
					$('out_head_a').style.background = ' #ffffff url(' + this.down('img.small').src  + ') no-repeat center';
					$('out_head_a').href =  this.down('img.big').src ;
				}
				var alta = this.down('img.small').alt;
				
				$$('#ap_map a').each(function(all){
					all.removeClassName('marked');
					if( all.hasClassName('map_a_'+ alta +'') ){
						all.addClassName('marked');
					}
				})
				Effect.ScrollTo('out_head_a');
		} 
	},
	'#ap_map a:click': function(a){
		a.stop();
		v = this.readAttribute('class').replace('map_a_','');
		
		$('out_head_a').style.background = 'url(' + $$('#bubal tr')[v].down('img.small').src  + ') #ffffff no-repeat center';
		$('out_head_a').href =  $$('#bubal tr')[v].down('img.big').src ;
		
		$$('#bubal tr').each(function(all){
			all.removeClassName('bblack23');
		})
		
		$$('#bubal tr')[v].addClassName('bblack23');
		
		$$('#ap_map a').each(function(all){
				all.removeClassName('marked');
			})
		
		this.addClassName('marked');
	},
	'#play_button':{
		click: function(){
			$('video_player').appear();
			
			var FlashVars = {};
			var s={};
			//s.menu = false;
			//s.bgcolor = '#CCCCCC';
			//s.wmode = 'transparent';
			
			swfobject.embedSWF("swf/video.swf", "video_player", "270", "137", "9.0.0" , "swf/expressInstall.swf" , FlashVars , s );

		}
	},
	'input[type=text]': {
		focus: function(){
			if (this.getValue() == this.getAttribute('title')) 
				this.setValue('');
		},
		blur: function(){
				if (this.getValue().length == 0) this.setValue(this.getAttribute('title'));
			}
	},
	'#left_col .tele': function(){
		this.innerHTML = 'Randi Tveit<span>95 29 06 91</span></div><img class="blue_logo" src="img/blue_logo.jpg" alt="small logo" /><p style=" position:absolute; left:32px; bottom:-145px; font-size:11px; padding-top:20px; color:#d32a3e;">Alle tegninger, 3D og illustrasjoner er kun ment å gi inntrykk av en ferdig bebyggelse. Det kan således inneholde elementer som ikke inngår i utbyggers leveranse, både når det gjelder utvendige forhold og innredning. Disse gjelder derfor ikke som kontraktsmateriell.<p>';
		this.style.visibility = 'visible';
	}
});

function animate(element, timeout){
	var index 		= 0,
		backgrounds = ['img/index_head_1.gif', 'img/index_head_2.gif', 'img/index_head_3.jpg'];

	element = $(element);
	timeout = timeout || 2000;

	setTimeout(function(){
		//var sol = element.style.backgroundImage = 'url(' + backgrounds[index] + ')';
		element.morph('opacity:0.6', {
			afterFinish:function(){
				element.style.backgroundImage = 'url(' + backgrounds[index] + ')';
				new Effect.Opacity ( element,  { duration:0.7, from: 0.6 , to:1.0 })
				new Effect.Morph(element, {style: 'background-image:url( ' + backgrounds[index] + ' ) '	})

			}
		});
		
		index++;
		if (index < 2){
			setTimeout(arguments.callee, timeout);
		}
		
	}, timeout);
}



