/*
#################################################################################
#                                                                               #
#     Comwrap Ltd. - Outstanding Marketing Solutions - www.comwrap.eu 2009      #
#                                                                               #
#     Written by Steffen Kroggel  (skroggel@comwrap.eu)             			#
#                                                                               #
#     This script is protected by copyright. It is forbidden to copy this       #
#     script in parts or as a whole and to resell it without the explicit   	#
#     authorization of Comwrap Ltd. Germany.                                    # 
#                                                                               #
#################################################################################

2010/01/18 - Vers. 1.002

*/

var comwrap_ajax_search={target_site:"ajax_suche/?type=160&tx_indexedsearch[defOp]=0&tx_indexedsearch[type]=1&tx_indexedsearch[sword]=",target_element_id:"comwrap_ajax_search_results",timer:"",element_is_active:0,url_to_html_output:function(){if((document.getElementsByTagName("base")[0].href)&&(!(this.target_site.match(/^http:\/\//i)))){var a=document.getElementsByTagName("base")[0].href;if(a.match(/\/$/)){return a+this.target_site}else{return a+"/"+this.target_site}}return this.target_site},init:function(a){if($(a)){$(a).addEvent("keydown",function(b){comwrap_ajax_search.key_down(b,this)}.bindWithEvent($(a)));$(a).addEvent("blur",function(){comwrap_ajax_search.blur(this)}.bind($(a)));$(a).addEvent("focus",function(){comwrap_ajax_search.focus(this)}.bind($(a)))}},key_down:function(b,a){if(a){if((b.key=="backspace")||(b.key=="delete")){window.clearTimeout(this.timer);if(a.value.length<=3){$(this.target_element_id+"_inner").innerHTML="";$(this.target_element_id).removeClass("show-results");$(this.target_element_id).removeClass("show-waiting");return false}}if(a.value.length>=2){window.clearTimeout(this.timer);this.timer=window.setTimeout("comwrap_ajax_search.get_content('"+a.id+"');",200)}else{$(this.target_element_id).removeClass("show-results");$(this.target_element_id).removeClass("show-waiting")}return true}return false},blur:function(a){if(a){this.element_is_active=0;window.setTimeout("$('"+comwrap_ajax_search.target_element_id+"').removeClass('show-results');",200);window.setTimeout("$('"+comwrap_ajax_search.target_element_id+"').removeClass('show-waiting');",200)}},focus:function(a){if(a){if(a.value.length>=2){$(this.target_element_id).removeClass("show-results");$(this.target_element_id).removeClass("show-waiting");if($(this.target_element_id+"_inner").innerHTML.length>0){$(this.target_element_id).addClass("show-results")}}this.element_is_active=1}},get_content:function(a){if(document.getElementById(a).value){var b=new Request.HTML({method:"get",url:this.url_to_html_output()+document.getElementById(a).value,link:"chain",encoding:"utf-8",evalScripts:1,noCache:1,update:$(this.target_element_id+"_inner"),onFailure:function(){},onRequest:function(){$(comwrap_ajax_search.target_element_id).removeClass("show-results");$(comwrap_ajax_search.target_element_id).addClass("show-waiting")},onSuccess:function(){if((document.getElementById(a).value.length>=2)&&(comwrap_ajax_search.element_is_active==1)){$(comwrap_ajax_search.target_element_id).removeClass("show-waiting");$(comwrap_ajax_search.target_element_id).addClass("show-results")}}}).send();return true}return false}};