function DetectBrowser() {
    var BO = {};
    BO.ie        = false /*@cc_on || true @*/;
    BO.ie4       = BO.ie && !document.getElementById;
    BO.ie5       = BO.ie && !document.namespaces && !BO.ie4;
    BO.ie6       = BO.ie && document.implementation && document.implementation.hasFeature;
    BO.ie55      = BO.ie && document.namespaces && !BO.ie6;
    /*@cc_on
    BO.ie7       = @_jscript_version == '5.7';
    @*/
    BO.ns4       = !BO.ie &&  document.layers && window.confirm && !document.createElement;
    BO.opera     = self.opera;
    BO.gecko     = document.getBoxObjectFor;
    BO.khtml     = navigator.vendor === 'KDE';
    BO.konq      = BO.khtml || document.childNodes && !document.all && !navigator.taintEnabled;
    BO.safari    = document.childNodes && !document.all && !navigator.taintEnabled && !navigator.accentColorName;
    BO["safari1.2"] = !parseInt(0,10).toFixed && BO.safari && !window.XMLHttpRequest;
    BO["safari2.0"] = parseInt(0,10).toFixed && BO.safari && !BO["safari1.2"];
    BO["safari1.1"] = BO.safari && !BO["safari1.2"] && !BO["safari2.0"];
    BO.designmode = document.getElementById && document.designMode;
    return BO;
}

var BO = new DetectBrowser();

Cookie = {
	set : function(objHash) {
		cookieString = objHash.name + '=' + escape(objHash.value);
		if (objHash.expires) cookieString += ';expires=' + objHash.expires.toGMTString();
		if (objHash.path) cookieString += ';path=' + objHash.path;
		if (objHash.domain) cookieString += ';domain=' + objHash.domain;
		document.cookie = cookieString;
	},
	
	get : function(strKey) {
		var retVal = document.cookie.match(new RegExp(strKey + '=([^;$]*)'));
		return (retVal && retVal.length) ? unescape(retVal[1]) : null;
	},
	
	del : function(objHash) {
		var obj = objHash;
		obj.expires = new Date(0);
		this.set(obj);
	}
};

WebmailEnhancer.prototype = {
	atmail : function() {
		this.form.action = 'https://webmail02.one.com/atmail.pl';
		this.form.target = '_top';
		
		this.form.usernamehost.value = this.form.login_username.value;
		this.form.password.value = this.form.secretkey.value;
	},
	
	other : function(action) {
		this.form.action = action;
		this.form.target = '_top';
		
		this.form.login.value = this.form.login_username.value;
		this.form.password.value = this.form.secretkey.value;
	},
	
	isAdvancedBrowser : function() {
		return BO.ie6 || BO.ie7 || BO.gecko;
	},
	
	toggleAdvanced : function() {
		this.advanced = !this.advanced;
		this.advancedImage.className = this.advanced ? 'checked' : '';
		this.advancedCheckbox.checked = this.advanced;
		Cookie.set({
			name : 'advancedWebmail',
			value : this.advanced.toString(),
			path : '/',
			domain : document.location.domain,
			expires : new Date(2020,0)
		});
	},
	
	loadScreen : function() {
		if (window.loadscreen && document.getElementById('sitecontainer')) {
			var loadScreen = document.createElement('div');
			loadScreen.style.position = 'absolute';
			loadScreen.style.top = '50%';
			loadScreen.style.left = '50%';
			loadScreen.style.width = '514px';
			loadScreen.style.marginTop = '-60px';
			loadScreen.style.marginLeft = '-257px';
			
			document.body.appendChild(loadScreen);
			document.getElementById('sitecontainer').style.display = 'none';
			loadScreen.innerHTML = window.loadscreen;
		}
	}
};

function WebmailEnhancer(objHTMLFormElement) {
	if (!objHTMLFormElement) {
		return false;
	}
	this.form = objHTMLFormElement;
	this.advancedImage = document.getElementById('advanced');
	if (this.advancedImage) {
		this.advancedCheckbox = document.getElementById('advancedCheckbox');
		this.advanced = false;
		this.advancedImage.parentNode.className = '';
		if (Cookie.get('advancedWebmail') === 'true') {
			this.toggleAdvanced();
		}
		
		var This = this;
		this.advancedCheckbox.onclick = function() { This.toggleAdvanced(); };
	}
		
	var This = this;
	
	this.form.onsubmit = function() {
		if (!This.form.login_username.value || !This.form.secretkey.value) {
			alert(noWebmailCredentials);
			return false;
		}
		
		// This.loadScreen();
			
		try {
			this.XHR = new AjaxRequest({
				'url' : '/webmail.do',
				'synchronous' : true,
				'method' : 'GET',
				'requestHeaders' : {'Content-type' : 'application/x-www-form-urlencoded'},
				'contents' : {
					'email' : This.form.login_username.value,
					'time' : new Date().getTime()
				},
				'onSuccess' : function(objAjaxRequest) {
					var actionNode = objAjaxRequest.xmlhttprequest.responseXML.getElementsByTagName('formhandler')[0];
					var action = actionNode.firstChild && actionNode.firstChild.nodeValue || false;
					if (action) {
						if (This.isAdvancedBrowser() && !/atmail/.exec(action)) {
							/* Disabled while mod_deflate is disabled
							if (BO.ie6 && !BO.ie7) {
								return true; // Waiting for Microsoft to fix their problem introduced with the IE update from 11/12/2007
							}
							*/
							This.other(action);
						} else if (This.advanced) {
							This.atmail();
						}
					} else {
						// Fallback to squirrel
						return true;
					}
				}
			});
			
			this.XHR.execute();
		} catch(err) {
			// There is no sane recovery. Fallback to default
		}
	}
}

// Globals
var errors;

/**
  *	initLogin() activates the DHTML popup boxes that are the alternative to the actual login pages.
  *	The popup closes on a click outside its boundaries
  */
var poplinks = ['webmail-link','control-link','webmail-1','control-1']
var login;

function stopEvent(e) {
        if (!e) var e = window.event;
        e.cancelBubble = true;
        if (e.stopPropagation) e.stopPropagation();
}


function clearInputs() {
	var theForms = login.getElementsByTagName('form');
	for (var i = 0; i < theForms.length; i++) {
		theForms[i].reset();
	}
	if (document.onmousedown) document.onmousedown();
}

function initLogin() {
	login = document.getElementById('login');
	if (!login) { return false; }
	
	for (var i = 0, theforms = login.getElementsByTagName('form'); i < theforms.length; i++) {
		Events.attach(theforms[i], 'submit', function() {
			if (window.setTimeout) {
				window.setTimeout(clearInputs,10000);
			}
		});
	}

	// Set link behaviors for links that should use DHTML popup
	for (var i = 0; i < poplinks.length; i++) {
		if (document.getElementById(poplinks[i]) && document.getElementById(poplinks[i].split('-')[0])) {
			document.getElementById(poplinks[i]).onmousedown = function(e) {
				if (document.getElementById('domainSuffix')) { // If domainSuffix exists it overlays the popup. Make it invisible
					document.getElementById('domainSuffix').style.visibility = 'hidden';
				}
				if (document.getElementById('flash')) { // Remove flash while popup exists. flash gets rendered topmost.
					document.getElementById('flash').style.visibility = 'hidden';
				}
				login.className = 'pop_' + this.id.split('-')[0];
				if(document.getElementById(this.id.split('-')[0]).getElementsByTagName('p')[0]) {
					var temp =  document.getElementById(this.id.split('-')[0]).getElementsByTagName('p')[0].getElementsByTagName('input')[0];
					if (temp) { temp.focus(); }
				}
				stopEvent(e);
				return false;
			}

			document.getElementById(poplinks[i]).onclick = function() { return false; }
		}
	}

	login.onmousedown = stopEvent;

	document.onmousedown = function() {
		login.className = '';
		if (document.getElementById('domainSuffix')) {
			document.getElementById('domainSuffix').style.visibility = 'visible';
		}
		if (document.getElementById('flash')) {
			document.getElementById('flash').style.visibility = 'visible';
		}
	}

	document.getElementById('close').onmousedown = function(e) {
		document.onmousedown();
		return false;
	}
	
	if (window.location.hash === '#loginwebmail') {
		document.getElementById('webmail-link').onmousedown();
	}
}
/* initLogin() end */

// Cookie API  v1.0.1
// http://www.dithered.com/javascript/cookies/index.html
// maintained by Chris Nott (chris@NOSPAMdithered.com - remove NOSPAM)

// Write a cookie value
function setCookie(name, value, expires, path, domain, secure) {
	var curCookie = name + '=' + escape(value) + ((expires) ? '; expires=' + expires.toGMTString() : '') + ((path) ? '; path=' + path : '') + ((domain) ? '; domain=' + domain : '') + ((secure) ? '; secure' : '');
	document.cookie = curCookie;
}

function getCookie(name) {
	var dc = document.cookie;

	// find beginning of cookie value in document.cookie
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) {
			return null;
		}
	} else {
		begin += 2;
	}

	// find end of cookie value
	var end = document.cookie.indexOf(";", begin);
	if (end == -1) {
		end = dc.length;
	}

	// return cookie value
	return unescape(dc.substring(begin + prefix.length, end));
}

// Delete a named cookie value
function deleteCookie(name, path, domain) {
	var value = getCookie(name);
	if (value != null) {
		document.cookie = name + '=' + ((path) ? '; path=' + path : '') + ((domain) ? '; domain=' + domain : '') + '; expires=Thu, 01-Jan-70 00:00:01 GMT';
	}
	return value;
}

// Fix Netscape 2.x Date bug
function fixDate(date) {
	var workingDate = date;
	var base = new Date(0);
	var skew = base.getTime();
	if (skew > 0) {
		workingDate.setTime(workingDate.getTime() - skew);
	}
	return workingDate;
}

function setValidationMark(fieldIsValid, fieldNameValidation) {
	// Sets the picture on check_[fieldNameValidation] according to validation, red or green
	var imageName = 'check_' + fieldNameValidation;

	if (document.images[imageName]) {
		if (fieldIsValid == false) {
			document.images[imageName].src='/static/images/global/red.gif';
		} else {
			document.images[imageName].src='/static/images/global/green.gif';
		}
	}
}

// Surpresses pressing enter key, so the form does not submit
function noenter(e) {
	if (!e && window.event) {
		var e = window.event;
	}
	if (e && e.keyCode == 13) {
		return false;
	}
	return true;
}

// Hack needed to get Safari to post the form correctly. Doesn't post elements with display: none;
function prepareForm(submitForm, submitName, submitValue) {
	var submitValue = document.createElement("input");
	submitValue.type='hidden';
	submitValue.name=submitName;
	submitValue.value=submitValue; // Optional value to hidden field
	submitForm.appendChild(submitValue);
}

function doupdate(id, show, showClass) {
	if (document.getElementById) {
		obj = document.getElementById(id);
	} else if (document.layers) {
		obj = document.layers[id];
	} else if (document.all) {
		obj = document.all[id];
	} else {
		return;
	}

	if (obj) {
		showClass = showClass != null ? showClass : "show";
		obj.className = show ? showClass : "hide";
	} else {
		return;
	}
}

// Used to validate a form with a field called domainName
function checkDomainNameForm(domainForm) {
	errors = new Array();
	validateDomainName(domainForm);
	if (errors != '') {
		alert(errors);
		domainForm.domainName.focus();
		return false;
	} else {
		return true;
	}
}

// Trim whitespace from left and right sides of s.
function trim(s) {
	return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
}

function validateDomainName(form) {
	var str = trim(form.domainName.value);
	if (str == '' || str.length < 1) {
		errors = errors + domainNotEmpty;
	}
}

function setPopperBehaviour() {
	/*@cc_on
	window.onunload= function() {
		if(document.all) { //Ie only
			if (event.clientY < 0 && Math.abs(event.clientX - document.documentElement.clientWidth) < 100) {
				popper(); // If the event occured in the upper right x area.
			} else if (event.clientY < -5000 && event.clientX < -5000) {
				popper(); // Strange IE6 bug (feature?) when alt+f4 or the x is clicked, clientX and clientY gets very high negative values.
			} else if (event.altKey) {
				popper(); // We assume that alt+f4 was clicked
			}
		}
	}
	@*/
}

function popper() {
	var oldValue = getCookie('call_back');
	if (oldValue == null || oldValue != 'blocked') {
		// Set cookie that expires in one hour
		setCookie('call_back', 'true', new Date((new Date()).getTime() + 3600000));
		var h; var w; var t; var l;
		w = 400;
		h = 320;
		t = (screen.height-h)/2;
		l = (screen.width-w)/2;
		var popwin = window.open('/callback.do','','width='+ w +',height='+ h +',top='+ t +',left='+ l +',location=no, statusbar=no, directories=no, resizable=no, menubar=no, toolbar=no, scrollbars=no');
		if (popwin != null) {
			popwin.focus();
		}
	}
}

// This function will set onclick wndow.open() behavior on links with target="_blank"
function setLinkpopups() {
	var links = document.getElementsByTagName('a');
	for (var i=0;i<links.length;i++) {
		// Trigger on the Advanced Webmail screenshot link
		if (links[i].getAttribute('target') == '_blank' && (links[i].parentNode.className == 'advancedmail' || links[i].className == 'advancedmail')) {
			links[i].onclick = function() {
				window.open(this.href, "INFO", "width=850, height=552, top=0, menubar=no, status=no, location=no, toolbar=no, scrollbars=no, resizable=no");
				return false;
			}
		}
		// Trigger on the Simple Webmail screenshot link
		else if (links[i].getAttribute('target') == '_blank' && (links[i].parentNode.className == 'simplemail' || links[i].className == 'simplemail')) {
			links[i].onclick = function() {
				window.open(this.href, "INFO", "width=709, height=262, top=0, menubar=no, status=no, location=no, toolbar=no, scrollbars=no, resizable=no");
				return false;
			}
		}
		// Trigger on the Webcreator link
		else if (links[i].getAttribute('target') == '_blank' && links[i].className == 'info-link-webeditor') {
			links[i].onclick = function() {
				//window.open(this.href, "INFO", "width=720, height=437, top=0, menubar=no, status=no, location=no, toolbar=no, scrollbars=no, resizable=no");
				window.open(this.href, "INFO", "width=774, height=468, top=0, menubar=no, status=no, location=no, toolbar=no, scrollbars=no, resizable=no");
				return false;
			}
		}
		// Trigger on the CVC link on the payment page
		else if (links[i].getAttribute('target') == '_blank' && links[i].className == 'cvc') {
			links[i].onclick = function() {
				window.open(this.href, "INFO", "width=400, height=262, top=0, menubar=no, status=no, location=no, toolbar=no, scrollbars=no, resizable=no");
				return false;
			}
		}
		// Trigger on Eniro popups
		else if (links[i].getAttribute('target') == '_blank' && links[i].className == 'eniro_product') {
			links[i].onclick = function() {
				window.open(this.href, "INFO", "width=433, height=346, top=0, menubar=no, status=no, location=no, toolbar=no, scrollbars=no, resizable=no");
				return false;
			}
		}
		// Trigger on Eniro popups
		else if (links[i].getAttribute('target') == '_blank' && links[i].className == 'eniro_price') {
			links[i].onclick = function() {
				window.open(this.href, "INFO", "width=433, height=346, top=0, menubar=no, status=no, location=no, toolbar=no, scrollbars=no, resizable=no");
				return false;
			}
		}
		// Trigger on Eniro popups
		else if (links[i].getAttribute('target') == '_blank' && links[i].className == 'eniro_presales') {
			links[i].onclick = function() {
				window.open(this.href, "INFO", "width=433, height=346, top=0, menubar=no, status=no, location=no, toolbar=no, scrollbars=yes, resizable=no");
				return false;
			}
		}
		// Triggers on info links with target="_blank"
		else if (links[i].getAttribute('target') == '_blank' && links[i].className == 'info-link') {
			links[i].onclick = function() {
				window.open(this.href, 'INFO', 'width=310, height=250, top=0, menubar=no, status=no, location=no, toolbar=no, scrollbars=yes, resizable=no');
				return false;
			}
		}
	}
}

function globalOnload() {
	// Set popups for target="_blank" links
	if (document.getElementById('products') || document.getElementById('prices') || document.getElementById('product_info')) {
		setLinkpopups();
	}
	// Set DHTML popup for relevant links
	if (document.getElementById('login') && document.getElementById('login').onmousedown != stopEvent) {
		initLogin();
	}
	
	// Set up webmail login form
	new WebmailEnhancer(document.getElementById('webmailLogin'));
	
	/* Stupid IE version <= 6 doesn't support z-index on select boxes, so to avoid any select boxes
	being placed on top of the bottom search bar, we hide any selectboxes that is below the highest point of the search bar.
	The script is hidden from other browsers by the use of conditional compilation. It is only run by 
	IE 6 (jscript_version == 5.6) as the bottom bar is fixed in the bottom of the site for earlier versions.*/
	/*@cc_on
		/*@if (@_jscript_version == 5.6)
			if (document.getElementById('sitecontainer')) {
				Events.attach(document.getElementById('sitecontainer'), 'scroll', hideSelectBoxes);
				Events.attach(window, 'resize', hideSelectBoxes);
				hideSelectBoxes();
			}
		/*@end
	@*/

	// Call specificOnload if defined
	if (window.specificOnload) {
		specificOnload();
	}
}

var Events = {
	_events: new Array(),

	attach: function(obj, type, fn) {
		if (obj.addEventListener) {
			obj.addEventListener(type, fn, false);
		} else if(obj.attachEvent) {
			obj["e" + type + fn] = fn;
			obj[type + fn] = function() {
				var evt = window.event;
				evt.target = evt.srcElement;
				obj["e" + type + fn](evt);
			}
			obj.attachEvent("on" + type, obj[type + fn]);
		}
		this._events[this._events.length] = {
			obj: obj,
			type: type,
			fn: fn
		}
	},

	detach: function(obj, type, fn) {
		if (obj.removeEventListener) {
			obj.removeEventListener(type, fn, false);
		} else if(obj.detachEvent) {
			obj.detachEvent("on" + type, obj[type + fn]);
			obj[type + fn] = null; // replace with delete if IE5 support is not needed
			obj["e" + type + fn] = null; // replace with delete if IE5 support is not needed
		}
	},

	cleanup: function() {
		for(var i = 0; i < this._events.length; i++) {
			var evt = this._events[i];
			this.detach(evt.obj, evt.type, evt.fn);
		}
	},

	stop: function(e) {
		e = e || window.event;
		if (e) {
			e.cancelBubble = true;
			if (e.stopPropagation) {
				e.stopPropagation();
			}
		}
		return false;
	}
}

// We want to be sure that all events are detached before page unload.
// This prevents memory leaks.
Events.attach(window, "unload", function() {
	Events.cleanup(); 
});

Presentation.prototype = {
	toString : function(){return '[object Presentation]';},
	domref : null,
	// This object contains an associative array of infobox activators and infoboxes.
	infoRefs : new Object,
	// A reference to the infobox which is currently shown.
	boxRef : null,
	// A reference to the element containg the flash movie.
	flashRef : null,
	// A reference to the javascript-generated element (inside the element refered to from boxRef) containing the backgound image.
	backgroundDivRef : null,
	// A reference to the javascript-generated element (inside the element refered to from boxRef) containing the text content.
	contentDivRef : null,
	// The height of the Presentation element during onload.
	initAreaHeight : null,
	// The current height of the Presentation element.
	presentHeight : null,
	// Stupid extension to show an extra graphics element when the webeditor info box is shown.
	constBottomGraphics : "webeditor",
	constBottomGraphicsRef : null,
	// The top + bottom margin of the infobox - Defined in template-order.css.
	constBoxRefTopBottomMargin : 10,
	// The time that it should take to expand the info area (instant).
	constInfoMoveTime : 1,
	// The max moving time - It shouldn't be possible to move the content in more thant five seconds.
	constMaxMovingTime : 5000,
	// The maximum result height - It shouldn't be possible to move the content more that to 600 px.
	constMaxResultHeight : 600,
	// The time delay between each move step.
	constMSPerStep : 50,
	// We need two different timers so the scripts can run at the same time
	moveTimer : null,
	// Whether or not flash is used. If not, the initAreaHeight should be the height of the replacement image.
	usingFlash : null,

	fadeSpeed : 10,
	fadeStep : 20,
	opacity : 0,
	maxOpacity : 80,
	timer : null,
	fader : null,
	
	showInfoBox : function(objHTMLInfoBox) {
		if (this.flashRef.parentNode.offsetHeight != this.presentHeight) {
			// FF No Flash hack. For some reason, the height of the image cannot be measured 
			// during the construction phase under specific conditions.
			if (this.initAreaHeight == 0 && this.flashRef.parentNode.getElementsByTagName('img')[0]) {
				this.initAreaHeight = this.flashRef.parentNode.getElementsByTagName('img')[0].offsetHeight;
			}
			this.flashRef.style.height = this.initAreaHeight + 'px';
			if (this.flashRef.getElementsByTagName('object')[0]) {
				this.flashRef.getElementsByTagName('object')[0].style.height = this.initAreaHeight + 'px';
			}
			this.presentHeight = this.initAreaHeight;
		}
		if (objHTMLInfoBox) {
			// If an infobox is already visible.
			if (objHTMLInfoBox.obj.boxRef) {
				objHTMLInfoBox.obj.boxRef.style.display = '';
				this.removeContainers(objHTMLInfoBox.obj.boxRef);
				this.createContainers(objHTMLInfoBox);
			} else {
				this.flashRef.style.display = 'none';
				objHTMLInfoBox.parentNode.style.display = 'block';
				this.createContainers(objHTMLInfoBox);
			}
			objHTMLInfoBox.obj.boxRef = objHTMLInfoBox;
			objHTMLInfoBox.style.display = 'block';
			// This step should be unnessecary but isn't because of buggy IE6.
			objHTMLInfoBox.style.visibility = 'visible';
			
			// We need the backgound image to take up a place in the pageflow if the
			// text is higher that the height of the background image, to make the text
			// wrap around the image, But the container should never be higher than the 
			// text. This behaviour will be applied by making the div element containing
			// the background image have the same height if the text is smaller than the
			// background image, while it floats right.
			var contentDivHeight = this.contentDivRef.offsetHeight;
			
			if (contentDivHeight < parseInt(this.backgroundDivRef.offsetHeight)) {
				this.backgroundDivRef.style.height = contentDivHeight + 'px';
			} else {
				// reset the height.
				this.backgroundDivRef.style.height = '';
			}
			this.move(this.constInfoMoveTime, 
					objHTMLInfoBox.offsetHeight + this.constBoxRefTopBottomMargin,
					objHTMLInfoBox.parentNode);
			return false;
		} else {
			// Open standard popup.
			return true;
		}
	},
	hideInfoBox : function(objHTMLInfoBox) {
		if (objHTMLInfoBox != null) {
			var doAfterRun = function(objHTMLInfoAreaDivElement) {
				objHTMLInfoAreaDivElement.obj.flashRef.style.display = 'block';
				objHTMLInfoAreaDivElement.style.display = '';
				objHTMLInfoAreaDivElement.obj.boxRef.style.display = 'none';
				objHTMLInfoAreaDivElement.obj.boxRef.style.visibility = 'hidden';
				objHTMLInfoAreaDivElement.obj.removeContainers(objHTMLInfoAreaDivElement.obj.boxRef);
				objHTMLInfoAreaDivElement.obj.boxRef = null;
			}
			this.move(this.constInfoMoveTime,
					this.initAreaHeight,
					objHTMLInfoBox.parentNode,
					doAfterRun);
		}
	},

	// To make the info box work as we want it to, without polluting the html too much,
	// we create some of the elements on the fly. The elements are: A div containing
	// the textual content, and a div to contain the backgound image. Under special 
	// circumstancs an extra image container is created.
	createContainers : function(objHTMLInfoBox) {
		var contentDiv = document.createElement('div');
		contentDiv.innerHTML = objHTMLInfoBox.innerHTML;
		contentDiv.className = 'contentDiv';
		objHTMLInfoBox.innerHTML = '';
		this.contentDivRef = objHTMLInfoBox.appendChild(contentDiv);
		bgContainer = document.createElement('div');
		bgContainer.className = 'infoBackground';
		this.backgroundDivRef = objHTMLInfoBox.insertBefore(bgContainer, this.contentDivRef);
		if (objHTMLInfoBox.id == this.constBottomGraphics) {
			webeditorBottom = document.createElement('div');
			webeditorBottom.className = 'webeditorBottom';
			this.constBottomGraphicsRef = objHTMLInfoBox.appendChild(webeditorBottom);
		}
	},

	// The generated div elements are removed after the run.
	removeContainers : function(objHTMLInfoBox) {
		if (this.backgroundDivRef) {
			this.backgroundDivRef.parentNode.removeChild(this.backgroundDivRef);
			this.backgroundDivRef = null;
		}
		if (this.constBottomGraphicsRef) {
			this.constBottomGraphicsRef.parentNode.removeChild(this.constBottomGraphicsRef);
			this.constBottomGraphicsRef = null;
		}
		if (this.contentDivRef) {
			objHTMLInfoBox.innerHTML = this.contentDivRef.innerHTML;
			this.contentDivRef.style.display = '';
			this.contentDivRef = null;
		}
	},
	
	// This is one of the methods that the flash action script can call - 
	// Takes fewer arguments to minimize the room for error.
	moveUp : function(movingTime) {
		this.move(movingTime, this.initAreaHeight);
	},

	// Like the one above.
	moveDown : function (movingTime, resultHeight) {
		this.move(movingTime, resultHeight);
	},
	
	// This is the general move method - Called both directly and through moveDown and moveUp.
	move : function(movingTime, resultHeight, moveElement, doAfterRun) {
		// If the moveElement is not present, we assume that we are working on the flash area.
		if (!moveElement) {
			moveElement = this.flashRef;
			// The move animation used to extend the flash area works on a wrapper for the flash
			// object, the object tag is not resized until after the run - This is due to the
			// fact that it would be to hardware demanding to resize the flash object runtime.
			doAfterRun = function(moveElement) {
				if (moveElement.getElementsByTagName('object')[0]) {
					moveElement.getElementsByTagName('object')[0].style.height = moveElement.obj.presentHeight + 'px';
				}
			}
		}
		
		this.presentHeight = (!this.presentHeight) ? this.initAreaHeight : this.presentHeight;
		
		movingTime = (movingTime > this.constMaxMovingTime) ? this.constMaxMovingTime : movingTime;
		movingTime = (movingTime < 1) ? 1 : movingTime;
		resultHeight = (resultHeight < 0) ? 0 : resultHeight;
		resultHeight = (resultHeight > this.constMaxResultHeight) ? this.constMaxResultHeight : resultHeight;
		
		if (!moveElement) {
			return false;
		}
		moveElement.obj = this;
		
		// The distance which the element should be moved.
		moveDistance = resultHeight - this.presentHeight;
		
		// The number of steps the the move should be performed in.
		steps = Math.floor(movingTime / this.constMSPerStep);
		
		steps = (steps < 1) ? 1 : steps;
		
		absMoveDistance = Math.abs(moveDistance);
		// If the number of miliseconds it should take is too high for the move distance, we substract ten percent of the moving time until the move distance in pixel is equal to or higher than the number of steps.
		while (absMoveDistance / steps <= 1) {
			movingTime = movingTime - movingTime * 0.1;
			steps = Math.floor(movingTime / this.constMSPerStep);
		}
		
		restDistance = moveDistance % steps;
		
		// We need to divide with the numeric value of the move distance...
		distancePerStep = Math.floor(absMoveDistance / steps);
		
		// ...But the distance per step should still have to be the correct value according to the move distance.
		distancePerStep = (moveDistance < 0) ? distancePerStep * -1 : distancePerStep;
		var i = 0;
		
		var msPerStep = (movingTime < this.constMSPerStep) ? movingTime : this.constMSPerStep;
		var _this = this;
		window.clearInterval(this.moveTimer);
		this.moveTimer = window.setInterval(function(){
			if (i < steps) {
				// We need to either add or substract the rest distance, according to whether the distance is positive or negative.
				restConstant = (restDistance > 0) ? 1 : -1;
				if (restDistance != 0) {
					_this.presentHeight += distancePerStep;
					_this.presentHeight += restConstant;
					restDistance -= restConstant;
				} else {
					_this.presentHeight += distancePerStep;
				}
				moveElement.style.height = _this.presentHeight + 'px';
				i++;
			} else {
				window.clearInterval(_this.moveTimer);
				if (doAfterRun) {
					doAfterRun(moveElement);
				}
			}
		}, msPerStep);
	},

	makeFader : function() {
		this.fader = document.createElement('div');
		this.fader.style.position = 'absolute';
		this.fader.style.top = '0';
		this.fader.style.left = '0';
		this.fader.style.width = '100%';
		this.fader.style.zIndex = '9';
		windowHeight = 900;
		if (document.documentElement && document.documentElement.scrollHeight) { 
			windowHeight = document.documentElement.scrollHeight;
		} else if (self.innerHeight) {
			windowHeight = self.innerHeight;
		} else if (document.body) {
			windowHeight = document.body.scrollHeight;
		}
		this.fader.style.height = windowHeight + 'px';
		this.fader.style.backgroundColor = '#000';
		this.updateFader();
		var _this = this;
		this.fader.onclick = function(){_this.fadeOut();};
		
		document.body.appendChild(this.fader);
	},

	updateFader : function() {
		this.fader.style.display = (this.opacity > 0) ? 'block' : 'none';
		this.fader.style.opacity = this.opacity / 100;
		this.fader.style.MozOpacity = this.opacity / 100;
		this.fader.style.filter = 'alpha(opacity=' + parseInt(this.opacity) + ')';
	},
	
	fadeIn : function() {
		/*@cc_on
			/*@if (@_jscript_version <= 5.6)
			return;
			/*@end
		@*/
		if (!this.fader) this.makeFader();
		var _this = this;
		window.clearInterval(this.timer);
		this.timer = window.setInterval(function(){
			if (_this.opacity < _this.maxOpacity) {
				_this.opacity += _this.fadeStep;
				_this.updateFader();
			} else {
				window.clearInterval(_this.timer);
			}
		}, _this.fadeSpeed);
	},
	
	fadeOut : function() {
		var _this = this;
		window.clearInterval(this.timer);
		this.timer = window.setInterval(function(){
			if (_this.opacity > 0) {
				_this.opacity -= _this.fadeStep;
				_this.updateFader();
			} else {
				window.clearInterval(this.timer);
			}
		}, _this.fadeSpeed);
	}
}

function Presentation(objPresentation) {
	this.domref = objPresentation;
	this.domref.obj = this;
	this.usingFlash = usingFlash;
	this.initAreaHeight = (usingFlash) ? parseInt(flashHeight) : document.getElementById('flash').getElementsByTagName('img')[0].offsetHeight;
	this.presentHeight = this.initAreaHeight;
	this.flashRef = document.getElementById('flash');
	var innerContent = document.getElementById('innercontent');
	if (innerContent) {
		var links = innerContent.getElementsByTagName('a');
		for (var i = 0; i < links.length; i++) {
			var infoName = links[i].className;
			if (infoName) {
				// The link betweean each activator link, and the info box is through
				// the classname of the link and the id of the info box. 
				infoTarget = document.getElementById(infoName);
				if (infoTarget) {
					links[i].obj = this;
					this.infoRefs[infoName] = infoTarget;
					this.infoRefs[infoName].obj = this;
					links[i].onclick = function() {
						return this.obj.showInfoBox(this.obj.infoRefs[this.className]);
					}
				}
			}
		}
		closeButton = document.getElementById('infoClose');
		closeButton.obj = this;
		closeButton.onclick = function() {
			this.obj.hideInfoBox(this.obj.boxRef);
		}
	}
}

/*@cc_on
	/*@if (@_jscript_version <= 5.6)
		function hideSelectBoxes() {
			var innerContent = document.getElementById('innercontent');
			if (innerContent) {
				var selectBoxes = innerContent.getElementsByTagName('select');
				if (selectBoxes.length > 0) {
					var searchContainer = document.getElementById('searchcontainer');
					if (searchContainer && searchContainer.offsetHeight > 0) {
						var siteContainer = document.getElementById('sitecontainer');
						if (siteContainer) {
							for (var i = 0; i < selectBoxes.length; i++) {
								var selectBox = selectBoxes[i];
								var currentElement = selectBox;
								var totalOffsetTop = 0;
								while (currentElement.offsetParent) {
									totalOffsetTop += currentElement.offsetTop;
									currentElement = currentElement.offsetParent;
								}
								selectBoxLowestPoint = selectBox.offsetHeight + totalOffsetTop - siteContainer.scrollTop;
								searchContainerHighestPoint = document.documentElement.clientHeight - searchContainer.offsetHeight;
								if (selectBoxLowestPoint > searchContainerHighestPoint) {
									selectBox.style.visibility = 'hidden';
								} else {
									selectBox.style.visibility = '';
								}
							}
						}
					}
				}
			}
		}
	/*@end
@*/

// Due to the stupid eolas patent thing, we need to create the frontpage flash
// from an external script file to avoid forcing IE6+ users to click on the flash
// object to activate it.
function writeFrontpageFlash(height,flashUrl,gifUrl,bannerFullFlashDirUrl) {
	// It is really a bit stupid to declare global variables used by the Presentation Object
	// at this point. But we cannot make the presentation object output the flash as it needs
	// to be generated by document.write, and the presentation object cannot be initialized
	// until the html have been generated, while the flash should be generated inside the 
	// presentation html element, which ofcourse is before the element is fully loaded.
	flashHeight = height;
	usingFlash = flashInstalled();
	
	if (usingFlash) {
		document.write('<object type="application/x-shockwave-flash" style="height: ' + height + 'px" data="' + flashUrl + '" />');
		document.write('<param name="movie" value="' + flashUrl + '" />');
		document.write('<param name="quality" value="high" />');
		document.write('<param name="wmode" value="transparent" />');
		document.write('<param name="menu" />');
		document.write('<param name="salign" value="t" />');
		document.write('<param name="base" value="' + bannerFullFlashDirUrl + '" />');
		document.write('</object>');
	} else {
		document.write('<img src="' + gifUrl + '" alt="" />');
	}
}

/** The next two methods are all nessecary to make the search-animation work our supported
  * browsers. The animation works in IE6+, Opera, FF and Safari. IE5-5.5 fails in an acceptable 
  * way. For all browsers (except IE6), the "search in progress" is hidden with visibility:hidden
  * and position:absoulte, which should provide the same behaviour as display:none. But because
  * Opera doesn't fetch images that has display:none, and doesn't fetch images after unload has begun,
  * we cannot use display:none. On the other hand, because of the way the search bar is positioned
  * in Internet Explorer 6, the browser cannot contain absolutely positioned elements, and therefore,
  * IE6 demands that the wrapper is hidden with display:none. The properties is reversed it the IE6
  * specific stylesheet.
  */
function initGlobalSearchAnimation() {
	var globalDomainSearchForm = document.getElementById('searchcontainer').getElementsByTagName('form')[0];
	globalDomainSearchForm.onsubmit = function() {
		if(true == checkDomainNameForm(globalDomainSearchForm)) {
			objHtmlDiv = document.getElementById("searching");
			objHtmlDiv.style.display = 'none';
			objHtmlDiv.style.visibility = 'visible';
			objHtmlDiv.style.position = 'static';
			doupdate('search-area', false);
			doupdate('searching', true);
			setTimeout('refreshSource(document.getElementById("globalwaitmessage").getElementsByTagName("img")[0])',0);
			return true;
		} else {
			return false;
		}
	}
}
/** To force Internet Explorers to display the animation every time we need to refresh the source.
  */
function refreshSource(objHtmlImg) {
	if (objHtmlImg) {
		if (objHtmlImg.src) {
			objHtmlImg.src = objHtmlImg.src;
		}
	}
}
function generalWaitAnimation(waitMessageId) {
	var waitmessageWrapper = document.getElementById(waitMessageId);
	if (waitmessageWrapper) {
		waitmessageImage = waitmessageWrapper.getElementsByTagName("img")[0];
		if (waitmessageImage) {
			setTimeout('refreshSource(waitmessageImage)',0);
		}
		doupdate(waitMessageId, true);
	}
}

/** This method checks whether or not flash is installed.
  * Note: 
  * 2: Flash installed
  * 1: Flash not installed
  * 0: Unknown if Flash is installed 
  * Inspiration gathered at Quirksmode.org.
  */

function flashInstalled() {
	if (BO.ie55) {return 0;}
	var flashinstalled = 0;
	if (navigator.plugins && navigator.plugins.length) {
		x = navigator.plugins["Shockwave Flash"];
		if (x) {
			flashinstalled = 2;
		} else {
			flashinstalled = 1;
			if (navigator.plugins["Shockwave Flash 2.0"]) {
				flashinstalled = 2;
			}
		}
	} else if (navigator.mimeTypes && navigator.mimeTypes.length) {
		x = navigator.mimeTypes['application/x-shockwave-flash'];
		if (x && x.enabledPlugin) {
			flashinstalled = 2;
		} else {
			flashinstalled = 1;
		}
	}
	/* This section runs for IE only. */
	else {
		for(var i=10; i>0; i--){
			try {
				var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
				flashinstalled = 2;
				break;
			} catch(e){}
		}
	}
	return (flashinstalled == 2) ? true : false;
}

function openGuide(objHtmlLink) {
	window.open(objHtmlLink.href, "GUIDE", "width=703, height=552, top=0, menubar=no, status=no, location=no, toolbar=no, scrollbars=yes, resizable=no");
}
window.onload = globalOnload;
