window.addEvent('domready', initPage);
function initPage(){
	toolTip();
	$$('.listing tr.bg0, .listing tr.bg1').addEvent('mouseover', function() {
		this.addClass('omo');
	});
	$$('.listing tr.bg0, .listing tr.bg1').addEvent('mouseout', function() {
		this.removeClass('omo');
	});
};

function tb(obj)	{ obj.target = '_blank';}
function Go(x)		{ window.open(x,"_self");}
function toggle(el, ty)	{ $(el).style.display = ($(el).style.display == 'none') ? (!ty ? 'block' : ty) : 'none';}

function showTip() {
	var el = $('toolTip');
	var title = this.getAttribute('ttid');
	el.innerHTML	= title;
	el.style.visibility = "visible";
	this.onmousemove = function(event) {
		this.event = event || window.event;
		x = this.event.pageX || this.event.clientX + document.documentElement.scrollLeft;
		y = this.event.pageY || this.event.clientY + document.documentElement.scrollTop;

		if((document.body.clientWidth-20) < (x+el.offsetWidth)) {
			el.style.right	= (document.body.clientWidth-x) + 'px';
			el.style.left	= '';
		} else {
			el.style.left	= (x+10) + 'px';
			el.style.right	= '';
		}
		el.style.top	= (y + 10) + 'px';
	}
}
function toolTip() {
	titles	= new Array();
	var el	= document.createElement("div");
	el.id	= "toolTip";
	document.body.appendChild(el);

	var arrLinks = $$(".toolTip");
	for (i = 0; i < arrLinks.length == true; i++) {
		if(arrLinks[i].getAttribute('title')) {
			arrLinks[i].setAttribute("ttid", arrLinks[i].getAttribute('title'));
			arrLinks[i].removeAttribute('title');
			arrLinks[i].addEvents({
				'mouseover':	showTip,/* folgendes funzt nur mit moo1.2 mootools-light würde nicht mehr funzen
						function(event) { 
							el.innerHTML = this.getAttribute('ttid');//getAttribute('ttid');
							el.style.visibility = "visible";
						},
				'mousemove': 	function(event) {
							x = event.page.x || event.client.x + document.documentElement.scrollLeft;
							y = event.page.y || event.client.y + document.documentElement.scrollTop;
							
							if((document.body.clientWidth-20) < (x+el.offsetWidth)) {
								el.style.right	= (document.body.clientWidth-x) + 'px';
								el.style.left	= '';
							} else {
								el.style.left	= (x+10) + 'px';
								el.style.right	= '';
							}
							el.style.top	= (y + 10) + 'px';

						},*/
				'mouseout':	function() {
							el.style.visibility = "hidden";
						}
			});
		}
	}
}

function UnCryptMailto(s) {
	var n = 0;
	var r = '';
	for(var i = 0; i < s.length; i++) {
		n = s.charCodeAt(i);
		if (n >= 8364) {n = 128;}
		r += String.fromCharCode(n-(1));
	}
	return r;
}
function linkTo_UnCryptMailto(s) { location.href=UnCryptMailto(s);}

var req = false;
try { req = new XMLHttpRequest(); }						// Mozilla, Opera, Netscape ...
catch (trymicrosoft) {
	try { req = new ActiveXObject("Msxml2.XMLHTTP"); }			// IE 6.0
	catch (othermicrosoft) {
		try { req = new ActiveXObject("Microsoft.XMLHTTP"); }		// IE 5.5 and older
		catch (failed) { req = false; }
	}
}
function linkcounter(type, url, session_id) {
	req.open('get', '/plugins/ajax.php?load=linkcounter&type='+type+'&url='+url+'&session_id='+session_id,true);
	req.send(null);
}

function ShowOverlay(trans) {
	new Element('div', {'id': 'site-overlayBG'}).injectInside(document.body);
	new Element('div', {'id': 'site-overlay'}).injectInside(document.body);
	new Fx.Style('site-overlayBG', 'opacity', {duration: 500}).start(0,trans).chain(function(){$('site-overlay').setStyle('opacity', 1);});
}
function HideOverlay() {
	$('site-overlay').remove();
	new Fx.Style('site-overlayBG', 'opacity', {duration: 500}).start(0).chain(function(){ $('site-overlayBG').remove();});
}
function toggleOverlay2() {
	if(!$('site-overlay')) {
		eOL = new Element('div', {'id': 'site-overlay'}).injectInside(document.body);
		eOL.set('opacity', 0);
		eOL.set('tween', { duration: 500 });
	}
	if (eOL.getStyle('opacity') == 0) {
		eOL.fade(0, 0.5);
	} else {
		eOL.fade(0.5, 0);
	}
}

function toggleOverlay(id) {
	if(!$('site-overlay')) {
		eOL = new Element('div', {'id': 'site-overlay'}).injectInside(document.body);
		eCB = new Element('div', {'id': 'site-centerbox'}).injectInside(document.body);
		eDL = new Element('div', {'id': id}).injectInside(eCB);
		eOL.set('tween', { duration: 500 });
		$$(eOL, eCB).setStyles({top:window.getScrollTop(),height:window.getHeight()});
		eOL.fade(0, 0.5).get('tween').chain(function() {eDL.set('opacity', 1);});
	} else {
		eCB.destroy();
		eOL.fade(0.5, 0).get('tween').chain(function() {eOL.destroy();});
	}
}

function ShowProgressBar(text) {

//	siteOverlay();

	// PROGRESS-BOX
	var msg	= document.createElement("div");
	msg.id = "site-progress";
	$('site-centerbox').appendChild(msg);

	new Fx.Style('site-progress', 'opacity', {duration: 200}).start(0,1);

	msg.innerHTML	= (!text ? "Bitte warten. Seite wird geladen..." : text);

}

/*
function siteOverlay() {
	if(!$('site-overlay')) {
		var ol	= document.createElement("div");
		ol.id	= "site-overlay";
		document.body.appendChild(ol);
		$('site-overlay').setOpacity(0.1);
		$('site-overlay').style.display = 'none';
		var box	= document.createElement("div");
		box.id	= "site-centerbox";
		document.body.appendChild(box);
	}
	
	if($('site-overlay').style.display == 'none')
		$('site-overlay', 'site-centerbox').style.display = 'block';
	else	$('site-overlay', 'site-centerbox').style.display = 'none';

}

function toggleDialog() {
	siteOverlay();
	if(!$('site-dialog')) {
		var msg	= document.createElement("div");
		msg.id = "site-dialog";
		$('site-centerbox').appendChild(msg);
	} else {
		$('site-centerbox').appendChild($('site-dialog'));
		toggle('site-dialog');
	}
}

function ShowProgressBar(text) {

	siteOverlay();

	// PROGRESS-BOX
	var msg	= document.createElement("div");
	msg.id = "site-progress";
	$('site-centerbox').appendChild(msg);

	new Fx.Style('site-progress', 'opacity', {duration: 200}).start(0,1);

	msg.innerHTML	= (!text ? "Bitte warten. Seite wird geladen..." : text);

}


function HideProgressBar() {
	siteOverlay();
	new Fx.Style('site-progress', 'opacity', {duration: 200}).start(1,0);
}
*/
