var Map;
var Url;
var Site = {

	
	start: function()
	{	

		if (window.ie6) location.href='/unsupportedbrowser.php'; 
	
		Site.menu1(); 	// animation
		Site.menu2(); 	// visual		
		Site.nav1(); 	// navigation menu, visual
		Site.sidebar(); // sidebar
		Site.logo(); 	// logotype
		Site.top(); 	// all top bar
		Site.tips();	// tips
		Site.mainpage();// main page
		
		
	
	},
	

	preload: function(truefalse)
	{
		/*
	
		
			var fx = new Fx.Styles($('preloader-inner-status'), {duration:3000, wait:false});	
			var fx2 = new Fx.Styles($('preloader'), {duration:1000, wait:false});
			var fx3 = new Fx.Styles($('preloader-inner'), {duration:10, wait:false});
			
			if (truefalse)
			{		
				fx.start({ 'width': '300px' });
			}
			else
			{
				fx2.start({	'height': '0px' });	
				$('preloader-inner').setStyle('display', 'none');
				$('preloader-inner-status').setStyle('display', 'none');			
			}
			
		*/
		
	},	
	
	map: function()
	{
		$('content').innerHTML = '<h1>Interactive map</h1><p><strong>You can find your way across Scandinavian countries using our interactive map,<br/>just like the way a navigator uses stars.</strong></p><div id="gmapWrap"><div id="gmap"></div></div>';
		loadGoogleMaps();
	},
	
	loadMap: function() {
      map = new GMap2(document.getElementById("gmap"));
      map.setCenter(new GLatLng(37.4419, -122.1419), 6);
      map.addOverlay(new GMarker(map.getCenter()));
	},
	
	includeScript: function(filename)
	{
		var body = document.getElementsByTagName('body').item(0);
		script = document.createElement('script');
		script.src = filename;
		script.type = 'text/javascript';
		body.appendChild(script)
	},	
	
	mainpage: function()
	{
		
		e = $('btn-qrsmall');		
		
		if (e)
		{
			
			var fx = new Fx.Styles(e, {duration:300, wait:false, transition: Fx.Transitions.Quad.easeOut});
		
			e.addEvent('mouseenter', function(event) {			
				fx.start({
					'margin-left': '10px',
					'opacity': '0.6'
				});
			});			
			
			e.addEvent('mouseleave', function(event) {				
				fx.start({				 
					'margin-left': '0',
					'opacity': '0.99'				
				});
			});				
			
		}
		
	},
	
	menu1: function()
	{
	
		// setup
		var height = 16;		
	
		// sweden		
		var objsweden = $('vd-div-sweden');
		var objnorway = $('vd-div-norway');
		var objfinland = $('vd-div-finland');		
		var objdenmark = $('vd-div-denmark');
		var objiceland = $('vd-div-iceland');
		


		var fxsweden = new Fx.Styles(objsweden, {duration:200, wait:false});	
		var fxnorway = new Fx.Styles(objnorway, {duration:200, wait:false});	
		var fxfinland = new Fx.Styles(objfinland, {duration:200, wait:false});	
		var fxdenmark = new Fx.Styles(objdenmark, {duration:200, wait:false});	
		var fxiceland = new Fx.Styles(objiceland, {duration:200, wait:false});	
		
		objsweden.addEvent('mouseleave', function(event) { fxsweden.start({ 'height': height+'px' }); });
		objnorway.addEvent('mouseleave', function(event) { fxnorway.start({ 'height': height+'px' }); });
		objfinland.addEvent('mouseleave', function(event) { fxfinland.start({ 'height': height+'px' }); });
		objdenmark.addEvent('mouseleave', function(event) { fxdenmark.start({ 'height': height+'px' }); });
		objiceland.addEvent('mouseleave', function(event) { fxiceland.start({ 'height': height+'px' }); });		
		

		objsweden.addEvent('mouseenter', function(event) {
			event = new Event(event).stop();	
			heightall = height * 8;
			fxsweden.start({
				'height': heightall+'px'		
			});	
			
			fxnorway.start({'height': height+'px'});	
			fxfinland.start({'height': height+'px'});	
			fxdenmark.start({'height': height+'px'});	
			fxiceland.start({'height': height+'px'});				
		});	
	
		objnorway.addEvent('mouseenter', function(event) {
			event = new Event(event).stop();	
			heightall = height * 8;
			fxnorway.start({
				'height': heightall+'px'		
			});	
			
			fxsweden.start({'height': height+'px'});	
			fxfinland.start({'height': height+'px'});	
			fxdenmark.start({'height': height+'px'});	
			fxiceland.start({'height': height+'px'});				
		});	
		
		objfinland.addEvent('mouseenter', function(event) {
			event = new Event(event).stop();	
			heightall = height * 8;
			fxfinland.start({
				'height': heightall+'px'		
			});	
			
			fxnorway.start({'height': height+'px'});	
			fxsweden.start({'height': height+'px'});	
			fxdenmark.start({'height': height+'px'});	
			fxiceland.start({'height': height+'px'});				
		});	
	
		objdenmark.addEvent('mouseenter', function(event) {
			event = new Event(event).stop();	
			heightall = height * 8;
			fxdenmark.start({
				'height': heightall+'px'		
			});		
			
			fxnorway.start({'height': height+'px'});	
			fxfinland.start({'height': height+'px'});	
			fxsweden.start({'height': height+'px'});	
			fxiceland.start({'height': height+'px'});				
		});	
		
		objiceland.addEvent('mouseenter', function(event) {
			event = new Event(event).stop();	
			heightall = height * 8;
			fxiceland.start({
				'height': heightall+'px'		
			});	
			
			fxnorway.start({'height': height+'px'});	
			fxfinland.start({'height': height+'px'});	
			fxdenmark.start({'height': height+'px'});	
			fxsweden.start({'height': height+'px'});				
		});	
		


	},
	
	menu2: function()
	{
		var list = $$('.vd-link-country, .vd-link-city, .cs-link, .case-link');
		list.each(function(e) {
			var fx = new Fx.Styles(e, {duration:100, wait:false});	
			
			e.addEvent('mouseenter', function(event) {			
				fx.start({
					'padding-left': '0'
				});
			});			
			
			e.addEvent('mouseleave', function(event) {			
				fx.start({
					'padding-left': '0'
				});
			});				

		});
	
		
	},
	
	
	
	nav1: function()
	{
		var list = $$('.dfmenu-li');
		list.each(function(e) {
			var left = e.getChildren()[0];
			var right = e.getChildren()[1];			
			var fx = new Fx.Styles(e, {duration:200, wait:false});			
			var fxleft = new Fx.Styles(left, {duration:200, wait:false});
			var fxright = new Fx.Styles(right, {duration:200, wait:false});	
			
			e.addEvent('mouseenter', function(event) {	
				left.addClass('dfmenu-li-left-active');
				right.addClass('dfmenu-li-right-active');				
				fx.start({
					'margin-top': '0'
				});
			});			
			
			e.addEvent('mouseleave', function(event) {	
				left.removeClass('dfmenu-li-left-active');											  
				right.removeClass('dfmenu-li-right-active');				
				fx.start({
					'margin-top': '0'
				});
			});				

		});		
	},
	
	logo: function()
	{
		var e = $('logo-link');
		var i = $('logo-image');		
		var label = $('logo-label');	
		label.setStyle('opacity','0');
		label.setStyle('display','inline');		
		
		var fx = new Fx.Styles(i, {duration:300, wait:false});			
		var fxlabel = new Fx.Styles(label, {duration:200, wait:false});	

		e.addEvent('mouseenter', function(event) {	
			fx.start({
				'width': '150px',
				'height': '57px'
			});

			fxlabel.start({
				'opacity': '0.99'
			});

		});			
		
		e.addEvent('mouseleave', function(event) {				
			fx.start({				 
				'width': '184px',
				'height': '70px'
			});

			fxlabel.start({
				'opacity': '0'
			});
			
		});				
	
	},
	
	
	top: function()
	{			
			
		if (!window.ie)
		{			
			var list = $$('.top-item');
			list.each(function(e) {
				
		
				var fx = new Fx.Styles(e, {duration:300, wait:false, transition: Fx.Transitions.Quad.easeOut});			
				
			
		
				e.addEvent('mouseenter', function(event) {			
					fx.start({
						'margin-top': '10px',
						'opacity': '0.6'
					});
				});			
				
				e.addEvent('mouseleave', function(event) {				
					fx.start({				 
						'margin-top': '0',
						'opacity': '0.99'				
					});
				});	
				
			});
		}

	
	},
	
	sidebar: function()
	{	
		// menu		
		var list = $$('.sidebar-btn');
		list.each(function(el) {	
	
			var overfxs = new Fx.Styles(el, {duration:200, wait:false});	
			var objid = el.getProperty("id");
			if (!window.ie )
			{	
				el.addEvent('mouseenter', function(e){
					overfxs.start({
						'margin-left': '3px'
					});
				});
				el.addEvent('mouseleave', function(e){
					overfxs.start({
						'margin-left': '0'
					});
				});			
			}	
			 
		});	
		
		e = $('sidebar-btn-venue');
		var fx = new Fx.Styles(e, {duration:200, wait:false});
			e.addEvent('mouseenter', function(e){
				fx.start({
					'height': '270px'
				});
			});
			e.addEvent('mouseleave', function(e){
				fx.start({
					'height': '62px'
				});
			});	
			
		e2 = $('sidebar-btn-spotlight');
		var fx2 = new Fx.Styles(e2, {duration:200, wait:false});
			e2.addEvent('mouseenter', function(e2){
				fx2.start({
					'height': '140px'
				});
			});
			e2.addEvent('mouseleave', function(e2){
				fx2.start({
					'height': '62px'
				});
			});	
			
			
		emap = $('sidebar-btn-map');
		emap.addEvent('click', function(event) { Site.map(); emap.setStyle('outline','none'); });			
			
	},		
	
	tips: function()
	{
		var Tips1 = new Tips($$('.tips'));		
	}

		
};






var Flashmovie = {

	start: function()
	{
	
		var so = new SWFObject("/displayVideo/flvplayer2.swf","flvplayer","445","275","8","#000000");
		so.addParam("movie","/displayVideo/flvplayer2.swf");
		so.addParam("wmode","transparent");
		so.write("flashcontent");	
	
	}
	
}





var Dfmenu = {


	menu3: function()
	{
		
		// prepare
		var hijos = $$('.dfmenu-child');
		hijos.each(function(el, i){
			el.setStyle('display', 'block');				
		});
	
		// walk through
		var list = $$('.dfmenu-li');
		list.each(function(element) {	
						   

			
			if (element.getChildren()[2])
			{
				hijos = element.getChildren()[2];
	
				var height = hijos.getStyle('height');	 
				hijos.setStyle('height','0px');				
				var fx = new Fx.Styles(hijos, {duration:300, wait:false});					
					
				element.addEvent('mouseenter', function(){	
						fx.start({
							'height': height
						});							
				});					
				
				element.addEvent('mouseleave', function(){	
						fx.start({
							'height': '0px'		
						});	
				});		
			}						
		});	
		

		// remove border at last list item								   
		var list = $$('.pie');
		list.each(function(element) {	
			if (element.getPrevious()) element.getPrevious().getChildren()[0].setStyle('border','0');
		});	
		
		
		
	},
	
	menu4: function()
	{	
		// menu		
		var list = $$('.dfmenu-child-a');
		list.each(function(el) {	
	
			var overfxs = new Fx.Styles(el, {duration:200, wait:false});	
	
			el.addEvent('mouseenter', function(e){
				overfxs.start({
					'margin-left': '0',
					'color': '#ffffff'
				});
			});
			el.addEvent('mouseleave', function(e){
				overfxs.start({
					'margin-left': '0',
					'color': '#ffffff'					
				});
			});			
				
			 
		});	
	}
	
	


	
}












var Map = {
	
	start: function()
	{
		
		
		
		// set up star
		var star = $('mapa-star');
		var fx = new Fx.Styles(star, {duration:200, wait:false});					
		
		// set up array destinations
		var dest = new Array(); // new Array(5)
		for (i=0; i <19; i++)
		dest[i]=new Array(3)
		
		// sweden
		dest[0][0] = "mapa-destination-link-stockholm";
		dest[0][1] = "202px";
		dest[0][2] = "695px";		
		dest[1][0] = "mapa-destination-link-kiruna";
		dest[1][1] = "120px";
		dest[1][2] = "705px";		
		dest[2][0] = "mapa-destination-link-malmo";
		dest[2][1] = "244px";
		dest[2][2] = "667px";		
		dest[3][0] = "mapa-destination-link-goteborg";
		dest[3][1] = "220px";
		dest[3][2] = "662px";		
		dest[4][0] = "mapa-destination-link-lulea";
		dest[4][1] = "145px";
		dest[4][2] = "713px";
		
		$('mapa-staricon-stockholm').setStyles({ top: '206px', left: '699px' });
		$('mapa-staricon-goteborg').setStyles({ top: '224px', left: '666px' });
		$('mapa-staricon-malmo').setStyles({ top: '246px', left: '671px' });
		$('mapa-staricon-kiruna').setStyles({ top: '124px', left: '709px' });
		$('mapa-staricon-lulea').setStyles({ top: '149px', left: '717px' });		

		// norway
		dest[5][0] = "mapa-destination-link-oslo";
		dest[5][1] = "205px";
		dest[5][2] = "657px";		
		dest[6][0] = "mapa-destination-link-bergen";
		dest[6][1] = "190px";
		dest[6][2] = "630px";		
		dest[7][0] = "mapa-destination-link-trondheim";
		dest[7][1] = "159px";
		dest[7][2] = "660px";		
		dest[8][0] = "mapa-destination-link-tromso";
		dest[8][1] = "95px";
		dest[8][2] = "705px";		
		dest[9][0] = "mapa-destination-link-stavanger";
		dest[9][1] = "200px";
		dest[9][2] = "640px";		
		dest[10][0] = "mapa-destination-link-lofoten";
		dest[10][1] = "150px";
		dest[10][2] = "670px";		
		dest[11][0] = "mapa-destination-link-alta";
		dest[11][1] = "90px";
		dest[11][2] = "720px";	
		
		$('mapa-staricon-oslo').setStyles({ top: '209px', left: '661px' });		
		$('mapa-staricon-bergen').setStyles({ top: '194px', left: '634px' });		
		$('mapa-staricon-trondheim').setStyles({ top: '163px', left: '664px' });		
		$('mapa-staricon-tromso').setStyles({ top: '99px', left: '709px' });		
		$('mapa-staricon-stavanger').setStyles({ top: '204px', left: '644px' });		
		$('mapa-staricon-lofoten').setStyles({ top: '154px', left: '674px' });		
		$('mapa-staricon-alta').setStyles({ top: '94px', left: '724px' });				
		
		
		//finland
		dest[12][0] = "mapa-destination-link-helsinki";
		dest[12][1] = "195px";
		dest[12][2] = "725px";		
		dest[13][0] = "mapa-destination-link-turku";
		dest[13][1] = "190px";
		dest[13][2] = "717px";		
		dest[14][0] = "mapa-destination-link-ivalo";
		dest[14][1] = "110px";
		dest[14][2] = "735px";		
		dest[15][0] = "mapa-destination-link-rovaniemi";
		dest[15][1] = "140px";
		dest[15][2] = "735px";	
		
		$('mapa-staricon-helsinki').setStyles({ top: '199px', left: '729px' });		
		$('mapa-staricon-turku').setStyles({ top: '194px', left: '721px' });		
		$('mapa-staricon-ivalo').setStyles({ top: '114px', left: '739px' });		
		$('mapa-staricon-rovaniemi').setStyles({ top: '144px', left: '739px' });				
		
		
		// denmark
		dest[16][0] = "mapa-destination-link-copenhagen";
		dest[16][1] = "242px";
		dest[16][2] = "660px";		
		dest[17][0] = "mapa-destination-link-helsingor";
		dest[17][1] = "234px";
		dest[17][2] = "660px";		
		
		$('mapa-staricon-copenhagen').setStyles({ top: '250px', left: '660px' });		
		$('mapa-staricon-helsingor').setStyles({ top: '243px', left: '662px' });				
		
		// iceland
		dest[18][0] = "mapa-destination-link-reykjavik";
		dest[18][1] = "115px";
		dest[18][2] = "534px";	
		
		$('mapa-staricon-reykjavik').setStyles({ top: '119px', left: '539px' });				
		
		
		// combine them and show some magic
		$each(dest, function(el, i){			
			$(el[0]).addEvent('mouseenter', function(){														 
				star.setStyles({ top: el[1], left: el[2], opacity: '0', display: 'inline' });					
				fx.start({
					'opacity': '0.99'
				});	
					
			});			
		});

		
		$each(dest, function(el, i){			
			$(el[0]).addEvent('mouseleave', function(){									 				
				fx.start({
					'opacity': '0'
				});	
			});			
		});		



		var scroll = new Fx.Scroll('mapa-layer', {
			wait: false,
			duration: 1200,			
			transition: Fx.Transitions.Quad.easeInOut
		});
		
		
		$each($$('.mapa-return'), function(el) {
			el.addEvent('click', function(event) {
				event = new Event(event).stop();
				scroll.toElement('mapa-layer-start');
			});		
		});					

		$('mapa-destination-link-stockholm').addEvent('click', function(event) {
			event = new Event(event).stop();
			scroll.toElement('mapa-layer-stockholm');
		});
		$('staricon-link-stockholm').addEvent('click', function(event) {
			event = new Event(event).stop();
			scroll.toElement('mapa-layer-stockholm');
		});		
		 
		$('mapa-destination-link-goteborg').addEvent('click', function(event) {
			event = new Event(event).stop();
			scroll.toElement('mapa-layer-goteborg');
		});
		$('staricon-link-goteborg').addEvent('click', function(event) {
			event = new Event(event).stop();
			scroll.toElement('mapa-layer-goteborg');
		});				
		 
		$('mapa-destination-link-malmo').addEvent('click', function(event) {
			event = new Event(event).stop();
			scroll.toElement('mapa-layer-malmo');
		});
		$('staricon-link-malmo').addEvent('click', function(event) {
			event = new Event(event).stop();
			scroll.toElement('mapa-layer-malmo');
		});			
	}
		
};



window.addEvent('domready', function (){
		Site.start();		
		window.addEvent('load', function(){					 					 	
			Dfmenu.menu3();	// sliding submenus
			Dfmenu.menu4();	// submenu visual			
			Site.preload(false);
			Flashmovie.start();
		});	
});
