var descarray = new Object();

descarray['menu_artikelN']='Hier können Sie neue Einträge erzeugen.<br />Wobei sie diese in plaintext schreiben<br /> können oder in HTML.';
descarray['menu_artikelW']='Hier können Sie neue Einträge erzeugen.<br />Wobei sie diese mittels eines Editor<br /> wie in Word gestalten können.';

var help_window;

// :::::::: welcher Browser ? ::::::::
if (document.layers) {navigator.family = "nn4"}
if (document.all) {navigator.family = "ie4"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {navigator.family = "gecko"}

overdiv="0";

//  :::::::: kreiert Tabelle für die PopUp-Box ::::::::
function popLayer(content){

if(descarray[content])
 content = descarray[content];

if (navigator.family == "gecko")
{
 pad="0"; bord="1 bordercolor=black";
} else {
 pad="1"; bord="0";
}

desc = "<table cellspacing=0 cellpadding="+pad+" border="+bord+" bgcolor=black><tr><td>\n"
        +"<table cellspacing=0 cellpadding=4 border=0 width=100%><tr><td class=\"help_div_table\">\n"
		+"<a class=\"help_div_text\">\n"
        +content
        +"\n</a>\n</td></tr></table>\n"
        +"</td></tr></table>";
if(navigator.family =="nn4") {
        document.object1.document.write(desc);
        document.object1.document.close();
        document.object1.left=x+15;
        document.object1.top=y-5;
        }
else if(navigator.family =="ie4"){
        object1.innerHTML=desc;
        object1.style.pixelLeft=x+15;
        object1.style.pixelTop=y-5;
        }
else if(navigator.family =="gecko"){
        document.getElementById("object1").innerHTML=desc;
        document.getElementById("object1").style.left=x+15;
        document.getElementById("object1").style.top=y-5;
        }
}

//  :::::::: überwacht Maus-Position / plaziert die Box dementsprechend ::::::::


var isNav = (navigator.appName.indexOf("Netscape") !=-1);

function handlerMM(e){

// entweder feste x/y-Position für die Info-Box
// x = 300; // Infobox x-Position bei 300 von links
// y = 0;   // Infobox y-Position bei 0 (oben)

// oder Plazierung neben Mauszeiger

x = (isNav) ? e.pageX : event.clientX + document.body.scrollLeft;
y = (isNav) ? e.pageY : event.clientY + document.body.scrollTop;

}

if (isNav){document.captureEvents(Event.MOUSEMOVE);} document.onmousemove = handlerMM;


//  :::::::: versteckt die PopUp-Box ::::::::
function hideLayer(){
if (overdiv == "0") {
        if(navigator.family =="nn4") {eval(document.object1.top="-500");}
        else if(navigator.family =="ie4"){object1.innerHTML="";}
        else if(navigator.family =="gecko") {document.getElementById("object1").style.top="-500";}
        }
}

function popWin(a)
{
 help_window = window.open('/admin/help/' + a + '.php','Hilfe','width=680,height=600,resizable,scrollbars=yes');
 help_window.focus();
}

function popUp(URL, width, height) {
 
  if (!width>0)
   width=800;
   
  if (!height>0)
   height=600;
   
  day = new Date();
  id = day.getTime();
  eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=" + width + ",height=" + height +" ,left = 20,top = 20');");
  
  return false;
}

function cb_kopieren(inhalt)
{
	ablage = inhalt.createTextRange();
	ablage.execCommand('Copy');
}

function cb_einfuegen(inhalt)
{
	inhalt.select();
	ablage=inhalt.createTextRange();
	ablage.execCommand('Paste');
}

function to_info_box (inhalt)
{
 document.getElementById("link_row").value=inhalt;
}

var over_menu='';

function time()
{
 Stamp = new Date();
 return Math.round(Date.parse(Stamp)/1000);
}

function set_over( id )
{
 over_menu=id;
 window.setTimeout("is_over ( '" + id + "' )", 200);
}
  
function is_over ( id )
{
 if (id == over_menu)
 {
  document.getElementById( id ).style.display='inline';
 }
}

function set_out( id )
{
 over_menu='';
 document.getElementById( id ).style.display='none';
}


// global xmlhttprequest object
var xmlHttp = false;



/** AJAX functions **/

// constants
var REQUEST_GET        = 0;
var REQEST_POST        = 2;
var REQUEST_HEAD       = 1;
var REQUEST_XML        = 3;



/**
 * instantiates a new xmlhttprequest object
 *
 * @return xmlhttprequest object or false
 */
function getXMLRequester( )
{
    var xmlHttp = false;
            
    // try to create a new instance of the xmlhttprequest object        
    try
    {
        // Internet Explorer
        if( window.ActiveXObject )
        {
            for( var i = 5; i; i-- )
            {
                try
                {
                    // loading of a newer version of msxml dll (msxml3 - msxml5) failed
                    // use fallback solution
                    // old style msxml version independent, deprecated
                    if( i == 2 )
                    {
                        xmlHttp = new ActiveXObject( "Microsoft.XMLHTTP" );    
                    }
                    // try to use the latest msxml dll
                    else
                    {
                        
                        xmlHttp = new ActiveXObject( "Msxml2.XMLHTTP." + i + ".0" );
                    }
                    break;
                }
                catch( excNotLoadable )
                {                        
                    xmlHttp = false;
                }
            }
        }
        // Mozilla, Opera und Safari
        else if( window.XMLHttpRequest )
        {
            xmlHttp = new XMLHttpRequest();
        }
    }
    // loading of xmlhttp object failed
    catch( excNotLoadable )
    {
        xmlHttp = false;
    }
    return xmlHttp ;
}


/**
 * sends a http request to server
 * @param strSource, String, datasource on server, e.g. data.php
 * @param strData, String, data to send to server, optionally
 * @param intType, Integer,request type, possible values: REQUEST_GET, REQUEST_POST, REQUEST_XML, REQUEST_HEAD default REQUEST_GET
 * @param strData, Integer, ID of this request, will be given to registered event handler onreadystatechange', optionally
 * @return String, request data or data source
 */
function sendRequest( strSource, strData, intType, intID )
{
    if( !strData )
        strData = '';

    // default type (0 = GET, 1 = xml, 2 = POST )
    if( isNaN( intType ) )
        intType = 0; // GET

    // previous request not finished yet, abort it before sending a new request
    if( xmlHttp && xmlHttp.readyState )
    {
        xmlHttp.abort( );
        xmlHttp = false;
    }
        
    // create a new instance of xmlhttprequest object
    // if it fails, return
    if( !xmlHttp )
    {
        xmlHttp = getXMLRequester( );
        if( !xmlHttp )
            return;
    }
    
    // parse query string
    if( intType != 1 && ( strData && strData.substr( 0, 1 ) == '&' || strData.substr( 0, 1 ) == '?' ) )
        strData = strData.substring( 1, strData.length );

    // data to send using POST
    var dataReturn = strData ? strData : strSource;
    
    switch( intType )
    {
        case 1:    // xml
            strData = "xml=" + strData;
        case 2: // POST
            // open the connection 
            xmlHttp.open( "POST", strSource, true );
            xmlHttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
            xmlHttp.setRequestHeader( 'Content-length', strData.length );
            break;
        case 3: // HEAD
            // open the connection 
            xmlHttp.open( "HEAD", strSource, true );
            strData = null;
            break;
        default: // GET
            // open the connection 
            var strDataFile = strSource + (strData ? '?' + strData : '' );
            xmlHttp.open( "GET", strDataFile, true );
            strData = null;
    }
    
    // set onload data event-handler
    xmlHttp.onreadystatechange = new Function( "", "processResponse(" + intID + ")" ); ;

    // send request to server
    xmlHttp.send( strData );    // param = POST data
    
    return dataReturn;
}
    

function processResponse( intID )
{
    // status 0 UNINITIALIZED open() has not been called yet.
    // status 1 LOADING send() has not been called yet.
    // status 2 LOADED send() has been called, headers and status are available.
    // status 3 INTERACTIVE Downloading, responseText holds the partial data.
    // status 4 COMPLETED Finished with all operations.
    switch( xmlHttp.readyState )
    {
        // uninitialized
        case 0:
        // loading
        case 1:
        // loaded
        case 2:
        // interactive
        case 3:
            break;
        // complete
        case 4:    
            // check http status
            if( xmlHttp.status == 200 )    // success
            {
                processData( xmlHttp, intID );
            }
            // loading not successfull, e.g. page not available
            else
            {
                if( window.handleAJAXError )
                    handleAJAXError( xmlHttp, intID );
                else
                    alert( "ERROR\n HTTP status = " + xmlHttp.status + "\n" + xmlHttp.statusText ) ;
            }
    }
}


function encode_utf8(rohtext) 
{
 // dient der Normalisierung des Zeilenumbruchs
 rohtext = rohtext.replace(/\r\n/g,"\n");
 var utftext = "";
 for(var n=0; n<rohtext.length; n++)
 {
  // ermitteln des Unicodes des  aktuellen Zeichens
  var c=rohtext.charCodeAt(n);
  // alle Zeichen von 0-127 => 1byte
  if (c<128)
   utftext += String.fromCharCode(c);
   // alle Zeichen von 127 bis 2047 => 2byte
  else if((c>127) && (c<2048)) {
   utftext += String.fromCharCode((c>>6)|192);
   utftext += String.fromCharCode((c&63)|128);}
   // alle Zeichen von 2048 bis 66536 => 3byte
  else {
  utftext += String.fromCharCode((c>>12)|224);
  utftext += String.fromCharCode(((c>>6)&63)|128);
  utftext += String.fromCharCode((c&63)|128);}
 }
 return utftext;
}

function decode_utf8(utftext) 
{
 var plaintext = ""; var i=0; var c=c1=c2=0;
 // while-Schleife, weil einige Zeichen uebersprungen werden
 while(i<utftext.length)
 {
  c = utftext.charCodeAt(i);
  if (c<128) 
  {
   plaintext += String.fromCharCode(c);
   i++;
  } else if((c>191) && (c<224)) {
   c2 = utftext.charCodeAt(i+1);
   plaintext += String.fromCharCode(((c&31)<<6) | (c2&63));
   i+=2;
  } else {
   c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2);
   plaintext += String.fromCharCode(((c&15)<<12) | ((c2&63)<<6) | (c3&63));
   i+=3;
  }
 }
 return plaintext;
}

function question (nachricht, url)
{
 var reply = prompt(nachricht + "\nGeben Sie OK ein!", "");

 if (reply=="OK" || reply=="ok")
  { window.location.href=url; }
 else
  {}
}


function URLencode(sStr)
{
 sStr=sStr.split('"').join('%22');
 sStr=sStr.split('&').join('%26');
 sStr=sStr.split("'").join('%27');
 sStr=sStr.split('€').join('%80');
 sStr=sStr.split('+').join('%2B');
 sStr=sStr.split('/').join('%2F');
 sStr=sStr.split('=').join('%3D');

 return sStr;
}

var theSelection = false;
var imageTag = false;

// Check for Browser & Platform for PC & IE specific bits
// More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
var clientVer = parseInt(navigator.appVersion); // Get browser version

var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));
var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1)
                && (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1)
                && (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1));
var is_moz = 0;

var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1));
var is_mac = (clientPC.indexOf("mac")!=-1);

// Define the bbCode tags
bbcode = new Array();
bbtags = new Array('<b>','</b>','<u>','</u>','<i>','</i>','<p>','</p>','<a href="" target="_self">','</a>');

function set_smile( smile ) 
{
	var txtarea = document.getElementById('htext');
	text = smile;
	if (txtarea.createTextRange && txtarea.caretPos) {
		var pos  = txtarea.caretPos;
		pos.text = pos.text.charAt(pos.text.length - 1) == ' ' ? pos.text + text + ' ' : pos.text + text;
	} else {
		txtarea.value  += text;
	}
	txtarea.focus();
}

function bbstyle(bbnumber) {
	var txtarea = document.getElementById('htext');

	txtarea.focus();
	donotinsert = false;
	theSelection = false;
	bblast = 0;

	if (bbnumber == -1) { // Close all open tags & default button names
		while (bbcode[0]) {
			butnumber = arraypop(bbcode) - 1;
			txtarea.value += bbtags[butnumber + 1];
			buttext = eval('document.post.addbbcode' + butnumber + '.value');
			eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
		}
		imageTag = false; // All tags are closed including image tags :D
		txtarea.focus();
		return;
	}

	if ((clientVer >= 4) && is_ie && is_win)
	{
		theSelection = document.selection.createRange().text; // Get text selection
		if (theSelection) {
			// Add tags around selection
			document.selection.createRange().text = bbtags[bbnumber] + theSelection + bbtags[bbnumber+1];
			txtarea.focus();
			theSelection = '';
			return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, bbtags[bbnumber], bbtags[bbnumber+1]);
		return;
	}

	// Find last occurance of an open tag the same as the one just clicked
	for (i = 0; i < bbcode.length; i++) {
		if (bbcode[i] == bbnumber+1) {
			bblast = i;
			donotinsert = true;
		}
	}

	if (donotinsert) {		// Close all open tags up to the one just clicked & default button names
		while (bbcode[bblast]) {
				txtarea.value += bbtags[butnumber + 1];
				imageTag = false;
			}
			txtarea.focus();
			return;
	} else { // Open tags

		// Open tag
		txtarea.value += bbtags[bbnumber];
		if ((bbnumber == 14) && (imageTag == false)) imageTag = 1; // Check to stop additional tags after an unclosed image tag
		arraypush(bbcode,bbnumber+1);
		txtarea.focus();
		return;
	}
	storeCaret(txtarea);
}

// From http://www.massless.org/mozedit/
function mozWrap(txtarea, open, close)
{
	var selLength = txtarea.textLength;
	var selStart = txtarea.selectionStart;
	var selEnd = txtarea.selectionEnd;
	if (selEnd == 1 || selEnd == 2)
		selEnd = selLength;

	var s1 = (txtarea.value).substring(0,selStart);
	var s2 = (txtarea.value).substring(selStart, selEnd)
	var s3 = (txtarea.value).substring(selEnd, selLength);
	txtarea.value = s1 + open + s2 + close + s3;
	return;
}

// Insert at Claret position. Code from
// http://www.faqts.com/knowledge_base/view.phtml/aid/1052/fid/130
function storeCaret(textEl) {
	if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}

// Replacement for arrayname.push(value) not implemented in IE until version 5.5
// Appends element to the array
function arraypush(thearray,value) {
	thearray[ getarraysize(thearray) ] = value;
}

// Replacement for arrayname.pop() not implemented in IE until version 5.5
// Removes and returns the last element of an array
function arraypop(thearray) {
	thearraysize = getarraysize(thearray);
	retval = thearray[thearraysize - 1];
	delete thearray[thearraysize - 1];
	return retval;
}
function getarraysize(thearray) {
	for (i = 0; i < thearray.length; i++) {
		if ((thearray[i] == "undefined") || (thearray[i] == "") || (thearray[i] == null))
			return i;
		}
	return thearray.length;
}

function copy_news( id )
{
 openPrompt(1);
 document.getElementById("promt_copy_id").value=id;
}

function openPrompt(promtid) 
{ 
 var margintop = -250;

 var scroll_pos = get_scroll_pos();

 margintop += scroll_pos.top;

 document.getElementById("promptdiv" + promtid).style.marginTop = margintop + 'px';
 document.getElementById("promptdiv" + promtid).style.display   = "block";
}

function hidepromptdiv (promtid)
{ 
 document.getElementById("promptdiv" + promtid).style.display = "none";
} 

function markieren(aTag, eTag, id) {
  var input = document.getElementById(id);
  input.focus();
  /* für Internet Explorer */
  if(typeof document.selection != 'undefined') {
    /* Einfügen des Formatierungscodes */
    var range = document.selection.createRange();
    var insText = range.text;
    range.text = aTag + insText + eTag;
    /* Anpassen der Cursorposition */
    range = document.selection.createRange();
    if (insText.length == 0) {
      range.move('character', -eTag.length);
    } else {
      range.moveStart('character', aTag.length + insText.length + eTag.length);      
    }
    range.select();
  }
  /* für neuere auf Gecko basierende Browser */
  else if(typeof input.selectionStart != 'undefined')
  {
    /* Einfügen des Formatierungscodes */
    var start = input.selectionStart;
    var end = input.selectionEnd;
    var insText = input.value.substring(start, end);
    input.value = input.value.substr(0, start) + aTag + insText + eTag + input.value.substr(end);
    /* Anpassen der Cursorposition */
    var pos;
    if (insText.length == 0) {
      pos = start + aTag.length;
    } else {
      pos = start + aTag.length + insText.length + eTag.length;
    }
    input.selectionStart = pos;
    input.selectionEnd = pos;
  }
  /* für die übrigen Browser */
  else
  {
    /* Abfrage der Einfügeposition */
    var pos;
    var re = new RegExp('^[0-9]{0,3}$');
    while(!re.test(pos)) {
      pos = prompt("Einfügen an Position (0.." + input.value.length + "):", "0");
    }
    if(pos > input.value.length) {
      pos = input.value.length;
    }
    /* Einfügen des Formatierungscodes */
    var insText = prompt("Bitte geben Sie den zu formatierenden Text ein:");
    input.value = input.value.substr(0, pos) + aTag + insText + eTag + input.value.substr(pos);
  }
}
function alles_markieren(aTag, eTag, id ) {
  var input = document.getElementById(id);
  input.focus();
  var text = aTag + input.value + eTag;
  input.value=text;
}
function dropdown_changer( type, id  ) {
 var input = document.getElementById( id + "_" + type + '_dropdown');
 var output = document.getElementById( id + "_" + type);
 output.value=output.value + input.value;
}


function more_meneu( id, field )
{
var div = document.getElementById('more_meneu_' + field  ).style.display;
if (div=="none")
 {
  document.getElementById('bild_' + id ).src='/images/minus.gif';
  document.getElementById('more_meneu_' + field  ).style.display='inline';
 } else {
  document.getElementById('bild_' + id ).src='/images/plus.gif';
  document.getElementById('more_meneu_' + field  ).style.display='none';
 }
}

function markieren(aTag, eTag, id) {
  var input = document.getElementById(id);
  input.focus();
  /* für Internet Explorer */
  if(typeof document.selection != 'undefined') {
    /* Einfügen des Formatierungscodes */
    var range = document.selection.createRange();
    var insText = range.text;
    range.text = aTag + insText + eTag;
    /* Anpassen der Cursorposition */
    range = document.selection.createRange();
    if (insText.length == 0) {
      range.move('character', -eTag.length);
    } else {
      range.moveStart('character', aTag.length + insText.length + eTag.length);      
    }
    range.select();
  }
  /* für neuere auf Gecko basierende Browser */
  else if(typeof input.selectionStart != 'undefined')
  {
    /* Einfügen des Formatierungscodes */
    var start = input.selectionStart;
    var end = input.selectionEnd;
    var insText = input.value.substring(start, end);
    input.value = input.value.substr(0, start) + aTag + insText + eTag + input.value.substr(end);
    /* Anpassen der Cursorposition */
    var pos;
    if (insText.length == 0) {
      pos = start + aTag.length;
    } else {
      pos = start + aTag.length + insText.length + eTag.length;
    }
    input.selectionStart = pos;

    input.selectionEnd = pos;
  }
  /* für die übrigen Browser */
  else
  {
    /* Abfrage der Einfügeposition */
    var pos;
    var re = new RegExp('^[0-9]{0,3}$');
    while(!re.test(pos)) {
      pos = prompt("Einfügen an Position (0.." + input.value.length + "):", "0");
    }
    if(pos > input.value.length) {
      pos = input.value.length;
    }
    /* Einfügen des Formatierungscodes */
    var insText = prompt("Bitte geben Sie den zu formatierenden Text ein:");
    input.value = input.value.substr(0, pos) + aTag + insText + eTag + input.value.substr(pos);
  }
}

function alles_markieren(aTag, eTag, id ) {
  var input = document.getElementById(id);
  input.focus();
  var text = aTag + input.value + eTag;
  input.value=text;
}

function dropdown_changer( type, id  ) {
 var input = document.getElementById( id + "_" + type + '_dropdown');
 var output = document.getElementById( id + "_" + type);
 output.value=output.value + input.value;
}

function change_lang( lang )
{
 secure_check_value = false;	
 document.newPostForm.new_lang.value=lang;
 document.newPostForm.fSubmit.value='lang';
 document.newPostForm.submit();
}

function popCal(too) 
{
  var date = document.getElementById(too).value;
  day = new Date();
  id = day.getTime();
  calenda = window.open('/admin/calendar.php?too=' +  too + '&full_date=' + date, 'calenda', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=174,height=171,left = 20,top = 20');
  calenda.focus();

}

function get_scroll_pos()
{
  var ergebniss = new Object();

  ergebniss.left = (document.all)?document.body.scrollLeft:window.pageXOffset;
  ergebniss.top  = (document.all)?document.body.scrollTop:window.pageYOffset;

  return ergebniss;
}

function setCookie(name, value, expiresin, path, domain, secure) {
  if (expiresin<1)
   expiresin=1;
  
  now=new Date();
  expires=new Date(now.getTime()+expiresin*86400000);

  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path)    ? "; path=" + path : "") +
      ((domain)  ? "; domain=" + domain : "") +
      ((secure)  ? "; secure" : "");
  document.cookie = curCookie;
}

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}


var Utf8 = {

    // public method for url encoding
    encode : function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    },

    // public method for url decoding
    decode : function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while ( i < utftext.length ) {

            c = utftext.charCodeAt(i);

            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i+1);

                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }

        }

        return string;
    }

}

var js_selector = {
 select_cache: '',
 cur_obj: null,
 is_activ: false,
 
 construct: function( select_obj )
 {  
  this.cur_obj = select_obj;
  this.select_cache = '';
  this.is_activ = true;
  this.cur_value = '',
  
  this.addEvent(document, 'keydown', this.TasteGedrueckt); 
 },
 
 destruct: function()
 { 
  this.select_cache = '';
  this.is_activ = false;
  this.removeEvent(document, 'keydown', this.TasteGedrueckt, false);
  
  if (this.cur_value!='')
   this.cur_obj.value = this.cur_value;
 },

 TasteGedrueckt: function (Ereignis) 
 { 
  if (js_selector.is_activ != true)
   return false;
  
  if (!Ereignis)
    Ereignis = window.event;

  if (Ereignis.keyCode)
  { 
   js_selector.select_cache = js_selector.select_cache + String.fromCharCode(Ereignis.keyCode).toLowerCase();
   
   for (i in js_selector.cur_obj.options)
   {
	try {   
	 js_selector.cur_obj.options[i].selected=false;
	} catch (e) { }
   }	
   
   for (i in js_selector.cur_obj.options)
   { 
    try {
	 // var tmp_a = js_selector.cur_obj.options[i].text.substr(js_selector.cur_obj.options[i].text.indexOf('>')+1).toLowerCase().substr(0, js_selector.select_cache.length);   	
     throw js_selector.cur_obj.options[i].text.replace(/^[\s\.]+|\s+$/, '').toLowerCase().substr(0, js_selector.select_cache.length); 
    } catch (tmp_a) { 
	 if (tmp_a.length>0)
	 {
	  if (tmp_a ==  js_selector.select_cache)
	  {
	   js_selector.cur_obj.options[i].selected=true;
	   js_selector.cur_value = js_selector.cur_obj.options[i].value; 
	   break;
	  }
	 }
    }   
   }

  }
 },

 addEvent: function (obj, evType, fn)
 { 
  if (obj.addEventListener){ 
   obj.addEventListener(evType, fn, true); 
   return true; 

  } else if (obj.attachEvent){ 
   var r = obj.attachEvent("on"+evType, fn); 
   return r; 

  } else { 
   return false; 

  } 
 },

 removeEvent: function (obj, evType, fn, useCapture)
 {
  if (obj.removeEventListener){
    obj.removeEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.detachEvent){
    var r = obj.detachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Handler could not be removed");
  }
 }
}

function activate_select( select_obj )
{
 js_selector.construct( select_obj ); 
}

function deactivate_select ( select_obj )
{
 js_selector.destruct(); 
}

var reset_select_obj;

function reset_select(Ereignis)
{
  if (!Ereignis)
    Ereignis = window.event;

  if (Ereignis.keyCode==46)
  { 	
   for (i in reset_select_obj.options)
   {
	try {   
	 reset_select_obj.options[i].selected=false;
	} catch (e) { }
   }
   
   reset_select_obj.options[0].selected=true;
  }
}

function reset_select_add( obj )
{ 
 reset_select_obj = obj;
 js_selector.addEvent(document, 'keydown', reset_select);
}

function reset_select_remove()
{
 reset_select_obj = null;	
 js_selector.removeEvent(document, 'keydown', reset_select, false);
}
