(function(d,m){var x,p,g,i,u,r,j,o,w,t,v,a,l,q,h,f,b,e,n,c,k=false,y=true,s;d.extend({UKDA_QuestionnaireSearch:{Full:function(){k=true;x();function z(A){var B=m.getValue(A,m.getCurrent());if(B===null){return""}B=unescape(B);B=B.replace(/\+/g," ");return B}c.doctext.value=z("doctext");c.keyword.value=z("keyword");c.title.value=z("title");c.country.value=z("country");f("surveymode",z("surveymode"));f("studytype",z("studytype"));f("doctype",z("doctype"));a("crossnational",z("crossnational"));f("yearfrom",z("yearfrom"));f("yearto",z("yearto"));q("keyword_operator",z("keyword_operator"));q("title_operator",z("title_operator"));q("country_operator",z("country_operator"));q("surveymode_operator",z("surveymode_operator"));q("studytype_operator",z("studytype_operator"));q("doctype_operator",z("doctype_operator"));s={thead:d("#refine THEAD").hide(),tbody:d("#refine TBODY").hide(),hideLink:d("#refine TFOOT .hide").hide(),showLink:d("#refine TFOOT .show").show()};s.hideLink.click(function(A){A.preventDefault();return r()});s.showLink.click(function(A){A.preventDefault();return r()});d(window).keydown(function(A){if(A.keyCode===13){t()}});d(".do-previous").click(function(A){A.preventDefault();return j()});d(".do-next").click(function(A){A.preventDefault();return o()});b();n()},Mini:function(){x();var z=d('LABEL[for="doctext"]').text();if(z.indexOf("*")===-1){y=false}}}});x=function(){c=document.query;c.doctext.focus();d(c).bind("reset",function(){return w()});d(c).submit(function(){return t()})};p=function(){var B,D=d.trim(c.doctext.value),O,Q,I,H,z,P,F,C,M,E,K,N,J,A,G,L;D=u(D);if(D!==""){D=D+" "}B=D;if(k){O=d.trim(c.keyword.value);Q=d.trim(c.title.value);I=d.trim(c.country.value);H=h("surveymode");z=h("studytype");P=h("doctype");F=v("crossnational");C=h("yearfrom");M=h("yearto");E="";K=l("keyword_operator");N=l("title_operator");J=l("country_operator");A=l("surveymode_operator");G=l("studytype_operator");L=l("doctype_operator")}else{O=(c.keyword)?d.trim(c.keyword.value):"";Q=(c.title)?d.trim(c.title.value):"";I=(c.country)?d.trim(c.country.value):"";H=(c.surveymode)?d.trim(c.surveymode.value):"";z=(c.studytype)?d.trim(c.studytype.value):"";P=(c.doctype)?d.trim(c.doctype.value):"";F=(c.crossnational)?d.trim(c.crossnational.value):"";C=(c.yearfrom)?d.trim(c.yearfrom.value):"";M=(c.yearto)?d.trim(c.yearto.value):"";E="";K=(c.keyword_operator)?d.trim(c.keyword_operator.value):"AND";N=(c.title_operator)?d.trim(c.title_operator.value):"AND";J=(c.country_operator)?d.trim(c.country_operator.value):"AND";A=(c.surveymode_operator)?d.trim(c.surveymode_operator.value):"AND";G=(c.studytype_operator)?d.trim(c.studytype_operator.value):"AND";L=(c.doctype_operator)?d.trim(c.doctype_operator.value):"AND"}O=g("keywords",O,K);Q=g("title",Q,N);I=g("country",I,J);H=g("surveymode",H,A);z=g("studytype",z,G);P=g("documenttype",P,L);F=g("crossnational",F,"AND");E=i(C,M);B+=O;B+=Q;B+=I;B+=H;B+=z;B+=P;B+=F;B+=E;B=jQuery.trim(B);if(!y){if(B.slice(0,4)==="AND "){B=B.slice(4)}}c.query.value=B};g=function(F,z,A){if(z!==""){z=u(z)}if(z!==""){switch(F){case"surveymode":case"studytype":case"documenttype":case"crossnational":z=F+':"'+z+'"';break;default:var D=new RegExp('"([^"]*)"',"g"),E,B,G,C;if(D.test(z)){E=z.match(D);G="";for(C=0;C<E.length;C++){B=E[C];z=z.replace(B,"");B=B.replace(/"/g,"");B=d.trim(B);B=F+':"'+B+'"';if(G===""){G+=B}else{G+=" AND "+B}}z=d.trim(z);if(z!==""){z=F+":"+z.replace(/\s+/g," AND "+F+":");z=z+" AND "+G}else{z=G}}else{z=F+":"+z.replace(/\s+/g," AND "+F+":")}break}z=A+" ("+z+") "}return z};i=function(A,z){var C="",B,D;if(A!==""&&z!==""){A=parseInt(A,10);z=parseInt(z,10);if(A===z){C="year:"+A}else{if(A<z){for(B=A;B<=z;B++){C+=" OR year:"+B}C=C.substring(4)}}}else{if(A!==""){D=new Date();for(B=parseInt(A,10);B<=D.getFullYear();B++){C+=" OR year:"+B}C=C.substring(4)}else{if(z!==""){for(B=1980;B<=parseInt(z,10);B++){C+=" OR year:"+B}C=C.substring(4)}}}if(C!==""){C="AND ("+C+")"}return C};u=function(z){z=z.replace(/'/g,"");z=z.replace(/\(/g,"");z=z.replace(/\)/g,"");z=z.replace(/\[/g,"");z=z.replace(/\]/g,"");z=z.replace(/\{/g,"");z=z.replace(/\}/g,"");z=z.replace(/\!/g,"");z=z.replace(/\s+"\s+/g," ");z=z.replace(/\s+~\s+/g," ");z=z.replace(/\s+\^\s+/g," ");z=z.replace(/\s+\+\s+/g," ");z=z.replace(/\s+\-\s+/g," ");z=z.replace(/\s+\?\s+/g," ");z=z.replace(/\s+"$/g," ");z=z.replace(/\s+~$/g," ");z=z.replace(/\s+\^$/g," ");z=z.replace(/\s+\+$/g," ");z=z.replace(/\s+\-$/g," ");z=z.replace(/\s+\?$/g," ");z=z.replace(/^"\s+/g," ");z=z.replace(/^~\s+/g," ");z=z.replace(/^\^\s+/g," ");z=z.replace(/^\+\s+/g," ");z=z.replace(/^\-\s+/g," ");z=z.replace(/^\?\s+/g," ");return z};r=function(){if(s){s.thead.toggle();s.tbody.toggle();s.hideLink.toggle();s.showLink.toggle()}};o=function(){c.resultstart.value=Number(c.resultstart.value)+Number(c.resultsperpage.value);c.submit()};j=function(){c.resultstart.value=Number(c.resultstart.value)-Number(c.resultsperpage.value);c.submit()};w=function(){document.getElementById("errdtext").innerHTML=""};t=function(){var G=false,z=document.getElementById("errdtext"),F,E,C,D,B,A;if(y){if(d.trim(u(c.doctext.value))===""){z.innerHTML='<span class="errmsg">Please enter some document text to search for.</span>';G=true}}if(k){F=document.getElementById("errkeyword");E=document.getElementById("errtitle");C=document.getElementById("errcountry");D=document.getElementById("erryear");B=h("yearfrom");A=h("yearto");if(c.keyword.value.indexOf(" AND ")!==-1||c.keyword.value.indexOf(" OR ")!==-1||c.keyword.value.indexOf(" NOT ")!==-1){F.innerHTML='<span class="errmsg">This field does not support the entry of AND, OR and NOT operators. When multiple words are entered, AND is used by default. Please remove any operators from your query.</span>';G=true}if(c.title.value.indexOf(" AND ")!==-1||c.title.value.indexOf(" OR ")!==-1||c.title.value.indexOf(" NOT ")!==-1){E.innerHTML='<span class="errmsg">This field does not support the entry of AND, OR and NOT operators. When multiple words are entered, AND is used by default. Please remove any operators from your query.</span>';G=true}if(c.country.value.indexOf(" AND ")!==-1||c.country.value.indexOf(" OR ")!==-1||c.country.value.indexOf(" NOT ")!==-1){C.innerHTML='<span class="errmsg">This field does not support the entry of AND, OR and NOT operators. When multiple words are entered, AND is used by default. Please remove any operators from your query.</span>';G=true}if((B!==""&&A!=="")){if(parseInt(B,10)>parseInt(A,10)){D.innerHTML="<span class=\"errmsg\">Please check the years. The 'from' year cannot be after the 'to' year.</span>";G=true}}}if(G){return false}else{c.resultstart.value=1;p();return true}};v=function(A){var z=c.elements[A];if(z.checked){return z.value}else{return""}};a=function(B,A){var z=c.elements[B];if(z.value===A){z.checked=true}};l=function(B){var z=c.elements[B],A;for(A=0;A<z.length;A++){if(z[A].checked){return z[A].value}}};q=function(C,B){var z=c.elements[C],A;for(A=0;A<z.length;A++){if(z[A].value===B){z[A].checked=true}}};h=function(z){var B=document.getElementById(z),A;for(A=0;A<B.length;A++){if(B.options[A].selected){return B.options[A].value}}};f=function(z,B){var C=document.getElementById(z),A;for(A=0;A<C.length;A++){if(C.options[A].value===B){C.options[A].selected=true}}};b=function(){d(".link-to-pdf").each(function(){var z=d(this).attr("href"),A=z.indexOf("#search=");if(A!==-1){z=z.substr(0,(A+8))+e(z.substr((A+8)));d(this).attr("href",z)}})};e=function(C){var E=new RegExp("\"'","g"),B=new RegExp("\\s'","g"),A=new RegExp("'\"","g"),z=new RegExp("'\\s","g"),F,D;F=C.match(E);if(F){for(D=0;D<F.length;D++){C=C.replace(F[D],'"')}}F=C.match(B);if(F){for(D=0;D<F.length;D++){C=C.replace(F[D]," ")}}F=C.match(A);if(F){for(D=0;D<F.length;D++){C=C.replace(F[D],'"')}}F=C.match(z);if(F){for(D=0;D<F.length;D++){C=C.replace(F[D]," ")}}C=C.replace(/"/gi,"");C=C.replace(/AND \(.*\)/g,"");C=C.replace(/OR \(.*\)/g,"");C=C.replace(/NOT \(.*\)/g,"");C=C.replace(/\s?\ba\b\s?/gi," ");C=C.replace(/\s?\bam\b\s?/gi," ");C=C.replace(/\s?\ban\b\s?/gi," ");C=C.replace(/\s?\band\b\s?/gi," ");C=C.replace(/\s?\bare\b\s?/gi," ");C=C.replace(/\s?\bas\b\s?/gi," ");C=C.replace(/\s?\bat\b\s?/gi," ");C=C.replace(/\s?\bbe\b\s?/gi," ");C=C.replace(/\s?\bby\b\s?/gi," ");C=C.replace(/\s?\bis\b\s?/gi," ");C=C.replace(/\s?\bdid\b\s?/gi," ");C=C.replace(/\s?\bdo\b\s?/gi," ");C=C.replace(/\s?\bfor\b\s?/gi," ");C=C.replace(/\s?\bfrom\b\s?/gi," ");C=C.replace(/\s?\bin\b\s?/gi," ");C=C.replace(/\s?\bis\b\s?/gi," ");C=C.replace(/\s?\bit\b\s?/gi," ");C=C.replace(/\s?\bme\b\s?/gi," ");C=C.replace(/\s?\bnot\b\s?/gi," ");C=C.replace(/\s?\bof\b\s?/gi," ");C=C.replace(/\s?\bon\b\s?/gi," ");C=C.replace(/\s?\bor\b\s?/gi," ");C=C.replace(/\s?\bso\b\s?/gi," ");C=C.replace(/\s?\bthan\b\s?/gi," ");C=C.replace(/\s?\bthat\b\s?/gi," ");C=C.replace(/\s?\bthe\b\s?/gi," ");C=C.replace(/\s?\bthis\b\s?/gi," ");C=C.replace(/\s?\bto\b\s?/gi," ");C=C.replace(/\s?\bwill\b\s?/gi," ");C=C.replace(/\s?\bwith\b\s?/gi," ");C=C.replace(/\s?\bwould\b\s?/gi," ");C=C.replace(/\s?\byou\b\s?/gi," ");C=d.trim(C);C='"'+C+'"';return C};n=function(){var z=c.doctext.value.toLowerCase(),A;d(".search-results-item B").each(function(){A=d(this).text();A=A.toLowerCase();if(z.indexOf(A)===-1){d(this).css("font-weight","normal")}})}}(jQuery,WebUI.Core.Url));(function(a){a.extend({UKDA_QuestionSearch:function(){a("#reset").click(function(e){var f=document.getElementById("questiontext"),d=document.getElementById("surveyseries"),c=document.getElementById("yearfrom"),b=document.getElementById("yearto");f.value="";d.value="";c.selectedIndex=0;b.selectedIndex=0;e.preventDefault()})}})}(jQuery));(function(a){a.extend({UKDA_CollapseSQBTips:function(){var c,d,b;c=a("DL.sqbtips");if((c).length>0){d=c.children("DT");b=c.children("DD");b.hide();d.each(function(e){a(this).wrapInner(a(document.createElement("A")).attr("href","#"));a(this).children("A").bind("click",{index:e},function(){b.eq(e).toggle();return false})})}}})}(jQuery));$(document).ready(function(){WebUI.Utils.trackDocsInGA({asynch:false})});$(document).ready(function(){$.UKDA_CollapseSQBTips();if(window.location.href.indexOf("/sqb/qb/questions.asp")!==-1){$.UKDA_QuestionSearch()}else{if(window.location.href.indexOf("collectionid")!==-1){$.UKDA_QuestionnaireSearch.Full()}else{if($(".questionnairesmini").length>0){$.UKDA_QuestionnaireSearch.Mini()}}}});
