var xMousePos		= 0;
var yMousePos		= 0;
var titleByHref		= new Array();
var currentHtmlSet	= '';
var currentHtml		= '';
var alpha			= 0.0;
var alphaStep 		= 1;	// step per second
var previousMs		= 0;
var previewDiv		= null;

function eMe() {
	var a = new Array("et", "x.n", "er@gm", "el.ec", "ni", "da");
	var s = "";
	for(var i=0; i < a.length; i++) {
		s = a[i] + s;
	}
	var h = window.open("mailto:" + s);
	if (h != null) {
		h.close();
	}
}
function ol() {
	if ((top) && (top.document) && (top.document.title) && (self) && (self.document) && (self.document.title)) {
		top.document.title	= self.document.title;
	}
}

function getElementById(id, parent) {
	var d	= (parent != null ? parent : document);
	if (document.getElementById) {
		return document.getElementById(id);
	}
	var o	= (document.all ? d.all[id] : d[id]);
	var l	= d.layers;
	if ((!o) && (l)) {
		for(var i=0; i<l.length; i++) {
			o = getElementById(id, l[i].document);
			if (o != null) {
				break;
			}
		}
	}
	if (!o) {
		o	= eval('document.'+id);
	}
	if (!o) {
		o=document.layers[id];
	}
	if ((o) && (!o.style)) {
		o.style	= o;
	}
	return o;
}
function updatePreviewContent() {
	var oDiv		= previewDiv;
	oDiv	= previewDiv	= getElementById('previewDiv');
	if (!oDiv) {
		//oDiv	= previewDiv	= getElementById('previewDiv');
	}
	if (!oDiv) {
		if ((document.createElement) && (document.body)) {
			oDiv	= previewDiv	= document.createElement('div');
			oDiv.id	= 'previewDiv';
			oDiv.style.position	= 'absolute';
			oDiv.style.display	= 'none';
			document.body.appendChild(oDiv);
		} else {
			return;
		}
	}
	var x			= xMousePos + 5;
	var y			= yMousePos + 5;
	var alphaValue = Math.max(0.001, Math.min(0.999, alpha*alpha*alpha*alpha));
	if (alphaValue >= 0.999) {
		//alphaValue	= '';
	}
	var attributes	= new Array();
	var pixelSuffix	= (document.layers ? '' : 'px');
	var visible		= (alpha > 0.0);
	attributes['opacity'] = alphaValue;
	attributes['MozOpacity'] = alphaValue;
	attributes['KhtmlOpacity'] = alphaValue;
	attributes['filter'] = 'Alpha(opacity=' + Math.round(alphaValue*100) + ')';
	attributes['left'] = Math.round(x) + pixelSuffix;
	attributes['top'] = Math.round(y) + pixelSuffix;
	attributes['zIndex'] = 1000;
	attributes['display'] = (visible ? '' : 'none');
	attributes['visibility'] = (visible ? 'visible' : 'hidden');
	applyStyles(oDiv, attributes);
	if ((currentHtmlSet != currentHtml) && ((currentHtml != '') || (alpha <= 0.0))) {
		currentHtmlSet	= currentHtml;	// this avoids flicker
		if (document.layers) {
			var d = oDiv.document;
			d.open();
			d.write(currentHtml);
			d.close();
		} else {
			oDiv.innerHTML	= currentHtml;
		}
	}
}
function previewContent(txt) {
	var changed	= (currentHtml != txt);
	currentHtml	= txt;
	updatePreviewContent();
	if (changed) {
		doPreviewTrigger();
	}
}
function applyStyles(o, attributes) {
	if ((o) && (o.style)) {		
		for (var attributeName in attributes) {
			eval('o.style.' + attributeName + '="' + attributes[attributeName] + '"');
			//o.style[attributeName]	= attributes[attributeName];
		}
	}
}
function showImageByLink(linkObj, name, w, h, size) {
	var href		= new String(linkObj.href);
	var header		= name;
	var footer		= w + 'x' + h;
	linkObj.title		= '';
	if (href.indexOf('javascript:') == 0) {
		var i	= href.indexOf('\'');
		var j	= href.lastIndexOf('\'');
		if ((i >= 0) && (j > i)) {
			href	= href.substring(i + 1, j);
		}
	}
	previewContent('<table class="preview" cellspacing="0" cellpadding="0"><tr><td class="previewHeader" colspan="2">'+header+
		'</td></tr><tr><td class="previewContent" colspan="2"><img src="'+href+'" width="'+w+'" height="'+h+'"/></td></tr><tr><td class="previewFooter">'+footer+
		'</td><td class="previewFooter" style="text-align:right;">'+size+'</td></tr></table>');
}
function hideImageByLink(linkObj) {
	previewContent('');
}
function doPreviewTrigger() {
	var ms	= (new Date()).getMilliseconds();
	var d	= 50;
	if (previousMs != 0) {
		d	= ms - previousMs;
	}
	d	= Math.max(50, Math.min(1000, d));
	var step	= alphaStep * d / 1000.0;	// normalize speed
	previousMs	= 0;
	if (currentHtml != '') {
		if (alpha >= 1.0) {
			return;
		}
		alpha	+= step;
	} else {
		if (alpha <= 0.0) {
			return;
		}
		alpha	-= step;
	}
	alpha	= Math.max(0, Math.min(1, alpha));
	previousMs	= ms;
	updatePreviewContent();
	window.setTimeout('doPreviewTrigger();', 50);
}
function doOnMouseMove(e) {
    if (document.layers) {
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    } else if (document.all) {
        xMousePos = window.event.x+document.body.scrollLeft;
        yMousePos = window.event.y+document.body.scrollTop;
        xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
        yMousePosMax = document.body.clientHeight+document.body.scrollTop;
    } else if (document.getElementById) {
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    }
}

if (document.layers) { // Netscape
    document.captureEvents(Event.MOUSEMOVE);
}

document.onmousemove = doOnMouseMove;

//window.onload = ol;