function $E(tag,el){return $(el||document).getElement(tag)}


function pageWidth() {return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;} function pageHeight() {return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;} function posLeft() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;} function posTop() {return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;} function posRight() {return posLeft()+pageWidth();} function posBottom() {return posTop()+pageHeight();}


window.addEvents({ domready:function(){
	
	if ($("clickmap")) {
	
	var nheight = pageHeight()-70;
 	$("clickmap").setStyle("height", nheight+"px");	

	var halfheight = pageHeight() / 2-100;
	$("arrowleft").setStyle("top", halfheight+"px");	
	$("arrowright").setStyle("top", halfheight+"px");	


	$('clickmapleft').addEvent('mouseenter', function(){
   		$("arrowleft").setStyle("display", "block"); 
   	});

	$('clickmapleft').addEvent('mouseleave', function(){
	   $("arrowleft").setStyle("display", "none");
	});

	$('clickmapright').addEvent('mouseenter', function(){
	   $("arrowright").setStyle("display", "block");
	});
	
	$('clickmapright').addEvent('mouseleave', function(){
	   $("arrowright").setStyle("display", "none");
	});
	
	$('nav1').addEvent('mouseenter', function(){
	   $("textdescript").setStyle("display", "none");
	});
	
	$('nav1').addEvent('mouseleave', function(){
	   $("textdescript").setStyle("display", "block");
	});


	
	/* Tips 4 
	var Tips4 = new Tips($$('.Tips4'), {
			showDelay: 900,
			hideDelay: 400,
			className: 'custom'
	});*/

		
	}
	
	//new Effect.Appear('fade');
	
	//new Fx.Style("myDiv1", "opacity").start(1.0);
	
	//$("fade").setStyle("display", "block");
	
	//new Fx.Style("fade", "opacity").start(0.0);
	
//$('fadeimg').fade('.9');

/*
var myFunction = function(){
	var div = $('fade').setStyle('display', 'block');
	new Fx.Style(div, 'opacity', {duration: 1000} ).start(1);
};
 
myFunction(); //<- this does it all
*/

/*
$('active').addEvent('mouseover', function(){
    alert('clicked!');
});
*/






/*
var mySlide = new Fx.Slide('flyout');




$('active').addEvent('mouseenter', function(e){
		e.stop();
		mySlide.show();
	});

$('active').addEvent('mouseleave', function(e){
		e.stop();
		mySlide.hide();
	});


*/


		if ($('fadeimgg')) {	

		var div = $('fadeimg').setStyles({
                display:'block',
                opacity: 0
        });

		
		
       // in 1.2

        new Fx.Morph(div, {duration:1000, onComplete: function() {
                new Fx.Morph(div, {duration:2000}).start({opacity:1});
        }}).start({'opacity':1}); 
        
      
        }
 
        
        
/*

Senaste fungerande

var myVerticalSlide = new Fx.Slide('vertical_slide');

myVerticalSlide.hide();

$('v_toggle').addEvent('click', function(e){
		e.stop();
		myVerticalSlide.toggle();
	});

*/



		$extend(kina,{bg:$E('img',$E('#bg',db=$(document.body))),timer:(Browser.Engine.gecko||Browser.Engine.webkit)?null:setInterval(kina.fix,200),menu:$('menu')});/*gal.call(gal);*/
		if($$('dl')[0]){var hs=$$('dt'),fx=hs.map(function(el){return new Fx.Morph(el,{wait:false})});new Accordion(hs,hs.getNext(),{opacity:false,onActive:function(head,box){if($chk(this.active))fx[this.active].start({'color':'#000','backgroundColor':'#fff'});fx[this.active=this.togglers.indexOf(head)].start({'color':'#fff','backgroundColor':'#000'})}})}
	},
	keypress:function(e){var e=new Event(e);if(e.key=='down'||e.key=='right')e.stop()}
});

kina={
	doc:{x:0,y:0},
	fix:function(){if(kina.bg.complete&&(db.offsetWidth!=kina.doc.x||db.offsetHeight!=kina.doc.y||kina.fix.src!=kina.bg.src)){
		
		var bg=kina.bg.getSize();
		kina.doc={x:db.offsetWidth,y:db.offsetHeight};
		kina.fix.src==kina.bg.src||$extend(kina.fix,{p:bg.x/bg.y,src:kina.bg.src});
		kina.bg.setStyles({width:(bg.y=kina.doc.x>(bg.x=Math.round(kina.doc.y*kina.fix.p)))?kina.doc.x:bg.x,height:bg.y?Math.round(kina.doc.x/kina.fix.p):kina.doc.y})}}
}

/*
$extend(gal=function(){
	if(gal.el=$('photos')){$extend(this,{fx:new Fx.Tween(kina.menu,'bottom'),float:$('float').addEvent('click',gal.key)}).el.getElements('a').addEvent('click',this.swap)[0].addClass('cur');document.addEvents({mousemove:gal.mouse,keydown:gal.key})}
},{
	mouse:function(e){var w=db.offsetWidth/2,x=e.client.x,y=db.offsetHeight-e.client.y,el=gal.float;if(y<(gal.menu?85:20)){$clear(gal.timer);gal.menu||(gal.menu=gal.fx.start(20))}else{if(gal.menu)gal.menu=!(gal.timer=setTimeout(function(){gal.fx.start(-55)},700));else{if(y<85&&el.className)el.className=el.style.display='';else if(y>85){if(!el.className)el.style.display='block';if(x>w&&el.className!='nxt')el.className='nxt';else if(x<w&&el.className!='prv')el.className='prv';with(el.style){left=x-20+'px';top=e.client.y-10+'px'}}}}},
	swap:function(){$E('.cur',gal.el).removeClass('cur');kina.bg.src=this.addClass('cur').getElement('img').src},
	key:function(e){var nxt=e.key?(e.code==39):(gal.float.className=='nxt');return (e.key&&e.code!=37&&e.code!=39)?false:gal.swap.call($E('.cur',gal.el)[nxt?'getNext':'getPrevious']()||gal.el[nxt?'getFirst':'getLast']())},
	menu:true
});*/