(function(b,a){b.Cse=function(){this.backgroundElId="dhv_csebackground";this.containerElId="dhv_csecontainer";this.backgroundEl=null;this.containerEl=null;this.queryElId="cse_query";this.resultElId="dhv_cseresults";this.minResultHeight=120;this.language="de";this.initialized=false;this.enabled=true;this.cseKey="";this.queryElWatermark="";this.queryEl=null;this.closeElId="dhv_cseclose"};b.Cse.prototype.init=function(){var e=a("#"+this.backgroundElId);var c=a("#"+this.containerElId);if(e.length>0&&c.length>0){this.backgroundEl=e;this.containerEl=c;this.resize();var d=this;a(window).resize(function(){d.resize()});a(document).keydown(function(f){if(f.which==27){if(d.backgroundEl.is(":visible")){d.hide()}}});if(this.queryElWatermark){$queryEl=a("#"+this.queryElId);if($queryEl.length>0){this.queryEl=$queryEl;this.queryEl.css("background-position","left center").css("background-repeat","no-repeat");this.toggleQueryElWatermark(true);this.queryEl.bind("focus",function(){d.toggleQueryElWatermark(false)});this.queryEl.bind("blur",function(){d.toggleQueryElWatermark(true)})}}}if(this.language=="de"){a("#"+this.closeElId).attr("title","Suche schließen (Esc)").html("Suche&nbsp;schließen&nbsp;X")}else{a("#"+this.closeElId).attr("title","Close search (Esc)").html("Close&nbsp;search&nbsp;X")}};b.Cse.prototype.toggleQueryElWatermark=function(c){if(this.queryEl!=null){if(c){var d=this.queryEl.val();if(d==""){this.queryEl.css("background-image","url("+this.queryElWatermark+")")}else{c=false}}if(!c){this.queryEl.css("background-image","")}}};b.Cse.prototype.toggleSearch=function(c){if(this.enabled){if(this.backgroundEl!=null&&this.containerEl!=null){if(c){this.backgroundEl.show();this.containerEl.show();if(!this.initialized){this.initialize()}else{var d=a("#cse_query").val();if(d&&(d!=a("input.gsc-input").val()||$container.height()<this.minResultHeight)){this.clearResults();this.execSearch()}}}else{this.containerEl.hide();this.backgroundEl.hide()}}}};b.Cse.prototype.hide=function(){this.toggleSearch(false)};b.Cse.prototype.show=function(){this.toggleSearch(true)};b.Cse.prototype.initialize=function(){if(!this.initialized&&this.enabled){this.initialized=true;var c=document.createElement("script");c.src="http://www.google.com/jsapi?callback=dhvCse.loadCse";c.type="text/javascript";document.getElementsByTagName("head")[0].appendChild(c)}};b.Cse.prototype.loadCse=function(){var c=this;google.load("search","1",{language:this.language,callback:function(){c.onCseLoaded()}})};b.Cse.prototype.onCseLoaded=function(){var d=new google.search.CustomSearchControl(this.cseKey);d.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);var c=new google.search.DrawOptions();c.setSearchFormRoot("cse-search-form");d.draw(this.resultElId,c);this.execSearch()};b.Cse.prototype.execSearch=function(){var c=this.queryEl.val();if(c){a("input.gsc-input").css("background-image","").val(c);a("input.gsc-search-button").click()}};b.Cse.prototype.clearResults=function(){a(".gsc-clear-button").click()};b.Cse.prototype.resize=function(){if(this.backgroundEl!=null){var c=a(document).height();var d=a(document).width();this.backgroundEl.css("height",c).css("width",d)}}})(Dhv,jQuery);var dhvCse=new Dhv.Cse();
