j = jQuery.noConflict();j(document).ready(function(){var timerId;j("#navlist").children().hover(function(evt){if(timerId){clearTimeout(timerId)}var id=j(this).attr("id").substring(3);var ids="";j("#navlist").children().each(function(){var liId=j(this).attr("id").substring(3);if(id!=liId){if(j("#mu_"+liId).length>0){j("#mu_"+liId).css("display","none")}}});var menu=j("#mu_"+id);if(menu.length==0){return}if(menu.css("display")=="none"){menu.css("display","block");menu.css("left",j(this).offset().left);menu.css("top",j(this).offset().top+20)}menu.hover(function(evt){if(timerId){clearTimeout(timerId)}},function(evt){var el=evt.relatedTarget;if(el.className=="channelNavigation"){return}timerId=setTimeout("j('#mu_"+id+"').hide()",500)})},function(evt){var id=j(this).attr("id").substring(3);timerId=setTimeout("j('#mu_"+id+"').hide()",500)})});(function(d){var e=new Image(16,11);e.src="/images/search/gr_searchCalcLoader.gif";var c="/images/search/gr_searchNoImage.gif";var f={1:{image:"",url:"/catalogue/view/"},2:{image:"",url:"/actions/catalogue.do?method=view&productId="},3:{image:"/images/wallpapers/search/thumb_sml_",url:"/actions/wallpapers.do?method=view&wallpaperId="},4:{image:"/images/series/search/thumb_sml_",url:"/series/home/"},5:{image:"/images/periodicals/search/thumb_sml_",url:"/actions/periodicals.do?method=view&periodicalId="},7:{image:"/images/directors/search/thumb_sml_",url:"/actions/directors.do?method=view&directorId="},8:{image:"",url:"/actions/label.do?method=view&labelId="},9:{image:"",url:""},6:{image:"/trailers/images/search/thumb_sml_",url:"/actions/video.do?method=view&videoId="},10:{image:"",url:""},12:{image:"",url:""}};var b=["Exact Match","Series","Products","Videos","Downloads","Directors","Labels","News","Minisites"];var a;d.fn.extend({searchauto:function(g,h){var i=typeof g=="string";h=d.extend({},d.SearchAutocompleter.defaults,{url:i?g:null,data:i?null:g,delay:i?d.SearchAutocompleter.defaults.delay:10,max:h&&!h.scroll?10:150},h);h.highlight=h.highlight||function(k){return k};h.formatMatch=h.formatMatch||h.formatItem;return this.each(function(){new d.SearchAutocompleter(this,h)})},result:function(g){return this.bind("result",g)},search:function(g){return this.trigger("search",[g])},flushCache:function(){return this.trigger("flushCache")},setOptions:function(g){return this.trigger("setOptions",[g])},unautocomplete:function(){return this.trigger("unautocomplete")}});d.SearchAutocompleter=function(r,m){var h={UP:38,DOWN:40,DEL:46,TAB:9,RETURN:13,ESC:27,COMMA:188,PAGEUP:33,PAGEDOWN:34,BACKSPACE:8};var g=d(r).attr("searchauto","off").attr("autocomplete","off").addClass(m.inputClass);var p;var v="";var s=d.SearchAutocompleter.Cache(m);var k=0;var A;var D={mouseDownOnSelect:false};var x=d.SearchAutocompleter.Select(m,r,i,D);var C;d.browser.opera&&d(r.form).bind("submit.searchautocomplete",function(){if(C){C=false;return false}});g.bind((d.browser.opera?"keypress":"keydown")+".searchautocomplete",function(E){k=1;A=E.keyCode;switch(E.keyCode){case h.UP:E.preventDefault();if(x.visible()){x.prev()}else{z(0,true)}break;case h.DOWN:E.preventDefault();if(x.visible()){x.next()}else{z(0,true)}break;case h.PAGEUP:E.preventDefault();if(x.visible()){x.pageUp()}else{z(0,true)}break;case h.PAGEDOWN:E.preventDefault();if(x.visible()){x.pageDown()}else{z(0,true)}break;case m.multiple&&d.trim(m.multipleSeparator)==","&&h.COMMA:case h.TAB:case h.RETURN:if(i()){E.preventDefault();C=true;return false}clearTimeout(p);d(a).hide();x.hide();break;case h.ESC:x.hide();d(a).hide();break;case h.BACKSPACE:default:clearTimeout(p);p=setTimeout(z,m.delay);d(a).hide();break}}).focus(function(){k++}).blur(function(){k=0;d(a).hide();if(!D.mouseDownOnSelect){y()}}).click(function(){if(k++>1&&!x.visible()){z(0,true)}}).bind("search",function(){var E=(arguments.length>1)?arguments[1]:null;function F(J,I){var G;if(I&&I.length){for(var H=0;H<I.length;H++){if(I[H].result.toLowerCase()==J.toLowerCase()){G=I[H];break}}}if(typeof E=="function"){E(G)}else{g.trigger("result",G&&[G.data,G.value])}}d.each(n(g.val()),function(G,H){l(H,F,F)})}).bind("flushCache",function(){s.flush()}).bind("setOptions",function(){d.extend(m,arguments[1]);if("data" in arguments[1]){s.populate()}}).bind("searchunautocomplete",function(){x.unbind();g.unbind();d(r.form).unbind(".searchauto")});function i(){var H=x.selected();if(!H){return false}window.location=H;var E=H.result;v=E;if(m.multiple){var K=n(g.val());if(K.length>1){var G=m.multipleSeparator.length;var J=d(r).selection().start;var I,F=0;d.each(K,function(L,M){F+=M.length;if(J<=F){I=L;return false}F+=G});K[I]=E;E=K.join(m.multipleSeparator)}E+=m.multipleSeparator}g.val(E);B();g.trigger("result",[H.data,H.value]);return true}function z(H,F){if(A==h.DEL){x.hide();return}var E=g.val();if(!F&&E==v){return}var G=d(r).offset();a=d('<img src="'+e.src+'" id="autoImgLoader" width="16" height="11"/>').css("position","absolute").appendTo(document.body).hide();d(a).css({top:G.top+10,left:G.left+150}).show();v=E;E=o(E);if(E.length>=m.minChars){g.addClass(m.loadingClass);if(!m.matchCase){E=E.toLowerCase()}l(E,q,B)}else{t();d(a).hide();x.hide()}}function n(E){if(!E){return[""]}if(!m.multiple){return[d.trim(E)]}return d.map(E.split(m.multipleSeparator),function(F){return d.trim(E).length?d.trim(F):null})}function o(E){if(!m.multiple){return E}var G=n(E);if(G.length==1){return G[0]}var F=d(r).selection().start;if(F==E.length){G=n(E)}else{G=n(E.replace(E.substring(F),""))}return G[G.length-1]}function w(E,F){if(m.autoFill&&(o(g.val()).toLowerCase()==E.toLowerCase())&&A!=h.BACKSPACE){g.val(g.val()+F.substring(o(v).length));d(r).selection(v.length,v.length+F.length)}}function y(){clearTimeout(p);p=setTimeout(B,200)}function B(){var E=x.visible();x.hide();clearTimeout(p);t();if(m.mustMatch){g.search(function(F){if(!F){if(m.multiple){var G=n(g.val()).slice(0,-1);g.val(G.join(m.multipleSeparator)+(G.length?m.multipleSeparator:""))}else{g.val("");g.trigger("result",null)}}})}}function q(F,E){if(E&&k){t();x.display(E,F);x.show()}else{B()}}function l(F,H,E){if(!m.matchCase){F=F.toLowerCase()}var G=s.load(F);if(G&&G.length){H(F,G)}else{if((typeof m.url=="string")&&(m.url.length>0)){var I={timestamp:+new Date()};d.each(m.extraParams,function(J,K){I[J]=typeof K=="function"?K():K});d.ajax({mode:"abort",port:"searchautocomplete"+r.name,dataType:m.dataType,url:m.url,data:d.extend({q:o(F),limit:m.max},I),contentType:"application/json",beforeSend:function(J){J.setRequestHeader("Content-type","application/json; charset=utf-8")},success:function(J){s.add(F,J);H(F,J)},error:function(J,L,K){}})}else{alert("fail");x.emptyList();E(F)}}}function u(E){return E}function t(){g.removeClass(m.loadingClass)}};d.SearchAutocompleter.defaults={inputClass:"ac_input",resultsClass:"ac_results",loadingClass:"ac_loading",minChars:1,delay:500,matchCase:false,matchSubset:false,matchContains:false,cacheLength:10,max:100,mustMatch:false,extraParams:{},selectFirst:false,formatItem:function(g){return g[0]},formatMatch:null,autoFill:false,width:0,multiple:false,multipleSeparator:", ",highlight:function(h,g){return h.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+g.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi,"\\$1")+")(?![^<>]*>)(?![^&;]+;)","gi"),"<strong>$1</strong>")},scroll:false,scrollHeight:800};d.SearchAutocompleter.Cache=function(h){var l={};var i=0;function n(q,p){if(!h.matchCase){q=q.toLowerCase()}var o=q.indexOf(p);if(h.matchContains=="word"){o=q.toLowerCase().search("\\b"+p.toLowerCase())}if(o==-1){return false}return o==0||h.matchContains}function m(p,o){if(i>h.cacheLength){g()}if(!l[p]){i++}l[p]=o}function k(){if(!h.data){return false}var p={},o=0;if(!h.url){h.cacheLength=1}p[""]=[];for(var r=0,q=h.data.length;r<q;r++){var u=h.data[r];u=(typeof u=="string")?[u]:u;var t=h.formatMatch(u,r+1,h.data.length);if(t===false){continue}var s=t.charAt(0).toLowerCase();if(!p[s]){p[s]=[]}var v={value:t,data:u,result:h.formatResult&&h.formatResult(u)||t};p[s].push(v);if(o++<h.max){p[""].push(v)}}d.each(p,function(w,x){h.cacheLength++;m(w,x)})}setTimeout(k,25);function g(){l={};i=0}return{flush:g,add:m,populate:k,load:function(s){if(!h.cacheLength||!i){return null}if(!h.url&&h.matchContains){var r=[];for(var o in l){if(o.length>0){var t=l[o];d.each(t,function(u,q){if(n(q.value,s)){r.push(q)}})}}return r}else{if(l[s]){return l[s]}else{if(h.matchSubset){for(var p=s.length-1;p>=h.minChars;p--){var t=l[s.substr(0,p)];if(t){var r=[];d.each(t,function(u,q){if(n(q.value,s)){r[r.length]=q}});return r}}}}}return null}}};d.SearchAutocompleter.Select=function(k,p,r,v){var o={ACTIVE:"ac_over"};var q,l=-1,x,s="",y=true,h,u;function t(){if(!y){return}h=d("<div/>").hide().attr("id","searchWrapper").addClass(k.resultsClass).css("position","absolute").appendTo(document.body);var z=d('<div id="searchDropBox" />').appendTo(h);u=d("<div/>").attr("id","searchDropBoxContent").appendTo(z).mouseover(function(A){if(w(A).nodeName&&w(A).nodeName.toUpperCase()=="LI"){l=d("li",u).removeClass(o.ACTIVE).index(w(A));d(w(A)).addClass(o.ACTIVE)}});if(k.width>0){h.css("width",k.width)}y=false}function w(A){var z=A.target;while(z&&z.tagName!="LI"){z=z.parentNode}if(!z){return[]}return z}function n(z){q.slice(l,l+1).removeClass(o.ACTIVE);m(z);var B=q.slice(l,l+1).addClass(o.ACTIVE);if(k.scroll){var A=0;q.slice(0,l).each(function(){A+=this.offsetHeight});if((A+B[0].offsetHeight-u.scrollTop())>u[0].clientHeight){u.scrollTop(A+B[0].offsetHeight-u.innerHeight())}else{if(A<u.scrollTop()){u.scrollTop(A)}}}}function m(z){l+=z;if(l<0){l=q.size()-1}else{if(l>=q.size()){l=0}}}function g(z){return k.max&&k.max<z?k.max:z}function i(){u.empty();d(a).hide();for(var A in b){var M=x[b[A]];exactStr="";if(b[A]=="Exact Match"){exactStr=" exact"}if(M.length>0){var K=d('<div class="searchDropBoxContent'+exactStr+'"/>').appendTo(u);var L=d('<div class="searchTypeGroup'+exactStr+'"/>').appendTo(K);var F=d('<div class="searchType'+exactStr+'"><a href="#">'+b[A]+"</a></div>").appendTo(L);var H=d("<ul/>").appendTo(L);for(var D=0;D<Math.min(M.length,10);D++){var B=M[D].name;var C=M[D].Id;var I=M[D].type;var G=M[D].desc;var z;if(f[I].url==""){z=M[D].url}else{z=f[I].url+C}var E='<a href="'+z+'">';if(f[I].image!=""){E+='<img src="'+f[I].image+C+'.jpg" class="seriesImage" name="img'+I+C+'" onerror="document.images.img'+I+C+".src='"+c+"'\" />"}E+=B;if(G!=""){E+="<br/><small>"+G+"</small>"}if(f[I].image!=""){E+='<br style="clear: both;"/>'}E+="</a>";var J=d("<li/>").html(E).appendTo(H)[0];d.data(J,"ac_data",z)}d('<br style="clear: both;"/>').appendTo(L)}}u.append('<div id="searchDropBoxFooter"><ul><li><a href="/actions/search.do?method=grouped&searchTerms='+s+"\">See all <strong>'"+s+"'</strong> search results &raquo;</a></li></ul></div>");q=u.find("li");if(k.selectFirst){q.slice(0,1).addClass(o.ACTIVE);l=0}if(d.fn.bgiframe){u.bgiframe()}}return{display:function(A,z){t();x=A;s=z;i()},next:function(){n(1)},prev:function(){n(-1)},pageUp:function(){if(l!=0&&l-8<0){n(-l)}else{n(-8)}},pageDown:function(){if(l!=q.size()-1&&l+8>q.size()){n(q.size()-1-l)}else{n(8)}},hide:function(){h&&h.hide();q&&q.removeClass(o.ACTIVE);l=-1},visible:function(){return h&&h.is(":visible")},current:function(){return this.visible()&&(q.filter("."+o.ACTIVE)[0]||k.selectFirst&&q[0])},show:function(){d("#autoImgLoader").hide();var B=d(p).offset();h.css({top:B.top+p.offsetHeight,left:B.left-122}).show();if(k.scroll){u.scrollTop(0);u.css({maxHeight:k.scrollHeight,overflow:"auto"});if(d.browser.msie&&typeof document.body.style.maxHeight==="undefined"){var z=0;q.each(function(){z+=this.offsetHeight});var A=z>k.scrollHeight;u.css("height",A?k.scrollHeight:z);if(!A){}}}},selected:function(){var z=q&&q.filter("."+o.ACTIVE).removeClass(o.ACTIVE);return z&&z.length&&d.data(z[0],"ac_data")},emptyList:function(){u&&u.empty()},unbind:function(){h&&h.remove()}}};d.fn.selection=function(o,g){if(o!==undefined){return this.each(function(){if(this.createTextRange){var p=this.createTextRange();if(g===undefined||o==g){p.move("character",o);p.select()}else{p.collapse(true);p.moveStart("character",o);p.moveEnd("character",g);p.select()}}else{if(this.setSelectionRange){this.setSelectionRange(o,g)}else{if(this.selectionStart){this.selectionStart=o;this.selectionEnd=g}}}})}var m=this[0];if(m.createTextRange){var h=document.selection.createRange(),n=m.value,l="<->",i=h.text.length;h.text=l;var k=m.value.indexOf(l);m.value=n;this.selection(k,k+i);return{start:k,end:k+i}}else{if(m.selectionStart!==undefined){return{start:m.selectionStart,end:m.selectionEnd}}}}})(jQuery);j(document).ready(function(){j("#siteSearchTerms").searchauto("/actions/search.do?method=auto",{dataType:"json"})});
