function getAjaxObject() {
	var ajax;
	try{
		ajax = new XMLHttpRequest();
	} catch (e) {
		try{
			ajax = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajax = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (failed) {
				return null;
			}
		}
	}
	return ajax;
}
function saveClick(p,q,sd,url,pid) {
	var ajax = getAjaxObject();
	if( ajax === null ) { return true; }
	ajax.open('GET', '/meta/cgi-bin/clickstats.pl?i='+pid+'&s='+sd+'&q='+q+'&p='+p+'&url='+encodeURIComponent(url), true);
	ajax.send(null);
	return true;
}
function show_metager_is_working() {
	window.scrollTo(0,0);
	var background = document.createElement('div');
	background.style.position="absolute";
	background.style.top="0";
	background.style.left="0";
	background.style.width="100%";
	background.style.height="100%";
	background.style.backgroundImage="url(/semitransparent.png)";
	background.style.backgroundRepeat="repeat";
	
	var container = document.createElement('div');
	container.style.margin="auto";
	container.style.marginTop="10em";
	container.style.padding="1em";
	container.style.width="30em";
	container.style.background="white";
	
	var box = document.createElement('div');
	box.style.border="1px solid rgb(6, 81, 157)";
	box.style.padding="1ex";
	box.style.textAlign="center";
	
	var title = document.createElement('h3');
	title.style.textAlign="center";
	title.appendChild(document.createTextNode('MetaGer sucht...'));
	
	var image = document.createElement('img');
	image.alt="Bitte warten bis das MetaGer-Ergebnis geladen wurde.";
	image.border="0";
	image.src="/laden.gif";
	
	box.appendChild(title);
	box.appendChild(image);
	container.appendChild(box);
	background.appendChild(container);
	document.body.insertBefore(background, document.body.firstChild);
	return true;
}

var searchInterval;
var colorCounter=0;
var colorMaxCount=17;
var color= new Array ( "#dd0000", "#00dd00", "#0000dd", "#bb0000", "#00bb00", "#0000bb", "#dd0000", "#00dd00", "#0000dd", "#dd0000", "#00dd00", "#0000dd", "#bb0000", "#00bb00", "#0000bb", "#dd0000", "#00dd00", "#0000dd");

function messageoff() {
	document.getElementById('working').style.visibility='hidden';
	document.getElementById('working').style.height=0;
	document.getElementById('working').style.padding=0;
	document.getElementById('working').style.margin=0;
	document.getElementById('working').style.margin=0;
	document.getElementById('working').innerText="";
	document.getElementById('working2').style.visibility='visible';
	document.getElementById('working2').style.height='0';
	document.getElementById('working2').style.padding='2px';
	document.getElementById('working2').style.margin=0;
	clearInterval(searchInterval); 
//	if(colorCounter<=colorMaxCount) {
//		document.getElementById('working2text').style.color=color[colorCounter];
//		colorCounter++;
//		searchInterval=setInterval("messageoff()", 2000);
//	}
}

function messageon() {
	document.getElementById('working').style.visibility='visible';
	document.getElementById('working').style.height='1em';
	document.getElementById('working').style.padding='2px';
	document.getElementById('working').style.margin=0;
	
	document.getElementById('working2').style.visibility='hidden'; 
	document.getElementById('working2').style.height=0;
	document.getElementById('working2').style.padding=0;
	document.getElementById('working2').style.margin=0;
	searchInterval=setInterval("messageoff()", 10000);
}

function begriff_austauschen(nr, neuer_begriff) {
	var begriffe = document.forms[0].eingabe.value.split(" ");
	for(var a = 0; a < begriffe.length; a++) {
		if(begriffe[a] == "" && a <= nr) { nr++; }
	}
	begriffe[nr] = neuer_begriff;
	document.forms[0].eingabe.value = begriffe.join(" ");
}

function nlc(el,ct,cd,sg) {
	var e = window.encodeURIComponent ? encodeURIComponent : escape;
	el.href="/url.html?sa=t&ct="+e(ct)+"&cd="+e(cd)+"&url="+e(el.href).replace(/\+/g,"%2B")+sg;
	el.onmousedown="";
	return true;
}

function clc(el,p,pos) {
	var e = window.encodeURIComponent ? encodeURIComponent : escape;
	el.href="http://www.clewwa.de/url?p="+e(p)+"&pos="+e(pos)+"&url="+e(el.href).replace(/\+/g,"%2B");
	el.onmousedown="";
	return true;
}

