function infradoxSearch(filterresetstring){this.settings={targetopener:0,
targetparent:1,
within:0,
newfirst:1,
filterstring:"",
filterresetstring:"",
auxparameters:"",
words:[],
operators:[],
templates:["sr-loadersearch","sr-body"],
territory:{set:1,required:0},
disablefastphrase:0,
minlen:0,
repeatsearch:0,
styleparams:null,
geturl:0};
this.settings.filterresetstring=filterresetstring;
var that=this;
infradoxSearch.instance=that;};
infradoxSearch.prototype.search=function(useoperators){var q,uspkey,templateKey,searchKey,sp,s,ma,fs,rexp,sett=this.settings;
if(infradoxAjax&&infradoxAjax.xmlHttp){infradoxAjax.xmlHttp.onreadystatechange=function(){};}
if(sett.territory.required&&(sett.territory.set==0)){menuHandler(ms.territory);
return;}
q=this.query(useoperators);
if(!q){alert(sMessage_EmptySearch);return;}
rexp=/\$/gi;
q=q.replace(rexp,'"');
q=q.replace(/’/,"'");
uspKey=(sett.within?'1':'0');
templateKey='&t='+((sett.targetparent||sett.targetopener)?sett.templates[0]:sett.templates[1])+'.html';
searchKey='&'+(sett.targetparent?'searchtext':'search')+'='+q;
s='';
if(ms.searchresults){ma=ms.searchresults.split('_');
if(ma.length>0){s='&_m='+ma[1];
if(ma.length==3){s+='&_s='+ma[2];}
s+='&_men='+ms.searchresults;}};
if(s=='') s='&_m='+cfg.menu.sr.m;
url='a=disp&rs=1&pt=1'+s;
if(!sett.geturl) url='go?'+url;
url+='&_yp1=0';
url+='&usp='+uspKey+'&_spe='+(sett.within?'1':'0')+templateKey+searchKey;
url+='&_rve='+(sett.newfirst?'1':'0');
fs=sett.filterstring;
if(fs) url+=fs;
if(!sett.targetopener){if(!sett.styleparams){sp=(parent.resultspanel||window).infradoxState.getStyleParams();
} else sp=sett.styleparams;
if(sp) url+=sp;}
if(sett.auxparameters) url+=sett.auxparameters;
sett.within=0;
if(cfg.search.encode!=0) url=encodeURI(url);
if(sett.targetopener){window.close();
opener.parent.location.href=url;
}else{if(!sett.geturl){infradoxApp.loadTarget(url,1,(sett.targetparent?CONST_FRAMEPARENT:CONST_FRAMERESULTS))}}
sett.disablefastphrase=0;
sett.repeatsearch=0;
if(sett.geturl) return url;};
infradoxSearch.prototype.query=function(useops){var rexp,klen,q='',kw,arr,hasop=0,sett=this.settings,wl,arrn;
var fastphrase=(cfg.search.fastphrase.enabled&&!sett.disablefastphrase), minlen=0;
if(cfg.search.minlen) minlen=cfg.search.minlen;
if(sett.words){if(sett.repeatsearch||(sett.words[0].charAt(0)=='^')){q=sett.words[0];
return q;}
if(minlen!=0){klen=sett.words.length;
for(var i=0;i<klen;i++){arrn=[];
arr=sett.words[i].split(' ');
for(var j=0;j<arr.length;j++){if(arr[j].length>=minlen){arrn[arrn.length]=arr[j];}}
sett.words[i]=arrn.join(' ');}}
this.normalisewords();
klen=sett.words.length;
if(klen>0){if(useops){if(!sett.operators) useops=0;
if(useops&&(sett.operators.length==0)){useops=0;}}
if( ((klen>1)||((klen==1)&&fastphrase))||sett.within){for(var i=0;i<klen;i++){kw=sett.words[i];
hasop=0;
arr=kw.split(' ');
if(arr.length>1){for(var j=0;j<arr.length;j++){wl=arr[j].toLowerCase();
hasop=(wl=='and');
if(hasop) break;
hasop=(wl=='or');
if(hasop) break;
hasop=(wl=='and not');
if(hasop) break;
hasop=(wl=='like');
if(hasop) break;
hasop=(wl=='near');
if(hasop) break;}}
if(fastphrase){if(!hasop){if((kw.indexOf(' ')>-1)||(kw.indexOf('%20')>-1)){if(kw[0]!='"') sett.words[i]='"'+kw+'"';}}
}else{if(!hasop){if(arr.length>1){sett.words[i]='('+arr.join(' and ')+')';
}else{sett.words[i]=arr.join('');}
}else{sett.words[i]='('+sett.words[i]+')';}}}}
if(useops&&((sett.words.length>1)||sett.within )){q=this.querywithoperators();
}else{q=sett.words.join(' ');}
rexp=/&/gi;
q=q.replace(rexp,"@38");}}
return q;};
infradoxSearch.prototype.normalisewords=function(){var s=new Array(),reSpace=/[\s\xA0]+/,temp='',w=this.settings.words,hasop=0;
for(var i=0;i<w.length;i++){w[i]=(w[i].replace(/^[\s\xA0]+/,"").replace(/[\s\xA0]+$/,""));
if(w[i]) s[s.length]=w[i];}
this.settings.words=s;};
infradoxSearch.prototype.querywithoperators=function(){var sett=this.settings,q;
q=sett.words[0],boolOp='';
for(var i=1;i<sett.words.length;i++){boolOp=this.booleanoperator(sett.operators.length==1?sett.operators[0]:sett.operators[i-1]);
q+=boolOp+sett.words[i];}
return q;};
infradoxSearch.prototype.booleanoperator=function(value){if(value<=2){return ' '+['AND','OR','AND NOT'][value]+' '
} else return ' AND ';};
infradoxSearch.prototype.getSelectedKeywords=function(frame,divContainer,noc){var list,container,arrK=new Array();
noc=noc?noc:'onekeyword';
container=frame.gete(divContainer);
if(!container){alert('container not found');
return arrK;}
list=frame.iA.getElementsByClassName(container,'*',noc);
if(list){for(var i=0;i<list.length;i++){if(list[i].checked) arrK[arrK.length]=list[i].name;}}
return arrK;};
infradoxSearch.prototype.powerSearch=function(f,filters,targetparent){var op1=0,op2=0,op3=0,op4=0;
if(f.key1style) op1=f.key1style[0].checked?0:f.key1style[1].checked?1:2;
if(f.key2style) op2=f.key2style[0].checked?0:f.key2style[1].checked?1:2;
if(f.key3style) op3=f.key3style[0].checked?0:f.key3style[1].checked?1:2;
if(f.key4style) op4=f.key4style[0].checked?0:f.key4style[1].checked?1:2;
var f1='',f2='',f3='',f4='',f5='';
if(f.key1) f1=f.key1.value;
if(f.key2) f2=f.key2.value;
if(f.key3) f3=f.key3.value;
if(f.key4) f4=f.key4.value;
if(f.key5) f5=f.key5.value;
var _targparent=0;
if(targetparent) _targparent=1;
infradoxAction.executeSearch(this,_targparent,f.psInResults.checked,
[op1,op2,op3,op4],[f1,f2,f3,f4,f5],filters);};

