function cnt(site,what,to,session) {
	var xmlHttp = null;
	if (typeof XMLHttpRequest != 'undefined') { xmlHttp = new XMLHttpRequest(); }
	if (!xmlHttp) {
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e_cnt_1) {
			try {
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e_cnt_2) {
				xmlHttp = null;
			}
		}
	}

	if (xmlHttp) {
		xmlHttp.open('GET', '/cgi-bin/redir.pl?site='+site+'&amp;what='+what+'&amp;se='+session+'&amp;to='+to, true);
		xmlHttp.onreadystatechange = function () {
			if (xmlHttp.readyState == 4) { var is_loaded = 1; }
		};
		xmlHttp.send(null);
	}
	return true;
}

function set_click(c,d) {
	for(var b=document.getElementsByTagName("a"),e=0;e<b.length;e++)
		if(b[e].href!=""&&b[e].hostname!=window.location.hostname&&b[e].hostname!=""&&(b[e].protocol=="http:"||b[e].protocol=="https:")){
			if(b[e].hostname!="62.8.239.62"){
				b[e].setAttribute("onclick","cnt('"+c+"','http',this.href,"+d+");");
				b[e].target="_blank"}b[e].setAttribute("onkeypress","")
			} else 
				if(b[e].protocol=="mailto:") {
					b[e].setAttribute("onclick","cnt('"+c+"','mail',this.href,"+d+");");
					b[e].setAttribute("onkeypress","")
				}
}

function view_tel(site,what,to,session){
	if (document.getElementById("tel_hide_nr").style.display!="inline"){
		var xmlHttp=null;
		if (typeof XMLHttpRequest != 'undefined'){xmlHttp = new XMLHttpRequest();}
		if (!xmlHttp){
			try{
				xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
			} catch(e_vtel_1) {
				try {
					xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
				} catch(e_vtel_2) {
					xmlHttp = null;
				}
			}
		}
		if (xmlHttp) {
			xmlHttp.open('GET', '/cgi-bin/redir.pl?site='+site+'&amp;what='+what+'&amp;se='+session+'&amp;to='+to, true);
			xmlHttp.onreadystatechange = function () {
				if (xmlHttp.readyState == 4) {
					document.getElementById("tel_hide_text").style.display="none";
					document.getElementById("tel_hide_nr").style.display="inline";
				}
			};
			xmlHttp.send(null);
		}

	}
	return false;
}

function view_fax(site,what,to,session) {
	if (document.getElementById("fax_hide_nr").style.display!="inline") {
		var xmlHttp = null;
		if (typeof XMLHttpRequest != 'undefined') { xmlHttp = new XMLHttpRequest(); }
		if (!xmlHttp) {
			try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
			} catch(e_vfax_1) {
				try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
				} catch(e_vfax_2) { xmlHttp = null; }
			}
		}
		if (xmlHttp) {
			xmlHttp.open('GET', '/cgi-bin/redir.pl?site='+site+'&amp;what='+what+'&amp;se='+session+'&amp;to='+to, true);
			xmlHttp.onreadystatechange = function () {
				if (xmlHttp.readyState == 4) {
					document.getElementById("fax_hide_text").style.display="none";
					document.getElementById("fax_hide_nr").style.display="inline";
				}
			};
			xmlHttp.send(null);
		}
	}
	return false;
}

function view_pr(path) {
	if (document.getElementById('pagerank')){
		var xmlHttp = null;
		if (typeof XMLHttpRequest != 'undefined') {xmlHttp = new XMLHttpRequest();}
		if (!xmlHttp){try{xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
			}catch(e_vf_1){try{xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
				}catch(e_vf_2){xmlHttp = null;}
			}
		}
		if (xmlHttp) {
			xmlHttp.open('GET', '/cgi-bin/pr_counter.pl?target='+path, true);
			xmlHttp.onreadystatechange = function () {
				if (xmlHttp.readyState == 4) {
					var footer_div = document.getElementById('pagerank');
					footer_div.innerHTML = xmlHttp.responseText;
				}
			};
			xmlHttp.send(null);
		}
	}
	return false;
}

// Suggest
var req;
var suggest_field_focus = 0;
var suggest_out_focus = 0;
var suggest_blur_delayed = 0;

function loadXMLDoc(url) {
	// branch for native XMLHttpRequest object
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChange;
		req.open("get", url, true);
		req.send(null);
	// branch for IE/Windows ActiveX version
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.onreadystatechange = processReqChange();
			req.open("get", url, true);
			req.send();
		}
	}
	var xml_loading = 1;
}

function processReqChange()  {
	var out_div;

	// only if req shows "complete"
	if (req.readyState == 4) {
	// only if "OK"
		if (req.status == 200) {
			var response  = req.responseXML;
			if (document.all) {
				out_div=document.all[suggest_output_name];
			} else {
				out_div=document.getElementById(suggest_output_name);
			}
			text = document.createElement("div");
			text.setAttribute("style","margin: 5px;");
 			text.appendChild(document.createTextNode("Treffer: "+response.getElementsByTagName('keyword').length));
			text.appendChild(document.createElement("br"));
			for (i=0;i<response.getElementsByTagName('keyword').length;i++) {
				link_text  = "/suggest/show_"+suggest_session+"_"+suggest_user+"_";
				link_text += suggest_entity+"_"+suggest_lang+"_"+suggest_layout+"_";
				link_text += response.getElementsByTagName('key_id')[i].firstChild.data+"_22.html";
				link = document.createElement("a");
				link.onclick = function() {suggest_out_focus=1;return 1;};
				link.setAttribute("href",link_text);
				link.setAttribute("target","_top");
				link.appendChild(document.createTextNode(" "+response.getElementsByTagName('keyword')[i].firstChild.data));
				link.appendChild(document.createTextNode("  ("));
				if (response.getElementsByTagName('count')[i].firstChild.data == 1) {
					link.appendChild(document.createTextNode(response.getElementsByTagName('count')[i].firstChild.data+" Produkt) "));
				} else {
					link.appendChild(document.createTextNode(response.getElementsByTagName('count')[i].firstChild.data+" Produkte) "));
				}
				text.appendChild(link);
				text.appendChild(document.createElement("br"));
			}
			if (response.getElementsByTagName('keyword').length > 0) {
				out_div.style.color = "black";
				out_div.style.visibility = "visible";
			} else {
				out_div.style.visibility = "hidden";
			}
			if (out_div.hasChildNodes()) out_div.removeChild(out_div.firstChild);
			out_div.appendChild(text);
		}
	} else {
		if (document.all) {
			var out_div=document.all[suggest_output_name];
		} else {
			var out_div=document.getElementById(suggest_output_name);
		}
		text = document.createElement("div");
		text.appendChild(document.createTextNode("Moment bitte ..."));
		text.appendChild(document.createElement("br"));
		out_div.style.visibility = "visible";
		out_div.style.color = "red";
		if (out_div.hasChildNodes()) out_div.removeChild(out_div.firstChild);
		out_div.appendChild(text);
	}
}

function suggest(input) {
	if (input.length > 2) {
		var url  = suggest_script_url + escape(input);
		loadXMLDoc(url);
	}
}

function suggest_delay_blur(output) {
	if (suggest_blur_delayed != 1) {
		window.setTimeout(function() {suggest_delay_blur(output)},1000);
		suggest_blur_delayed=1;
	} else {
		if (suggest_out_focus != 1) {
			suggest_field_focus=0;
			if (document.all) {
				document.all[output].style.visibility='hidden';
			} else {
				document.getElementById(output).style.visibility='hidden';
			}
		};
		suggest_blur_delayed=0;
	}
}

function init_suggest() {
	if (window.ActiveXObject) {
		var doc_sff = document.all[suggest_form_field];
		var doc_son = document.all[suggest_output_name];
		doc_sff.onkeyup = function() {return suggest(document.all[suggest_form_field].value);};
		doc_sff.onblur = function() { return suggest_delay_blur(suggest_output_name);};
		doc_sff.onfocus = function() { if (! suggest_out_focus) {suggest_field_focus=1;if (this.value == '<Stichwort>') this.value = '';};return true;};
		doc_son.onblur = function() { if (! suggest_field_focus) {suggest_out_focus=0;document.all[suggest_output_name].style.visibility='hidden';};return true;};
		doc_son.onfocus = function() {suggest_out_focus=1;document.all[suggest_output_name].style.visibility='visible'; return true;};
	} else if (window.XMLHttpRequest) {
		document.getElementById(suggest_form_field).setAttribute("onkeyup","return suggest(document.getElementById(suggest_form_field).value);");
		document.getElementById(suggest_form_field).setAttribute("onblur","return suggest_delay_blur(suggest_output_name);");
		document.getElementById(suggest_form_field).setAttribute("onfocus","if (! suggest_out_focus) {suggest_field_focus=1;if (this.value == '<Stichwort>') this.value = '';};return true;");
		document.getElementById(suggest_form_field).setAttribute("autocomplete","off");
		document.getElementById(suggest_output_name).setAttribute("onblur","if (! suggest_field_focus) {suggest_out_focus=0;document.getElementById(suggest_output_name).style.visibility='hidden';}; return true;");
		document.getElementById(suggest_output_name).setAttribute("onfocus","suggest_out_focus=1;document.getElementById(suggest_output_name).style.visibility='visible'; return true;");
	}
}


