/* (C) 2009 Plot and go GmbH - Bremen*/

axsuche=new ajax_connect();
axsuchepos=0;
suche_last_tab=0;
suche_timer=0;
showads=1;
isiframe=0;


function suche_start() 
{
	var suche_input=document.getElementById("suche_input");
	suche_input.onkeyup=suchedrop_up;
	suche_input.onkeydown=suchedrop_down;
	suche_input.setAttribute("AutoComplete", "off");
	document.suche.q.focus();
	document.suche.onsubmit=suchedrop_submit;
	suche_extra='';
}

function suchedrop_submit()
{
	if (axsuchepos==0) return true;
	var a=document.getElementById('suche_a_'+axsuchepos);
        if (isiframe) window.open(a.href);
        else window.location.href=a.href;
	return false;
}

function suchedrop_up()
{
	if (axsuchepos) return;
	if (suche_timer) window.clearTimeout(suche_timer);
	suche_timer=window.setTimeout("suchedrop_result()",250);
}


function suchedrop_down(evt)
{
	var evtobj=window.event ? event : evt;
	var key=evtobj.keyCode ? evtobj.keyCode : evtobj.charCode;
	var txt;
	var suche_input=document.getElementById("suche_input");
	
	if (key==40) {
		axsuchepos++;
		if (axsuchepos==1) suche_oldval=suche_input.value;
	} else if (key==38) {
		axsuchepos--;
		if (axsuchepos==0) suche_input.value=suche_oldval;
	} else if (key==13) {
		return true;
	} else {
		axsuchepos=0;
	}

	if (axsuchepos > 0) {
		var tab=document.getElementById('suche_tab_'+axsuchepos);
		var a=document.getElementById('suche_a_'+axsuchepos);
		if (a) {
			if (suche_last_tab) {
				suche_last_tab.style.background='#ffe';
			} 
			suche_input.value=a.innerHTML;
			tab.style.background='#afa';
			suche_last_tab=tab;
		} else {
			axsuchepos--;
		}
	}
	
}

function suchedrop_result()
{

	var suche_input=document.getElementById("suche_input");
	var suche_auto=document.getElementById("suche_auto");
	
	if (suche_input.value.length < 3) {
		suche_auto.innerHTML='';
		return;
	}
	axsuche.connect("i5search.php?val="+suche_input.value+suche_extra,htmlchangevisible,suche_auto);
}


rtimer=0;

function runrtimer()
{
  if (rtimer) window.clearTimeout(rtimer); 
  rtimer=window.setTimeout("location.reload(false)",100);
}

function externlink(a,b)
{
  a.target=b;
  return true;
}

function favorit()
{
  alert("Dr�cken Sie bitte die Tasten Strg + D. Das f�gt diese Seite zu den Favoriten hinzu.");
}

function startseite(a)
{
  alert('Geht nicht');
}

function suche(a)
{
  n=open('suche.php?was='+a,'suche','width=300,height=400,left=600,top=200,scrollbars=yes,resizeable=yes');
  n.focus();
}

function popuphw(seite,frame,h,w)
{
  n=open(seite,frame,'width='+h+',height='+w+',left=600,top=200,scrollbars=yes,resizeable=yes');
  n.focus();
}


function popup(seite,frame)
{
  n=open(seite,frame);
  n.focus();
}

function chgadmimgupl(e,i)
{
  var d=document.getElementById("admimgupl"+i);
  var ss=e.value.substr(5,1);
  if (ss == 'B') d.style.visibility='visible';
  else d.style.visibility='hidden';
}


function makeajax()
{
  try { return new XMLHttpRequest(); }
  catch (e) { try { return new ActiveXObject("Msxml2.XMLHTTP"); } 
    catch (e) { try { return new ActiveXObject("Microsoft.XMLHTTP"); } 
      catch (e) { alert('No Ajax') } 
    }
  }
  return null;
}

// ajax
function ajax_connect()
{
  var xmlhttp, bComplete = false;
  var wait=0;
  var req;
  xmlhttp=makeajax();
  if (!xmlhttp) return null;
  this.connect = function(sURL,fnDone,xthis)
  {
    if (!xmlhttp) return 0;
    if (xmlhttp.readyState != 0) {
      xmlhttp.abort();
      //delete xmlhttp;
      //xmlhttp=makeajax();
    }
    xmlhttp.onreadystatechange = function() {
      if (xmlhttp.readyState == 4) {
        if (xmlhttp.responseText.length > 0) {
          fnDone(xmlhttp.responseText,xthis);
        }
      }
    }
    xmlhttp.open("GET",sURL, true);
	  xmlhttp.setRequestHeader("Content-Type","text/plain; charset=utf-8");
    xmlhttp.send('');
    return 1;
  };
  return this;
}

// wechselbanner
var htmlchange = function (txt,a) 
{ 
  a.innerHTML=txt; 
}

// wechselbanner
var htmlchangejs = function (txt,a) 
{ 
  a.innerHTML=txt; 
	launchJavascript(txt);
}


launchJavascript

var htmlchangevisible = function (txt,a) 
{ 
  a.innerHTML=txt; 
  a.style.visibility='visible';
}

function autobanner(plz,parameter)
{
  var div=document.getElementById("banner");
  var ajax=new ajax_connect();
  ajax.connect("i5data.php?parameter="+parameter+"&bannerplz="+plz,htmlchange,div);
}

linklisttimer=0;

function exchvisi(a,b)
{
  if (a) document.getElementById(a).style.visibility='visible';
  if (b) document.getElementById(b).style.visibility='hidden';
  if (linklisttimer) window.clearTimeout(linklisttimer);
  linklisttimer=0;
}

function linklisthide(a)
{
  linklisttimer=window.setTimeout("document.getElementById('"+a+"').style.visibility='hidden'",500);
}

function linklistshow(a)
{
  if (linklisttimer) window.clearTimeout(linklisttimer);
  linklisttimer=0;
}

function launchJavascript(responseText) {

	var ScriptFragment = '(?:<script.*?>)((\n|.)*?)(?:</script>)';
           
  var match    = new RegExp(ScriptFragment, 'img');
  var scripts  = responseText.match(match);

    if(scripts) {
        var js = '';
        for(var s = 0; s < scripts.length; s++) {
            var match = new RegExp(ScriptFragment, 'im');
            js += scripts[s].match(match)[1];
        }
        eval(js);
    }
}

active_rectangle=0;
onclick_rectangle=0;

function rect_mini_onclick(t)
{
	if (onclick_rectangle) {
		rect_maxi_show(onclick_rectangle);
		rect_mini_show(default_rectangle,0,0);
		return false;
	}
	t.target="_blank";
	return true;
}

function rect_close()
{
	var e=document.getElementById("rc_rect");
	e.style.visibility='hidden';
	e=document.getElementById("minirect");
	axpartnerpop.connect("i5data.php?minirect="+active_rectangle,htmlchangevisible,e);
}

function rect_maxi_show(rect)
{
	if (showads==0) return;
	active_rectangle=rect;
	var e=document.getElementById("rc_rect");
	axpartnerpop.connect("i5data.php?maxirect="+rect,htmlchangevisible,e);
}

function rect_mini_show(rect,oclick,defrect)
{
	onclick_rectangle=oclick;
	default_rectangle=defrect;
	var e=document.getElementById("minirect");
	axminipop.connect("i5data.php?minirect="+rect,htmlchange,e);
}







