﻿
var homepage = { version: 1.0 }
var r_debug = (document.location.href.indexOf('riktest') > -1);

var seeInsideDotMailer_ImagePath = '/flash/see_inside_dotmailer/img/';
var seeInsideDotMailer_MaxImageCount = 11;

homepage.addEvent = function(object, eventName, fn) {
	if (document.addEventListener) object.addEventListener(eventName, fn, false);
	else object.attachEvent('on' + eventName, fn);
}

homepage.removeEvent = function(object, eventName, fn) {
	if (document.removeEventListener) object.removeEventListener(eventName, fn, false);
	else object.detachEvent('on' + eventName, fn);
}


// Home page load function
homepage.addEvent(window, 'load', function() { 
	new homepage.lowerTabs();
	new homepage.preloader(); 
	document.body.style.minHeight = (homepage.util.getDocHeight()) + 'px';
	homepage.lightwindowLoader();
	homepage.dim = new homepage.dimmer();
});
// -----------------------


// Preloader
homepage.preloader = function() {
	var f = document.createElement('iframe');
	f.id = 'iframecahce';
	f.style.display = 'none';
	document.body.appendChild(f);
	var doc = document.getElementById('iframecahce').contentDocument;
	if (typeof(doc) == 'undefined' || doc == null) doc = document.getElementById('iframecahce').contentWindow.document;
	doc.location = '/includes/homepagecache.htm';
}

// Lightwindow (clone) initialiser
homepage.lightwindowLoader = function() {
	var elements = document.getElementsByTagName('a');
	for(var i=0; i<elements.length; i++) if(elements[i].className) if(elements[i].className.indexOf('lightwindow') > -1) {
		new homepage.lightwindow(elements[i]);
	}
}

// Lightwindow (clone) object creator
homepage.lightwindow = function(item) {
	var self = this;
	this.item = item;
	this.params = { };
	this.container = null;
	this.currentHeight = 0;
	this.iframe = null;
	
	this.setParams = function() {
		var params = self.item.getAttribute('params').split(/,/g);
		for(var i=0; i<params.length; i++) {
			var v = params[i].split(/\=/);
			if(v.length == 2) eval('self.params.' + v[0] + ' = ' + v[1]);
		}
		self.height = (self.params.lightwindow_height * 1.0) + 43;
		self.width = (self.params.lightwindow_width * 1.0) + 16;
	}
	
	this.setSize = function() {
		var s = homepage.util.getWindowSize();
		
		var offset = 0;
		if(navigator.appVersion.indexOf('MSIE 6') > -1) {
			if(window.pageYOffset) offset = window.pageYOffset;
			else if(document.documentElement) offset = document.documentElement.scrollTop;
			else offset = document.body.scrollTop;
		}

		self.container.style.width = self.currentWidth + 'px';
		self.container.style.height = self.currentHeight + 'px';
		self.container.style.left = Math.round((s.w - self.currentWidth) / 2) + 'px';
		self.container.style.top = Math.round(((s.h - self.currentHeight) / 2) + offset) + 'px';
		self.container.style.display = 'block';
	}
	
	this.createTitle = function() {
		var t = document.createElement('div');
		var a = document.createElement('a');
		a.innerHTML = 'Close';
		t.appendChild(a);
		t.className = 'titlebar';
		a.onclick = self.hide;
		self.container.appendChild(t);
	}
	
	this.show = function() {
		homepage.dim.callBack = self.animate;
		self.container = document.createElement('div');
		self.container.id = 'dM_lightwindow';
		self.currentHeight = 1;
		document.body.appendChild(self.container);
		homepage.dim.show();
		homepage.addEvent(window, 'resize', self.setSize);
		homepage.addEvent(window, 'scroll', self.setSize);
		self.createTitle();
		if(self.params.precache == 'true') self.createFrame(true);
		return false;
	}
	
	this.animate = function() {
		var diff = (self.height - self.currentHeight) / 4;
		if(diff < 1) diff = 1;
		self.currentHeight = self.currentHeight + Math.round(diff);
		self.currentWidth = Math.round((self.currentHeight / self.height) * self.width);
		self.setSize();
		if(self.currentHeight < self.height) setTimeout(self.animate, 20);
		else self.complete();
	}
	
	this.createFrame = function(precache) {
		if(this.iframe == null) {
			this.iframe = document.createElement('iframe');
			this.iframe.id = 'lightwindowIframe';
			this.iframe.doc = function() {
				var doc = document.getElementById('lightwindowIframe').contentDocument;
				if (typeof(doc) == 'undefined' || doc == null) doc = document.getElementById('lightwindowIframe').contentWindow.document;
				return doc;
			}
			this.iframe.style.width = (this.width- 16) + 'px';
			this.iframe.style.height = (this.height - 36) + 'px';
			this.iframe.style.position = 'absolute';
			this.iframe.style.top = '33px';
			this.iframe.style.left = '8px';
			this.iframe.frameBorder = '0';
			this.iframe.scrolling = 'no';
			this.container.appendChild(this.iframe);
			this.iframe.doc().location = this.item.href;
		}
		if(precache) this.iframe.style.display = 'none';
		else this.iframe.style.display = 'block';
	}
	
	this.complete = function() {
		homepage.dim.dimmer.onclick = self.hide;
		self.createFrame(false);
	}
	
	this.hide = function() {
		homepage.dim.hide();
		document.body.removeChild(self.container);
		homepage.removeEvent(window, 'resize', self.setSize);
		homepage.removeEvent(window, 'scroll', self.setSize);
		self.container = null;
		self.iframe = null;
	}
	
	this.setParams();
	this.item.onclick = this.show;
}


// Lower tabs show/hider
homepage.lowerTabs = function() {
	var self = this;
	var elements = document.getElementsByTagName('a');
	this.tabs = new Array();
	for(var i=0; i<elements.length; i++) if(elements[i].className) if(elements[i].className.indexOf('lowertab') > -1) this.tabs.push(elements[i]);
	if(this.tabs.length == 0) this.tabs = null;
	this.activeTab = null;
	this.nextTab = null;
	this.animating = false;

	this.init = function() {
		for(var i = 0; i < this.tabs.length; i++) {
			var t = this.tabs[i];
			t.content = document.getElementById(t.href.substring(t.href.indexOf('#') + 1));
			if(t.content) {
				t.content.fullHeight = t.content.offsetHeight;
				t.content.height = 0;
				t.content.style.height = '0px';
				t.style.cursor = 'pointer';
				t.removeAttribute('href');
			}
			t.onclick = this.tabClick;
		}
	}
	
	this.tabClick = function(e, element) {
		if(element == null) element = this;
		if(self.animating || element.content == null) return false;
	
		if(self.activeTab && self.activeTab != element) 
		{
			self.nextTab = element;
			self.animating = true;
			self.rad = -(Math.PI / 2);
			document.body.style.minHeight = (homepage.util.getDocHeight()) + 'px';
			self.AnimHideTab();
		} 
		else if (!self.activeTab)
		{
			self.nextTab = element;
			self.animating = true;
			self.rad = 0;
			self.AnimShowTab();
		}
		return false;
	}
	
	this.AnimHideTab = function() {
		self.rad = self.rad + (Math.PI / 40);
		var h = self.activeTab.content.fullHeight * (1 - Math.cos(self.rad));
		self.activeTab.content.style.height = Math.round(h) + 'px';
		
		if(Math.round(h) == 0) self.AnimShowTab();
		else setTimeout(self.AnimHideTab, 10);
	}
	
	this.AnimShowTab = function() {
		self.rad = self.rad + (Math.PI / 40);
		var h = self.nextTab.content.fullHeight * (1 - Math.cos(self.rad));
		self.nextTab.content.style.height = Math.round(h) + 'px';
		
		if(Math.round(h) == self.nextTab.content.fullHeight) 
		{
			self.activeTab = self.nextTab;
			self.animating = false;
		} 
		else setTimeout(self.AnimShowTab, 10);
	}
	
	if(this.tabs != null) if(this.tabs.length > 0) this.init();
}

homepage.util = {
	getBodySize: function() {
		return { w: Math.max(Math.max((window.innerWidth ? window.innerWidth : 0), (document.documentElement ? document.documentElement.clientWidth : 0)), (document.body ? document.body.clientWidth : 0)),
				 h: Math.max(Math.max((window.innerHeight ? window.innerHeight : 0), (document.documentElement ? document.documentElement.clientHeight : 0)), (document.body ? document.body.clientHeight : 0)) };
	},
	getWindowSize: function() {
		if (window.innerHeight) return { w: self.innerWidth, h: self.innerHeight }
		if (document.documentElement && document.documentElement.clientHeight) return {w: document.documentElement.clientWidth, h: document.documentElement.clientHeight }
		if (document.body) return { w: document.body.clientWidth, h: document.body.clientHeight }
	},
	getDocHeight: function() {
		var D = document;
		return Math.max(
			Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
			Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
			Math.max(D.body.clientHeight, D.documentElement.clientHeight)
		) - (navigator.appName.indexOf('webkit') > -1 ? 0 : 12) - (navigator.appName.toLowerCase().indexOf('microsoft') > -1 ? 25 : 0);
	}
}

homepage.dimmer = function() {
	var self = this;
	this.callBack = null;
    this.init = function() {
		this.dimmer = document.createElement('div');
		this.dimmer.style.background = 'black';
		this.dimmer.style.position = 'absolute';
		this.dimmer.style.left = this.dimmer.style.top = '0';
		this.dimmer.style.display = 'none';
		this.opacity = 0;
		this.setOpacity();
		document.body.appendChild(this.dimmer);
		homepage.addEvent(window, 'resize', self.setSize);
    }
    
    this.setSize = function() {			
		if(self.dimmer.style.display != 'none') {
			var s = homepage.util.getBodySize();
			self.dimmer.style.width = (s.w) + 'px';
			self.dimmer.style.height = ((s.h > document.body.scrollHeight ? s.h : document.body.scrollHeight) + 1) + 'px';
		}
    }
    
    this.setOpacity = function() {
    	if(navigator.appName.toLowerCase().indexOf('microsoft') > -1) this.dimmer.style.filter = 'alpha(opacity=' + Math.round(this.opacity * 100) + ')';
		this.dimmer.style.opacity = this.opacity;
		this.dimmer.style.MozOpacity = this.opacity;
	}
	
	this.dim = function() {
		self.opacity += 0.1;
		self.setOpacity();
		if(self.opacity < 0.5) setTimeout(self.dim, 10);
		else if (self.callBack != null) self.callBack();
    }
    
    this.undim = function() {			
		self.opacity -= 0.2;
		if(self.opacity < 0) self.opacity = 0;
		self.setOpacity();
		if(self.opacity > 0) setTimeout(self.undim, 10);
		else self.dimmer.style.display = 'none';
    }
    
    this.hide = function() {
		this.setSize();
		this.undim();
		this.dimmer.onclick = null;
		this.callBack = null;
    }
    this.show = function() {
		this.dimmer.style.display = 'block';
		this.setSize();
		this.dim();
    }
    this.init()
}	

/**
 * SWFObject v1.4.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
 *   legal reasons.
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}
if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}
if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}
deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){if(!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";
this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params=new Object();
this.variables=new Object();
this.attributes=new Array();
if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();
if(c){this.addParam("bgcolor",c);}
var q=_8?_8:"high";
this.addParam("quality",q);
this.setAttribute("useExpressInstall",_7);
this.setAttribute("doExpressInstall",false);
var _d=(_9)?_9:window.location;
this.setAttribute("xiRedirectUrl",_d);
this.setAttribute("redirectUrl","");
if(_a){this.setAttribute("redirectUrl",_a);}};
deconcept.SWFObject.prototype={setAttribute:function(_e,_f){
this.attributes[_e]=_f;
},getAttribute:function(_10){
return this.attributes[_10];
},addParam:function(_11,_12){
this.params[_11]=_12;
},getParams:function(){
return this.params;
},addVariable:function(_13,_14){
this.variables[_13]=_14;
},getVariable:function(_15){
return this.variables[_15];
},getVariables:function(){
return this.variables;
},getVariablePairs:function(){
var _16=new Array();
var key;
var _18=this.getVariables();
for(key in _18){_16.push(key+"="+_18[key]);}
return _16;},getSWFHTML:function(){var _19="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
if(this.getAttribute("doExpressInstall")){
this.addVariable("MMplayerType","PlugIn");}
_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";
_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";
var _1a=this.getParams();
for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}
var _1c=this.getVariablePairs().join("&");
if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";
}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";
_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";
var _1d=this.getParams();
for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}
var _1f=this.getVariablePairs().join("&");
if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}
return _19;
},write:function(_20){
if(this.getAttribute("useExpressInstall")){
var _21=new deconcept.PlayerVersion([6,0,65]);
if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){
this.setAttribute("doExpressInstall",true);
this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
document.title=document.title.slice(0,47)+" - Flash Player Installation";
this.addVariable("MMdoctitle",document.title);}}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
var n=(typeof _20=="string")?document.getElementById(_20):_20;
n.innerHTML=this.getSWFHTML();return true;
}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}
return false;}};
deconcept.SWFObjectUtil.getPlayerVersion=function(){
var _23=new deconcept.PlayerVersion([0,0,0]);
if(navigator.plugins&&navigator.mimeTypes.length){
var x=navigator.plugins["Shockwave Flash"];
if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}
}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}
catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}
catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}
catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}
return _23;};
deconcept.PlayerVersion=function(_27){
this.major=_27[0]!=null?parseInt(_27[0]):0;
this.minor=_27[1]!=null?parseInt(_27[1]):0;
this.rev=_27[2]!=null?parseInt(_27[2]):0;
};
deconcept.PlayerVersion.prototype.versionIsValid=function(fv){
if(this.major<fv.major){return false;}
if(this.major>fv.major){return true;}
if(this.minor<fv.minor){return false;}
if(this.minor>fv.minor){return true;}
if(this.rev<fv.rev){
return false;
}return true;};
deconcept.util={getRequestParameter:function(_29){
var q=document.location.search||document.location.hash;
if(q){var _2b=q.substring(1).split("&");
for(var i=0;i<_2b.length;i++){
if(_2b[i].substring(0,_2b[i].indexOf("="))==_29){
return _2b[i].substring((_2b[i].indexOf("=")+1));}}}
return "";}};
deconcept.SWFObjectUtil.cleanupSWFs=function(){if(window.opera||!document.all){return;}
var _2d=document.getElementsByTagName("OBJECT");
for(var i=0;i<_2d.length;i++){_2d[i].style.display="none";for(var x in _2d[i]){
if(typeof _2d[i][x]=="function"){_2d[i][x]=function(){};}}}};
deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};
__flash_savedUnloadHandler=function(){};
if(typeof window.onunload=="function"){
var _30=window.onunload;
window.onunload=function(){
deconcept.SWFObjectUtil.cleanupSWFs();_30();};
}else{window.onunload=deconcept.SWFObjectUtil.cleanupSWFs;}};
if(typeof window.onbeforeunload=="function"){
var oldBeforeUnload=window.onbeforeunload;
window.onbeforeunload=function(){
deconcept.SWFObjectUtil.prepUnload();
oldBeforeUnload();};
}else{window.onbeforeunload=deconcept.SWFObjectUtil.prepUnload;}
if(Array.prototype.push==null){
Array.prototype.push=function(_31){
this[this.length]=_31;
return this.length;};}
var getQueryParamValue=deconcept.util.getRequestParameter;
var FlashObject=deconcept.SWFObject;
var SWFObject=deconcept.SWFObject;

